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