1package appplatform 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// ServicesClient is the REST API for Azure Spring Cloud 30type ServicesClient struct { 31 BaseClient 32} 33 34// NewServicesClient creates an instance of the ServicesClient client. 35func NewServicesClient(subscriptionID string) ServicesClient { 36 return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this 40// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { 42 return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// CheckNameAvailability checks that the resource name is valid and is not already in use. 46// Parameters: 47// location - the region 48// availabilityParameters - parameters supplied to the operation. 49func (client ServicesClient) CheckNameAvailability(ctx context.Context, location string, availabilityParameters NameAvailabilityParameters) (result NameAvailability, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability") 52 defer func() { 53 sc := -1 54 if result.Response.Response != nil { 55 sc = result.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 if err := validation.Validate([]validation.Validation{ 61 {TargetValue: availabilityParameters, 62 Constraints: []validation.Constraint{{Target: "availabilityParameters.Type", Name: validation.Null, Rule: true, Chain: nil}, 63 {Target: "availabilityParameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 64 return result, validation.NewError("appplatform.ServicesClient", "CheckNameAvailability", err.Error()) 65 } 66 67 req, err := client.CheckNameAvailabilityPreparer(ctx, location, availabilityParameters) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") 70 return 71 } 72 73 resp, err := client.CheckNameAvailabilitySender(req) 74 if err != nil { 75 result.Response = autorest.Response{Response: resp} 76 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") 77 return 78 } 79 80 result, err = client.CheckNameAvailabilityResponder(resp) 81 if err != nil { 82 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") 83 return 84 } 85 86 return 87} 88 89// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 90func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, location string, availabilityParameters NameAvailabilityParameters) (*http.Request, error) { 91 pathParameters := map[string]interface{}{ 92 "location": autorest.Encode("path", location), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 } 95 96 const APIVersion = "2019-05-01-preview" 97 queryParameters := map[string]interface{}{ 98 "api-version": APIVersion, 99 } 100 101 preparer := autorest.CreatePreparer( 102 autorest.AsContentType("application/json; charset=utf-8"), 103 autorest.AsPost(), 104 autorest.WithBaseURL(client.BaseURI), 105 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/locations/{location}/checkNameAvailability", pathParameters), 106 autorest.WithJSON(availabilityParameters), 107 autorest.WithQueryParameters(queryParameters)) 108 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 109} 110 111// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 112// http.Response Body if it receives an error. 113func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 114 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 115} 116 117// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 118// closes the http.Response Body. 119func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) { 120 err = autorest.Respond( 121 resp, 122 azure.WithErrorUnlessStatusCode(http.StatusOK), 123 autorest.ByUnmarshallingJSON(&result), 124 autorest.ByClosing()) 125 result.Response = autorest.Response{Response: resp} 126 return 127} 128 129// CreateOrUpdate create a new Service or update an exiting Service. 130// Parameters: 131// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 132// from the Azure Resource Manager API or the portal. 133// serviceName - the name of the Service resource. 134// resource - parameters for the create or update operation 135func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (result ServicesCreateOrUpdateFuture, err error) { 136 if tracing.IsEnabled() { 137 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CreateOrUpdate") 138 defer func() { 139 sc := -1 140 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 141 sc = result.FutureAPI.Response().StatusCode 142 } 143 tracing.EndSpan(ctx, sc, err) 144 }() 145 } 146 if err := validation.Validate([]validation.Validation{ 147 {TargetValue: resource, 148 Constraints: []validation.Constraint{{Target: "resource.Properties", Name: validation.Null, Rule: false, 149 Chain: []validation.Constraint{{Target: "resource.Properties.ConfigServerProperties", Name: validation.Null, Rule: false, 150 Chain: []validation.Constraint{{Target: "resource.Properties.ConfigServerProperties.ConfigServer", Name: validation.Null, Rule: false, 151 Chain: []validation.Constraint{{Target: "resource.Properties.ConfigServerProperties.ConfigServer.GitProperty", Name: validation.Null, Rule: false, 152 Chain: []validation.Constraint{{Target: "resource.Properties.ConfigServerProperties.ConfigServer.GitProperty.URI", Name: validation.Null, Rule: true, Chain: nil}}}, 153 }}, 154 }}, 155 }}}}}); err != nil { 156 return result, validation.NewError("appplatform.ServicesClient", "CreateOrUpdate", err.Error()) 157 } 158 159 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, serviceName, resource) 160 if err != nil { 161 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request") 162 return 163 } 164 165 result, err = client.CreateOrUpdateSender(req) 166 if err != nil { 167 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "CreateOrUpdate", nil, "Failure sending request") 168 return 169 } 170 171 return 172} 173 174// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 175func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (*http.Request, error) { 176 pathParameters := map[string]interface{}{ 177 "resourceGroupName": autorest.Encode("path", resourceGroupName), 178 "serviceName": autorest.Encode("path", serviceName), 179 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 180 } 181 182 const APIVersion = "2019-05-01-preview" 183 queryParameters := map[string]interface{}{ 184 "api-version": APIVersion, 185 } 186 187 preparer := autorest.CreatePreparer( 188 autorest.AsContentType("application/json; charset=utf-8"), 189 autorest.AsPut(), 190 autorest.WithBaseURL(client.BaseURI), 191 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters), 192 autorest.WithJSON(resource), 193 autorest.WithQueryParameters(queryParameters)) 194 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 195} 196 197// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 198// http.Response Body if it receives an error. 199func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (future ServicesCreateOrUpdateFuture, err error) { 200 var resp *http.Response 201 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 202 if err != nil { 203 return 204 } 205 var azf azure.Future 206 azf, err = azure.NewFutureFromResponse(resp) 207 future.FutureAPI = &azf 208 future.Result = func(client ServicesClient) (sr ServiceResource, err error) { 209 var done bool 210 done, err = future.DoneWithContext(context.Background(), client) 211 if err != nil { 212 err = autorest.NewErrorWithError(err, "appplatform.ServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 213 return 214 } 215 if !done { 216 err = azure.NewAsyncOpIncompleteError("appplatform.ServicesCreateOrUpdateFuture") 217 return 218 } 219 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 220 sr.Response.Response, err = future.GetResult(sender) 221 if sr.Response.Response == nil && err == nil { 222 err = autorest.NewErrorWithError(err, "appplatform.ServicesCreateOrUpdateFuture", "Result", nil, "received nil response and error") 223 } 224 if err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { 225 sr, err = client.CreateOrUpdateResponder(sr.Response.Response) 226 if err != nil { 227 err = autorest.NewErrorWithError(err, "appplatform.ServicesCreateOrUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") 228 } 229 } 230 return 231 } 232 return 233} 234 235// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 236// closes the http.Response Body. 237func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServiceResource, err error) { 238 err = autorest.Respond( 239 resp, 240 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 241 autorest.ByUnmarshallingJSON(&result), 242 autorest.ByClosing()) 243 result.Response = autorest.Response{Response: resp} 244 return 245} 246 247// Delete operation to delete a Service. 248// Parameters: 249// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 250// from the Azure Resource Manager API or the portal. 251// serviceName - the name of the Service resource. 252func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, serviceName string) (result ServicesDeleteFuture, err error) { 253 if tracing.IsEnabled() { 254 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") 255 defer func() { 256 sc := -1 257 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 258 sc = result.FutureAPI.Response().StatusCode 259 } 260 tracing.EndSpan(ctx, sc, err) 261 }() 262 } 263 req, err := client.DeletePreparer(ctx, resourceGroupName, serviceName) 264 if err != nil { 265 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Delete", nil, "Failure preparing request") 266 return 267 } 268 269 result, err = client.DeleteSender(req) 270 if err != nil { 271 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Delete", nil, "Failure sending request") 272 return 273 } 274 275 return 276} 277 278// DeletePreparer prepares the Delete request. 279func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 280 pathParameters := map[string]interface{}{ 281 "resourceGroupName": autorest.Encode("path", resourceGroupName), 282 "serviceName": autorest.Encode("path", serviceName), 283 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 284 } 285 286 const APIVersion = "2019-05-01-preview" 287 queryParameters := map[string]interface{}{ 288 "api-version": APIVersion, 289 } 290 291 preparer := autorest.CreatePreparer( 292 autorest.AsDelete(), 293 autorest.WithBaseURL(client.BaseURI), 294 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters), 295 autorest.WithQueryParameters(queryParameters)) 296 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 297} 298 299// DeleteSender sends the Delete request. The method will close the 300// http.Response Body if it receives an error. 301func (client ServicesClient) DeleteSender(req *http.Request) (future ServicesDeleteFuture, err error) { 302 var resp *http.Response 303 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 304 if err != nil { 305 return 306 } 307 var azf azure.Future 308 azf, err = azure.NewFutureFromResponse(resp) 309 future.FutureAPI = &azf 310 future.Result = func(client ServicesClient) (ar autorest.Response, err error) { 311 var done bool 312 done, err = future.DoneWithContext(context.Background(), client) 313 if err != nil { 314 err = autorest.NewErrorWithError(err, "appplatform.ServicesDeleteFuture", "Result", future.Response(), "Polling failure") 315 return 316 } 317 if !done { 318 err = azure.NewAsyncOpIncompleteError("appplatform.ServicesDeleteFuture") 319 return 320 } 321 ar.Response = future.Response() 322 return 323 } 324 return 325} 326 327// DeleteResponder handles the response to the Delete request. The method always 328// closes the http.Response Body. 329func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 330 err = autorest.Respond( 331 resp, 332 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 333 autorest.ByClosing()) 334 result.Response = resp 335 return 336} 337 338// DisableTestEndpoint sends the disable test endpoint request. 339// Parameters: 340// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 341// from the Azure Resource Manager API or the portal. 342// serviceName - the name of the Service resource. 343func (client ServicesClient) DisableTestEndpoint(ctx context.Context, resourceGroupName string, serviceName string) (result autorest.Response, err error) { 344 if tracing.IsEnabled() { 345 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.DisableTestEndpoint") 346 defer func() { 347 sc := -1 348 if result.Response != nil { 349 sc = result.Response.StatusCode 350 } 351 tracing.EndSpan(ctx, sc, err) 352 }() 353 } 354 req, err := client.DisableTestEndpointPreparer(ctx, resourceGroupName, serviceName) 355 if err != nil { 356 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", nil, "Failure preparing request") 357 return 358 } 359 360 resp, err := client.DisableTestEndpointSender(req) 361 if err != nil { 362 result.Response = resp 363 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", resp, "Failure sending request") 364 return 365 } 366 367 result, err = client.DisableTestEndpointResponder(resp) 368 if err != nil { 369 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "DisableTestEndpoint", resp, "Failure responding to request") 370 return 371 } 372 373 return 374} 375 376// DisableTestEndpointPreparer prepares the DisableTestEndpoint request. 377func (client ServicesClient) DisableTestEndpointPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 378 pathParameters := map[string]interface{}{ 379 "resourceGroupName": autorest.Encode("path", resourceGroupName), 380 "serviceName": autorest.Encode("path", serviceName), 381 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 382 } 383 384 const APIVersion = "2019-05-01-preview" 385 queryParameters := map[string]interface{}{ 386 "api-version": APIVersion, 387 } 388 389 preparer := autorest.CreatePreparer( 390 autorest.AsPost(), 391 autorest.WithBaseURL(client.BaseURI), 392 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/disableTestEndpoint", pathParameters), 393 autorest.WithQueryParameters(queryParameters)) 394 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 395} 396 397// DisableTestEndpointSender sends the DisableTestEndpoint request. The method will close the 398// http.Response Body if it receives an error. 399func (client ServicesClient) DisableTestEndpointSender(req *http.Request) (*http.Response, error) { 400 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 401} 402 403// DisableTestEndpointResponder handles the response to the DisableTestEndpoint request. The method always 404// closes the http.Response Body. 405func (client ServicesClient) DisableTestEndpointResponder(resp *http.Response) (result autorest.Response, err error) { 406 err = autorest.Respond( 407 resp, 408 azure.WithErrorUnlessStatusCode(http.StatusOK), 409 autorest.ByClosing()) 410 result.Response = resp 411 return 412} 413 414// EnableTestEndpoint sends the enable test endpoint request. 415// Parameters: 416// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 417// from the Azure Resource Manager API or the portal. 418// serviceName - the name of the Service resource. 419func (client ServicesClient) EnableTestEndpoint(ctx context.Context, resourceGroupName string, serviceName string) (result TestKeys, err error) { 420 if tracing.IsEnabled() { 421 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.EnableTestEndpoint") 422 defer func() { 423 sc := -1 424 if result.Response.Response != nil { 425 sc = result.Response.Response.StatusCode 426 } 427 tracing.EndSpan(ctx, sc, err) 428 }() 429 } 430 req, err := client.EnableTestEndpointPreparer(ctx, resourceGroupName, serviceName) 431 if err != nil { 432 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", nil, "Failure preparing request") 433 return 434 } 435 436 resp, err := client.EnableTestEndpointSender(req) 437 if err != nil { 438 result.Response = autorest.Response{Response: resp} 439 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", resp, "Failure sending request") 440 return 441 } 442 443 result, err = client.EnableTestEndpointResponder(resp) 444 if err != nil { 445 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "EnableTestEndpoint", resp, "Failure responding to request") 446 return 447 } 448 449 return 450} 451 452// EnableTestEndpointPreparer prepares the EnableTestEndpoint request. 453func (client ServicesClient) EnableTestEndpointPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 454 pathParameters := map[string]interface{}{ 455 "resourceGroupName": autorest.Encode("path", resourceGroupName), 456 "serviceName": autorest.Encode("path", serviceName), 457 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 458 } 459 460 const APIVersion = "2019-05-01-preview" 461 queryParameters := map[string]interface{}{ 462 "api-version": APIVersion, 463 } 464 465 preparer := autorest.CreatePreparer( 466 autorest.AsPost(), 467 autorest.WithBaseURL(client.BaseURI), 468 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/enableTestEndpoint", pathParameters), 469 autorest.WithQueryParameters(queryParameters)) 470 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 471} 472 473// EnableTestEndpointSender sends the EnableTestEndpoint request. The method will close the 474// http.Response Body if it receives an error. 475func (client ServicesClient) EnableTestEndpointSender(req *http.Request) (*http.Response, error) { 476 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 477} 478 479// EnableTestEndpointResponder handles the response to the EnableTestEndpoint request. The method always 480// closes the http.Response Body. 481func (client ServicesClient) EnableTestEndpointResponder(resp *http.Response) (result TestKeys, err error) { 482 err = autorest.Respond( 483 resp, 484 azure.WithErrorUnlessStatusCode(http.StatusOK), 485 autorest.ByUnmarshallingJSON(&result), 486 autorest.ByClosing()) 487 result.Response = autorest.Response{Response: resp} 488 return 489} 490 491// Get get a Service and its properties. 492// Parameters: 493// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 494// from the Azure Resource Manager API or the portal. 495// serviceName - the name of the Service resource. 496func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result ServiceResource, err error) { 497 if tracing.IsEnabled() { 498 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get") 499 defer func() { 500 sc := -1 501 if result.Response.Response != nil { 502 sc = result.Response.Response.StatusCode 503 } 504 tracing.EndSpan(ctx, sc, err) 505 }() 506 } 507 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) 508 if err != nil { 509 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", nil, "Failure preparing request") 510 return 511 } 512 513 resp, err := client.GetSender(req) 514 if err != nil { 515 result.Response = autorest.Response{Response: resp} 516 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", resp, "Failure sending request") 517 return 518 } 519 520 result, err = client.GetResponder(resp) 521 if err != nil { 522 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Get", resp, "Failure responding to request") 523 return 524 } 525 526 return 527} 528 529// GetPreparer prepares the Get request. 530func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 531 pathParameters := map[string]interface{}{ 532 "resourceGroupName": autorest.Encode("path", resourceGroupName), 533 "serviceName": autorest.Encode("path", serviceName), 534 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 535 } 536 537 const APIVersion = "2019-05-01-preview" 538 queryParameters := map[string]interface{}{ 539 "api-version": APIVersion, 540 } 541 542 preparer := autorest.CreatePreparer( 543 autorest.AsGet(), 544 autorest.WithBaseURL(client.BaseURI), 545 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters), 546 autorest.WithQueryParameters(queryParameters)) 547 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 548} 549 550// GetSender sends the Get request. The method will close the 551// http.Response Body if it receives an error. 552func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) { 553 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 554} 555 556// GetResponder handles the response to the Get request. The method always 557// closes the http.Response Body. 558func (client ServicesClient) GetResponder(resp *http.Response) (result ServiceResource, err error) { 559 err = autorest.Respond( 560 resp, 561 azure.WithErrorUnlessStatusCode(http.StatusOK), 562 autorest.ByUnmarshallingJSON(&result), 563 autorest.ByClosing()) 564 result.Response = autorest.Response{Response: resp} 565 return 566} 567 568// List handles requests to list all resources in a resource group. 569// Parameters: 570// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 571// from the Azure Resource Manager API or the portal. 572func (client ServicesClient) List(ctx context.Context, resourceGroupName string) (result ServiceResourceListPage, err error) { 573 if tracing.IsEnabled() { 574 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List") 575 defer func() { 576 sc := -1 577 if result.srl.Response.Response != nil { 578 sc = result.srl.Response.Response.StatusCode 579 } 580 tracing.EndSpan(ctx, sc, err) 581 }() 582 } 583 result.fn = client.listNextResults 584 req, err := client.ListPreparer(ctx, resourceGroupName) 585 if err != nil { 586 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", nil, "Failure preparing request") 587 return 588 } 589 590 resp, err := client.ListSender(req) 591 if err != nil { 592 result.srl.Response = autorest.Response{Response: resp} 593 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", resp, "Failure sending request") 594 return 595 } 596 597 result.srl, err = client.ListResponder(resp) 598 if err != nil { 599 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "List", resp, "Failure responding to request") 600 return 601 } 602 if result.srl.hasNextLink() && result.srl.IsEmpty() { 603 err = result.NextWithContext(ctx) 604 return 605 } 606 607 return 608} 609 610// ListPreparer prepares the List request. 611func (client ServicesClient) ListPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 612 pathParameters := map[string]interface{}{ 613 "resourceGroupName": autorest.Encode("path", resourceGroupName), 614 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 615 } 616 617 const APIVersion = "2019-05-01-preview" 618 queryParameters := map[string]interface{}{ 619 "api-version": APIVersion, 620 } 621 622 preparer := autorest.CreatePreparer( 623 autorest.AsGet(), 624 autorest.WithBaseURL(client.BaseURI), 625 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring", pathParameters), 626 autorest.WithQueryParameters(queryParameters)) 627 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 628} 629 630// ListSender sends the List request. The method will close the 631// http.Response Body if it receives an error. 632func (client ServicesClient) ListSender(req *http.Request) (*http.Response, error) { 633 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 634} 635 636// ListResponder handles the response to the List request. The method always 637// closes the http.Response Body. 638func (client ServicesClient) ListResponder(resp *http.Response) (result ServiceResourceList, err error) { 639 err = autorest.Respond( 640 resp, 641 azure.WithErrorUnlessStatusCode(http.StatusOK), 642 autorest.ByUnmarshallingJSON(&result), 643 autorest.ByClosing()) 644 result.Response = autorest.Response{Response: resp} 645 return 646} 647 648// listNextResults retrieves the next set of results, if any. 649func (client ServicesClient) listNextResults(ctx context.Context, lastResults ServiceResourceList) (result ServiceResourceList, err error) { 650 req, err := lastResults.serviceResourceListPreparer(ctx) 651 if err != nil { 652 return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", nil, "Failure preparing next results request") 653 } 654 if req == nil { 655 return 656 } 657 resp, err := client.ListSender(req) 658 if err != nil { 659 result.Response = autorest.Response{Response: resp} 660 return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", resp, "Failure sending next results request") 661 } 662 result, err = client.ListResponder(resp) 663 if err != nil { 664 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listNextResults", resp, "Failure responding to next results request") 665 } 666 return 667} 668 669// ListComplete enumerates all values, automatically crossing page boundaries as required. 670func (client ServicesClient) ListComplete(ctx context.Context, resourceGroupName string) (result ServiceResourceListIterator, err error) { 671 if tracing.IsEnabled() { 672 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List") 673 defer func() { 674 sc := -1 675 if result.Response().Response.Response != nil { 676 sc = result.page.Response().Response.Response.StatusCode 677 } 678 tracing.EndSpan(ctx, sc, err) 679 }() 680 } 681 result.page, err = client.List(ctx, resourceGroupName) 682 return 683} 684 685// ListBySubscription handles requests to list all resources in a subscription. 686func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceResourceListPage, err error) { 687 if tracing.IsEnabled() { 688 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") 689 defer func() { 690 sc := -1 691 if result.srl.Response.Response != nil { 692 sc = result.srl.Response.Response.StatusCode 693 } 694 tracing.EndSpan(ctx, sc, err) 695 }() 696 } 697 result.fn = client.listBySubscriptionNextResults 698 req, err := client.ListBySubscriptionPreparer(ctx) 699 if err != nil { 700 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", nil, "Failure preparing request") 701 return 702 } 703 704 resp, err := client.ListBySubscriptionSender(req) 705 if err != nil { 706 result.srl.Response = autorest.Response{Response: resp} 707 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", resp, "Failure sending request") 708 return 709 } 710 711 result.srl, err = client.ListBySubscriptionResponder(resp) 712 if err != nil { 713 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListBySubscription", resp, "Failure responding to request") 714 return 715 } 716 if result.srl.hasNextLink() && result.srl.IsEmpty() { 717 err = result.NextWithContext(ctx) 718 return 719 } 720 721 return 722} 723 724// ListBySubscriptionPreparer prepares the ListBySubscription request. 725func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { 726 pathParameters := map[string]interface{}{ 727 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 728 } 729 730 const APIVersion = "2019-05-01-preview" 731 queryParameters := map[string]interface{}{ 732 "api-version": APIVersion, 733 } 734 735 preparer := autorest.CreatePreparer( 736 autorest.AsGet(), 737 autorest.WithBaseURL(client.BaseURI), 738 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.AppPlatform/Spring", pathParameters), 739 autorest.WithQueryParameters(queryParameters)) 740 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 741} 742 743// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 744// http.Response Body if it receives an error. 745func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 746 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 747} 748 749// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 750// closes the http.Response Body. 751func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceResourceList, err error) { 752 err = autorest.Respond( 753 resp, 754 azure.WithErrorUnlessStatusCode(http.StatusOK), 755 autorest.ByUnmarshallingJSON(&result), 756 autorest.ByClosing()) 757 result.Response = autorest.Response{Response: resp} 758 return 759} 760 761// listBySubscriptionNextResults retrieves the next set of results, if any. 762func (client ServicesClient) listBySubscriptionNextResults(ctx context.Context, lastResults ServiceResourceList) (result ServiceResourceList, err error) { 763 req, err := lastResults.serviceResourceListPreparer(ctx) 764 if err != nil { 765 return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") 766 } 767 if req == nil { 768 return 769 } 770 resp, err := client.ListBySubscriptionSender(req) 771 if err != nil { 772 result.Response = autorest.Response{Response: resp} 773 return result, autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") 774 } 775 result, err = client.ListBySubscriptionResponder(resp) 776 if err != nil { 777 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") 778 } 779 return 780} 781 782// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. 783func (client ServicesClient) ListBySubscriptionComplete(ctx context.Context) (result ServiceResourceListIterator, err error) { 784 if tracing.IsEnabled() { 785 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") 786 defer func() { 787 sc := -1 788 if result.Response().Response.Response != nil { 789 sc = result.page.Response().Response.Response.StatusCode 790 } 791 tracing.EndSpan(ctx, sc, err) 792 }() 793 } 794 result.page, err = client.ListBySubscription(ctx) 795 return 796} 797 798// ListTestKeys list test keys for a Service. 799// Parameters: 800// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 801// from the Azure Resource Manager API or the portal. 802// serviceName - the name of the Service resource. 803func (client ServicesClient) ListTestKeys(ctx context.Context, resourceGroupName string, serviceName string) (result TestKeys, err error) { 804 if tracing.IsEnabled() { 805 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListTestKeys") 806 defer func() { 807 sc := -1 808 if result.Response.Response != nil { 809 sc = result.Response.Response.StatusCode 810 } 811 tracing.EndSpan(ctx, sc, err) 812 }() 813 } 814 req, err := client.ListTestKeysPreparer(ctx, resourceGroupName, serviceName) 815 if err != nil { 816 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", nil, "Failure preparing request") 817 return 818 } 819 820 resp, err := client.ListTestKeysSender(req) 821 if err != nil { 822 result.Response = autorest.Response{Response: resp} 823 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", resp, "Failure sending request") 824 return 825 } 826 827 result, err = client.ListTestKeysResponder(resp) 828 if err != nil { 829 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "ListTestKeys", resp, "Failure responding to request") 830 return 831 } 832 833 return 834} 835 836// ListTestKeysPreparer prepares the ListTestKeys request. 837func (client ServicesClient) ListTestKeysPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 838 pathParameters := map[string]interface{}{ 839 "resourceGroupName": autorest.Encode("path", resourceGroupName), 840 "serviceName": autorest.Encode("path", serviceName), 841 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 842 } 843 844 const APIVersion = "2019-05-01-preview" 845 queryParameters := map[string]interface{}{ 846 "api-version": APIVersion, 847 } 848 849 preparer := autorest.CreatePreparer( 850 autorest.AsPost(), 851 autorest.WithBaseURL(client.BaseURI), 852 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/listTestKeys", pathParameters), 853 autorest.WithQueryParameters(queryParameters)) 854 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 855} 856 857// ListTestKeysSender sends the ListTestKeys request. The method will close the 858// http.Response Body if it receives an error. 859func (client ServicesClient) ListTestKeysSender(req *http.Request) (*http.Response, error) { 860 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 861} 862 863// ListTestKeysResponder handles the response to the ListTestKeys request. The method always 864// closes the http.Response Body. 865func (client ServicesClient) ListTestKeysResponder(resp *http.Response) (result TestKeys, err error) { 866 err = autorest.Respond( 867 resp, 868 azure.WithErrorUnlessStatusCode(http.StatusOK), 869 autorest.ByUnmarshallingJSON(&result), 870 autorest.ByClosing()) 871 result.Response = autorest.Response{Response: resp} 872 return 873} 874 875// RegenerateTestKey regenerate a test key for a Service. 876// Parameters: 877// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 878// from the Azure Resource Manager API or the portal. 879// serviceName - the name of the Service resource. 880// regenerateTestKeyRequest - parameters for the operation 881func (client ServicesClient) RegenerateTestKey(ctx context.Context, resourceGroupName string, serviceName string, regenerateTestKeyRequest RegenerateTestKeyRequestPayload) (result TestKeys, err error) { 882 if tracing.IsEnabled() { 883 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.RegenerateTestKey") 884 defer func() { 885 sc := -1 886 if result.Response.Response != nil { 887 sc = result.Response.Response.StatusCode 888 } 889 tracing.EndSpan(ctx, sc, err) 890 }() 891 } 892 req, err := client.RegenerateTestKeyPreparer(ctx, resourceGroupName, serviceName, regenerateTestKeyRequest) 893 if err != nil { 894 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", nil, "Failure preparing request") 895 return 896 } 897 898 resp, err := client.RegenerateTestKeySender(req) 899 if err != nil { 900 result.Response = autorest.Response{Response: resp} 901 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", resp, "Failure sending request") 902 return 903 } 904 905 result, err = client.RegenerateTestKeyResponder(resp) 906 if err != nil { 907 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "RegenerateTestKey", resp, "Failure responding to request") 908 return 909 } 910 911 return 912} 913 914// RegenerateTestKeyPreparer prepares the RegenerateTestKey request. 915func (client ServicesClient) RegenerateTestKeyPreparer(ctx context.Context, resourceGroupName string, serviceName string, regenerateTestKeyRequest RegenerateTestKeyRequestPayload) (*http.Request, error) { 916 pathParameters := map[string]interface{}{ 917 "resourceGroupName": autorest.Encode("path", resourceGroupName), 918 "serviceName": autorest.Encode("path", serviceName), 919 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 920 } 921 922 const APIVersion = "2019-05-01-preview" 923 queryParameters := map[string]interface{}{ 924 "api-version": APIVersion, 925 } 926 927 preparer := autorest.CreatePreparer( 928 autorest.AsContentType("application/json; charset=utf-8"), 929 autorest.AsPost(), 930 autorest.WithBaseURL(client.BaseURI), 931 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}/regenerateTestKey", pathParameters), 932 autorest.WithJSON(regenerateTestKeyRequest), 933 autorest.WithQueryParameters(queryParameters)) 934 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 935} 936 937// RegenerateTestKeySender sends the RegenerateTestKey request. The method will close the 938// http.Response Body if it receives an error. 939func (client ServicesClient) RegenerateTestKeySender(req *http.Request) (*http.Response, error) { 940 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 941} 942 943// RegenerateTestKeyResponder handles the response to the RegenerateTestKey request. The method always 944// closes the http.Response Body. 945func (client ServicesClient) RegenerateTestKeyResponder(resp *http.Response) (result TestKeys, err error) { 946 err = autorest.Respond( 947 resp, 948 azure.WithErrorUnlessStatusCode(http.StatusOK), 949 autorest.ByUnmarshallingJSON(&result), 950 autorest.ByClosing()) 951 result.Response = autorest.Response{Response: resp} 952 return 953} 954 955// Update operation to update an exiting Service. 956// Parameters: 957// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value 958// from the Azure Resource Manager API or the portal. 959// serviceName - the name of the Service resource. 960// resource - parameters for the update operation 961func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (result ServicesUpdateFuture, err error) { 962 if tracing.IsEnabled() { 963 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") 964 defer func() { 965 sc := -1 966 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 967 sc = result.FutureAPI.Response().StatusCode 968 } 969 tracing.EndSpan(ctx, sc, err) 970 }() 971 } 972 req, err := client.UpdatePreparer(ctx, resourceGroupName, serviceName, resource) 973 if err != nil { 974 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Update", nil, "Failure preparing request") 975 return 976 } 977 978 result, err = client.UpdateSender(req) 979 if err != nil { 980 err = autorest.NewErrorWithError(err, "appplatform.ServicesClient", "Update", nil, "Failure sending request") 981 return 982 } 983 984 return 985} 986 987// UpdatePreparer prepares the Update request. 988func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, serviceName string, resource ServiceResource) (*http.Request, error) { 989 pathParameters := map[string]interface{}{ 990 "resourceGroupName": autorest.Encode("path", resourceGroupName), 991 "serviceName": autorest.Encode("path", serviceName), 992 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 993 } 994 995 const APIVersion = "2019-05-01-preview" 996 queryParameters := map[string]interface{}{ 997 "api-version": APIVersion, 998 } 999 1000 preparer := autorest.CreatePreparer( 1001 autorest.AsContentType("application/json; charset=utf-8"), 1002 autorest.AsPatch(), 1003 autorest.WithBaseURL(client.BaseURI), 1004 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AppPlatform/Spring/{serviceName}", pathParameters), 1005 autorest.WithJSON(resource), 1006 autorest.WithQueryParameters(queryParameters)) 1007 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1008} 1009 1010// UpdateSender sends the Update request. The method will close the 1011// http.Response Body if it receives an error. 1012func (client ServicesClient) UpdateSender(req *http.Request) (future ServicesUpdateFuture, err error) { 1013 var resp *http.Response 1014 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1015 if err != nil { 1016 return 1017 } 1018 var azf azure.Future 1019 azf, err = azure.NewFutureFromResponse(resp) 1020 future.FutureAPI = &azf 1021 future.Result = func(client ServicesClient) (sr ServiceResource, err error) { 1022 var done bool 1023 done, err = future.DoneWithContext(context.Background(), client) 1024 if err != nil { 1025 err = autorest.NewErrorWithError(err, "appplatform.ServicesUpdateFuture", "Result", future.Response(), "Polling failure") 1026 return 1027 } 1028 if !done { 1029 err = azure.NewAsyncOpIncompleteError("appplatform.ServicesUpdateFuture") 1030 return 1031 } 1032 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1033 sr.Response.Response, err = future.GetResult(sender) 1034 if sr.Response.Response == nil && err == nil { 1035 err = autorest.NewErrorWithError(err, "appplatform.ServicesUpdateFuture", "Result", nil, "received nil response and error") 1036 } 1037 if err == nil && sr.Response.Response.StatusCode != http.StatusNoContent { 1038 sr, err = client.UpdateResponder(sr.Response.Response) 1039 if err != nil { 1040 err = autorest.NewErrorWithError(err, "appplatform.ServicesUpdateFuture", "Result", sr.Response.Response, "Failure responding to request") 1041 } 1042 } 1043 return 1044 } 1045 return 1046} 1047 1048// UpdateResponder handles the response to the Update request. The method always 1049// closes the http.Response Body. 1050func (client ServicesClient) UpdateResponder(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