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