1package eventgrid 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/tracing" 14 "net/http" 15) 16 17// EventSubscriptionsClient is the azure EventGrid Management Client 18type EventSubscriptionsClient struct { 19 BaseClient 20} 21 22// NewEventSubscriptionsClient creates an instance of the EventSubscriptionsClient client. 23func NewEventSubscriptionsClient(subscriptionID string) EventSubscriptionsClient { 24 return NewEventSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 25} 26 27// NewEventSubscriptionsClientWithBaseURI creates an instance of the EventSubscriptionsClient client using a custom 28// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 29// stack). 30func NewEventSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) EventSubscriptionsClient { 31 return EventSubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate asynchronously creates a new event subscription or updates an existing event subscription based on 35// the specified scope. 36// Parameters: 37// scope - the identifier of the resource to which the event subscription needs to be created or updated. The 38// scope can be a subscription, or a resource group, or a top level resource belonging to a resource provider 39// namespace, or an EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, 40// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 41// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 42// for a resource, and 43// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 44// for an EventGrid topic. 45// eventSubscriptionName - name of the event subscription. Event subscription names must be between 3 and 64 46// characters in length and should use alphanumeric letters only. 47// eventSubscriptionInfo - event subscription properties containing the destination and filter information 48func (client EventSubscriptionsClient) CreateOrUpdate(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionInfo EventSubscription) (result EventSubscriptionsCreateOrUpdateFuture, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.CreateOrUpdate") 51 defer func() { 52 sc := -1 53 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 54 sc = result.FutureAPI.Response().StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 req, err := client.CreateOrUpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionInfo) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "CreateOrUpdate", nil, "Failure preparing request") 62 return 63 } 64 65 result, err = client.CreateOrUpdateSender(req) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "CreateOrUpdate", nil, "Failure sending request") 68 return 69 } 70 71 return 72} 73 74// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 75func (client EventSubscriptionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionInfo EventSubscription) (*http.Request, error) { 76 pathParameters := map[string]interface{}{ 77 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 78 "scope": scope, 79 } 80 81 const APIVersion = "2019-01-01" 82 queryParameters := map[string]interface{}{ 83 "api-version": APIVersion, 84 } 85 86 preparer := autorest.CreatePreparer( 87 autorest.AsContentType("application/json; charset=utf-8"), 88 autorest.AsPut(), 89 autorest.WithBaseURL(client.BaseURI), 90 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters), 91 autorest.WithJSON(eventSubscriptionInfo), 92 autorest.WithQueryParameters(queryParameters)) 93 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 94} 95 96// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 97// http.Response Body if it receives an error. 98func (client EventSubscriptionsClient) CreateOrUpdateSender(req *http.Request) (future EventSubscriptionsCreateOrUpdateFuture, err error) { 99 var resp *http.Response 100 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 101 if err != nil { 102 return 103 } 104 var azf azure.Future 105 azf, err = azure.NewFutureFromResponse(resp) 106 future.FutureAPI = &azf 107 future.Result = future.result 108 return 109} 110 111// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 112// closes the http.Response Body. 113func (client EventSubscriptionsClient) CreateOrUpdateResponder(resp *http.Response) (result EventSubscription, err error) { 114 err = autorest.Respond( 115 resp, 116 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 117 autorest.ByUnmarshallingJSON(&result), 118 autorest.ByClosing()) 119 result.Response = autorest.Response{Response: resp} 120 return 121} 122 123// Delete delete an existing event subscription 124// Parameters: 125// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top 126// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use 127// '/subscriptions/{subscriptionId}/' for a subscription, 128// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 129// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 130// for a resource, and 131// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 132// for an EventGrid topic. 133// eventSubscriptionName - name of the event subscription 134func (client EventSubscriptionsClient) Delete(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscriptionsDeleteFuture, err error) { 135 if tracing.IsEnabled() { 136 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Delete") 137 defer func() { 138 sc := -1 139 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 140 sc = result.FutureAPI.Response().StatusCode 141 } 142 tracing.EndSpan(ctx, sc, err) 143 }() 144 } 145 req, err := client.DeletePreparer(ctx, scope, eventSubscriptionName) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Delete", nil, "Failure preparing request") 148 return 149 } 150 151 result, err = client.DeleteSender(req) 152 if err != nil { 153 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Delete", nil, "Failure sending request") 154 return 155 } 156 157 return 158} 159 160// DeletePreparer prepares the Delete request. 161func (client EventSubscriptionsClient) DeletePreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) { 162 pathParameters := map[string]interface{}{ 163 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 164 "scope": scope, 165 } 166 167 const APIVersion = "2019-01-01" 168 queryParameters := map[string]interface{}{ 169 "api-version": APIVersion, 170 } 171 172 preparer := autorest.CreatePreparer( 173 autorest.AsDelete(), 174 autorest.WithBaseURL(client.BaseURI), 175 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters), 176 autorest.WithQueryParameters(queryParameters)) 177 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 178} 179 180// DeleteSender sends the Delete request. The method will close the 181// http.Response Body if it receives an error. 182func (client EventSubscriptionsClient) DeleteSender(req *http.Request) (future EventSubscriptionsDeleteFuture, err error) { 183 var resp *http.Response 184 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 185 if err != nil { 186 return 187 } 188 var azf azure.Future 189 azf, err = azure.NewFutureFromResponse(resp) 190 future.FutureAPI = &azf 191 future.Result = future.result 192 return 193} 194 195// DeleteResponder handles the response to the Delete request. The method always 196// closes the http.Response Body. 197func (client EventSubscriptionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 198 err = autorest.Respond( 199 resp, 200 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 201 autorest.ByClosing()) 202 result.Response = resp 203 return 204} 205 206// Get get properties of an event subscription 207// Parameters: 208// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top 209// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use 210// '/subscriptions/{subscriptionId}/' for a subscription, 211// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 212// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 213// for a resource, and 214// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 215// for an EventGrid topic. 216// eventSubscriptionName - name of the event subscription 217func (client EventSubscriptionsClient) Get(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscription, err error) { 218 if tracing.IsEnabled() { 219 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.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 req, err := client.GetPreparer(ctx, scope, eventSubscriptionName) 229 if err != nil { 230 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", nil, "Failure preparing request") 231 return 232 } 233 234 resp, err := client.GetSender(req) 235 if err != nil { 236 result.Response = autorest.Response{Response: resp} 237 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", resp, "Failure sending request") 238 return 239 } 240 241 result, err = client.GetResponder(resp) 242 if err != nil { 243 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Get", resp, "Failure responding to request") 244 return 245 } 246 247 return 248} 249 250// GetPreparer prepares the Get request. 251func (client EventSubscriptionsClient) GetPreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) { 252 pathParameters := map[string]interface{}{ 253 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 254 "scope": scope, 255 } 256 257 const APIVersion = "2019-01-01" 258 queryParameters := map[string]interface{}{ 259 "api-version": APIVersion, 260 } 261 262 preparer := autorest.CreatePreparer( 263 autorest.AsGet(), 264 autorest.WithBaseURL(client.BaseURI), 265 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters), 266 autorest.WithQueryParameters(queryParameters)) 267 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 268} 269 270// GetSender sends the Get request. The method will close the 271// http.Response Body if it receives an error. 272func (client EventSubscriptionsClient) GetSender(req *http.Request) (*http.Response, error) { 273 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 274} 275 276// GetResponder handles the response to the Get request. The method always 277// closes the http.Response Body. 278func (client EventSubscriptionsClient) GetResponder(resp *http.Response) (result EventSubscription, err error) { 279 err = autorest.Respond( 280 resp, 281 azure.WithErrorUnlessStatusCode(http.StatusOK), 282 autorest.ByUnmarshallingJSON(&result), 283 autorest.ByClosing()) 284 result.Response = autorest.Response{Response: resp} 285 return 286} 287 288// GetFullURL get the full endpoint URL for an event subscription 289// Parameters: 290// scope - the scope of the event subscription. The scope can be a subscription, or a resource group, or a top 291// level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use 292// '/subscriptions/{subscriptionId}/' for a subscription, 293// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 294// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 295// for a resource, and 296// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 297// for an EventGrid topic. 298// eventSubscriptionName - name of the event subscription 299func (client EventSubscriptionsClient) GetFullURL(ctx context.Context, scope string, eventSubscriptionName string) (result EventSubscriptionFullURL, err error) { 300 if tracing.IsEnabled() { 301 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.GetFullURL") 302 defer func() { 303 sc := -1 304 if result.Response.Response != nil { 305 sc = result.Response.Response.StatusCode 306 } 307 tracing.EndSpan(ctx, sc, err) 308 }() 309 } 310 req, err := client.GetFullURLPreparer(ctx, scope, eventSubscriptionName) 311 if err != nil { 312 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", nil, "Failure preparing request") 313 return 314 } 315 316 resp, err := client.GetFullURLSender(req) 317 if err != nil { 318 result.Response = autorest.Response{Response: resp} 319 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", resp, "Failure sending request") 320 return 321 } 322 323 result, err = client.GetFullURLResponder(resp) 324 if err != nil { 325 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "GetFullURL", resp, "Failure responding to request") 326 return 327 } 328 329 return 330} 331 332// GetFullURLPreparer prepares the GetFullURL request. 333func (client EventSubscriptionsClient) GetFullURLPreparer(ctx context.Context, scope string, eventSubscriptionName string) (*http.Request, error) { 334 pathParameters := map[string]interface{}{ 335 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 336 "scope": scope, 337 } 338 339 const APIVersion = "2019-01-01" 340 queryParameters := map[string]interface{}{ 341 "api-version": APIVersion, 342 } 343 344 preparer := autorest.CreatePreparer( 345 autorest.AsPost(), 346 autorest.WithBaseURL(client.BaseURI), 347 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl", pathParameters), 348 autorest.WithQueryParameters(queryParameters)) 349 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 350} 351 352// GetFullURLSender sends the GetFullURL request. The method will close the 353// http.Response Body if it receives an error. 354func (client EventSubscriptionsClient) GetFullURLSender(req *http.Request) (*http.Response, error) { 355 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 356} 357 358// GetFullURLResponder handles the response to the GetFullURL request. The method always 359// closes the http.Response Body. 360func (client EventSubscriptionsClient) GetFullURLResponder(resp *http.Response) (result EventSubscriptionFullURL, err error) { 361 err = autorest.Respond( 362 resp, 363 azure.WithErrorUnlessStatusCode(http.StatusOK), 364 autorest.ByUnmarshallingJSON(&result), 365 autorest.ByClosing()) 366 result.Response = autorest.Response{Response: resp} 367 return 368} 369 370// ListByResource list all event subscriptions that have been created for a specific topic 371// Parameters: 372// resourceGroupName - the name of the resource group within the user's subscription. 373// providerNamespace - namespace of the provider of the topic 374// resourceTypeName - name of the resource type 375// resourceName - name of the resource 376func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (result EventSubscriptionsListResult, err error) { 377 if tracing.IsEnabled() { 378 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource") 379 defer func() { 380 sc := -1 381 if result.Response.Response != nil { 382 sc = result.Response.Response.StatusCode 383 } 384 tracing.EndSpan(ctx, sc, err) 385 }() 386 } 387 req, err := client.ListByResourcePreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName) 388 if err != nil { 389 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", nil, "Failure preparing request") 390 return 391 } 392 393 resp, err := client.ListByResourceSender(req) 394 if err != nil { 395 result.Response = autorest.Response{Response: resp} 396 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure sending request") 397 return 398 } 399 400 result, err = client.ListByResourceResponder(resp) 401 if err != nil { 402 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure responding to request") 403 return 404 } 405 406 return 407} 408 409// ListByResourcePreparer prepares the ListByResource request. 410func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (*http.Request, error) { 411 pathParameters := map[string]interface{}{ 412 "providerNamespace": autorest.Encode("path", providerNamespace), 413 "resourceGroupName": autorest.Encode("path", resourceGroupName), 414 "resourceName": autorest.Encode("path", resourceName), 415 "resourceTypeName": autorest.Encode("path", resourceTypeName), 416 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 417 } 418 419 const APIVersion = "2019-01-01" 420 queryParameters := map[string]interface{}{ 421 "api-version": APIVersion, 422 } 423 424 preparer := autorest.CreatePreparer( 425 autorest.AsGet(), 426 autorest.WithBaseURL(client.BaseURI), 427 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 428 autorest.WithQueryParameters(queryParameters)) 429 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 430} 431 432// ListByResourceSender sends the ListByResource request. The method will close the 433// http.Response Body if it receives an error. 434func (client EventSubscriptionsClient) ListByResourceSender(req *http.Request) (*http.Response, error) { 435 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 436} 437 438// ListByResourceResponder handles the response to the ListByResource request. The method always 439// closes the http.Response Body. 440func (client EventSubscriptionsClient) ListByResourceResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 441 err = autorest.Respond( 442 resp, 443 azure.WithErrorUnlessStatusCode(http.StatusOK), 444 autorest.ByUnmarshallingJSON(&result), 445 autorest.ByClosing()) 446 result.Response = autorest.Response{Response: resp} 447 return 448} 449 450// ListGlobalByResourceGroup list all global event subscriptions under a specific Azure subscription and resource group 451// Parameters: 452// resourceGroupName - the name of the resource group within the user's subscription. 453func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string) (result EventSubscriptionsListResult, err error) { 454 if tracing.IsEnabled() { 455 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup") 456 defer func() { 457 sc := -1 458 if result.Response.Response != nil { 459 sc = result.Response.Response.StatusCode 460 } 461 tracing.EndSpan(ctx, sc, err) 462 }() 463 } 464 req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName) 465 if err != nil { 466 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", nil, "Failure preparing request") 467 return 468 } 469 470 resp, err := client.ListGlobalByResourceGroupSender(req) 471 if err != nil { 472 result.Response = autorest.Response{Response: resp} 473 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure sending request") 474 return 475 } 476 477 result, err = client.ListGlobalByResourceGroupResponder(resp) 478 if err != nil { 479 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure responding to request") 480 return 481 } 482 483 return 484} 485 486// ListGlobalByResourceGroupPreparer prepares the ListGlobalByResourceGroup request. 487func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 488 pathParameters := map[string]interface{}{ 489 "resourceGroupName": autorest.Encode("path", resourceGroupName), 490 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 491 } 492 493 const APIVersion = "2019-01-01" 494 queryParameters := map[string]interface{}{ 495 "api-version": APIVersion, 496 } 497 498 preparer := autorest.CreatePreparer( 499 autorest.AsGet(), 500 autorest.WithBaseURL(client.BaseURI), 501 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 502 autorest.WithQueryParameters(queryParameters)) 503 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 504} 505 506// ListGlobalByResourceGroupSender sends the ListGlobalByResourceGroup request. The method will close the 507// http.Response Body if it receives an error. 508func (client EventSubscriptionsClient) ListGlobalByResourceGroupSender(req *http.Request) (*http.Response, error) { 509 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 510} 511 512// ListGlobalByResourceGroupResponder handles the response to the ListGlobalByResourceGroup request. The method always 513// closes the http.Response Body. 514func (client EventSubscriptionsClient) ListGlobalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 515 err = autorest.Respond( 516 resp, 517 azure.WithErrorUnlessStatusCode(http.StatusOK), 518 autorest.ByUnmarshallingJSON(&result), 519 autorest.ByClosing()) 520 result.Response = autorest.Response{Response: resp} 521 return 522} 523 524// ListGlobalByResourceGroupForTopicType list all global event subscriptions under a resource group for a specific 525// topic type. 526// Parameters: 527// resourceGroupName - the name of the resource group within the user's subscription. 528// topicTypeName - name of the topic type 529func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 530 if tracing.IsEnabled() { 531 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType") 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.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName) 541 if err != nil { 542 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", nil, "Failure preparing request") 543 return 544 } 545 546 resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req) 547 if err != nil { 548 result.Response = autorest.Response{Response: resp} 549 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure sending request") 550 return 551 } 552 553 result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp) 554 if err != nil { 555 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure responding to request") 556 return 557 } 558 559 return 560} 561 562// ListGlobalByResourceGroupForTopicTypePreparer prepares the ListGlobalByResourceGroupForTopicType request. 563func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string) (*http.Request, error) { 564 pathParameters := map[string]interface{}{ 565 "resourceGroupName": autorest.Encode("path", resourceGroupName), 566 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 567 "topicTypeName": autorest.Encode("path", topicTypeName), 568 } 569 570 const APIVersion = "2019-01-01" 571 queryParameters := map[string]interface{}{ 572 "api-version": APIVersion, 573 } 574 575 preparer := autorest.CreatePreparer( 576 autorest.AsGet(), 577 autorest.WithBaseURL(client.BaseURI), 578 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 579 autorest.WithQueryParameters(queryParameters)) 580 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 581} 582 583// ListGlobalByResourceGroupForTopicTypeSender sends the ListGlobalByResourceGroupForTopicType request. The method will close the 584// http.Response Body if it receives an error. 585func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) { 586 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 587} 588 589// ListGlobalByResourceGroupForTopicTypeResponder handles the response to the ListGlobalByResourceGroupForTopicType request. The method always 590// closes the http.Response Body. 591func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 592 err = autorest.Respond( 593 resp, 594 azure.WithErrorUnlessStatusCode(http.StatusOK), 595 autorest.ByUnmarshallingJSON(&result), 596 autorest.ByClosing()) 597 result.Response = autorest.Response{Response: resp} 598 return 599} 600 601// ListGlobalBySubscription list all aggregated global event subscriptions under a specific Azure subscription 602func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context) (result EventSubscriptionsListResult, err error) { 603 if tracing.IsEnabled() { 604 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription") 605 defer func() { 606 sc := -1 607 if result.Response.Response != nil { 608 sc = result.Response.Response.StatusCode 609 } 610 tracing.EndSpan(ctx, sc, err) 611 }() 612 } 613 req, err := client.ListGlobalBySubscriptionPreparer(ctx) 614 if err != nil { 615 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", nil, "Failure preparing request") 616 return 617 } 618 619 resp, err := client.ListGlobalBySubscriptionSender(req) 620 if err != nil { 621 result.Response = autorest.Response{Response: resp} 622 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure sending request") 623 return 624 } 625 626 result, err = client.ListGlobalBySubscriptionResponder(resp) 627 if err != nil { 628 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure responding to request") 629 return 630 } 631 632 return 633} 634 635// ListGlobalBySubscriptionPreparer prepares the ListGlobalBySubscription request. 636func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { 637 pathParameters := map[string]interface{}{ 638 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 639 } 640 641 const APIVersion = "2019-01-01" 642 queryParameters := map[string]interface{}{ 643 "api-version": APIVersion, 644 } 645 646 preparer := autorest.CreatePreparer( 647 autorest.AsGet(), 648 autorest.WithBaseURL(client.BaseURI), 649 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 650 autorest.WithQueryParameters(queryParameters)) 651 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 652} 653 654// ListGlobalBySubscriptionSender sends the ListGlobalBySubscription request. The method will close the 655// http.Response Body if it receives an error. 656func (client EventSubscriptionsClient) ListGlobalBySubscriptionSender(req *http.Request) (*http.Response, error) { 657 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 658} 659 660// ListGlobalBySubscriptionResponder handles the response to the ListGlobalBySubscription request. The method always 661// closes the http.Response Body. 662func (client EventSubscriptionsClient) ListGlobalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 663 err = autorest.Respond( 664 resp, 665 azure.WithErrorUnlessStatusCode(http.StatusOK), 666 autorest.ByUnmarshallingJSON(&result), 667 autorest.ByClosing()) 668 result.Response = autorest.Response{Response: resp} 669 return 670} 671 672// ListGlobalBySubscriptionForTopicType list all global event subscriptions under an Azure subscription for a topic 673// type. 674// Parameters: 675// topicTypeName - name of the topic type 676func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string) (result EventSubscriptionsListResult, err error) { 677 if tracing.IsEnabled() { 678 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType") 679 defer func() { 680 sc := -1 681 if result.Response.Response != nil { 682 sc = result.Response.Response.StatusCode 683 } 684 tracing.EndSpan(ctx, sc, err) 685 }() 686 } 687 req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName) 688 if err != nil { 689 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", nil, "Failure preparing request") 690 return 691 } 692 693 resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req) 694 if err != nil { 695 result.Response = autorest.Response{Response: resp} 696 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure sending request") 697 return 698 } 699 700 result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp) 701 if err != nil { 702 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure responding to request") 703 return 704 } 705 706 return 707} 708 709// ListGlobalBySubscriptionForTopicTypePreparer prepares the ListGlobalBySubscriptionForTopicType request. 710func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string) (*http.Request, error) { 711 pathParameters := map[string]interface{}{ 712 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 713 "topicTypeName": autorest.Encode("path", topicTypeName), 714 } 715 716 const APIVersion = "2019-01-01" 717 queryParameters := map[string]interface{}{ 718 "api-version": APIVersion, 719 } 720 721 preparer := autorest.CreatePreparer( 722 autorest.AsGet(), 723 autorest.WithBaseURL(client.BaseURI), 724 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 725 autorest.WithQueryParameters(queryParameters)) 726 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 727} 728 729// ListGlobalBySubscriptionForTopicTypeSender sends the ListGlobalBySubscriptionForTopicType request. The method will close the 730// http.Response Body if it receives an error. 731func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) { 732 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 733} 734 735// ListGlobalBySubscriptionForTopicTypeResponder handles the response to the ListGlobalBySubscriptionForTopicType request. The method always 736// closes the http.Response Body. 737func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 738 err = autorest.Respond( 739 resp, 740 azure.WithErrorUnlessStatusCode(http.StatusOK), 741 autorest.ByUnmarshallingJSON(&result), 742 autorest.ByClosing()) 743 result.Response = autorest.Response{Response: resp} 744 return 745} 746 747// ListRegionalByResourceGroup list all event subscriptions from the given location under a specific Azure subscription 748// and resource group 749// Parameters: 750// resourceGroupName - the name of the resource group within the user's subscription. 751// location - name of the location 752func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string) (result EventSubscriptionsListResult, err error) { 753 if tracing.IsEnabled() { 754 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup") 755 defer func() { 756 sc := -1 757 if result.Response.Response != nil { 758 sc = result.Response.Response.StatusCode 759 } 760 tracing.EndSpan(ctx, sc, err) 761 }() 762 } 763 req, err := client.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location) 764 if err != nil { 765 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", nil, "Failure preparing request") 766 return 767 } 768 769 resp, err := client.ListRegionalByResourceGroupSender(req) 770 if err != nil { 771 result.Response = autorest.Response{Response: resp} 772 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure sending request") 773 return 774 } 775 776 result, err = client.ListRegionalByResourceGroupResponder(resp) 777 if err != nil { 778 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure responding to request") 779 return 780 } 781 782 return 783} 784 785// ListRegionalByResourceGroupPreparer prepares the ListRegionalByResourceGroup request. 786func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location string) (*http.Request, error) { 787 pathParameters := map[string]interface{}{ 788 "location": autorest.Encode("path", location), 789 "resourceGroupName": autorest.Encode("path", resourceGroupName), 790 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 791 } 792 793 const APIVersion = "2019-01-01" 794 queryParameters := map[string]interface{}{ 795 "api-version": APIVersion, 796 } 797 798 preparer := autorest.CreatePreparer( 799 autorest.AsGet(), 800 autorest.WithBaseURL(client.BaseURI), 801 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters), 802 autorest.WithQueryParameters(queryParameters)) 803 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 804} 805 806// ListRegionalByResourceGroupSender sends the ListRegionalByResourceGroup request. The method will close the 807// http.Response Body if it receives an error. 808func (client EventSubscriptionsClient) ListRegionalByResourceGroupSender(req *http.Request) (*http.Response, error) { 809 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 810} 811 812// ListRegionalByResourceGroupResponder handles the response to the ListRegionalByResourceGroup request. The method always 813// closes the http.Response Body. 814func (client EventSubscriptionsClient) ListRegionalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 815 err = autorest.Respond( 816 resp, 817 azure.WithErrorUnlessStatusCode(http.StatusOK), 818 autorest.ByUnmarshallingJSON(&result), 819 autorest.ByClosing()) 820 result.Response = autorest.Response{Response: resp} 821 return 822} 823 824// ListRegionalByResourceGroupForTopicType list all event subscriptions from the given location under a specific Azure 825// subscription and resource group and topic type 826// Parameters: 827// resourceGroupName - the name of the resource group within the user's subscription. 828// location - name of the location 829// topicTypeName - name of the topic type 830func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 831 if tracing.IsEnabled() { 832 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType") 833 defer func() { 834 sc := -1 835 if result.Response.Response != nil { 836 sc = result.Response.Response.StatusCode 837 } 838 tracing.EndSpan(ctx, sc, err) 839 }() 840 } 841 req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName) 842 if err != nil { 843 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", nil, "Failure preparing request") 844 return 845 } 846 847 resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req) 848 if err != nil { 849 result.Response = autorest.Response{Response: resp} 850 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure sending request") 851 return 852 } 853 854 result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp) 855 if err != nil { 856 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure responding to request") 857 return 858 } 859 860 return 861} 862 863// ListRegionalByResourceGroupForTopicTypePreparer prepares the ListRegionalByResourceGroupForTopicType request. 864func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (*http.Request, error) { 865 pathParameters := map[string]interface{}{ 866 "location": autorest.Encode("path", location), 867 "resourceGroupName": autorest.Encode("path", resourceGroupName), 868 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 869 "topicTypeName": autorest.Encode("path", topicTypeName), 870 } 871 872 const APIVersion = "2019-01-01" 873 queryParameters := map[string]interface{}{ 874 "api-version": APIVersion, 875 } 876 877 preparer := autorest.CreatePreparer( 878 autorest.AsGet(), 879 autorest.WithBaseURL(client.BaseURI), 880 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 881 autorest.WithQueryParameters(queryParameters)) 882 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 883} 884 885// ListRegionalByResourceGroupForTopicTypeSender sends the ListRegionalByResourceGroupForTopicType request. The method will close the 886// http.Response Body if it receives an error. 887func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) { 888 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 889} 890 891// ListRegionalByResourceGroupForTopicTypeResponder handles the response to the ListRegionalByResourceGroupForTopicType request. The method always 892// closes the http.Response Body. 893func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 894 err = autorest.Respond( 895 resp, 896 azure.WithErrorUnlessStatusCode(http.StatusOK), 897 autorest.ByUnmarshallingJSON(&result), 898 autorest.ByClosing()) 899 result.Response = autorest.Response{Response: resp} 900 return 901} 902 903// ListRegionalBySubscription list all event subscriptions from the given location under a specific Azure subscription 904// Parameters: 905// location - name of the location 906func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string) (result EventSubscriptionsListResult, err error) { 907 if tracing.IsEnabled() { 908 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription") 909 defer func() { 910 sc := -1 911 if result.Response.Response != nil { 912 sc = result.Response.Response.StatusCode 913 } 914 tracing.EndSpan(ctx, sc, err) 915 }() 916 } 917 req, err := client.ListRegionalBySubscriptionPreparer(ctx, location) 918 if err != nil { 919 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", nil, "Failure preparing request") 920 return 921 } 922 923 resp, err := client.ListRegionalBySubscriptionSender(req) 924 if err != nil { 925 result.Response = autorest.Response{Response: resp} 926 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure sending request") 927 return 928 } 929 930 result, err = client.ListRegionalBySubscriptionResponder(resp) 931 if err != nil { 932 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure responding to request") 933 return 934 } 935 936 return 937} 938 939// ListRegionalBySubscriptionPreparer prepares the ListRegionalBySubscription request. 940func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string) (*http.Request, error) { 941 pathParameters := map[string]interface{}{ 942 "location": autorest.Encode("path", location), 943 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 944 } 945 946 const APIVersion = "2019-01-01" 947 queryParameters := map[string]interface{}{ 948 "api-version": APIVersion, 949 } 950 951 preparer := autorest.CreatePreparer( 952 autorest.AsGet(), 953 autorest.WithBaseURL(client.BaseURI), 954 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters), 955 autorest.WithQueryParameters(queryParameters)) 956 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 957} 958 959// ListRegionalBySubscriptionSender sends the ListRegionalBySubscription request. The method will close the 960// http.Response Body if it receives an error. 961func (client EventSubscriptionsClient) ListRegionalBySubscriptionSender(req *http.Request) (*http.Response, error) { 962 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 963} 964 965// ListRegionalBySubscriptionResponder handles the response to the ListRegionalBySubscription request. The method always 966// closes the http.Response Body. 967func (client EventSubscriptionsClient) ListRegionalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 968 err = autorest.Respond( 969 resp, 970 azure.WithErrorUnlessStatusCode(http.StatusOK), 971 autorest.ByUnmarshallingJSON(&result), 972 autorest.ByClosing()) 973 result.Response = autorest.Response{Response: resp} 974 return 975} 976 977// ListRegionalBySubscriptionForTopicType list all event subscriptions from the given location under a specific Azure 978// subscription and topic type. 979// Parameters: 980// location - name of the location 981// topicTypeName - name of the topic type 982func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 983 if tracing.IsEnabled() { 984 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType") 985 defer func() { 986 sc := -1 987 if result.Response.Response != nil { 988 sc = result.Response.Response.StatusCode 989 } 990 tracing.EndSpan(ctx, sc, err) 991 }() 992 } 993 req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName) 994 if err != nil { 995 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", nil, "Failure preparing request") 996 return 997 } 998 999 resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req) 1000 if err != nil { 1001 result.Response = autorest.Response{Response: resp} 1002 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure sending request") 1003 return 1004 } 1005 1006 result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp) 1007 if err != nil { 1008 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure responding to request") 1009 return 1010 } 1011 1012 return 1013} 1014 1015// ListRegionalBySubscriptionForTopicTypePreparer prepares the ListRegionalBySubscriptionForTopicType request. 1016func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string) (*http.Request, error) { 1017 pathParameters := map[string]interface{}{ 1018 "location": autorest.Encode("path", location), 1019 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1020 "topicTypeName": autorest.Encode("path", topicTypeName), 1021 } 1022 1023 const APIVersion = "2019-01-01" 1024 queryParameters := map[string]interface{}{ 1025 "api-version": APIVersion, 1026 } 1027 1028 preparer := autorest.CreatePreparer( 1029 autorest.AsGet(), 1030 autorest.WithBaseURL(client.BaseURI), 1031 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 1032 autorest.WithQueryParameters(queryParameters)) 1033 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1034} 1035 1036// ListRegionalBySubscriptionForTopicTypeSender sends the ListRegionalBySubscriptionForTopicType request. The method will close the 1037// http.Response Body if it receives an error. 1038func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) { 1039 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1040} 1041 1042// ListRegionalBySubscriptionForTopicTypeResponder handles the response to the ListRegionalBySubscriptionForTopicType request. The method always 1043// closes the http.Response Body. 1044func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 1045 err = autorest.Respond( 1046 resp, 1047 azure.WithErrorUnlessStatusCode(http.StatusOK), 1048 autorest.ByUnmarshallingJSON(&result), 1049 autorest.ByClosing()) 1050 result.Response = autorest.Response{Response: resp} 1051 return 1052} 1053 1054// Update asynchronously updates an existing event subscription. 1055// Parameters: 1056// scope - the scope of existing event subscription. The scope can be a subscription, or a resource group, or a 1057// top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use 1058// '/subscriptions/{subscriptionId}/' for a subscription, 1059// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 1060// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 1061// for a resource, and 1062// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 1063// for an EventGrid topic. 1064// eventSubscriptionName - name of the event subscription to be updated 1065// eventSubscriptionUpdateParameters - updated event subscription information 1066func (client EventSubscriptionsClient) Update(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (result EventSubscriptionsUpdateFuture, err error) { 1067 if tracing.IsEnabled() { 1068 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Update") 1069 defer func() { 1070 sc := -1 1071 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 1072 sc = result.FutureAPI.Response().StatusCode 1073 } 1074 tracing.EndSpan(ctx, sc, err) 1075 }() 1076 } 1077 req, err := client.UpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionUpdateParameters) 1078 if err != nil { 1079 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", nil, "Failure preparing request") 1080 return 1081 } 1082 1083 result, err = client.UpdateSender(req) 1084 if err != nil { 1085 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", nil, "Failure sending request") 1086 return 1087 } 1088 1089 return 1090} 1091 1092// UpdatePreparer prepares the Update request. 1093func (client EventSubscriptionsClient) UpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (*http.Request, error) { 1094 pathParameters := map[string]interface{}{ 1095 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 1096 "scope": scope, 1097 } 1098 1099 const APIVersion = "2019-01-01" 1100 queryParameters := map[string]interface{}{ 1101 "api-version": APIVersion, 1102 } 1103 1104 preparer := autorest.CreatePreparer( 1105 autorest.AsContentType("application/json; charset=utf-8"), 1106 autorest.AsPatch(), 1107 autorest.WithBaseURL(client.BaseURI), 1108 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters), 1109 autorest.WithJSON(eventSubscriptionUpdateParameters), 1110 autorest.WithQueryParameters(queryParameters)) 1111 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1112} 1113 1114// UpdateSender sends the Update request. The method will close the 1115// http.Response Body if it receives an error. 1116func (client EventSubscriptionsClient) UpdateSender(req *http.Request) (future EventSubscriptionsUpdateFuture, err error) { 1117 var resp *http.Response 1118 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1119 if err != nil { 1120 return 1121 } 1122 var azf azure.Future 1123 azf, err = azure.NewFutureFromResponse(resp) 1124 future.FutureAPI = &azf 1125 future.Result = future.result 1126 return 1127} 1128 1129// UpdateResponder handles the response to the Update request. The method always 1130// closes the http.Response Body. 1131func (client EventSubscriptionsClient) UpdateResponder(resp *http.Response) (result EventSubscription, err error) { 1132 err = autorest.Respond( 1133 resp, 1134 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 1135 autorest.ByUnmarshallingJSON(&result), 1136 autorest.ByClosing()) 1137 result.Response = autorest.Response{Response: resp} 1138 return 1139} 1140