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