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