forked from chromedp/cdproto
/
cachestorage.go
181 lines (156 loc) · 5.54 KB
/
cachestorage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Package cachestorage provides the Chrome Debugging Protocol
// commands, types, and events for the CacheStorage domain.
//
// Generated by the chromedp-gen command.
package cachestorage
// Code generated by chromedp-gen. DO NOT EDIT.
import (
"context"
"github.com/jbegley1995/cdproto/cdp"
)
// DeleteCacheParams deletes a cache.
type DeleteCacheParams struct {
CacheID CacheID `json:"cacheId"` // Id of cache for deletion.
}
// DeleteCache deletes a cache.
//
// parameters:
// cacheID - Id of cache for deletion.
func DeleteCache(cacheID CacheID) *DeleteCacheParams {
return &DeleteCacheParams{
CacheID: cacheID,
}
}
// Do executes CacheStorage.deleteCache against the provided context.
func (p *DeleteCacheParams) Do(ctxt context.Context, h cdp.Executor) (err error) {
return h.Execute(ctxt, CommandDeleteCache, p, nil)
}
// DeleteEntryParams deletes a cache entry.
type DeleteEntryParams struct {
CacheID CacheID `json:"cacheId"` // Id of cache where the entry will be deleted.
Request string `json:"request"` // URL spec of the request.
}
// DeleteEntry deletes a cache entry.
//
// parameters:
// cacheID - Id of cache where the entry will be deleted.
// request - URL spec of the request.
func DeleteEntry(cacheID CacheID, request string) *DeleteEntryParams {
return &DeleteEntryParams{
CacheID: cacheID,
Request: request,
}
}
// Do executes CacheStorage.deleteEntry against the provided context.
func (p *DeleteEntryParams) Do(ctxt context.Context, h cdp.Executor) (err error) {
return h.Execute(ctxt, CommandDeleteEntry, p, nil)
}
// RequestCacheNamesParams requests cache names.
type RequestCacheNamesParams struct {
SecurityOrigin string `json:"securityOrigin"` // Security origin.
}
// RequestCacheNames requests cache names.
//
// parameters:
// securityOrigin - Security origin.
func RequestCacheNames(securityOrigin string) *RequestCacheNamesParams {
return &RequestCacheNamesParams{
SecurityOrigin: securityOrigin,
}
}
// RequestCacheNamesReturns return values.
type RequestCacheNamesReturns struct {
Caches []*Cache `json:"caches,omitempty"` // Caches for the security origin.
}
// Do executes CacheStorage.requestCacheNames against the provided context.
//
// returns:
// caches - Caches for the security origin.
func (p *RequestCacheNamesParams) Do(ctxt context.Context, h cdp.Executor) (caches []*Cache, err error) {
// execute
var res RequestCacheNamesReturns
err = h.Execute(ctxt, CommandRequestCacheNames, p, &res)
if err != nil {
return nil, err
}
return res.Caches, nil
}
// RequestCachedResponseParams fetches cache entry.
type RequestCachedResponseParams struct {
CacheID CacheID `json:"cacheId"` // Id of cache that contains the enty.
RequestURL string `json:"requestURL"` // URL spec of the request.
}
// RequestCachedResponse fetches cache entry.
//
// parameters:
// cacheID - Id of cache that contains the enty.
// requestURL - URL spec of the request.
func RequestCachedResponse(cacheID CacheID, requestURL string) *RequestCachedResponseParams {
return &RequestCachedResponseParams{
CacheID: cacheID,
RequestURL: requestURL,
}
}
// RequestCachedResponseReturns return values.
type RequestCachedResponseReturns struct {
Response *CachedResponse `json:"response,omitempty"` // Response read from the cache.
}
// Do executes CacheStorage.requestCachedResponse against the provided context.
//
// returns:
// response - Response read from the cache.
func (p *RequestCachedResponseParams) Do(ctxt context.Context, h cdp.Executor) (response *CachedResponse, err error) {
// execute
var res RequestCachedResponseReturns
err = h.Execute(ctxt, CommandRequestCachedResponse, p, &res)
if err != nil {
return nil, err
}
return res.Response, nil
}
// RequestEntriesParams requests data from cache.
type RequestEntriesParams struct {
CacheID CacheID `json:"cacheId"` // ID of cache to get entries from.
SkipCount int64 `json:"skipCount"` // Number of records to skip.
PageSize int64 `json:"pageSize"` // Number of records to fetch.
}
// RequestEntries requests data from cache.
//
// parameters:
// cacheID - ID of cache to get entries from.
// skipCount - Number of records to skip.
// pageSize - Number of records to fetch.
func RequestEntries(cacheID CacheID, skipCount int64, pageSize int64) *RequestEntriesParams {
return &RequestEntriesParams{
CacheID: cacheID,
SkipCount: skipCount,
PageSize: pageSize,
}
}
// RequestEntriesReturns return values.
type RequestEntriesReturns struct {
CacheDataEntries []*DataEntry `json:"cacheDataEntries,omitempty"` // Array of object store data entries.
HasMore bool `json:"hasMore,omitempty"` // If true, there are more entries to fetch in the given range.
}
// Do executes CacheStorage.requestEntries against the provided context.
//
// returns:
// cacheDataEntries - Array of object store data entries.
// hasMore - If true, there are more entries to fetch in the given range.
func (p *RequestEntriesParams) Do(ctxt context.Context, h cdp.Executor) (cacheDataEntries []*DataEntry, hasMore bool, err error) {
// execute
var res RequestEntriesReturns
err = h.Execute(ctxt, CommandRequestEntries, p, &res)
if err != nil {
return nil, false, err
}
return res.CacheDataEntries, res.HasMore, nil
}
// Command names.
const (
CommandDeleteCache = "CacheStorage.deleteCache"
CommandDeleteEntry = "CacheStorage.deleteEntry"
CommandRequestCacheNames = "CacheStorage.requestCacheNames"
CommandRequestCachedResponse = "CacheStorage.requestCachedResponse"
CommandRequestEntries = "CacheStorage.requestEntries"
)