1 package trafficmanager
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/tracing"
14 "net/http"
15 )
16
17
18 type EndpointsClient struct {
19 BaseClient
20 }
21
22
23 func NewEndpointsClient(subscriptionID string) EndpointsClient {
24 return NewEndpointsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewEndpointsClientWithBaseURI(baseURI string, subscriptionID string) EndpointsClient {
30 return EndpointsClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36
37
38
39
40
41 func (client EndpointsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.CreateOrUpdate")
44 defer func() {
45 sc := -1
46 if result.Response.Response != nil {
47 sc = result.Response.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters)
53 if err != nil {
54 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", nil, "Failure preparing request")
55 return
56 }
57
58 resp, err := client.CreateOrUpdateSender(req)
59 if err != nil {
60 result.Response = autorest.Response{Response: resp}
61 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure sending request")
62 return
63 }
64
65 result, err = client.CreateOrUpdateResponder(resp)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure responding to request")
68 return
69 }
70
71 return
72 }
73
74
75 func (client EndpointsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (*http.Request, error) {
76 pathParameters := map[string]interface{}{
77 "endpointName": autorest.Encode("path", endpointName),
78 "endpointType": autorest.Encode("path", endpointType),
79 "profileName": autorest.Encode("path", profileName),
80 "resourceGroupName": autorest.Encode("path", resourceGroupName),
81 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
82 }
83
84 const APIVersion = "2017-03-01"
85 queryParameters := map[string]interface{}{
86 "api-version": APIVersion,
87 }
88
89 preparer := autorest.CreatePreparer(
90 autorest.AsContentType("application/json; charset=utf-8"),
91 autorest.AsPut(),
92 autorest.WithBaseURL(client.BaseURI),
93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
94 autorest.WithJSON(parameters),
95 autorest.WithQueryParameters(queryParameters))
96 return preparer.Prepare((&http.Request{}).WithContext(ctx))
97 }
98
99
100
101 func (client EndpointsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
102 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
103 }
104
105
106
107 func (client EndpointsClient) CreateOrUpdateResponder(resp *http.Response) (result Endpoint, err error) {
108 err = autorest.Respond(
109 resp,
110 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
111 autorest.ByUnmarshallingJSON(&result),
112 autorest.ByClosing())
113 result.Response = autorest.Response{Response: resp}
114 return
115 }
116
117
118
119
120
121
122
123 func (client EndpointsClient) Delete(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string) (result DeleteOperationResult, err error) {
124 if tracing.IsEnabled() {
125 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Delete")
126 defer func() {
127 sc := -1
128 if result.Response.Response != nil {
129 sc = result.Response.Response.StatusCode
130 }
131 tracing.EndSpan(ctx, sc, err)
132 }()
133 }
134 req, err := client.DeletePreparer(ctx, resourceGroupName, profileName, endpointType, endpointName)
135 if err != nil {
136 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", nil, "Failure preparing request")
137 return
138 }
139
140 resp, err := client.DeleteSender(req)
141 if err != nil {
142 result.Response = autorest.Response{Response: resp}
143 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure sending request")
144 return
145 }
146
147 result, err = client.DeleteResponder(resp)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure responding to request")
150 return
151 }
152
153 return
154 }
155
156
157 func (client EndpointsClient) DeletePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string) (*http.Request, error) {
158 pathParameters := map[string]interface{}{
159 "endpointName": autorest.Encode("path", endpointName),
160 "endpointType": autorest.Encode("path", endpointType),
161 "profileName": autorest.Encode("path", profileName),
162 "resourceGroupName": autorest.Encode("path", resourceGroupName),
163 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
164 }
165
166 const APIVersion = "2017-03-01"
167 queryParameters := map[string]interface{}{
168 "api-version": APIVersion,
169 }
170
171 preparer := autorest.CreatePreparer(
172 autorest.AsDelete(),
173 autorest.WithBaseURL(client.BaseURI),
174 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
175 autorest.WithQueryParameters(queryParameters))
176 return preparer.Prepare((&http.Request{}).WithContext(ctx))
177 }
178
179
180
181 func (client EndpointsClient) DeleteSender(req *http.Request) (*http.Response, error) {
182 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
183 }
184
185
186
187 func (client EndpointsClient) DeleteResponder(resp *http.Response) (result DeleteOperationResult, err error) {
188 err = autorest.Respond(
189 resp,
190 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
191 autorest.ByUnmarshallingJSON(&result),
192 autorest.ByClosing())
193 result.Response = autorest.Response{Response: resp}
194 return
195 }
196
197
198
199
200
201
202
203 func (client EndpointsClient) Get(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string) (result Endpoint, err error) {
204 if tracing.IsEnabled() {
205 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Get")
206 defer func() {
207 sc := -1
208 if result.Response.Response != nil {
209 sc = result.Response.Response.StatusCode
210 }
211 tracing.EndSpan(ctx, sc, err)
212 }()
213 }
214 req, err := client.GetPreparer(ctx, resourceGroupName, profileName, endpointType, endpointName)
215 if err != nil {
216 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", nil, "Failure preparing request")
217 return
218 }
219
220 resp, err := client.GetSender(req)
221 if err != nil {
222 result.Response = autorest.Response{Response: resp}
223 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure sending request")
224 return
225 }
226
227 result, err = client.GetResponder(resp)
228 if err != nil {
229 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure responding to request")
230 return
231 }
232
233 return
234 }
235
236
237 func (client EndpointsClient) GetPreparer(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string) (*http.Request, error) {
238 pathParameters := map[string]interface{}{
239 "endpointName": autorest.Encode("path", endpointName),
240 "endpointType": autorest.Encode("path", endpointType),
241 "profileName": autorest.Encode("path", profileName),
242 "resourceGroupName": autorest.Encode("path", resourceGroupName),
243 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
244 }
245
246 const APIVersion = "2017-03-01"
247 queryParameters := map[string]interface{}{
248 "api-version": APIVersion,
249 }
250
251 preparer := autorest.CreatePreparer(
252 autorest.AsGet(),
253 autorest.WithBaseURL(client.BaseURI),
254 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
255 autorest.WithQueryParameters(queryParameters))
256 return preparer.Prepare((&http.Request{}).WithContext(ctx))
257 }
258
259
260
261 func (client EndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
262 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
263 }
264
265
266
267 func (client EndpointsClient) GetResponder(resp *http.Response) (result Endpoint, err error) {
268 err = autorest.Respond(
269 resp,
270 azure.WithErrorUnlessStatusCode(http.StatusOK),
271 autorest.ByUnmarshallingJSON(&result),
272 autorest.ByClosing())
273 result.Response = autorest.Response{Response: resp}
274 return
275 }
276
277
278
279
280
281
282
283
284 func (client EndpointsClient) Update(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) {
285 if tracing.IsEnabled() {
286 ctx = tracing.StartSpan(ctx, fqdn+"/EndpointsClient.Update")
287 defer func() {
288 sc := -1
289 if result.Response.Response != nil {
290 sc = result.Response.Response.StatusCode
291 }
292 tracing.EndSpan(ctx, sc, err)
293 }()
294 }
295 req, err := client.UpdatePreparer(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters)
296 if err != nil {
297 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", nil, "Failure preparing request")
298 return
299 }
300
301 resp, err := client.UpdateSender(req)
302 if err != nil {
303 result.Response = autorest.Response{Response: resp}
304 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure sending request")
305 return
306 }
307
308 result, err = client.UpdateResponder(resp)
309 if err != nil {
310 err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure responding to request")
311 return
312 }
313
314 return
315 }
316
317
318 func (client EndpointsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (*http.Request, error) {
319 pathParameters := map[string]interface{}{
320 "endpointName": autorest.Encode("path", endpointName),
321 "endpointType": autorest.Encode("path", endpointType),
322 "profileName": autorest.Encode("path", profileName),
323 "resourceGroupName": autorest.Encode("path", resourceGroupName),
324 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
325 }
326
327 const APIVersion = "2017-03-01"
328 queryParameters := map[string]interface{}{
329 "api-version": APIVersion,
330 }
331
332 preparer := autorest.CreatePreparer(
333 autorest.AsContentType("application/json; charset=utf-8"),
334 autorest.AsPatch(),
335 autorest.WithBaseURL(client.BaseURI),
336 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
337 autorest.WithJSON(parameters),
338 autorest.WithQueryParameters(queryParameters))
339 return preparer.Prepare((&http.Request{}).WithContext(ctx))
340 }
341
342
343
344 func (client EndpointsClient) UpdateSender(req *http.Request) (*http.Response, error) {
345 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
346 }
347
348
349
350 func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) {
351 err = autorest.Respond(
352 resp,
353 azure.WithErrorUnlessStatusCode(http.StatusOK),
354 autorest.ByUnmarshallingJSON(&result),
355 autorest.ByClosing())
356 result.Response = autorest.Response{Response: resp}
357 return
358 }
359
View as plain text