1package dns 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// RecordSetsClient is the client for managing DNS zones and record. 19type RecordSetsClient struct { 20 BaseClient 21} 22 23// NewRecordSetsClient creates an instance of the RecordSetsClient client. 24func NewRecordSetsClient(subscriptionID string) RecordSetsClient { 25 return NewRecordSetsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewRecordSetsClientWithBaseURI creates an instance of the RecordSetsClient 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 NewRecordSetsClientWithBaseURI(baseURI string, subscriptionID string) RecordSetsClient { 31 return RecordSetsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates a RecordSet within a DNS zone. 35// Parameters: 36// resourceGroupName - the name of the resource group. The name is case insensitive. 37// zoneName - the name of the zone without a terminating dot. 38// recordType - the type of DNS record. 39// relativeRecordSetName - the name of the RecordSet, relative to the name of the zone. 40// parameters - parameters supplied to the CreateOrUpdate operation. 41// ifMatch - the etag of RecordSet. 42// ifNoneMatch - defines the If-None-Match condition. Set to '*' to force Create-If-Not-Exist. Other values 43// will be ignored. 44func (client RecordSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string, parameters RecordSet, ifMatch string, ifNoneMatch string) (result RecordSet, err error) { 45 if tracing.IsEnabled() { 46 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.CreateOrUpdate") 47 defer func() { 48 sc := -1 49 if result.Response.Response != nil { 50 sc = result.Response.Response.StatusCode 51 } 52 tracing.EndSpan(ctx, sc, err) 53 }() 54 } 55 if err := validation.Validate([]validation.Validation{ 56 {TargetValue: resourceGroupName, 57 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 58 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 59 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 60 {TargetValue: client.SubscriptionID, 61 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 62 return result, validation.NewError("dns.RecordSetsClient", "CreateOrUpdate", err.Error()) 63 } 64 65 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, zoneName, recordType, relativeRecordSetName, parameters, ifMatch, ifNoneMatch) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") 68 return 69 } 70 71 resp, err := client.CreateOrUpdateSender(req) 72 if err != nil { 73 result.Response = autorest.Response{Response: resp} 74 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure sending request") 75 return 76 } 77 78 result, err = client.CreateOrUpdateResponder(resp) 79 if err != nil { 80 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "CreateOrUpdate", resp, "Failure responding to request") 81 return 82 } 83 84 return 85} 86 87// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 88func (client RecordSetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string, parameters RecordSet, ifMatch string, ifNoneMatch string) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "recordType": autorest.Encode("path", recordType), 91 "relativeRecordSetName": relativeRecordSetName, 92 "resourceGroupName": autorest.Encode("path", resourceGroupName), 93 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 94 "zoneName": autorest.Encode("path", zoneName), 95 } 96 97 const APIVersion = "2015-05-04-preview" 98 queryParameters := map[string]interface{}{ 99 "api-version": APIVersion, 100 } 101 102 preparer := autorest.CreatePreparer( 103 autorest.AsContentType("application/json; charset=utf-8"), 104 autorest.AsPut(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), 107 autorest.WithJSON(parameters), 108 autorest.WithQueryParameters(queryParameters)) 109 if len(ifMatch) > 0 { 110 preparer = autorest.DecoratePreparer(preparer, 111 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 112 } 113 if len(ifNoneMatch) > 0 { 114 preparer = autorest.DecoratePreparer(preparer, 115 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) 116 } 117 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 118} 119 120// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 121// http.Response Body if it receives an error. 122func (client RecordSetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 123 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 124} 125 126// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 127// closes the http.Response Body. 128func (client RecordSetsClient) CreateOrUpdateResponder(resp *http.Response) (result RecordSet, err error) { 129 err = autorest.Respond( 130 resp, 131 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 132 autorest.ByUnmarshallingJSON(&result), 133 autorest.ByClosing()) 134 result.Response = autorest.Response{Response: resp} 135 return 136} 137 138// Delete removes a RecordSet from a DNS zone. 139// Parameters: 140// resourceGroupName - the name of the resource group. The name is case insensitive. 141// zoneName - the name of the zone without a terminating dot. 142// recordType - the type of DNS record. 143// relativeRecordSetName - the name of the RecordSet, relative to the name of the zone. 144// ifMatch - defines the If-Match condition. The delete operation will be performed only if the ETag of the 145// zone on the server matches this value. 146func (client RecordSetsClient) Delete(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string, ifMatch string) (result autorest.Response, err error) { 147 if tracing.IsEnabled() { 148 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.Delete") 149 defer func() { 150 sc := -1 151 if result.Response != nil { 152 sc = result.Response.StatusCode 153 } 154 tracing.EndSpan(ctx, sc, err) 155 }() 156 } 157 if err := validation.Validate([]validation.Validation{ 158 {TargetValue: resourceGroupName, 159 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 160 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 161 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 162 {TargetValue: client.SubscriptionID, 163 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 164 return result, validation.NewError("dns.RecordSetsClient", "Delete", err.Error()) 165 } 166 167 req, err := client.DeletePreparer(ctx, resourceGroupName, zoneName, recordType, relativeRecordSetName, ifMatch) 168 if err != nil { 169 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", nil, "Failure preparing request") 170 return 171 } 172 173 resp, err := client.DeleteSender(req) 174 if err != nil { 175 result.Response = resp 176 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure sending request") 177 return 178 } 179 180 result, err = client.DeleteResponder(resp) 181 if err != nil { 182 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Delete", resp, "Failure responding to request") 183 return 184 } 185 186 return 187} 188 189// DeletePreparer prepares the Delete request. 190func (client RecordSetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string, ifMatch string) (*http.Request, error) { 191 pathParameters := map[string]interface{}{ 192 "recordType": autorest.Encode("path", recordType), 193 "relativeRecordSetName": relativeRecordSetName, 194 "resourceGroupName": autorest.Encode("path", resourceGroupName), 195 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 196 "zoneName": autorest.Encode("path", zoneName), 197 } 198 199 const APIVersion = "2015-05-04-preview" 200 queryParameters := map[string]interface{}{ 201 "api-version": APIVersion, 202 } 203 204 preparer := autorest.CreatePreparer( 205 autorest.AsDelete(), 206 autorest.WithBaseURL(client.BaseURI), 207 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), 208 autorest.WithQueryParameters(queryParameters)) 209 if len(ifMatch) > 0 { 210 preparer = autorest.DecoratePreparer(preparer, 211 autorest.WithHeader("If-Match", autorest.String(ifMatch))) 212 } 213 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 214} 215 216// DeleteSender sends the Delete request. The method will close the 217// http.Response Body if it receives an error. 218func (client RecordSetsClient) DeleteSender(req *http.Request) (*http.Response, error) { 219 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 220} 221 222// DeleteResponder handles the response to the Delete request. The method always 223// closes the http.Response Body. 224func (client RecordSetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 225 err = autorest.Respond( 226 resp, 227 azure.WithErrorUnlessStatusCode(http.StatusOK), 228 autorest.ByClosing()) 229 result.Response = resp 230 return 231} 232 233// Get gets a RecordSet. 234// Parameters: 235// resourceGroupName - the name of the resource group. The name is case insensitive. 236// zoneName - the name of the zone without a terminating dot. 237// recordType - the type of DNS record. 238// relativeRecordSetName - the name of the RecordSet, relative to the name of the zone. 239func (client RecordSetsClient) Get(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string) (result RecordSet, err error) { 240 if tracing.IsEnabled() { 241 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.Get") 242 defer func() { 243 sc := -1 244 if result.Response.Response != nil { 245 sc = result.Response.Response.StatusCode 246 } 247 tracing.EndSpan(ctx, sc, err) 248 }() 249 } 250 if err := validation.Validate([]validation.Validation{ 251 {TargetValue: resourceGroupName, 252 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 253 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 254 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 255 {TargetValue: client.SubscriptionID, 256 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 257 return result, validation.NewError("dns.RecordSetsClient", "Get", err.Error()) 258 } 259 260 req, err := client.GetPreparer(ctx, resourceGroupName, zoneName, recordType, relativeRecordSetName) 261 if err != nil { 262 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", nil, "Failure preparing request") 263 return 264 } 265 266 resp, err := client.GetSender(req) 267 if err != nil { 268 result.Response = autorest.Response{Response: resp} 269 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure sending request") 270 return 271 } 272 273 result, err = client.GetResponder(resp) 274 if err != nil { 275 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "Get", resp, "Failure responding to request") 276 return 277 } 278 279 return 280} 281 282// GetPreparer prepares the Get request. 283func (client RecordSetsClient) GetPreparer(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, relativeRecordSetName string) (*http.Request, error) { 284 pathParameters := map[string]interface{}{ 285 "recordType": autorest.Encode("path", recordType), 286 "relativeRecordSetName": relativeRecordSetName, 287 "resourceGroupName": autorest.Encode("path", resourceGroupName), 288 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 289 "zoneName": autorest.Encode("path", zoneName), 290 } 291 292 const APIVersion = "2015-05-04-preview" 293 queryParameters := map[string]interface{}{ 294 "api-version": APIVersion, 295 } 296 297 preparer := autorest.CreatePreparer( 298 autorest.AsGet(), 299 autorest.WithBaseURL(client.BaseURI), 300 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/{recordType}/{relativeRecordSetName}", pathParameters), 301 autorest.WithQueryParameters(queryParameters)) 302 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 303} 304 305// GetSender sends the Get request. The method will close the 306// http.Response Body if it receives an error. 307func (client RecordSetsClient) GetSender(req *http.Request) (*http.Response, error) { 308 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 309} 310 311// GetResponder handles the response to the Get request. The method always 312// closes the http.Response Body. 313func (client RecordSetsClient) GetResponder(resp *http.Response) (result RecordSet, err error) { 314 err = autorest.Respond( 315 resp, 316 azure.WithErrorUnlessStatusCode(http.StatusOK), 317 autorest.ByUnmarshallingJSON(&result), 318 autorest.ByClosing()) 319 result.Response = autorest.Response{Response: resp} 320 return 321} 322 323// List lists the RecordSets of a specified type in a DNS zone. 324// Parameters: 325// resourceGroupName - the name of the resource group. The name is case insensitive. 326// zoneName - the name of the zone from which to enumerate RecordsSets. 327// recordType - the type of record sets to enumerate. 328// top - query parameters. If null is passed returns the default number of zones. 329// filter - the filter to apply on the operation. 330func (client RecordSetsClient) List(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top string, filter string) (result RecordSetListResultPage, err error) { 331 if tracing.IsEnabled() { 332 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.List") 333 defer func() { 334 sc := -1 335 if result.rslr.Response.Response != nil { 336 sc = result.rslr.Response.Response.StatusCode 337 } 338 tracing.EndSpan(ctx, sc, err) 339 }() 340 } 341 if err := validation.Validate([]validation.Validation{ 342 {TargetValue: resourceGroupName, 343 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 344 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 345 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 346 {TargetValue: client.SubscriptionID, 347 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 348 return result, validation.NewError("dns.RecordSetsClient", "List", err.Error()) 349 } 350 351 result.fn = client.listNextResults 352 req, err := client.ListPreparer(ctx, resourceGroupName, zoneName, recordType, top, filter) 353 if err != nil { 354 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "List", nil, "Failure preparing request") 355 return 356 } 357 358 resp, err := client.ListSender(req) 359 if err != nil { 360 result.rslr.Response = autorest.Response{Response: resp} 361 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "List", resp, "Failure sending request") 362 return 363 } 364 365 result.rslr, err = client.ListResponder(resp) 366 if err != nil { 367 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "List", resp, "Failure responding to request") 368 return 369 } 370 if result.rslr.hasNextLink() && result.rslr.IsEmpty() { 371 err = result.NextWithContext(ctx) 372 return 373 } 374 375 return 376} 377 378// ListPreparer prepares the List request. 379func (client RecordSetsClient) ListPreparer(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top string, filter string) (*http.Request, error) { 380 pathParameters := map[string]interface{}{ 381 "recordType": autorest.Encode("path", recordType), 382 "resourceGroupName": autorest.Encode("path", resourceGroupName), 383 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 384 "zoneName": autorest.Encode("path", zoneName), 385 } 386 387 const APIVersion = "2015-05-04-preview" 388 queryParameters := map[string]interface{}{ 389 "api-version": APIVersion, 390 } 391 if len(top) > 0 { 392 queryParameters["$top"] = autorest.Encode("query", top) 393 } 394 if len(filter) > 0 { 395 queryParameters["$filter"] = autorest.Encode("query", filter) 396 } 397 398 preparer := autorest.CreatePreparer( 399 autorest.AsGet(), 400 autorest.WithBaseURL(client.BaseURI), 401 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/{recordType}", pathParameters), 402 autorest.WithQueryParameters(queryParameters)) 403 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 404} 405 406// ListSender sends the List request. The method will close the 407// http.Response Body if it receives an error. 408func (client RecordSetsClient) ListSender(req *http.Request) (*http.Response, error) { 409 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 410} 411 412// ListResponder handles the response to the List request. The method always 413// closes the http.Response Body. 414func (client RecordSetsClient) ListResponder(resp *http.Response) (result RecordSetListResult, err error) { 415 err = autorest.Respond( 416 resp, 417 azure.WithErrorUnlessStatusCode(http.StatusOK), 418 autorest.ByUnmarshallingJSON(&result), 419 autorest.ByClosing()) 420 result.Response = autorest.Response{Response: resp} 421 return 422} 423 424// listNextResults retrieves the next set of results, if any. 425func (client RecordSetsClient) listNextResults(ctx context.Context, lastResults RecordSetListResult) (result RecordSetListResult, err error) { 426 req, err := lastResults.recordSetListResultPreparer(ctx) 427 if err != nil { 428 return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listNextResults", nil, "Failure preparing next results request") 429 } 430 if req == nil { 431 return 432 } 433 resp, err := client.ListSender(req) 434 if err != nil { 435 result.Response = autorest.Response{Response: resp} 436 return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listNextResults", resp, "Failure sending next results request") 437 } 438 result, err = client.ListResponder(resp) 439 if err != nil { 440 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listNextResults", resp, "Failure responding to next results request") 441 } 442 return 443} 444 445// ListComplete enumerates all values, automatically crossing page boundaries as required. 446func (client RecordSetsClient) ListComplete(ctx context.Context, resourceGroupName string, zoneName string, recordType RecordType, top string, filter string) (result RecordSetListResultIterator, err error) { 447 if tracing.IsEnabled() { 448 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.List") 449 defer func() { 450 sc := -1 451 if result.Response().Response.Response != nil { 452 sc = result.page.Response().Response.Response.StatusCode 453 } 454 tracing.EndSpan(ctx, sc, err) 455 }() 456 } 457 result.page, err = client.List(ctx, resourceGroupName, zoneName, recordType, top, filter) 458 return 459} 460 461// ListAll lists all RecordSets in a DNS zone. 462// Parameters: 463// resourceGroupName - the name of the resource group. The name is case insensitive. 464// zoneName - the name of the zone from which to enumerate RecordSets. 465// top - query parameters. If null is passed returns the default number of zones. 466// filter - the filter to apply on the operation. 467func (client RecordSetsClient) ListAll(ctx context.Context, resourceGroupName string, zoneName string, top string, filter string) (result RecordSetListResultPage, err error) { 468 if tracing.IsEnabled() { 469 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListAll") 470 defer func() { 471 sc := -1 472 if result.rslr.Response.Response != nil { 473 sc = result.rslr.Response.Response.StatusCode 474 } 475 tracing.EndSpan(ctx, sc, err) 476 }() 477 } 478 if err := validation.Validate([]validation.Validation{ 479 {TargetValue: resourceGroupName, 480 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 481 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 482 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 483 {TargetValue: client.SubscriptionID, 484 Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 485 return result, validation.NewError("dns.RecordSetsClient", "ListAll", err.Error()) 486 } 487 488 result.fn = client.listAllNextResults 489 req, err := client.ListAllPreparer(ctx, resourceGroupName, zoneName, top, filter) 490 if err != nil { 491 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAll", nil, "Failure preparing request") 492 return 493 } 494 495 resp, err := client.ListAllSender(req) 496 if err != nil { 497 result.rslr.Response = autorest.Response{Response: resp} 498 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAll", resp, "Failure sending request") 499 return 500 } 501 502 result.rslr, err = client.ListAllResponder(resp) 503 if err != nil { 504 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "ListAll", resp, "Failure responding to request") 505 return 506 } 507 if result.rslr.hasNextLink() && result.rslr.IsEmpty() { 508 err = result.NextWithContext(ctx) 509 return 510 } 511 512 return 513} 514 515// ListAllPreparer prepares the ListAll request. 516func (client RecordSetsClient) ListAllPreparer(ctx context.Context, resourceGroupName string, zoneName string, top string, filter string) (*http.Request, error) { 517 pathParameters := map[string]interface{}{ 518 "resourceGroupName": autorest.Encode("path", resourceGroupName), 519 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 520 "zoneName": autorest.Encode("path", zoneName), 521 } 522 523 const APIVersion = "2015-05-04-preview" 524 queryParameters := map[string]interface{}{ 525 "api-version": APIVersion, 526 } 527 if len(top) > 0 { 528 queryParameters["$top"] = autorest.Encode("query", top) 529 } 530 if len(filter) > 0 { 531 queryParameters["$filter"] = autorest.Encode("query", filter) 532 } 533 534 preparer := autorest.CreatePreparer( 535 autorest.AsGet(), 536 autorest.WithBaseURL(client.BaseURI), 537 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnszones/{zoneName}/recordsets", pathParameters), 538 autorest.WithQueryParameters(queryParameters)) 539 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 540} 541 542// ListAllSender sends the ListAll request. The method will close the 543// http.Response Body if it receives an error. 544func (client RecordSetsClient) ListAllSender(req *http.Request) (*http.Response, error) { 545 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 546} 547 548// ListAllResponder handles the response to the ListAll request. The method always 549// closes the http.Response Body. 550func (client RecordSetsClient) ListAllResponder(resp *http.Response) (result RecordSetListResult, err error) { 551 err = autorest.Respond( 552 resp, 553 azure.WithErrorUnlessStatusCode(http.StatusOK), 554 autorest.ByUnmarshallingJSON(&result), 555 autorest.ByClosing()) 556 result.Response = autorest.Response{Response: resp} 557 return 558} 559 560// listAllNextResults retrieves the next set of results, if any. 561func (client RecordSetsClient) listAllNextResults(ctx context.Context, lastResults RecordSetListResult) (result RecordSetListResult, err error) { 562 req, err := lastResults.recordSetListResultPreparer(ctx) 563 if err != nil { 564 return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllNextResults", nil, "Failure preparing next results request") 565 } 566 if req == nil { 567 return 568 } 569 resp, err := client.ListAllSender(req) 570 if err != nil { 571 result.Response = autorest.Response{Response: resp} 572 return result, autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllNextResults", resp, "Failure sending next results request") 573 } 574 result, err = client.ListAllResponder(resp) 575 if err != nil { 576 err = autorest.NewErrorWithError(err, "dns.RecordSetsClient", "listAllNextResults", resp, "Failure responding to next results request") 577 } 578 return 579} 580 581// ListAllComplete enumerates all values, automatically crossing page boundaries as required. 582func (client RecordSetsClient) ListAllComplete(ctx context.Context, resourceGroupName string, zoneName string, top string, filter string) (result RecordSetListResultIterator, err error) { 583 if tracing.IsEnabled() { 584 ctx = tracing.StartSpan(ctx, fqdn+"/RecordSetsClient.ListAll") 585 defer func() { 586 sc := -1 587 if result.Response().Response.Response != nil { 588 sc = result.page.Response().Response.Response.StatusCode 589 } 590 tracing.EndSpan(ctx, sc, err) 591 }() 592 } 593 result.page, err = client.ListAll(ctx, resourceGroupName, zoneName, top, filter) 594 return 595} 596