Debian Codegraph @

cachestorage/cachestorage.go

raw
1 // Package cachestorage provides the Chrome DevTools Protocol
2 // commands, types, and events for the CacheStorage domain.
3 //
4 // Generated by the cdproto-gen command.
5 package cachestorage
6
7 // Code generated by cdproto-gen. DO NOT EDIT.
8
9 import (
10 "context"
11
12 "github.com/chromedp/cdproto/cdp"
13 "github.com/chromedp/cdproto/storage"
14 )
15
16 // DeleteCacheParams deletes a cache.
17 type DeleteCacheParams struct {
18 CacheID CacheID `json:"cacheId"` // Id of cache for deletion.
19 }
20
21 // DeleteCache deletes a cache.
22 //
23 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#method-deleteCache
24 //
25 // parameters:
26 //
27 // cacheID - Id of cache for deletion.
28 func DeleteCache(cacheID CacheID) *DeleteCacheParams {
29 return &DeleteCacheParams{
30 CacheID: cacheID,
31 }
32 }
33
34 // Do executes CacheStorage.deleteCache against the provided context.
35 func (p *DeleteCacheParams) Do(ctx context.Context) (err error) {
36 return cdp.Execute(ctx, CommandDeleteCache, p, nil)
37 }
38
39 // DeleteEntryParams deletes a cache entry.
40 type DeleteEntryParams struct {
41 CacheID CacheID `json:"cacheId"` // Id of cache where the entry will be deleted.
42 Request string `json:"request"` // URL spec of the request.
43 }
44
45 // DeleteEntry deletes a cache entry.
46 //
47 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#method-deleteEntry
48 //
49 // parameters:
50 //
51 // cacheID - Id of cache where the entry will be deleted.
52 // request - URL spec of the request.
53 func DeleteEntry(cacheID CacheID, request string) *DeleteEntryParams {
54 return &DeleteEntryParams{
55 CacheID: cacheID,
56 Request: request,
57 }
58 }
59
60 // Do executes CacheStorage.deleteEntry against the provided context.
61 func (p *DeleteEntryParams) Do(ctx context.Context) (err error) {
62 return cdp.Execute(ctx, CommandDeleteEntry, p, nil)
63 }
64
65 // RequestCacheNamesParams requests cache names.
66 type RequestCacheNamesParams struct {
67 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, storageBucket must be specified. Security origin.
68 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
69 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
70 }
71
72 // RequestCacheNames requests cache names.
73 //
74 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#method-requestCacheNames
75 //
76 // parameters:
77 func RequestCacheNames() *RequestCacheNamesParams {
78 return &RequestCacheNamesParams{}
79 }
80
81 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
82 // storageBucket must be specified. Security origin.
83 func (p RequestCacheNamesParams) WithSecurityOrigin(securityOrigin string) *RequestCacheNamesParams {
84 p.SecurityOrigin = securityOrigin
85 return &p
86 }
87
88 // WithStorageKey storage key.
89 func (p RequestCacheNamesParams) WithStorageKey(storageKey string) *RequestCacheNamesParams {
90 p.StorageKey = storageKey
91 return &p
92 }
93
94 // WithStorageBucket storage bucket. If not specified, it uses the default
95 // bucket.
96 func (p RequestCacheNamesParams) WithStorageBucket(storageBucket *storage.Bucket) *RequestCacheNamesParams {
97 p.StorageBucket = storageBucket
98 return &p
99 }
100
101 // RequestCacheNamesReturns return values.
102 type RequestCacheNamesReturns struct {
103 Caches []*Cache `json:"caches,omitempty,omitzero"` // Caches for the security origin.
104 }
105
106 // Do executes CacheStorage.requestCacheNames against the provided context.
107 //
108 // returns:
109 //
110 // caches - Caches for the security origin.
111 func (p *RequestCacheNamesParams) Do(ctx context.Context) (caches []*Cache, err error) {
112 // execute
113 var res RequestCacheNamesReturns
114 err = cdp.Execute(ctx, CommandRequestCacheNames, p, &res)
115 if err != nil {
116 return nil, err
117 }
118
119 return res.Caches, nil
120 }
121
122 // RequestCachedResponseParams fetches cache entry.
123 type RequestCachedResponseParams struct {
124 CacheID CacheID `json:"cacheId"` // Id of cache that contains the entry.
125 RequestURL string `json:"requestURL"` // URL spec of the request.
126 RequestHeaders []*Header `json:"requestHeaders"` // headers of the request.
127 }
128
129 // RequestCachedResponse fetches cache entry.
130 //
131 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#method-requestCachedResponse
132 //
133 // parameters:
134 //
135 // cacheID - Id of cache that contains the entry.
136 // requestURL - URL spec of the request.
137 // requestHeaders - headers of the request.
138 func RequestCachedResponse(cacheID CacheID, requestURL string, requestHeaders []*Header) *RequestCachedResponseParams {
139 return &RequestCachedResponseParams{
140 CacheID: cacheID,
141 RequestURL: requestURL,
142 RequestHeaders: requestHeaders,
143 }
144 }
145
146 // RequestCachedResponseReturns return values.
147 type RequestCachedResponseReturns struct {
148 Response *CachedResponse `json:"response,omitempty,omitzero"` // Response read from the cache.
149 }
150
151 // Do executes CacheStorage.requestCachedResponse against the provided context.
152 //
153 // returns:
154 //
155 // response - Response read from the cache.
156 func (p *RequestCachedResponseParams) Do(ctx context.Context) (response *CachedResponse, err error) {
157 // execute
158 var res RequestCachedResponseReturns
159 err = cdp.Execute(ctx, CommandRequestCachedResponse, p, &res)
160 if err != nil {
161 return nil, err
162 }
163
164 return res.Response, nil
165 }
166
167 // RequestEntriesParams requests data from cache.
168 type RequestEntriesParams struct {
169 CacheID CacheID `json:"cacheId"` // ID of cache to get entries from.
170 SkipCount int64 `json:"skipCount,omitempty,omitzero"` // Number of records to skip.
171 PageSize int64 `json:"pageSize,omitempty,omitzero"` // Number of records to fetch.
172 PathFilter string `json:"pathFilter,omitempty,omitzero"` // If present, only return the entries containing this substring in the path
173 }
174
175 // RequestEntries requests data from cache.
176 //
177 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#method-requestEntries
178 //
179 // parameters:
180 //
181 // cacheID - ID of cache to get entries from.
182 func RequestEntries(cacheID CacheID) *RequestEntriesParams {
183 return &RequestEntriesParams{
184 CacheID: cacheID,
185 }
186 }
187
188 // WithSkipCount number of records to skip.
189 func (p RequestEntriesParams) WithSkipCount(skipCount int64) *RequestEntriesParams {
190 p.SkipCount = skipCount
191 return &p
192 }
193
194 // WithPageSize number of records to fetch.
195 func (p RequestEntriesParams) WithPageSize(pageSize int64) *RequestEntriesParams {
196 p.PageSize = pageSize
197 return &p
198 }
199
200 // WithPathFilter if present, only return the entries containing this
201 // substring in the path.
202 func (p RequestEntriesParams) WithPathFilter(pathFilter string) *RequestEntriesParams {
203 p.PathFilter = pathFilter
204 return &p
205 }
206
207 // RequestEntriesReturns return values.
208 type RequestEntriesReturns struct {
209 CacheDataEntries []*DataEntry `json:"cacheDataEntries,omitempty,omitzero"` // Array of object store data entries.
210 ReturnCount float64 `json:"returnCount,omitempty,omitzero"` // Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.
211 }
212
213 // Do executes CacheStorage.requestEntries against the provided context.
214 //
215 // returns:
216 //
217 // cacheDataEntries - Array of object store data entries.
218 // returnCount - Count of returned entries from this storage. If pathFilter is empty, it is the count of all entries from this storage.
219 func (p *RequestEntriesParams) Do(ctx context.Context) (cacheDataEntries []*DataEntry, returnCount float64, err error) {
220 // execute
221 var res RequestEntriesReturns
222 err = cdp.Execute(ctx, CommandRequestEntries, p, &res)
223 if err != nil {
224 return nil, 0, err
225 }
226
227 return res.CacheDataEntries, res.ReturnCount, nil
228 }
229
230 // Command names.
231 const (
232 CommandDeleteCache = "CacheStorage.deleteCache"
233 CommandDeleteEntry = "CacheStorage.deleteEntry"
234 CommandRequestCacheNames = "CacheStorage.requestCacheNames"
235 CommandRequestCachedResponse = "CacheStorage.requestCachedResponse"
236 CommandRequestEntries = "CacheStorage.requestEntries"
237 )