-
Notifications
You must be signed in to change notification settings - Fork 70
/
edgeworkers.go
293 lines (225 loc) · 11.2 KB
/
edgeworkers.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
// Package edgeworkers provides access to the Akamai EdgeWorkers and EdgeKV APIs
package edgeworkers
import (
"context"
"errors"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session"
)
var (
// ErrStructValidation is returned when given struct validation failed
ErrStructValidation = errors.New("struct validation")
)
type (
// Edgeworkers is the api interface for EdgeWorkers and EdgeKV
Edgeworkers interface {
// Activations
// ListActivations lists all activations for an EdgeWorker
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-activations-1
ListActivations(context.Context, ListActivationsRequest) (*ListActivationsResponse, error)
// GetActivation fetches an EdgeWorker activation by id
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-activation-1
GetActivation(context.Context, GetActivationRequest) (*Activation, error)
// ActivateVersion activates an EdgeWorker version on a given network
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-activations-1
ActivateVersion(context.Context, ActivateVersionRequest) (*Activation, error)
// CancelPendingActivation cancels pending activation with a given id
//
// See: https://techdocs.akamai.com/edgeworkers/reference/cancel-activation
CancelPendingActivation(context.Context, CancelActivationRequest) (*Activation, error)
// Contracts
// ListContracts lists contract IDs that can be used to list resource tiers
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-contracts-1
ListContracts(context.Context) (*ListContractsResponse, error)
// Deactivations
// ListDeactivations lists all deactivations for a given EdgeWorker ID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-deactivations-1
ListDeactivations(context.Context, ListDeactivationsRequest) (*ListDeactivationsResponse, error)
// GetDeactivation gets details for a specific deactivation
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-deactivation-1
GetDeactivation(context.Context, GetDeactivationRequest) (*Deactivation, error)
// DeactivateVersion deactivates an existing EdgeWorker version on the akamai network
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-deactivations-1
DeactivateVersion(context.Context, DeactivateVersionRequest) (*Deactivation, error)
// EdgeKVAccessTokens
// CreateEdgeKVAccessToken generates EdgeKV specific access token
//
// See: https://techdocs.akamai.com/edgekv/reference/post-tokens
CreateEdgeKVAccessToken(context.Context, CreateEdgeKVAccessTokenRequest) (*CreateEdgeKVAccessTokenResponse, error)
// GetEdgeKVAccessToken retrieves an EdgeKV access token
//
// See: https://techdocs.akamai.com/edgekv/reference/get-token
GetEdgeKVAccessToken(context.Context, GetEdgeKVAccessTokenRequest) (*GetEdgeKVAccessTokenResponse, error)
// ListEdgeKVAccessTokens lists EdgeKV access tokens
//
// See: https://techdocs.akamai.com/edgekv/reference/get-tokens
ListEdgeKVAccessTokens(context.Context, ListEdgeKVAccessTokensRequest) (*ListEdgeKVAccessTokensResponse, error)
// DeleteEdgeKVAccessToken revokes an EdgeKV access token
//
// See: https://techdocs.akamai.com/edgekv/reference/delete-token
DeleteEdgeKVAccessToken(context.Context, DeleteEdgeKVAccessTokenRequest) (*DeleteEdgeKVAccessTokenResponse, error)
// EdgeKVInitialize
// InitializeEdgeKV Initialize the EdgeKV database
//
// See: https://techdocs.akamai.com/edgekv/reference/put-initialize
InitializeEdgeKV(ctx context.Context) (*EdgeKVInitializationStatus, error)
// GetEdgeKVInitializationStatus is used to check on the current initialization status
//
// See: https://techdocs.akamai.com/edgekv/reference/get-initialize
GetEdgeKVInitializationStatus(ctx context.Context) (*EdgeKVInitializationStatus, error)
// EdgeKVItems
// ListItems lists items in EdgeKV group
//
// See: https://techdocs.akamai.com/edgekv/reference/get-group-1
ListItems(context.Context, ListItemsRequest) (*ListItemsResponse, error)
// GetItem reads an item from EdgeKV group
//
// See: https://techdocs.akamai.com/edgekv/reference/get-item
GetItem(context.Context, GetItemRequest) (*Item, error)
// UpsertItem creates or updates an item in EdgeKV group
//
// See: https://techdocs.akamai.com/edgekv/reference/put-item
UpsertItem(context.Context, UpsertItemRequest) (*string, error)
// DeleteItem deletes an item from EdgeKV group
//
// See: https://techdocs.akamai.com/edgekv/reference/delete-item
DeleteItem(context.Context, DeleteItemRequest) (*string, error)
// EdgeKVNamespaces
// ListEdgeKVNamespaces lists all namespaces in the given network
//
// See: https://techdocs.akamai.com/edgekv/reference/get-namespaces
ListEdgeKVNamespaces(context.Context, ListEdgeKVNamespacesRequest) (*ListEdgeKVNamespacesResponse, error)
// GetEdgeKVNamespace fetches a namespace by name
//
// See: https://techdocs.akamai.com/edgekv/reference/get-namespace
GetEdgeKVNamespace(context.Context, GetEdgeKVNamespaceRequest) (*Namespace, error)
// CreateEdgeKVNamespace creates a namespace on the given network
//
// See: https://techdocs.akamai.com/edgekv/reference/post-namespace
CreateEdgeKVNamespace(context.Context, CreateEdgeKVNamespaceRequest) (*Namespace, error)
// UpdateEdgeKVNamespace updates a namespace
//
// See: https://techdocs.akamai.com/edgekv/reference/put-namespace
UpdateEdgeKVNamespace(context.Context, UpdateEdgeKVNamespaceRequest) (*Namespace, error)
// EdgeWorkerIDs
// GetEdgeWorkerID gets details for a specific EdgeWorkerID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-id
GetEdgeWorkerID(context.Context, GetEdgeWorkerIDRequest) (*EdgeWorkerID, error)
// ListEdgeWorkersID lists EdgeWorkerIDs in the identified group
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-ids
ListEdgeWorkersID(context.Context, ListEdgeWorkersIDRequest) (*ListEdgeWorkersIDResponse, error)
// CreateEdgeWorkerID creates a new EdgeWorkerID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-ids
CreateEdgeWorkerID(context.Context, CreateEdgeWorkerIDRequest) (*EdgeWorkerID, error)
// UpdateEdgeWorkerID updates an EdgeWorkerID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/put-id
UpdateEdgeWorkerID(context.Context, UpdateEdgeWorkerIDRequest) (*EdgeWorkerID, error)
// CloneEdgeWorkerID clones an EdgeWorkerID to change the resource tier
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-id-clone
CloneEdgeWorkerID(context.Context, CloneEdgeWorkerIDRequest) (*EdgeWorkerID, error)
// DeleteEdgeWorkerID deletes an EdgeWorkerID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/delete-id
DeleteEdgeWorkerID(context.Context, DeleteEdgeWorkerIDRequest) error
// EdgeWorkerVersions
// GetEdgeWorkerVersion gets details for a specific EdgeWorkerVersion
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-version
GetEdgeWorkerVersion(context.Context, GetEdgeWorkerVersionRequest) (*EdgeWorkerVersion, error)
// ListEdgeWorkerVersions lists EdgeWorkerVersions in the identified group
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-versions
ListEdgeWorkerVersions(context.Context, ListEdgeWorkerVersionsRequest) (*ListEdgeWorkerVersionsResponse, error)
// GetEdgeWorkerVersionContent gets content bundle for a specific EdgeWorkerVersion
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-version-content
GetEdgeWorkerVersionContent(context.Context, GetEdgeWorkerVersionContentRequest) (*Bundle, error)
// CreateEdgeWorkerVersion creates a new EdgeWorkerVersion
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-versions
CreateEdgeWorkerVersion(context.Context, CreateEdgeWorkerVersionRequest) (*EdgeWorkerVersion, error)
// DeleteEdgeWorkerVersion deletes an EdgeWorkerVersion
//
// See: https://techdocs.akamai.com/edgeworkers/reference/delete-version
DeleteEdgeWorkerVersion(context.Context, DeleteEdgeWorkerVersionRequest) error
// Groups
// ListGroupsWithinNamespace lists group identifiers created when writing items to a namespace
//
// See: https://techdocs.akamai.com/edgekv/reference/get-groups
ListGroupsWithinNamespace(context.Context, ListGroupsWithinNamespaceRequest) ([]string, error)
// PermissionGroups
// GetPermissionGroup gets details on the capabilities enabled within a specified group
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-group
GetPermissionGroup(context.Context, GetPermissionGroupRequest) (*PermissionGroup, error)
// ListPermissionGroups lists groups and the associated permission capabilities
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-groups
ListPermissionGroups(context.Context) (*ListPermissionGroupsResponse, error)
// Properties
// ListProperties lists all properties for a given edgeworker ID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-properties
ListProperties(context.Context, ListPropertiesRequest) (*ListPropertiesResponse, error)
// Reports
// GetSummaryReport gets summary overview for EdgeWorker reports. Report id is 1
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-report
GetSummaryReport(context.Context, GetSummaryReportRequest) (*GetSummaryReportResponse, error)
// GetReport gets details for an EdgeWorker
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-report
GetReport(context.Context, GetReportRequest) (*GetReportResponse, error)
// ListReports lists EdgeWorker reports
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-reports
ListReports(context.Context) (*ListReportsResponse, error)
// ResourceTiers
// ListResourceTiers lists all resource tiers for a given contract
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-resource-tiers
ListResourceTiers(context.Context, ListResourceTiersRequest) (*ListResourceTiersResponse, error)
// GetResourceTier returns resource tier for a given edgeworker ID
//
// See: https://techdocs.akamai.com/edgeworkers/reference/get-id-resource-tier
GetResourceTier(context.Context, GetResourceTierRequest) (*ResourceTier, error)
// SecureTokens
// CreateSecureToken creates a new secure token
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-secure-token
CreateSecureToken(context.Context, CreateSecureTokenRequest) (*CreateSecureTokenResponse, error)
// Validations
// ValidateBundle given bundle validates it and returns a list of errors and/or warnings
//
// See: https://techdocs.akamai.com/edgeworkers/reference/post-validations
ValidateBundle(context.Context, ValidateBundleRequest) (*ValidateBundleResponse, error)
}
edgeworkers struct {
session.Session
}
// Option defines an Edgeworkers option
Option func(*edgeworkers)
// ClientFunc is a Edgeworkers client new method, this can be used for mocking
ClientFunc func(sess session.Session, opts ...Option) Edgeworkers
)
// Client returns a new edgeworkers Client instance with the specified controller
func Client(sess session.Session, opts ...Option) Edgeworkers {
e := &edgeworkers{
Session: sess,
}
for _, opt := range opts {
opt(e)
}
return e
}