1package eventgrid 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// DomainsClient is the azure EventGrid Management Client 30type DomainsClient struct { 31 BaseClient 32} 33 34// NewDomainsClient creates an instance of the DomainsClient client. 35func NewDomainsClient(subscriptionID string) DomainsClient { 36 return NewDomainsClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewDomainsClientWithBaseURI creates an instance of the DomainsClient client using a custom endpoint. Use this when 40// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 41func NewDomainsClientWithBaseURI(baseURI string, subscriptionID string) DomainsClient { 42 return DomainsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// CreateOrUpdate asynchronously creates or updates a new domain with the specified parameters. 46// Parameters: 47// resourceGroupName - the name of the resource group within the user's subscription. 48// domainName - name of the domain 49// domainInfo - domain information 50func (client DomainsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, domainName string, domainInfo Domain) (result DomainsCreateOrUpdateFuture, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.CreateOrUpdate") 53 defer func() { 54 sc := -1 55 if result.Response() != nil { 56 sc = result.Response().StatusCode 57 } 58 tracing.EndSpan(ctx, sc, err) 59 }() 60 } 61 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, domainName, domainInfo) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "CreateOrUpdate", nil, "Failure preparing request") 64 return 65 } 66 67 result, err = client.CreateOrUpdateSender(req) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "CreateOrUpdate", result.Response(), "Failure sending request") 70 return 71 } 72 73 return 74} 75 76// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 77func (client DomainsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, domainName string, domainInfo Domain) (*http.Request, error) { 78 pathParameters := map[string]interface{}{ 79 "domainName": autorest.Encode("path", domainName), 80 "resourceGroupName": autorest.Encode("path", resourceGroupName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2020-01-01-preview" 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.EventGrid/domains/{domainName}", pathParameters), 94 autorest.WithJSON(domainInfo), 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 DomainsClient) CreateOrUpdateSender(req *http.Request) (future DomainsCreateOrUpdateFuture, 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 future.Future, err = azure.NewFutureFromResponse(resp) 108 return 109} 110 111// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 112// closes the http.Response Body. 113func (client DomainsClient) CreateOrUpdateResponder(resp *http.Response) (result Domain, err error) { 114 err = autorest.Respond( 115 resp, 116 client.ByInspecting(), 117 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 118 autorest.ByUnmarshallingJSON(&result), 119 autorest.ByClosing()) 120 result.Response = autorest.Response{Response: resp} 121 return 122} 123 124// Delete delete existing domain 125// Parameters: 126// resourceGroupName - the name of the resource group within the user's subscription. 127// domainName - name of the domain 128func (client DomainsClient) Delete(ctx context.Context, resourceGroupName string, domainName string) (result DomainsDeleteFuture, err error) { 129 if tracing.IsEnabled() { 130 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.Delete") 131 defer func() { 132 sc := -1 133 if result.Response() != nil { 134 sc = result.Response().StatusCode 135 } 136 tracing.EndSpan(ctx, sc, err) 137 }() 138 } 139 req, err := client.DeletePreparer(ctx, resourceGroupName, domainName) 140 if err != nil { 141 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Delete", nil, "Failure preparing request") 142 return 143 } 144 145 result, err = client.DeleteSender(req) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Delete", result.Response(), "Failure sending request") 148 return 149 } 150 151 return 152} 153 154// DeletePreparer prepares the Delete request. 155func (client DomainsClient) DeletePreparer(ctx context.Context, resourceGroupName string, domainName string) (*http.Request, error) { 156 pathParameters := map[string]interface{}{ 157 "domainName": autorest.Encode("path", domainName), 158 "resourceGroupName": autorest.Encode("path", resourceGroupName), 159 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 160 } 161 162 const APIVersion = "2020-01-01-preview" 163 queryParameters := map[string]interface{}{ 164 "api-version": APIVersion, 165 } 166 167 preparer := autorest.CreatePreparer( 168 autorest.AsDelete(), 169 autorest.WithBaseURL(client.BaseURI), 170 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", pathParameters), 171 autorest.WithQueryParameters(queryParameters)) 172 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 173} 174 175// DeleteSender sends the Delete request. The method will close the 176// http.Response Body if it receives an error. 177func (client DomainsClient) DeleteSender(req *http.Request) (future DomainsDeleteFuture, err error) { 178 var resp *http.Response 179 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 180 if err != nil { 181 return 182 } 183 future.Future, err = azure.NewFutureFromResponse(resp) 184 return 185} 186 187// DeleteResponder handles the response to the Delete request. The method always 188// closes the http.Response Body. 189func (client DomainsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 190 err = autorest.Respond( 191 resp, 192 client.ByInspecting(), 193 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 194 autorest.ByClosing()) 195 result.Response = resp 196 return 197} 198 199// Get get properties of a domain 200// Parameters: 201// resourceGroupName - the name of the resource group within the user's subscription. 202// domainName - name of the domain 203func (client DomainsClient) Get(ctx context.Context, resourceGroupName string, domainName string) (result Domain, err error) { 204 if tracing.IsEnabled() { 205 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.Get") 206 defer func() { 207 sc := -1 208 if result.Response.Response != nil { 209 sc = result.Response.Response.StatusCode 210 } 211 tracing.EndSpan(ctx, sc, err) 212 }() 213 } 214 req, err := client.GetPreparer(ctx, resourceGroupName, domainName) 215 if err != nil { 216 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Get", nil, "Failure preparing request") 217 return 218 } 219 220 resp, err := client.GetSender(req) 221 if err != nil { 222 result.Response = autorest.Response{Response: resp} 223 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Get", resp, "Failure sending request") 224 return 225 } 226 227 result, err = client.GetResponder(resp) 228 if err != nil { 229 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Get", resp, "Failure responding to request") 230 } 231 232 return 233} 234 235// GetPreparer prepares the Get request. 236func (client DomainsClient) GetPreparer(ctx context.Context, resourceGroupName string, domainName string) (*http.Request, error) { 237 pathParameters := map[string]interface{}{ 238 "domainName": autorest.Encode("path", domainName), 239 "resourceGroupName": autorest.Encode("path", resourceGroupName), 240 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 241 } 242 243 const APIVersion = "2020-01-01-preview" 244 queryParameters := map[string]interface{}{ 245 "api-version": APIVersion, 246 } 247 248 preparer := autorest.CreatePreparer( 249 autorest.AsGet(), 250 autorest.WithBaseURL(client.BaseURI), 251 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", pathParameters), 252 autorest.WithQueryParameters(queryParameters)) 253 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 254} 255 256// GetSender sends the Get request. The method will close the 257// http.Response Body if it receives an error. 258func (client DomainsClient) GetSender(req *http.Request) (*http.Response, error) { 259 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 260} 261 262// GetResponder handles the response to the Get request. The method always 263// closes the http.Response Body. 264func (client DomainsClient) GetResponder(resp *http.Response) (result Domain, err error) { 265 err = autorest.Respond( 266 resp, 267 client.ByInspecting(), 268 azure.WithErrorUnlessStatusCode(http.StatusOK), 269 autorest.ByUnmarshallingJSON(&result), 270 autorest.ByClosing()) 271 result.Response = autorest.Response{Response: resp} 272 return 273} 274 275// ListByResourceGroup list all the domains under a resource group 276// Parameters: 277// resourceGroupName - the name of the resource group within the user's subscription. 278// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the 279// 'name' property only and with limited number of OData operations. These operations are: the 'contains' 280// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). 281// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, 282// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq 283// 'westus'. 284// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to 285// 100. If not specified, the default number of results to be returned is 20 items per page. 286func (client DomainsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DomainsListResultPage, err error) { 287 if tracing.IsEnabled() { 288 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListByResourceGroup") 289 defer func() { 290 sc := -1 291 if result.dlr.Response.Response != nil { 292 sc = result.dlr.Response.Response.StatusCode 293 } 294 tracing.EndSpan(ctx, sc, err) 295 }() 296 } 297 result.fn = client.listByResourceGroupNextResults 298 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top) 299 if err != nil { 300 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", nil, "Failure preparing request") 301 return 302 } 303 304 resp, err := client.ListByResourceGroupSender(req) 305 if err != nil { 306 result.dlr.Response = autorest.Response{Response: resp} 307 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", resp, "Failure sending request") 308 return 309 } 310 311 result.dlr, err = client.ListByResourceGroupResponder(resp) 312 if err != nil { 313 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListByResourceGroup", resp, "Failure responding to request") 314 } 315 316 return 317} 318 319// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 320func (client DomainsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32) (*http.Request, error) { 321 pathParameters := map[string]interface{}{ 322 "resourceGroupName": autorest.Encode("path", resourceGroupName), 323 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 324 } 325 326 const APIVersion = "2020-01-01-preview" 327 queryParameters := map[string]interface{}{ 328 "api-version": APIVersion, 329 } 330 if len(filter) > 0 { 331 queryParameters["$filter"] = autorest.Encode("query", filter) 332 } 333 if top != nil { 334 queryParameters["$top"] = autorest.Encode("query", *top) 335 } 336 337 preparer := autorest.CreatePreparer( 338 autorest.AsGet(), 339 autorest.WithBaseURL(client.BaseURI), 340 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains", pathParameters), 341 autorest.WithQueryParameters(queryParameters)) 342 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 343} 344 345// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 346// http.Response Body if it receives an error. 347func (client DomainsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 348 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 349} 350 351// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 352// closes the http.Response Body. 353func (client DomainsClient) ListByResourceGroupResponder(resp *http.Response) (result DomainsListResult, err error) { 354 err = autorest.Respond( 355 resp, 356 client.ByInspecting(), 357 azure.WithErrorUnlessStatusCode(http.StatusOK), 358 autorest.ByUnmarshallingJSON(&result), 359 autorest.ByClosing()) 360 result.Response = autorest.Response{Response: resp} 361 return 362} 363 364// listByResourceGroupNextResults retrieves the next set of results, if any. 365func (client DomainsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DomainsListResult) (result DomainsListResult, err error) { 366 req, err := lastResults.domainsListResultPreparer(ctx) 367 if err != nil { 368 return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 369 } 370 if req == nil { 371 return 372 } 373 resp, err := client.ListByResourceGroupSender(req) 374 if err != nil { 375 result.Response = autorest.Response{Response: resp} 376 return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 377 } 378 result, err = client.ListByResourceGroupResponder(resp) 379 if err != nil { 380 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 381 } 382 return 383} 384 385// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 386func (client DomainsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32) (result DomainsListResultIterator, err error) { 387 if tracing.IsEnabled() { 388 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListByResourceGroup") 389 defer func() { 390 sc := -1 391 if result.Response().Response.Response != nil { 392 sc = result.page.Response().Response.Response.StatusCode 393 } 394 tracing.EndSpan(ctx, sc, err) 395 }() 396 } 397 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, top) 398 return 399} 400 401// ListBySubscription list all the domains under an Azure subscription 402// Parameters: 403// filter - the query used to filter the search results using OData syntax. Filtering is permitted on the 404// 'name' property only and with limited number of OData operations. These operations are: the 'contains' 405// function as well as the following logical operations: not, and, or, eq (for equal), and ne (for not equal). 406// No arithmetic operations are supported. The following is a valid filter example: $filter=contains(namE, 407// 'PATTERN') and name ne 'PATTERN-1'. The following is not a valid filter example: $filter=location eq 408// 'westus'. 409// top - the number of results to return per page for the list operation. Valid range for top parameter is 1 to 410// 100. If not specified, the default number of results to be returned is 20 items per page. 411func (client DomainsClient) ListBySubscription(ctx context.Context, filter string, top *int32) (result DomainsListResultPage, err error) { 412 if tracing.IsEnabled() { 413 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListBySubscription") 414 defer func() { 415 sc := -1 416 if result.dlr.Response.Response != nil { 417 sc = result.dlr.Response.Response.StatusCode 418 } 419 tracing.EndSpan(ctx, sc, err) 420 }() 421 } 422 result.fn = client.listBySubscriptionNextResults 423 req, err := client.ListBySubscriptionPreparer(ctx, filter, top) 424 if err != nil { 425 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", nil, "Failure preparing request") 426 return 427 } 428 429 resp, err := client.ListBySubscriptionSender(req) 430 if err != nil { 431 result.dlr.Response = autorest.Response{Response: resp} 432 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", resp, "Failure sending request") 433 return 434 } 435 436 result.dlr, err = client.ListBySubscriptionResponder(resp) 437 if err != nil { 438 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListBySubscription", resp, "Failure responding to request") 439 } 440 441 return 442} 443 444// ListBySubscriptionPreparer prepares the ListBySubscription request. 445func (client DomainsClient) ListBySubscriptionPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) { 446 pathParameters := map[string]interface{}{ 447 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 448 } 449 450 const APIVersion = "2020-01-01-preview" 451 queryParameters := map[string]interface{}{ 452 "api-version": APIVersion, 453 } 454 if len(filter) > 0 { 455 queryParameters["$filter"] = autorest.Encode("query", filter) 456 } 457 if top != nil { 458 queryParameters["$top"] = autorest.Encode("query", *top) 459 } 460 461 preparer := autorest.CreatePreparer( 462 autorest.AsGet(), 463 autorest.WithBaseURL(client.BaseURI), 464 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains", pathParameters), 465 autorest.WithQueryParameters(queryParameters)) 466 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 467} 468 469// ListBySubscriptionSender sends the ListBySubscription request. The method will close the 470// http.Response Body if it receives an error. 471func (client DomainsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { 472 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 473} 474 475// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always 476// closes the http.Response Body. 477func (client DomainsClient) ListBySubscriptionResponder(resp *http.Response) (result DomainsListResult, err error) { 478 err = autorest.Respond( 479 resp, 480 client.ByInspecting(), 481 azure.WithErrorUnlessStatusCode(http.StatusOK), 482 autorest.ByUnmarshallingJSON(&result), 483 autorest.ByClosing()) 484 result.Response = autorest.Response{Response: resp} 485 return 486} 487 488// listBySubscriptionNextResults retrieves the next set of results, if any. 489func (client DomainsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DomainsListResult) (result DomainsListResult, err error) { 490 req, err := lastResults.domainsListResultPreparer(ctx) 491 if err != nil { 492 return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") 493 } 494 if req == nil { 495 return 496 } 497 resp, err := client.ListBySubscriptionSender(req) 498 if err != nil { 499 result.Response = autorest.Response{Response: resp} 500 return result, autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") 501 } 502 result, err = client.ListBySubscriptionResponder(resp) 503 if err != nil { 504 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") 505 } 506 return 507} 508 509// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. 510func (client DomainsClient) ListBySubscriptionComplete(ctx context.Context, filter string, top *int32) (result DomainsListResultIterator, err error) { 511 if tracing.IsEnabled() { 512 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListBySubscription") 513 defer func() { 514 sc := -1 515 if result.Response().Response.Response != nil { 516 sc = result.page.Response().Response.Response.StatusCode 517 } 518 tracing.EndSpan(ctx, sc, err) 519 }() 520 } 521 result.page, err = client.ListBySubscription(ctx, filter, top) 522 return 523} 524 525// ListSharedAccessKeys list the two keys used to publish to a domain 526// Parameters: 527// resourceGroupName - the name of the resource group within the user's subscription. 528// domainName - name of the domain 529func (client DomainsClient) ListSharedAccessKeys(ctx context.Context, resourceGroupName string, domainName string) (result DomainSharedAccessKeys, err error) { 530 if tracing.IsEnabled() { 531 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.ListSharedAccessKeys") 532 defer func() { 533 sc := -1 534 if result.Response.Response != nil { 535 sc = result.Response.Response.StatusCode 536 } 537 tracing.EndSpan(ctx, sc, err) 538 }() 539 } 540 req, err := client.ListSharedAccessKeysPreparer(ctx, resourceGroupName, domainName) 541 if err != nil { 542 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListSharedAccessKeys", nil, "Failure preparing request") 543 return 544 } 545 546 resp, err := client.ListSharedAccessKeysSender(req) 547 if err != nil { 548 result.Response = autorest.Response{Response: resp} 549 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListSharedAccessKeys", resp, "Failure sending request") 550 return 551 } 552 553 result, err = client.ListSharedAccessKeysResponder(resp) 554 if err != nil { 555 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "ListSharedAccessKeys", resp, "Failure responding to request") 556 } 557 558 return 559} 560 561// ListSharedAccessKeysPreparer prepares the ListSharedAccessKeys request. 562func (client DomainsClient) ListSharedAccessKeysPreparer(ctx context.Context, resourceGroupName string, domainName string) (*http.Request, error) { 563 pathParameters := map[string]interface{}{ 564 "domainName": autorest.Encode("path", domainName), 565 "resourceGroupName": autorest.Encode("path", resourceGroupName), 566 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 567 } 568 569 const APIVersion = "2020-01-01-preview" 570 queryParameters := map[string]interface{}{ 571 "api-version": APIVersion, 572 } 573 574 preparer := autorest.CreatePreparer( 575 autorest.AsPost(), 576 autorest.WithBaseURL(client.BaseURI), 577 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys", pathParameters), 578 autorest.WithQueryParameters(queryParameters)) 579 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 580} 581 582// ListSharedAccessKeysSender sends the ListSharedAccessKeys request. The method will close the 583// http.Response Body if it receives an error. 584func (client DomainsClient) ListSharedAccessKeysSender(req *http.Request) (*http.Response, error) { 585 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 586} 587 588// ListSharedAccessKeysResponder handles the response to the ListSharedAccessKeys request. The method always 589// closes the http.Response Body. 590func (client DomainsClient) ListSharedAccessKeysResponder(resp *http.Response) (result DomainSharedAccessKeys, err error) { 591 err = autorest.Respond( 592 resp, 593 client.ByInspecting(), 594 azure.WithErrorUnlessStatusCode(http.StatusOK), 595 autorest.ByUnmarshallingJSON(&result), 596 autorest.ByClosing()) 597 result.Response = autorest.Response{Response: resp} 598 return 599} 600 601// RegenerateKey regenerate a shared access key for a domain 602// Parameters: 603// resourceGroupName - the name of the resource group within the user's subscription. 604// domainName - name of the domain 605// regenerateKeyRequest - request body to regenerate key 606func (client DomainsClient) RegenerateKey(ctx context.Context, resourceGroupName string, domainName string, regenerateKeyRequest DomainRegenerateKeyRequest) (result DomainSharedAccessKeys, err error) { 607 if tracing.IsEnabled() { 608 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.RegenerateKey") 609 defer func() { 610 sc := -1 611 if result.Response.Response != nil { 612 sc = result.Response.Response.StatusCode 613 } 614 tracing.EndSpan(ctx, sc, err) 615 }() 616 } 617 if err := validation.Validate([]validation.Validation{ 618 {TargetValue: regenerateKeyRequest, 619 Constraints: []validation.Constraint{{Target: "regenerateKeyRequest.KeyName", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 620 return result, validation.NewError("eventgrid.DomainsClient", "RegenerateKey", err.Error()) 621 } 622 623 req, err := client.RegenerateKeyPreparer(ctx, resourceGroupName, domainName, regenerateKeyRequest) 624 if err != nil { 625 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "RegenerateKey", nil, "Failure preparing request") 626 return 627 } 628 629 resp, err := client.RegenerateKeySender(req) 630 if err != nil { 631 result.Response = autorest.Response{Response: resp} 632 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "RegenerateKey", resp, "Failure sending request") 633 return 634 } 635 636 result, err = client.RegenerateKeyResponder(resp) 637 if err != nil { 638 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "RegenerateKey", resp, "Failure responding to request") 639 } 640 641 return 642} 643 644// RegenerateKeyPreparer prepares the RegenerateKey request. 645func (client DomainsClient) RegenerateKeyPreparer(ctx context.Context, resourceGroupName string, domainName string, regenerateKeyRequest DomainRegenerateKeyRequest) (*http.Request, error) { 646 pathParameters := map[string]interface{}{ 647 "domainName": autorest.Encode("path", domainName), 648 "resourceGroupName": autorest.Encode("path", resourceGroupName), 649 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 650 } 651 652 const APIVersion = "2020-01-01-preview" 653 queryParameters := map[string]interface{}{ 654 "api-version": APIVersion, 655 } 656 657 preparer := autorest.CreatePreparer( 658 autorest.AsContentType("application/json; charset=utf-8"), 659 autorest.AsPost(), 660 autorest.WithBaseURL(client.BaseURI), 661 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey", pathParameters), 662 autorest.WithJSON(regenerateKeyRequest), 663 autorest.WithQueryParameters(queryParameters)) 664 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 665} 666 667// RegenerateKeySender sends the RegenerateKey request. The method will close the 668// http.Response Body if it receives an error. 669func (client DomainsClient) RegenerateKeySender(req *http.Request) (*http.Response, error) { 670 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 671} 672 673// RegenerateKeyResponder handles the response to the RegenerateKey request. The method always 674// closes the http.Response Body. 675func (client DomainsClient) RegenerateKeyResponder(resp *http.Response) (result DomainSharedAccessKeys, err error) { 676 err = autorest.Respond( 677 resp, 678 client.ByInspecting(), 679 azure.WithErrorUnlessStatusCode(http.StatusOK), 680 autorest.ByUnmarshallingJSON(&result), 681 autorest.ByClosing()) 682 result.Response = autorest.Response{Response: resp} 683 return 684} 685 686// Update asynchronously updates a domain with the specified parameters. 687// Parameters: 688// resourceGroupName - the name of the resource group within the user's subscription. 689// domainName - name of the domain 690// domainUpdateParameters - domain update information 691func (client DomainsClient) Update(ctx context.Context, resourceGroupName string, domainName string, domainUpdateParameters DomainUpdateParameters) (result DomainsUpdateFuture, err error) { 692 if tracing.IsEnabled() { 693 ctx = tracing.StartSpan(ctx, fqdn+"/DomainsClient.Update") 694 defer func() { 695 sc := -1 696 if result.Response() != nil { 697 sc = result.Response().StatusCode 698 } 699 tracing.EndSpan(ctx, sc, err) 700 }() 701 } 702 req, err := client.UpdatePreparer(ctx, resourceGroupName, domainName, domainUpdateParameters) 703 if err != nil { 704 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Update", nil, "Failure preparing request") 705 return 706 } 707 708 result, err = client.UpdateSender(req) 709 if err != nil { 710 err = autorest.NewErrorWithError(err, "eventgrid.DomainsClient", "Update", result.Response(), "Failure sending request") 711 return 712 } 713 714 return 715} 716 717// UpdatePreparer prepares the Update request. 718func (client DomainsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, domainName string, domainUpdateParameters DomainUpdateParameters) (*http.Request, error) { 719 pathParameters := map[string]interface{}{ 720 "domainName": autorest.Encode("path", domainName), 721 "resourceGroupName": autorest.Encode("path", resourceGroupName), 722 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 723 } 724 725 const APIVersion = "2020-01-01-preview" 726 queryParameters := map[string]interface{}{ 727 "api-version": APIVersion, 728 } 729 730 preparer := autorest.CreatePreparer( 731 autorest.AsContentType("application/json; charset=utf-8"), 732 autorest.AsPatch(), 733 autorest.WithBaseURL(client.BaseURI), 734 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", pathParameters), 735 autorest.WithJSON(domainUpdateParameters), 736 autorest.WithQueryParameters(queryParameters)) 737 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 738} 739 740// UpdateSender sends the Update request. The method will close the 741// http.Response Body if it receives an error. 742func (client DomainsClient) UpdateSender(req *http.Request) (future DomainsUpdateFuture, err error) { 743 var resp *http.Response 744 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 745 if err != nil { 746 return 747 } 748 future.Future, err = azure.NewFutureFromResponse(resp) 749 return 750} 751 752// UpdateResponder handles the response to the Update request. The method always 753// closes the http.Response Body. 754func (client DomainsClient) UpdateResponder(resp *http.Response) (result Domain, err error) { 755 err = autorest.Respond( 756 resp, 757 client.ByInspecting(), 758 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 759 autorest.ByUnmarshallingJSON(&result), 760 autorest.ByClosing()) 761 result.Response = autorest.Response{Response: resp} 762 return 763} 764