1 package apimanagement
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/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type ServiceClient struct {
20 BaseClient
21 }
22
23
24 func NewServiceClient(subscriptionID string) ServiceClient {
25 return NewServiceClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30 func NewServiceClientWithBaseURI(baseURI string, subscriptionID string) ServiceClient {
31 return ServiceClient{NewWithBaseURI(baseURI, subscriptionID)}
32 }
33
34
35
36
37
38
39
40
41
42 func (client ServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (result ServiceApplyNetworkConfigurationUpdatesFuture, err error) {
43 if tracing.IsEnabled() {
44 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ApplyNetworkConfigurationUpdates")
45 defer func() {
46 sc := -1
47 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
48 sc = result.FutureAPI.Response().StatusCode
49 }
50 tracing.EndSpan(ctx, sc, err)
51 }()
52 }
53 if err := validation.Validate([]validation.Validation{
54 {TargetValue: serviceName,
55 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
56 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
57 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil {
58 return result, validation.NewError("apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", err.Error())
59 }
60
61 req, err := client.ApplyNetworkConfigurationUpdatesPreparer(ctx, resourceGroupName, serviceName, parameters)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request")
64 return
65 }
66
67 result, err = client.ApplyNetworkConfigurationUpdatesSender(req)
68 if err != nil {
69 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ApplyNetworkConfigurationUpdates", result.Response(), "Failure sending request")
70 return
71 }
72
73 return
74 }
75
76
77 func (client ServiceClient) ApplyNetworkConfigurationUpdatesPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters *ServiceApplyNetworkConfigurationParameters) (*http.Request, error) {
78 pathParameters := map[string]interface{}{
79 "resourceGroupName": autorest.Encode("path", resourceGroupName),
80 "serviceName": autorest.Encode("path", serviceName),
81 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
82 }
83
84 const APIVersion = "2020-12-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.AsPost(),
92 autorest.WithBaseURL(client.BaseURI),
93 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates", pathParameters),
94 autorest.WithQueryParameters(queryParameters))
95 if parameters != nil {
96 preparer = autorest.DecoratePreparer(preparer,
97 autorest.WithJSON(parameters))
98 }
99 return preparer.Prepare((&http.Request{}).WithContext(ctx))
100 }
101
102
103
104 func (client ServiceClient) ApplyNetworkConfigurationUpdatesSender(req *http.Request) (future ServiceApplyNetworkConfigurationUpdatesFuture, err error) {
105 var resp *http.Response
106 future.FutureAPI = &azure.Future{}
107 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
108 if err != nil {
109 return
110 }
111 var azf azure.Future
112 azf, err = azure.NewFutureFromResponse(resp)
113 future.FutureAPI = &azf
114 future.Result = future.result
115 return
116 }
117
118
119
120 func (client ServiceClient) ApplyNetworkConfigurationUpdatesResponder(resp *http.Response) (result ServiceResource, err error) {
121 err = autorest.Respond(
122 resp,
123 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
124 autorest.ByUnmarshallingJSON(&result),
125 autorest.ByClosing())
126 result.Response = autorest.Response{Response: resp}
127 return
128 }
129
130
131
132
133
134
135
136 func (client ServiceClient) Backup(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceBackupFuture, err error) {
137 if tracing.IsEnabled() {
138 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Backup")
139 defer func() {
140 sc := -1
141 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
142 sc = result.FutureAPI.Response().StatusCode
143 }
144 tracing.EndSpan(ctx, sc, err)
145 }()
146 }
147 if err := validation.Validate([]validation.Validation{
148 {TargetValue: serviceName,
149 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
150 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
151 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
152 {TargetValue: parameters,
153 Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil},
154 {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil},
155 {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil},
156 {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
157 return result, validation.NewError("apimanagement.ServiceClient", "Backup", err.Error())
158 }
159
160 req, err := client.BackupPreparer(ctx, resourceGroupName, serviceName, parameters)
161 if err != nil {
162 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", nil, "Failure preparing request")
163 return
164 }
165
166 result, err = client.BackupSender(req)
167 if err != nil {
168 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Backup", result.Response(), "Failure sending request")
169 return
170 }
171
172 return
173 }
174
175
176 func (client ServiceClient) BackupPreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) {
177 pathParameters := map[string]interface{}{
178 "resourceGroupName": autorest.Encode("path", resourceGroupName),
179 "serviceName": autorest.Encode("path", serviceName),
180 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
181 }
182
183 const APIVersion = "2020-12-01"
184 queryParameters := map[string]interface{}{
185 "api-version": APIVersion,
186 }
187
188 preparer := autorest.CreatePreparer(
189 autorest.AsContentType("application/json; charset=utf-8"),
190 autorest.AsPost(),
191 autorest.WithBaseURL(client.BaseURI),
192 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup", pathParameters),
193 autorest.WithJSON(parameters),
194 autorest.WithQueryParameters(queryParameters))
195 return preparer.Prepare((&http.Request{}).WithContext(ctx))
196 }
197
198
199
200 func (client ServiceClient) BackupSender(req *http.Request) (future ServiceBackupFuture, err error) {
201 var resp *http.Response
202 future.FutureAPI = &azure.Future{}
203 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
204 if err != nil {
205 return
206 }
207 var azf azure.Future
208 azf, err = azure.NewFutureFromResponse(resp)
209 future.FutureAPI = &azf
210 future.Result = future.result
211 return
212 }
213
214
215
216 func (client ServiceClient) BackupResponder(resp *http.Response) (result ServiceResource, err error) {
217 err = autorest.Respond(
218 resp,
219 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
220 autorest.ByUnmarshallingJSON(&result),
221 autorest.ByClosing())
222 result.Response = autorest.Response{Response: resp}
223 return
224 }
225
226
227
228
229 func (client ServiceClient) CheckNameAvailability(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (result ServiceNameAvailabilityResult, err error) {
230 if tracing.IsEnabled() {
231 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CheckNameAvailability")
232 defer func() {
233 sc := -1
234 if result.Response.Response != nil {
235 sc = result.Response.Response.StatusCode
236 }
237 tracing.EndSpan(ctx, sc, err)
238 }()
239 }
240 if err := validation.Validate([]validation.Validation{
241 {TargetValue: parameters,
242 Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
243 return result, validation.NewError("apimanagement.ServiceClient", "CheckNameAvailability", err.Error())
244 }
245
246 req, err := client.CheckNameAvailabilityPreparer(ctx, parameters)
247 if err != nil {
248 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", nil, "Failure preparing request")
249 return
250 }
251
252 resp, err := client.CheckNameAvailabilitySender(req)
253 if err != nil {
254 result.Response = autorest.Response{Response: resp}
255 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure sending request")
256 return
257 }
258
259 result, err = client.CheckNameAvailabilityResponder(resp)
260 if err != nil {
261 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CheckNameAvailability", resp, "Failure responding to request")
262 return
263 }
264
265 return
266 }
267
268
269 func (client ServiceClient) CheckNameAvailabilityPreparer(ctx context.Context, parameters ServiceCheckNameAvailabilityParameters) (*http.Request, error) {
270 pathParameters := map[string]interface{}{
271 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
272 }
273
274 const APIVersion = "2020-12-01"
275 queryParameters := map[string]interface{}{
276 "api-version": APIVersion,
277 }
278
279 preparer := autorest.CreatePreparer(
280 autorest.AsContentType("application/json; charset=utf-8"),
281 autorest.AsPost(),
282 autorest.WithBaseURL(client.BaseURI),
283 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability", pathParameters),
284 autorest.WithJSON(parameters),
285 autorest.WithQueryParameters(queryParameters))
286 return preparer.Prepare((&http.Request{}).WithContext(ctx))
287 }
288
289
290
291 func (client ServiceClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
292 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
293 }
294
295
296
297 func (client ServiceClient) CheckNameAvailabilityResponder(resp *http.Response) (result ServiceNameAvailabilityResult, err error) {
298 err = autorest.Respond(
299 resp,
300 azure.WithErrorUnlessStatusCode(http.StatusOK),
301 autorest.ByUnmarshallingJSON(&result),
302 autorest.ByClosing())
303 result.Response = autorest.Response{Response: resp}
304 return
305 }
306
307
308
309
310
311
312
313 func (client ServiceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (result ServiceCreateOrUpdateFuture, err error) {
314 if tracing.IsEnabled() {
315 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.CreateOrUpdate")
316 defer func() {
317 sc := -1
318 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
319 sc = result.FutureAPI.Response().StatusCode
320 }
321 tracing.EndSpan(ctx, sc, err)
322 }()
323 }
324 if err := validation.Validate([]validation.Validation{
325 {TargetValue: serviceName,
326 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
327 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
328 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
329 {TargetValue: parameters,
330 Constraints: []validation.Constraint{{Target: "parameters.ServiceProperties", Name: validation.Null, Rule: true,
331 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.Null, Rule: true,
332 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherEmail", Name: validation.MaxLength, Rule: 100, Chain: nil}}},
333 {Target: "parameters.ServiceProperties.PublisherName", Name: validation.Null, Rule: true,
334 Chain: []validation.Constraint{{Target: "parameters.ServiceProperties.PublisherName", Name: validation.MaxLength, Rule: 100, Chain: nil}}},
335 }},
336 {Target: "parameters.Sku", Name: validation.Null, Rule: true,
337 Chain: []validation.Constraint{{Target: "parameters.Sku.Capacity", Name: validation.Null, Rule: true, Chain: nil}}},
338 {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
339 return result, validation.NewError("apimanagement.ServiceClient", "CreateOrUpdate", err.Error())
340 }
341
342 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, parameters)
343 if err != nil {
344 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", nil, "Failure preparing request")
345 return
346 }
347
348 result, err = client.CreateOrUpdateSender(req)
349 if err != nil {
350 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "CreateOrUpdate", result.Response(), "Failure sending request")
351 return
352 }
353
354 return
355 }
356
357
358 func (client ServiceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceResource) (*http.Request, error) {
359 pathParameters := map[string]interface{}{
360 "resourceGroupName": autorest.Encode("path", resourceGroupName),
361 "serviceName": autorest.Encode("path", serviceName),
362 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
363 }
364
365 const APIVersion = "2020-12-01"
366 queryParameters := map[string]interface{}{
367 "api-version": APIVersion,
368 }
369
370 parameters.Etag = nil
371 preparer := autorest.CreatePreparer(
372 autorest.AsContentType("application/json; charset=utf-8"),
373 autorest.AsPut(),
374 autorest.WithBaseURL(client.BaseURI),
375 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters),
376 autorest.WithJSON(parameters),
377 autorest.WithQueryParameters(queryParameters))
378 return preparer.Prepare((&http.Request{}).WithContext(ctx))
379 }
380
381
382
383 func (client ServiceClient) CreateOrUpdateSender(req *http.Request) (future ServiceCreateOrUpdateFuture, err error) {
384 var resp *http.Response
385 future.FutureAPI = &azure.Future{}
386 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
387 if err != nil {
388 return
389 }
390 var azf azure.Future
391 azf, err = azure.NewFutureFromResponse(resp)
392 future.FutureAPI = &azf
393 future.Result = future.result
394 return
395 }
396
397
398
399 func (client ServiceClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) {
400 err = autorest.Respond(
401 resp,
402 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
403 autorest.ByUnmarshallingJSON(&result),
404 autorest.ByClosing())
405 result.Response = autorest.Response{Response: resp}
406 return
407 }
408
409
410
411
412
413 func (client ServiceClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceDeleteFuture, err error) {
414 if tracing.IsEnabled() {
415 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Delete")
416 defer func() {
417 sc := -1
418 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
419 sc = result.FutureAPI.Response().StatusCode
420 }
421 tracing.EndSpan(ctx, sc, err)
422 }()
423 }
424 if err := validation.Validate([]validation.Validation{
425 {TargetValue: serviceName,
426 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
427 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
428 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil {
429 return result, validation.NewError("apimanagement.ServiceClient", "Delete", err.Error())
430 }
431
432 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName)
433 if err != nil {
434 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", nil, "Failure preparing request")
435 return
436 }
437
438 result, err = client.DeleteSender(req)
439 if err != nil {
440 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Delete", result.Response(), "Failure sending request")
441 return
442 }
443
444 return
445 }
446
447
448 func (client ServiceClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
449 pathParameters := map[string]interface{}{
450 "resourceGroupName": autorest.Encode("path", resourceGroupName),
451 "serviceName": autorest.Encode("path", serviceName),
452 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
453 }
454
455 const APIVersion = "2020-12-01"
456 queryParameters := map[string]interface{}{
457 "api-version": APIVersion,
458 }
459
460 preparer := autorest.CreatePreparer(
461 autorest.AsDelete(),
462 autorest.WithBaseURL(client.BaseURI),
463 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters),
464 autorest.WithQueryParameters(queryParameters))
465 return preparer.Prepare((&http.Request{}).WithContext(ctx))
466 }
467
468
469
470 func (client ServiceClient) DeleteSender(req *http.Request) (future ServiceDeleteFuture, err error) {
471 var resp *http.Response
472 future.FutureAPI = &azure.Future{}
473 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
474 if err != nil {
475 return
476 }
477 var azf azure.Future
478 azf, err = azure.NewFutureFromResponse(resp)
479 future.FutureAPI = &azf
480 future.Result = future.result
481 return
482 }
483
484
485
486 func (client ServiceClient) DeleteResponder(resp *http.Response) (result ServiceResource, err error) {
487 err = autorest.Respond(
488 resp,
489 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
490 autorest.ByUnmarshallingJSON(&result),
491 autorest.ByClosing())
492 result.Response = autorest.Response{Response: resp}
493 return
494 }
495
496
497
498
499
500 func (client ServiceClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceResource, err error) {
501 if tracing.IsEnabled() {
502 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Get")
503 defer func() {
504 sc := -1
505 if result.Response.Response != nil {
506 sc = result.Response.Response.StatusCode
507 }
508 tracing.EndSpan(ctx, sc, err)
509 }()
510 }
511 if err := validation.Validate([]validation.Validation{
512 {TargetValue: serviceName,
513 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
514 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
515 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil {
516 return result, validation.NewError("apimanagement.ServiceClient", "Get", err.Error())
517 }
518
519 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName)
520 if err != nil {
521 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", nil, "Failure preparing request")
522 return
523 }
524
525 resp, err := client.GetSender(req)
526 if err != nil {
527 result.Response = autorest.Response{Response: resp}
528 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure sending request")
529 return
530 }
531
532 result, err = client.GetResponder(resp)
533 if err != nil {
534 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Get", resp, "Failure responding to request")
535 return
536 }
537
538 return
539 }
540
541
542 func (client ServiceClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
543 pathParameters := map[string]interface{}{
544 "resourceGroupName": autorest.Encode("path", resourceGroupName),
545 "serviceName": autorest.Encode("path", serviceName),
546 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
547 }
548
549 const APIVersion = "2020-12-01"
550 queryParameters := map[string]interface{}{
551 "api-version": APIVersion,
552 }
553
554 preparer := autorest.CreatePreparer(
555 autorest.AsGet(),
556 autorest.WithBaseURL(client.BaseURI),
557 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters),
558 autorest.WithQueryParameters(queryParameters))
559 return preparer.Prepare((&http.Request{}).WithContext(ctx))
560 }
561
562
563
564 func (client ServiceClient) GetSender(req *http.Request) (*http.Response, error) {
565 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
566 }
567
568
569
570 func (client ServiceClient) GetResponder(resp *http.Response) (result ServiceResource, err error) {
571 err = autorest.Respond(
572 resp,
573 azure.WithErrorUnlessStatusCode(http.StatusOK),
574 autorest.ByUnmarshallingJSON(&result),
575 autorest.ByClosing())
576 result.Response = autorest.Response{Response: resp}
577 return
578 }
579
580
581 func (client ServiceClient) GetDomainOwnershipIdentifier(ctx context.Context) (result ServiceGetDomainOwnershipIdentifierResult, err error) {
582 if tracing.IsEnabled() {
583 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.GetDomainOwnershipIdentifier")
584 defer func() {
585 sc := -1
586 if result.Response.Response != nil {
587 sc = result.Response.Response.StatusCode
588 }
589 tracing.EndSpan(ctx, sc, err)
590 }()
591 }
592 req, err := client.GetDomainOwnershipIdentifierPreparer(ctx)
593 if err != nil {
594 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", nil, "Failure preparing request")
595 return
596 }
597
598 resp, err := client.GetDomainOwnershipIdentifierSender(req)
599 if err != nil {
600 result.Response = autorest.Response{Response: resp}
601 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", resp, "Failure sending request")
602 return
603 }
604
605 result, err = client.GetDomainOwnershipIdentifierResponder(resp)
606 if err != nil {
607 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetDomainOwnershipIdentifier", resp, "Failure responding to request")
608 return
609 }
610
611 return
612 }
613
614
615 func (client ServiceClient) GetDomainOwnershipIdentifierPreparer(ctx context.Context) (*http.Request, error) {
616 pathParameters := map[string]interface{}{
617 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
618 }
619
620 const APIVersion = "2020-12-01"
621 queryParameters := map[string]interface{}{
622 "api-version": APIVersion,
623 }
624
625 preparer := autorest.CreatePreparer(
626 autorest.AsPost(),
627 autorest.WithBaseURL(client.BaseURI),
628 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", pathParameters),
629 autorest.WithQueryParameters(queryParameters))
630 return preparer.Prepare((&http.Request{}).WithContext(ctx))
631 }
632
633
634
635 func (client ServiceClient) GetDomainOwnershipIdentifierSender(req *http.Request) (*http.Response, error) {
636 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
637 }
638
639
640
641 func (client ServiceClient) GetDomainOwnershipIdentifierResponder(resp *http.Response) (result ServiceGetDomainOwnershipIdentifierResult, err error) {
642 err = autorest.Respond(
643 resp,
644 azure.WithErrorUnlessStatusCode(http.StatusOK),
645 autorest.ByUnmarshallingJSON(&result),
646 autorest.ByClosing())
647 result.Response = autorest.Response{Response: resp}
648 return
649 }
650
651
652
653
654
655 func (client ServiceClient) GetSsoToken(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceGetSsoTokenResult, err error) {
656 if tracing.IsEnabled() {
657 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.GetSsoToken")
658 defer func() {
659 sc := -1
660 if result.Response.Response != nil {
661 sc = result.Response.Response.StatusCode
662 }
663 tracing.EndSpan(ctx, sc, err)
664 }()
665 }
666 if err := validation.Validate([]validation.Validation{
667 {TargetValue: serviceName,
668 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
669 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
670 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil {
671 return result, validation.NewError("apimanagement.ServiceClient", "GetSsoToken", err.Error())
672 }
673
674 req, err := client.GetSsoTokenPreparer(ctx, resourceGroupName, serviceName)
675 if err != nil {
676 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", nil, "Failure preparing request")
677 return
678 }
679
680 resp, err := client.GetSsoTokenSender(req)
681 if err != nil {
682 result.Response = autorest.Response{Response: resp}
683 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure sending request")
684 return
685 }
686
687 result, err = client.GetSsoTokenResponder(resp)
688 if err != nil {
689 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "GetSsoToken", resp, "Failure responding to request")
690 return
691 }
692
693 return
694 }
695
696
697 func (client ServiceClient) GetSsoTokenPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) {
698 pathParameters := map[string]interface{}{
699 "resourceGroupName": autorest.Encode("path", resourceGroupName),
700 "serviceName": autorest.Encode("path", serviceName),
701 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
702 }
703
704 const APIVersion = "2020-12-01"
705 queryParameters := map[string]interface{}{
706 "api-version": APIVersion,
707 }
708
709 preparer := autorest.CreatePreparer(
710 autorest.AsPost(),
711 autorest.WithBaseURL(client.BaseURI),
712 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken", pathParameters),
713 autorest.WithQueryParameters(queryParameters))
714 return preparer.Prepare((&http.Request{}).WithContext(ctx))
715 }
716
717
718
719 func (client ServiceClient) GetSsoTokenSender(req *http.Request) (*http.Response, error) {
720 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
721 }
722
723
724
725 func (client ServiceClient) GetSsoTokenResponder(resp *http.Response) (result ServiceGetSsoTokenResult, err error) {
726 err = autorest.Respond(
727 resp,
728 azure.WithErrorUnlessStatusCode(http.StatusOK),
729 autorest.ByUnmarshallingJSON(&result),
730 autorest.ByClosing())
731 result.Response = autorest.Response{Response: resp}
732 return
733 }
734
735
736 func (client ServiceClient) List(ctx context.Context) (result ServiceListResultPage, err error) {
737 if tracing.IsEnabled() {
738 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List")
739 defer func() {
740 sc := -1
741 if result.slr.Response.Response != nil {
742 sc = result.slr.Response.Response.StatusCode
743 }
744 tracing.EndSpan(ctx, sc, err)
745 }()
746 }
747 result.fn = client.listNextResults
748 req, err := client.ListPreparer(ctx)
749 if err != nil {
750 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", nil, "Failure preparing request")
751 return
752 }
753
754 resp, err := client.ListSender(req)
755 if err != nil {
756 result.slr.Response = autorest.Response{Response: resp}
757 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure sending request")
758 return
759 }
760
761 result.slr, err = client.ListResponder(resp)
762 if err != nil {
763 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "List", resp, "Failure responding to request")
764 return
765 }
766 if result.slr.hasNextLink() && result.slr.IsEmpty() {
767 err = result.NextWithContext(ctx)
768 return
769 }
770
771 return
772 }
773
774
775 func (client ServiceClient) ListPreparer(ctx context.Context) (*http.Request, error) {
776 pathParameters := map[string]interface{}{
777 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
778 }
779
780 const APIVersion = "2020-12-01"
781 queryParameters := map[string]interface{}{
782 "api-version": APIVersion,
783 }
784
785 preparer := autorest.CreatePreparer(
786 autorest.AsGet(),
787 autorest.WithBaseURL(client.BaseURI),
788 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service", pathParameters),
789 autorest.WithQueryParameters(queryParameters))
790 return preparer.Prepare((&http.Request{}).WithContext(ctx))
791 }
792
793
794
795 func (client ServiceClient) ListSender(req *http.Request) (*http.Response, error) {
796 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
797 }
798
799
800
801 func (client ServiceClient) ListResponder(resp *http.Response) (result ServiceListResult, err error) {
802 err = autorest.Respond(
803 resp,
804 azure.WithErrorUnlessStatusCode(http.StatusOK),
805 autorest.ByUnmarshallingJSON(&result),
806 autorest.ByClosing())
807 result.Response = autorest.Response{Response: resp}
808 return
809 }
810
811
812 func (client ServiceClient) listNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) {
813 req, err := lastResults.serviceListResultPreparer(ctx)
814 if err != nil {
815 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", nil, "Failure preparing next results request")
816 }
817 if req == nil {
818 return
819 }
820 resp, err := client.ListSender(req)
821 if err != nil {
822 result.Response = autorest.Response{Response: resp}
823 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure sending next results request")
824 }
825 result, err = client.ListResponder(resp)
826 if err != nil {
827 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listNextResults", resp, "Failure responding to next results request")
828 }
829 return
830 }
831
832
833 func (client ServiceClient) ListComplete(ctx context.Context) (result ServiceListResultIterator, err error) {
834 if tracing.IsEnabled() {
835 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.List")
836 defer func() {
837 sc := -1
838 if result.Response().Response.Response != nil {
839 sc = result.page.Response().Response.Response.StatusCode
840 }
841 tracing.EndSpan(ctx, sc, err)
842 }()
843 }
844 result.page, err = client.List(ctx)
845 return
846 }
847
848
849
850
851 func (client ServiceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceListResultPage, err error) {
852 if tracing.IsEnabled() {
853 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup")
854 defer func() {
855 sc := -1
856 if result.slr.Response.Response != nil {
857 sc = result.slr.Response.Response.StatusCode
858 }
859 tracing.EndSpan(ctx, sc, err)
860 }()
861 }
862 result.fn = client.listByResourceGroupNextResults
863 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
864 if err != nil {
865 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", nil, "Failure preparing request")
866 return
867 }
868
869 resp, err := client.ListByResourceGroupSender(req)
870 if err != nil {
871 result.slr.Response = autorest.Response{Response: resp}
872 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure sending request")
873 return
874 }
875
876 result.slr, err = client.ListByResourceGroupResponder(resp)
877 if err != nil {
878 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "ListByResourceGroup", resp, "Failure responding to request")
879 return
880 }
881 if result.slr.hasNextLink() && result.slr.IsEmpty() {
882 err = result.NextWithContext(ctx)
883 return
884 }
885
886 return
887 }
888
889
890 func (client ServiceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
891 pathParameters := map[string]interface{}{
892 "resourceGroupName": autorest.Encode("path", resourceGroupName),
893 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
894 }
895
896 const APIVersion = "2020-12-01"
897 queryParameters := map[string]interface{}{
898 "api-version": APIVersion,
899 }
900
901 preparer := autorest.CreatePreparer(
902 autorest.AsGet(),
903 autorest.WithBaseURL(client.BaseURI),
904 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service", pathParameters),
905 autorest.WithQueryParameters(queryParameters))
906 return preparer.Prepare((&http.Request{}).WithContext(ctx))
907 }
908
909
910
911 func (client ServiceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
912 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
913 }
914
915
916
917 func (client ServiceClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceListResult, err error) {
918 err = autorest.Respond(
919 resp,
920 azure.WithErrorUnlessStatusCode(http.StatusOK),
921 autorest.ByUnmarshallingJSON(&result),
922 autorest.ByClosing())
923 result.Response = autorest.Response{Response: resp}
924 return
925 }
926
927
928 func (client ServiceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServiceListResult) (result ServiceListResult, err error) {
929 req, err := lastResults.serviceListResultPreparer(ctx)
930 if err != nil {
931 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
932 }
933 if req == nil {
934 return
935 }
936 resp, err := client.ListByResourceGroupSender(req)
937 if err != nil {
938 result.Response = autorest.Response{Response: resp}
939 return result, autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
940 }
941 result, err = client.ListByResourceGroupResponder(resp)
942 if err != nil {
943 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
944 }
945 return
946 }
947
948
949 func (client ServiceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServiceListResultIterator, err error) {
950 if tracing.IsEnabled() {
951 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.ListByResourceGroup")
952 defer func() {
953 sc := -1
954 if result.Response().Response.Response != nil {
955 sc = result.page.Response().Response.Response.StatusCode
956 }
957 tracing.EndSpan(ctx, sc, err)
958 }()
959 }
960 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
961 return
962 }
963
964
965
966
967
968
969
970 func (client ServiceClient) Restore(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (result ServiceRestoreFuture, err error) {
971 if tracing.IsEnabled() {
972 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Restore")
973 defer func() {
974 sc := -1
975 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
976 sc = result.FutureAPI.Response().StatusCode
977 }
978 tracing.EndSpan(ctx, sc, err)
979 }()
980 }
981 if err := validation.Validate([]validation.Validation{
982 {TargetValue: serviceName,
983 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
984 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
985 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
986 {TargetValue: parameters,
987 Constraints: []validation.Constraint{{Target: "parameters.StorageAccount", Name: validation.Null, Rule: true, Chain: nil},
988 {Target: "parameters.AccessKey", Name: validation.Null, Rule: true, Chain: nil},
989 {Target: "parameters.ContainerName", Name: validation.Null, Rule: true, Chain: nil},
990 {Target: "parameters.BackupName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
991 return result, validation.NewError("apimanagement.ServiceClient", "Restore", err.Error())
992 }
993
994 req, err := client.RestorePreparer(ctx, resourceGroupName, serviceName, parameters)
995 if err != nil {
996 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", nil, "Failure preparing request")
997 return
998 }
999
1000 result, err = client.RestoreSender(req)
1001 if err != nil {
1002 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Restore", result.Response(), "Failure sending request")
1003 return
1004 }
1005
1006 return
1007 }
1008
1009
1010 func (client ServiceClient) RestorePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceBackupRestoreParameters) (*http.Request, error) {
1011 pathParameters := map[string]interface{}{
1012 "resourceGroupName": autorest.Encode("path", resourceGroupName),
1013 "serviceName": autorest.Encode("path", serviceName),
1014 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
1015 }
1016
1017 const APIVersion = "2020-12-01"
1018 queryParameters := map[string]interface{}{
1019 "api-version": APIVersion,
1020 }
1021
1022 preparer := autorest.CreatePreparer(
1023 autorest.AsContentType("application/json; charset=utf-8"),
1024 autorest.AsPost(),
1025 autorest.WithBaseURL(client.BaseURI),
1026 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore", pathParameters),
1027 autorest.WithJSON(parameters),
1028 autorest.WithQueryParameters(queryParameters))
1029 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1030 }
1031
1032
1033
1034 func (client ServiceClient) RestoreSender(req *http.Request) (future ServiceRestoreFuture, err error) {
1035 var resp *http.Response
1036 future.FutureAPI = &azure.Future{}
1037 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1038 if err != nil {
1039 return
1040 }
1041 var azf azure.Future
1042 azf, err = azure.NewFutureFromResponse(resp)
1043 future.FutureAPI = &azf
1044 future.Result = future.result
1045 return
1046 }
1047
1048
1049
1050 func (client ServiceClient) RestoreResponder(resp *http.Response) (result ServiceResource, err error) {
1051 err = autorest.Respond(
1052 resp,
1053 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1054 autorest.ByUnmarshallingJSON(&result),
1055 autorest.ByClosing())
1056 result.Response = autorest.Response{Response: resp}
1057 return
1058 }
1059
1060
1061
1062
1063
1064
1065 func (client ServiceClient) Update(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (result ServiceUpdateFuture, err error) {
1066 if tracing.IsEnabled() {
1067 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceClient.Update")
1068 defer func() {
1069 sc := -1
1070 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1071 sc = result.FutureAPI.Response().StatusCode
1072 }
1073 tracing.EndSpan(ctx, sc, err)
1074 }()
1075 }
1076 if err := validation.Validate([]validation.Validation{
1077 {TargetValue: serviceName,
1078 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1079 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
1080 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil {
1081 return result, validation.NewError("apimanagement.ServiceClient", "Update", err.Error())
1082 }
1083
1084 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, parameters)
1085 if err != nil {
1086 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", nil, "Failure preparing request")
1087 return
1088 }
1089
1090 result, err = client.UpdateSender(req)
1091 if err != nil {
1092 err = autorest.NewErrorWithError(err, "apimanagement.ServiceClient", "Update", result.Response(), "Failure sending request")
1093 return
1094 }
1095
1096 return
1097 }
1098
1099
1100 func (client ServiceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, parameters ServiceUpdateParameters) (*http.Request, error) {
1101 pathParameters := map[string]interface{}{
1102 "resourceGroupName": autorest.Encode("path", resourceGroupName),
1103 "serviceName": autorest.Encode("path", serviceName),
1104 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
1105 }
1106
1107 const APIVersion = "2020-12-01"
1108 queryParameters := map[string]interface{}{
1109 "api-version": APIVersion,
1110 }
1111
1112 parameters.Etag = nil
1113 preparer := autorest.CreatePreparer(
1114 autorest.AsContentType("application/json; charset=utf-8"),
1115 autorest.AsPatch(),
1116 autorest.WithBaseURL(client.BaseURI),
1117 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", pathParameters),
1118 autorest.WithJSON(parameters),
1119 autorest.WithQueryParameters(queryParameters))
1120 return preparer.Prepare((&http.Request{}).WithContext(ctx))
1121 }
1122
1123
1124
1125 func (client ServiceClient) UpdateSender(req *http.Request) (future ServiceUpdateFuture, err error) {
1126 var resp *http.Response
1127 future.FutureAPI = &azure.Future{}
1128 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1129 if err != nil {
1130 return
1131 }
1132 var azf azure.Future
1133 azf, err = azure.NewFutureFromResponse(resp)
1134 future.FutureAPI = &azf
1135 future.Result = future.result
1136 return
1137 }
1138
1139
1140
1141 func (client ServiceClient) UpdateResponder(resp *http.Response) (result ServiceResource, err error) {
1142 err = autorest.Respond(
1143 resp,
1144 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1145 autorest.ByUnmarshallingJSON(&result),
1146 autorest.ByClosing())
1147 result.Response = autorest.Response{Response: resp}
1148 return
1149 }
1150
View as plain text