-
Notifications
You must be signed in to change notification settings - Fork 69
/
gtm.go
255 lines (199 loc) · 9.86 KB
/
gtm.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
// Package gtm provides access to the Akamai GTM V1_4 APIs
//
// See: https://techdocs.akamai.com/gtm/reference/api
package gtm
import (
"context"
"errors"
"net/http"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v9/pkg/session"
)
var (
// ErrStructValidation is returned when given struct validation failed.
ErrStructValidation = errors.New("struct validation")
)
type (
// GTM is the gtm api interface
GTM interface {
// Domains
// NullFieldMap retrieves map of null fields.
NullFieldMap(context.Context, *Domain) (*NullFieldMapStruct, error)
// GetDomainStatus retrieves current status for the given domain name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-status-current
GetDomainStatus(context.Context, GetDomainStatusRequest) (*GetDomainStatusResponse, error)
// ListDomains retrieves all Domains.
//
// See: https://techdocs.akamai.com/gtm/reference/get-domains
ListDomains(context.Context) ([]DomainItem, error)
// GetDomain retrieves a Domain with the given domain name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-domain
GetDomain(context.Context, GetDomainRequest) (*GetDomainResponse, error)
// CreateDomain creates domain.
//
// See: https://techdocs.akamai.com/gtm/reference/post-domain
CreateDomain(context.Context, CreateDomainRequest) (*CreateDomainResponse, error)
// DeleteDomain is a method applied to a domain object resulting in removal.
//
// See: ** Not Supported by API **
DeleteDomain(context.Context, DeleteDomainRequest) (*DeleteDomainResponse, error)
// UpdateDomain is a method applied to a domain object resulting in an update.
//
// See: https://techdocs.akamai.com/gtm/reference/put-domain
UpdateDomain(context.Context, UpdateDomainRequest) (*UpdateDomainResponse, error)
// Properties
// ListProperties retrieves all Properties for the provided domainName.
//
// See: https://techdocs.akamai.com/gtm/reference/get-properties
ListProperties(context.Context, ListPropertiesRequest) ([]Property, error)
// GetProperty retrieves a Property with the given domain and property names.
//
// See: https://techdocs.akamai.com/gtm/reference/get-property
GetProperty(context.Context, GetPropertyRequest) (*GetPropertyResponse, error)
// CreateProperty creates property.
//
// See: https://techdocs.akamai.com/gtm/reference/put-property
CreateProperty(context.Context, CreatePropertyRequest) (*CreatePropertyResponse, error)
// DeleteProperty is a method applied to a property object resulting in removal.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-property
DeleteProperty(context.Context, DeletePropertyRequest) (*DeletePropertyResponse, error)
// UpdateProperty is a method applied to a property object resulting in an update.
//
// See: https://techdocs.akamai.com/gtm/reference/put-property
UpdateProperty(context.Context, UpdatePropertyRequest) (*UpdatePropertyResponse, error)
// Datacenters
// ListDatacenters retrieves all Datacenters.
//
// See: https://techdocs.akamai.com/gtm/reference/get-datacenters
ListDatacenters(context.Context, ListDatacentersRequest) ([]Datacenter, error)
// GetDatacenter retrieves a Datacenter with the given name. NOTE: Id arg is int!
//
// See: https://techdocs.akamai.com/gtm/reference/get-datacenter
GetDatacenter(context.Context, GetDatacenterRequest) (*Datacenter, error)
// CreateDatacenter creates the datacenter identified by the receiver argument in the specified domain.
//
// See: https://techdocs.akamai.com/gtm/reference/post-datacenter
CreateDatacenter(context.Context, CreateDatacenterRequest) (*CreateDatacenterResponse, error)
// DeleteDatacenter deletes the datacenter identified by the receiver argument from the domain specified.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-datacenter
DeleteDatacenter(context.Context, DeleteDatacenterRequest) (*DeleteDatacenterResponse, error)
// UpdateDatacenter updates the datacenter identified in the receiver argument in the provided domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-datacenter
UpdateDatacenter(context.Context, UpdateDatacenterRequest) (*UpdateDatacenterResponse, error)
// CreateMapsDefaultDatacenter creates Default Datacenter for Maps.
CreateMapsDefaultDatacenter(context.Context, string) (*Datacenter, error)
// CreateIPv4DefaultDatacenter creates Default Datacenter for IPv4 Selector.
CreateIPv4DefaultDatacenter(context.Context, string) (*Datacenter, error)
// CreateIPv6DefaultDatacenter creates Default Datacenter for IPv6 Selector.
CreateIPv6DefaultDatacenter(context.Context, string) (*Datacenter, error)
// Resources
// ListResources retrieves all Resources
//
// See: https://techdocs.akamai.com/gtm/reference/get-resources
ListResources(context.Context, ListResourcesRequest) ([]Resource, error)
// GetResource retrieves a Resource with the given name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-resource
GetResource(context.Context, GetResourceRequest) (*GetResourceResponse, error)
// CreateResource creates the datacenter identified by the receiver argument in the specified domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-resource
CreateResource(context.Context, CreateResourceRequest) (*CreateResourceResponse, error)
// DeleteResource deletes the datacenter identified by the receiver argument from the domain specified.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-resource
DeleteResource(context.Context, DeleteResourceRequest) (*DeleteResourceResponse, error)
// UpdateResource updates the datacenter identified in the receiver argument in the provided domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-resource
UpdateResource(context.Context, UpdateResourceRequest) (*UpdateResourceResponse, error)
// ASMaps
// ListASMaps retrieves all AsMaps.
//
// See: https://techdocs.akamai.com/gtm/reference/get-as-maps
ListASMaps(context.Context, ListASMapsRequest) ([]ASMap, error)
// GetASMap retrieves a AsMap with the given name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-as-map
GetASMap(context.Context, GetASMapRequest) (*GetASMapResponse, error)
// CreateASMap creates the datacenter identified by the receiver argument in the specified domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-as-map
CreateASMap(context.Context, CreateASMapRequest) (*CreateASMapResponse, error)
// DeleteASMap deletes the datacenter identified by the receiver argument from the domain specified.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-as-map
DeleteASMap(context.Context, DeleteASMapRequest) (*DeleteASMapResponse, error)
// UpdateASMap updates the datacenter identified in the receiver argument in the provided domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-as-map
UpdateASMap(context.Context, UpdateASMapRequest) (*UpdateASMapResponse, error)
// GeoMaps
// ListGeoMaps retrieves all GeoMaps.
//
// See: https://techdocs.akamai.com/gtm/reference/get-geographic-maps
ListGeoMaps(context.Context, ListGeoMapsRequest) ([]GeoMap, error)
// GetGeoMap retrieves a GeoMap with the given name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-geographic-map
GetGeoMap(context.Context, GetGeoMapRequest) (*GetGeoMapResponse, error)
// CreateGeoMap creates the datacenter identified by the receiver argument in the specified domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-geographic-map
CreateGeoMap(context.Context, CreateGeoMapRequest) (*CreateGeoMapResponse, error)
// DeleteGeoMap deletes the datacenter identified by the receiver argument from the domain specified.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-geographic-map
DeleteGeoMap(context.Context, DeleteGeoMapRequest) (*DeleteGeoMapResponse, error)
// UpdateGeoMap updates the datacenter identified in the receiver argument in the provided domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-geographic-map
UpdateGeoMap(context.Context, UpdateGeoMapRequest) (*UpdateGeoMapResponse, error)
// CIDRMaps
// ListCIDRMaps retrieves all CIDRMaps.
//
// See: https://techdocs.akamai.com/gtm/reference/get-cidr-maps
ListCIDRMaps(context.Context, ListCIDRMapsRequest) ([]CIDRMap, error)
// GetCIDRMap retrieves a CIDRMap with the given name.
//
// See: https://techdocs.akamai.com/gtm/reference/get-cidr-map
GetCIDRMap(context.Context, GetCIDRMapRequest) (*GetCIDRMapResponse, error)
// CreateCIDRMap creates the datacenter identified by the receiver argument in the specified domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-cidr-map
CreateCIDRMap(context.Context, CreateCIDRMapRequest) (*CreateCIDRMapResponse, error)
// DeleteCIDRMap deletes the datacenter identified by the receiver argument from the domain specified.
//
// See: https://techdocs.akamai.com/gtm/reference/delete-cidr-maps
DeleteCIDRMap(context.Context, DeleteCIDRMapRequest) (*DeleteCIDRMapResponse, error)
// UpdateCIDRMap updates the datacenter identified in the receiver argument in the provided domain.
//
// See: https://techdocs.akamai.com/gtm/reference/put-cidr-map
UpdateCIDRMap(context.Context, UpdateCIDRMapRequest) (*UpdateCIDRMapResponse, error)
}
gtm struct {
session.Session
}
// Option defines a GTM option
Option func(*gtm)
// ClientFunc is a gtm client new method, this can used for mocking
ClientFunc func(sess session.Session, opts ...Option) GTM
)
// Client returns a new dns Client instance with the specified controller
func Client(sess session.Session, opts ...Option) GTM {
p := >m{
Session: sess,
}
for _, opt := range opts {
opt(p)
}
return p
}
// Exec overrides the session.Exec to add dns options
func (g *gtm) Exec(r *http.Request, out interface{}, in ...interface{}) (*http.Response, error) {
return g.Session.Exec(r, out, in...)
}