1package storagesync 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 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// ServicesClient is the microsoft Storage Sync Service API 19type ServicesClient struct { 20 BaseClient 21} 22 23// NewServicesClient creates an instance of the ServicesClient client. 24func NewServicesClient(subscriptionID string) ServicesClient { 25 return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this 29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { 31 return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CheckNameAvailability check the give namespace name availability. 35// Parameters: 36// locationName - the desired region for the name check. 37// parameters - parameters to check availability of the given namespace name 38func (client ServicesClient) CheckNameAvailability(ctx context.Context, locationName string, parameters CheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { 39 if tracing.IsEnabled() { 40 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability") 41 defer func() { 42 sc := -1 43 if result.Response.Response != nil { 44 sc = result.Response.Response.StatusCode 45 } 46 tracing.EndSpan(ctx, sc, err) 47 }() 48 } 49 if err := validation.Validate([]validation.Validation{ 50 {TargetValue: client.SubscriptionID, 51 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 52 {TargetValue: parameters, 53 Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, 54 {Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 55 return result, validation.NewError("storagesync.ServicesClient", "CheckNameAvailability", err.Error()) 56 } 57 58 req, err := client.CheckNameAvailabilityPreparer(ctx, locationName, parameters) 59 if err != nil { 60 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") 61 return 62 } 63 64 resp, err := client.CheckNameAvailabilitySender(req) 65 if err != nil { 66 result.Response = autorest.Response{Response: resp} 67 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") 68 return 69 } 70 71 result, err = client.CheckNameAvailabilityResponder(resp) 72 if err != nil { 73 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") 74 return 75 } 76 77 return 78} 79 80// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 81func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, locationName string, parameters CheckNameAvailabilityParameters) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "locationName": autorest.Encode("path", locationName), 84 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 85 } 86 87 const APIVersion = "2018-10-01" 88 queryParameters := map[string]interface{}{ 89 "api-version": APIVersion, 90 } 91 92 preparer := autorest.CreatePreparer( 93 autorest.AsContentType("application/json; charset=utf-8"), 94 autorest.AsPost(), 95 autorest.WithBaseURL(client.BaseURI), 96 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/locations/{locationName}/checkNameAvailability", pathParameters), 97 autorest.WithJSON(parameters), 98 autorest.WithQueryParameters(queryParameters)) 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 103// http.Response Body if it receives an error. 104func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 105 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 106} 107 108// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 109// closes the http.Response Body. 110func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { 111 err = autorest.Respond( 112 resp, 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119 120// Create create a new StorageSyncService. 121// Parameters: 122// resourceGroupName - the name of the resource group. The name is case insensitive. 123// storageSyncServiceName - name of Storage Sync Service resource. 124// parameters - storage Sync Service resource name. 125func (client ServicesClient) Create(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters ServiceCreateParameters) (result Service, err error) { 126 if tracing.IsEnabled() { 127 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Create") 128 defer func() { 129 sc := -1 130 if result.Response.Response != nil { 131 sc = result.Response.Response.StatusCode 132 } 133 tracing.EndSpan(ctx, sc, err) 134 }() 135 } 136 if err := validation.Validate([]validation.Validation{ 137 {TargetValue: client.SubscriptionID, 138 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 139 {TargetValue: resourceGroupName, 140 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 141 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 142 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 143 {TargetValue: parameters, 144 Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 145 return result, validation.NewError("storagesync.ServicesClient", "Create", err.Error()) 146 } 147 148 req, err := client.CreatePreparer(ctx, resourceGroupName, storageSyncServiceName, parameters) 149 if err != nil { 150 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", nil, "Failure preparing request") 151 return 152 } 153 154 resp, err := client.CreateSender(req) 155 if err != nil { 156 result.Response = autorest.Response{Response: resp} 157 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", resp, "Failure sending request") 158 return 159 } 160 161 result, err = client.CreateResponder(resp) 162 if err != nil { 163 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Create", resp, "Failure responding to request") 164 return 165 } 166 167 return 168} 169 170// CreatePreparer prepares the Create request. 171func (client ServicesClient) CreatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters ServiceCreateParameters) (*http.Request, error) { 172 pathParameters := map[string]interface{}{ 173 "resourceGroupName": autorest.Encode("path", resourceGroupName), 174 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 175 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 176 } 177 178 const APIVersion = "2018-10-01" 179 queryParameters := map[string]interface{}{ 180 "api-version": APIVersion, 181 } 182 183 preparer := autorest.CreatePreparer( 184 autorest.AsContentType("application/json; charset=utf-8"), 185 autorest.AsPut(), 186 autorest.WithBaseURL(client.BaseURI), 187 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), 188 autorest.WithJSON(parameters), 189 autorest.WithQueryParameters(queryParameters)) 190 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 191} 192 193// CreateSender sends the Create request. The method will close the 194// http.Response Body if it receives an error. 195func (client ServicesClient) CreateSender(req *http.Request) (*http.Response, error) { 196 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 197} 198 199// CreateResponder handles the response to the Create request. The method always 200// closes the http.Response Body. 201func (client ServicesClient) CreateResponder(resp *http.Response) (result Service, err error) { 202 err = autorest.Respond( 203 resp, 204 azure.WithErrorUnlessStatusCode(http.StatusOK), 205 autorest.ByUnmarshallingJSON(&result), 206 autorest.ByClosing()) 207 result.Response = autorest.Response{Response: resp} 208 return 209} 210 211// Delete delete a given StorageSyncService. 212// Parameters: 213// resourceGroupName - the name of the resource group. The name is case insensitive. 214// storageSyncServiceName - name of Storage Sync Service resource. 215func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result autorest.Response, err error) { 216 if tracing.IsEnabled() { 217 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") 218 defer func() { 219 sc := -1 220 if result.Response != nil { 221 sc = result.Response.StatusCode 222 } 223 tracing.EndSpan(ctx, sc, err) 224 }() 225 } 226 if err := validation.Validate([]validation.Validation{ 227 {TargetValue: client.SubscriptionID, 228 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 229 {TargetValue: resourceGroupName, 230 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 231 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 232 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 233 return result, validation.NewError("storagesync.ServicesClient", "Delete", err.Error()) 234 } 235 236 req, err := client.DeletePreparer(ctx, resourceGroupName, storageSyncServiceName) 237 if err != nil { 238 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", nil, "Failure preparing request") 239 return 240 } 241 242 resp, err := client.DeleteSender(req) 243 if err != nil { 244 result.Response = resp 245 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", resp, "Failure sending request") 246 return 247 } 248 249 result, err = client.DeleteResponder(resp) 250 if err != nil { 251 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Delete", resp, "Failure responding to request") 252 return 253 } 254 255 return 256} 257 258// DeletePreparer prepares the Delete request. 259func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { 260 pathParameters := map[string]interface{}{ 261 "resourceGroupName": autorest.Encode("path", resourceGroupName), 262 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 263 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 264 } 265 266 const APIVersion = "2018-10-01" 267 queryParameters := map[string]interface{}{ 268 "api-version": APIVersion, 269 } 270 271 preparer := autorest.CreatePreparer( 272 autorest.AsDelete(), 273 autorest.WithBaseURL(client.BaseURI), 274 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), 275 autorest.WithQueryParameters(queryParameters)) 276 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 277} 278 279// DeleteSender sends the Delete request. The method will close the 280// http.Response Body if it receives an error. 281func (client ServicesClient) DeleteSender(req *http.Request) (*http.Response, error) { 282 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 283} 284 285// DeleteResponder handles the response to the Delete request. The method always 286// closes the http.Response Body. 287func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 288 err = autorest.Respond( 289 resp, 290 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 291 autorest.ByClosing()) 292 result.Response = resp 293 return 294} 295 296// Get get a given StorageSyncService. 297// Parameters: 298// resourceGroupName - the name of the resource group. The name is case insensitive. 299// storageSyncServiceName - name of Storage Sync Service resource. 300func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (result Service, err error) { 301 if tracing.IsEnabled() { 302 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get") 303 defer func() { 304 sc := -1 305 if result.Response.Response != nil { 306 sc = result.Response.Response.StatusCode 307 } 308 tracing.EndSpan(ctx, sc, err) 309 }() 310 } 311 if err := validation.Validate([]validation.Validation{ 312 {TargetValue: client.SubscriptionID, 313 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 314 {TargetValue: resourceGroupName, 315 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 316 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 317 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 318 return result, validation.NewError("storagesync.ServicesClient", "Get", err.Error()) 319 } 320 321 req, err := client.GetPreparer(ctx, resourceGroupName, storageSyncServiceName) 322 if err != nil { 323 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", nil, "Failure preparing request") 324 return 325 } 326 327 resp, err := client.GetSender(req) 328 if err != nil { 329 result.Response = autorest.Response{Response: resp} 330 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", resp, "Failure sending request") 331 return 332 } 333 334 result, err = client.GetResponder(resp) 335 if err != nil { 336 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Get", resp, "Failure responding to request") 337 return 338 } 339 340 return 341} 342 343// GetPreparer prepares the Get request. 344func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string) (*http.Request, error) { 345 pathParameters := map[string]interface{}{ 346 "resourceGroupName": autorest.Encode("path", resourceGroupName), 347 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 348 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 349 } 350 351 const APIVersion = "2018-10-01" 352 queryParameters := map[string]interface{}{ 353 "api-version": APIVersion, 354 } 355 356 preparer := autorest.CreatePreparer( 357 autorest.AsGet(), 358 autorest.WithBaseURL(client.BaseURI), 359 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), 360 autorest.WithQueryParameters(queryParameters)) 361 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 362} 363 364// GetSender sends the Get request. The method will close the 365// http.Response Body if it receives an error. 366func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) { 367 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 368} 369 370// GetResponder handles the response to the Get request. The method always 371// closes the http.Response Body. 372func (client ServicesClient) GetResponder(resp *http.Response) (result Service, err error) { 373 err = autorest.Respond( 374 resp, 375 azure.WithErrorUnlessStatusCode(http.StatusOK), 376 autorest.ByUnmarshallingJSON(&result), 377 autorest.ByClosing()) 378 result.Response = autorest.Response{Response: resp} 379 return 380} 381 382// ListByResourceGroup get a StorageSyncService list by Resource group name. 383// Parameters: 384// resourceGroupName - the name of the resource group. The name is case insensitive. 385func (client ServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServiceArray, err error) { 386 if tracing.IsEnabled() { 387 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") 388 defer func() { 389 sc := -1 390 if result.Response.Response != nil { 391 sc = result.Response.Response.StatusCode 392 } 393 tracing.EndSpan(ctx, sc, err) 394 }() 395 } 396 if err := validation.Validate([]validation.Validation{ 397 {TargetValue: client.SubscriptionID, 398 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 399 {TargetValue: resourceGroupName, 400 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 401 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 402 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 403 return result, validation.NewError("storagesync.ServicesClient", "ListByResourceGroup", err.Error()) 404 } 405 406 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 407 if err != nil { 408 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") 409 return 410 } 411 412 resp, err := client.ListByResourceGroupSender(req) 413 if err != nil { 414 result.Response = autorest.Response{Response: resp} 415 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") 416 return 417 } 418 419 result, err = client.ListByResourceGroupResponder(resp) 420 if err != nil { 421 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") 422 return 423 } 424 425 return 426} 427 428// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 429func (client ServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 430 pathParameters := map[string]interface{}{ 431 "resourceGroupName": autorest.Encode("path", resourceGroupName), 432 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 433 } 434 435 const APIVersion = "2018-10-01" 436 queryParameters := map[string]interface{}{ 437 "api-version": APIVersion, 438 } 439 440 preparer := autorest.CreatePreparer( 441 autorest.AsGet(), 442 autorest.WithBaseURL(client.BaseURI), 443 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices", pathParameters), 444 autorest.WithQueryParameters(queryParameters)) 445 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 446} 447 448// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 449// http.Response Body if it receives an error. 450func (client ServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 451 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 452} 453 454// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 455// closes the http.Response Body. 456func (client ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServiceArray, err error) { 457 err = autorest.Respond( 458 resp, 459 azure.WithErrorUnlessStatusCode(http.StatusOK), 460 autorest.ByUnmarshallingJSON(&result), 461 autorest.ByClosing()) 462 result.Response = autorest.Response{Response: resp} 463 return 464} 465 466// ListBySubscription get a StorageSyncService list by subscription. 467func (client ServicesClient) ListBySubscription(ctx context.Context) (result ServiceArray, err error) { 468 if tracing.IsEnabled() { 469 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListBySubscription") 470 defer func() { 471 sc := -1 472 if result.Response.Response != nil { 473 sc = result.Response.Response.StatusCode 474 } 475 tracing.EndSpan(ctx, sc, err) 476 }() 477 } 478 if err := validation.Validate([]validation.Validation{ 479 {TargetValue: client.SubscriptionID, 480 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 481 return result, validation.NewError("storagesync.ServicesClient", "ListBySubscription", err.Error()) 482 } 483 484 req, err := client.ListBySubscriptionPreparer(ctx) 485 if err != nil { 486 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", nil, "Failure preparing request") 487 return 488 } 489 490 resp, err := client.ListBySubscriptionSender(req) 491 if err != nil { 492 result.Response = autorest.Response{Response: resp} 493 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", resp, "Failure sending request") 494 return 495 } 496 497 result, err = client.ListBySubscriptionResponder(resp) 498 if err != nil { 499 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "ListBySubscription", resp, "Failure responding to request") 500 return 501 } 502 503 return 504} 505 506// ListBySubscriptionPreparer prepares the ListBySubscription request. 507func (client ServicesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { 508 pathParameters := map[string]interface{}{ 509 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 510 } 511 512 const APIVersion = "2018-10-01" 513 queryParameters := map[string]interface{}{ 514 "api-version": APIVersion, 515 } 516 517 preparer := autorest.CreatePreparer( 518 autorest.AsGet(), 519 autorest.WithBaseURL(client.BaseURI), 520 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorageSync/storageSyncServices", pathParameters), 521 autorest.WithQueryParameters(queryParameters)) 522 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 523} 524 525// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 526// http.Response Body if it receives an error. 527func (client ServicesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 528 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 529} 530 531// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 532// closes the http.Response Body. 533func (client ServicesClient) ListBySubscriptionResponder(resp *http.Response) (result ServiceArray, err error) { 534 err = autorest.Respond( 535 resp, 536 azure.WithErrorUnlessStatusCode(http.StatusOK), 537 autorest.ByUnmarshallingJSON(&result), 538 autorest.ByClosing()) 539 result.Response = autorest.Response{Response: resp} 540 return 541} 542 543// Update patch a given StorageSyncService. 544// Parameters: 545// resourceGroupName - the name of the resource group. The name is case insensitive. 546// storageSyncServiceName - name of Storage Sync Service resource. 547// parameters - storage Sync Service resource. 548func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters *ServiceUpdateParameters) (result Service, err error) { 549 if tracing.IsEnabled() { 550 ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") 551 defer func() { 552 sc := -1 553 if result.Response.Response != nil { 554 sc = result.Response.Response.StatusCode 555 } 556 tracing.EndSpan(ctx, sc, err) 557 }() 558 } 559 if err := validation.Validate([]validation.Validation{ 560 {TargetValue: client.SubscriptionID, 561 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 562 {TargetValue: resourceGroupName, 563 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 564 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 565 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 566 return result, validation.NewError("storagesync.ServicesClient", "Update", err.Error()) 567 } 568 569 req, err := client.UpdatePreparer(ctx, resourceGroupName, storageSyncServiceName, parameters) 570 if err != nil { 571 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", nil, "Failure preparing request") 572 return 573 } 574 575 resp, err := client.UpdateSender(req) 576 if err != nil { 577 result.Response = autorest.Response{Response: resp} 578 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", resp, "Failure sending request") 579 return 580 } 581 582 result, err = client.UpdateResponder(resp) 583 if err != nil { 584 err = autorest.NewErrorWithError(err, "storagesync.ServicesClient", "Update", resp, "Failure responding to request") 585 return 586 } 587 588 return 589} 590 591// UpdatePreparer prepares the Update request. 592func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, storageSyncServiceName string, parameters *ServiceUpdateParameters) (*http.Request, error) { 593 pathParameters := map[string]interface{}{ 594 "resourceGroupName": autorest.Encode("path", resourceGroupName), 595 "storageSyncServiceName": autorest.Encode("path", storageSyncServiceName), 596 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 597 } 598 599 const APIVersion = "2018-10-01" 600 queryParameters := map[string]interface{}{ 601 "api-version": APIVersion, 602 } 603 604 preparer := autorest.CreatePreparer( 605 autorest.AsContentType("application/json; charset=utf-8"), 606 autorest.AsPatch(), 607 autorest.WithBaseURL(client.BaseURI), 608 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageSync/storageSyncServices/{storageSyncServiceName}", pathParameters), 609 autorest.WithQueryParameters(queryParameters)) 610 if parameters != nil { 611 preparer = autorest.DecoratePreparer(preparer, 612 autorest.WithJSON(parameters)) 613 } 614 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 615} 616 617// UpdateSender sends the Update request. The method will close the 618// http.Response Body if it receives an error. 619func (client ServicesClient) UpdateSender(req *http.Request) (*http.Response, error) { 620 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 621} 622 623// UpdateResponder handles the response to the Update request. The method always 624// closes the http.Response Body. 625func (client ServicesClient) UpdateResponder(resp *http.Response) (result Service, err error) { 626 err = autorest.Respond( 627 resp, 628 azure.WithErrorUnlessStatusCode(http.StatusOK), 629 autorest.ByUnmarshallingJSON(&result), 630 autorest.ByClosing()) 631 result.Response = autorest.Response{Response: resp} 632 return 633} 634