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-09-15-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-09-15-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-09-15-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-09-15-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// ListByDomainTopic list all event subscriptions that have been created for a specific domain topic 378// Parameters: 379// resourceGroupName - the name of the resource group within the user's subscription. 380// domainName - name of the top level domain 381// topicName - name of the domain topic 382func (client EventSubscriptionsClient) ListByDomainTopic(ctx context.Context, resourceGroupName string, domainName string, topicName string) (result EventSubscriptionsListResult, err error) { 383 if tracing.IsEnabled() { 384 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByDomainTopic") 385 defer func() { 386 sc := -1 387 if result.Response.Response != nil { 388 sc = result.Response.Response.StatusCode 389 } 390 tracing.EndSpan(ctx, sc, err) 391 }() 392 } 393 req, err := client.ListByDomainTopicPreparer(ctx, resourceGroupName, domainName, topicName) 394 if err != nil { 395 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", nil, "Failure preparing request") 396 return 397 } 398 399 resp, err := client.ListByDomainTopicSender(req) 400 if err != nil { 401 result.Response = autorest.Response{Response: resp} 402 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure sending request") 403 return 404 } 405 406 result, err = client.ListByDomainTopicResponder(resp) 407 if err != nil { 408 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByDomainTopic", resp, "Failure responding to request") 409 } 410 411 return 412} 413 414// ListByDomainTopicPreparer prepares the ListByDomainTopic request. 415func (client EventSubscriptionsClient) ListByDomainTopicPreparer(ctx context.Context, resourceGroupName string, domainName string, topicName string) (*http.Request, error) { 416 pathParameters := map[string]interface{}{ 417 "domainName": autorest.Encode("path", domainName), 418 "resourceGroupName": autorest.Encode("path", resourceGroupName), 419 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 420 "topicName": autorest.Encode("path", topicName), 421 } 422 423 const APIVersion = "2018-09-15-preview" 424 queryParameters := map[string]interface{}{ 425 "api-version": APIVersion, 426 } 427 428 preparer := autorest.CreatePreparer( 429 autorest.AsGet(), 430 autorest.WithBaseURL(client.BaseURI), 431 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 432 autorest.WithQueryParameters(queryParameters)) 433 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 434} 435 436// ListByDomainTopicSender sends the ListByDomainTopic request. The method will close the 437// http.Response Body if it receives an error. 438func (client EventSubscriptionsClient) ListByDomainTopicSender(req *http.Request) (*http.Response, error) { 439 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 440} 441 442// ListByDomainTopicResponder handles the response to the ListByDomainTopic request. The method always 443// closes the http.Response Body. 444func (client EventSubscriptionsClient) ListByDomainTopicResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 445 err = autorest.Respond( 446 resp, 447 client.ByInspecting(), 448 azure.WithErrorUnlessStatusCode(http.StatusOK), 449 autorest.ByUnmarshallingJSON(&result), 450 autorest.ByClosing()) 451 result.Response = autorest.Response{Response: resp} 452 return 453} 454 455// ListByResource list all event subscriptions that have been created for a specific topic 456// Parameters: 457// resourceGroupName - the name of the resource group within the user's subscription. 458// providerNamespace - namespace of the provider of the topic 459// resourceTypeName - name of the resource type 460// resourceName - name of the resource 461func (client EventSubscriptionsClient) ListByResource(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (result EventSubscriptionsListResult, err error) { 462 if tracing.IsEnabled() { 463 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListByResource") 464 defer func() { 465 sc := -1 466 if result.Response.Response != nil { 467 sc = result.Response.Response.StatusCode 468 } 469 tracing.EndSpan(ctx, sc, err) 470 }() 471 } 472 req, err := client.ListByResourcePreparer(ctx, resourceGroupName, providerNamespace, resourceTypeName, resourceName) 473 if err != nil { 474 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", nil, "Failure preparing request") 475 return 476 } 477 478 resp, err := client.ListByResourceSender(req) 479 if err != nil { 480 result.Response = autorest.Response{Response: resp} 481 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure sending request") 482 return 483 } 484 485 result, err = client.ListByResourceResponder(resp) 486 if err != nil { 487 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListByResource", resp, "Failure responding to request") 488 } 489 490 return 491} 492 493// ListByResourcePreparer prepares the ListByResource request. 494func (client EventSubscriptionsClient) ListByResourcePreparer(ctx context.Context, resourceGroupName string, providerNamespace string, resourceTypeName string, resourceName string) (*http.Request, error) { 495 pathParameters := map[string]interface{}{ 496 "providerNamespace": autorest.Encode("path", providerNamespace), 497 "resourceGroupName": autorest.Encode("path", resourceGroupName), 498 "resourceName": autorest.Encode("path", resourceName), 499 "resourceTypeName": autorest.Encode("path", resourceTypeName), 500 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 501 } 502 503 const APIVersion = "2018-09-15-preview" 504 queryParameters := map[string]interface{}{ 505 "api-version": APIVersion, 506 } 507 508 preparer := autorest.CreatePreparer( 509 autorest.AsGet(), 510 autorest.WithBaseURL(client.BaseURI), 511 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 512 autorest.WithQueryParameters(queryParameters)) 513 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 514} 515 516// ListByResourceSender sends the ListByResource request. The method will close the 517// http.Response Body if it receives an error. 518func (client EventSubscriptionsClient) ListByResourceSender(req *http.Request) (*http.Response, error) { 519 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 520} 521 522// ListByResourceResponder handles the response to the ListByResource request. The method always 523// closes the http.Response Body. 524func (client EventSubscriptionsClient) ListByResourceResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 525 err = autorest.Respond( 526 resp, 527 client.ByInspecting(), 528 azure.WithErrorUnlessStatusCode(http.StatusOK), 529 autorest.ByUnmarshallingJSON(&result), 530 autorest.ByClosing()) 531 result.Response = autorest.Response{Response: resp} 532 return 533} 534 535// ListGlobalByResourceGroup list all global event subscriptions under a specific Azure subscription and resource group 536// Parameters: 537// resourceGroupName - the name of the resource group within the user's subscription. 538func (client EventSubscriptionsClient) ListGlobalByResourceGroup(ctx context.Context, resourceGroupName string) (result EventSubscriptionsListResult, err error) { 539 if tracing.IsEnabled() { 540 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroup") 541 defer func() { 542 sc := -1 543 if result.Response.Response != nil { 544 sc = result.Response.Response.StatusCode 545 } 546 tracing.EndSpan(ctx, sc, err) 547 }() 548 } 549 req, err := client.ListGlobalByResourceGroupPreparer(ctx, resourceGroupName) 550 if err != nil { 551 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", nil, "Failure preparing request") 552 return 553 } 554 555 resp, err := client.ListGlobalByResourceGroupSender(req) 556 if err != nil { 557 result.Response = autorest.Response{Response: resp} 558 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure sending request") 559 return 560 } 561 562 result, err = client.ListGlobalByResourceGroupResponder(resp) 563 if err != nil { 564 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroup", resp, "Failure responding to request") 565 } 566 567 return 568} 569 570// ListGlobalByResourceGroupPreparer prepares the ListGlobalByResourceGroup request. 571func (client EventSubscriptionsClient) ListGlobalByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 572 pathParameters := map[string]interface{}{ 573 "resourceGroupName": autorest.Encode("path", resourceGroupName), 574 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 575 } 576 577 const APIVersion = "2018-09-15-preview" 578 queryParameters := map[string]interface{}{ 579 "api-version": APIVersion, 580 } 581 582 preparer := autorest.CreatePreparer( 583 autorest.AsGet(), 584 autorest.WithBaseURL(client.BaseURI), 585 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 586 autorest.WithQueryParameters(queryParameters)) 587 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 588} 589 590// ListGlobalByResourceGroupSender sends the ListGlobalByResourceGroup request. The method will close the 591// http.Response Body if it receives an error. 592func (client EventSubscriptionsClient) ListGlobalByResourceGroupSender(req *http.Request) (*http.Response, error) { 593 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 594} 595 596// ListGlobalByResourceGroupResponder handles the response to the ListGlobalByResourceGroup request. The method always 597// closes the http.Response Body. 598func (client EventSubscriptionsClient) ListGlobalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 599 err = autorest.Respond( 600 resp, 601 client.ByInspecting(), 602 azure.WithErrorUnlessStatusCode(http.StatusOK), 603 autorest.ByUnmarshallingJSON(&result), 604 autorest.ByClosing()) 605 result.Response = autorest.Response{Response: resp} 606 return 607} 608 609// ListGlobalByResourceGroupForTopicType list all global event subscriptions under a resource group for a specific 610// topic type. 611// Parameters: 612// resourceGroupName - the name of the resource group within the user's subscription. 613// topicTypeName - name of the topic type 614func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 615 if tracing.IsEnabled() { 616 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalByResourceGroupForTopicType") 617 defer func() { 618 sc := -1 619 if result.Response.Response != nil { 620 sc = result.Response.Response.StatusCode 621 } 622 tracing.EndSpan(ctx, sc, err) 623 }() 624 } 625 req, err := client.ListGlobalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, topicTypeName) 626 if err != nil { 627 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", nil, "Failure preparing request") 628 return 629 } 630 631 resp, err := client.ListGlobalByResourceGroupForTopicTypeSender(req) 632 if err != nil { 633 result.Response = autorest.Response{Response: resp} 634 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure sending request") 635 return 636 } 637 638 result, err = client.ListGlobalByResourceGroupForTopicTypeResponder(resp) 639 if err != nil { 640 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalByResourceGroupForTopicType", resp, "Failure responding to request") 641 } 642 643 return 644} 645 646// ListGlobalByResourceGroupForTopicTypePreparer prepares the ListGlobalByResourceGroupForTopicType request. 647func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, topicTypeName string) (*http.Request, error) { 648 pathParameters := map[string]interface{}{ 649 "resourceGroupName": autorest.Encode("path", resourceGroupName), 650 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 651 "topicTypeName": autorest.Encode("path", topicTypeName), 652 } 653 654 const APIVersion = "2018-09-15-preview" 655 queryParameters := map[string]interface{}{ 656 "api-version": APIVersion, 657 } 658 659 preparer := autorest.CreatePreparer( 660 autorest.AsGet(), 661 autorest.WithBaseURL(client.BaseURI), 662 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 663 autorest.WithQueryParameters(queryParameters)) 664 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 665} 666 667// ListGlobalByResourceGroupForTopicTypeSender sends the ListGlobalByResourceGroupForTopicType request. The method will close the 668// http.Response Body if it receives an error. 669func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) { 670 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 671} 672 673// ListGlobalByResourceGroupForTopicTypeResponder handles the response to the ListGlobalByResourceGroupForTopicType request. The method always 674// closes the http.Response Body. 675func (client EventSubscriptionsClient) ListGlobalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 676 err = autorest.Respond( 677 resp, 678 client.ByInspecting(), 679 azure.WithErrorUnlessStatusCode(http.StatusOK), 680 autorest.ByUnmarshallingJSON(&result), 681 autorest.ByClosing()) 682 result.Response = autorest.Response{Response: resp} 683 return 684} 685 686// ListGlobalBySubscription list all aggregated global event subscriptions under a specific Azure subscription 687func (client EventSubscriptionsClient) ListGlobalBySubscription(ctx context.Context) (result EventSubscriptionsListResult, err error) { 688 if tracing.IsEnabled() { 689 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscription") 690 defer func() { 691 sc := -1 692 if result.Response.Response != nil { 693 sc = result.Response.Response.StatusCode 694 } 695 tracing.EndSpan(ctx, sc, err) 696 }() 697 } 698 req, err := client.ListGlobalBySubscriptionPreparer(ctx) 699 if err != nil { 700 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", nil, "Failure preparing request") 701 return 702 } 703 704 resp, err := client.ListGlobalBySubscriptionSender(req) 705 if err != nil { 706 result.Response = autorest.Response{Response: resp} 707 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure sending request") 708 return 709 } 710 711 result, err = client.ListGlobalBySubscriptionResponder(resp) 712 if err != nil { 713 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscription", resp, "Failure responding to request") 714 } 715 716 return 717} 718 719// ListGlobalBySubscriptionPreparer prepares the ListGlobalBySubscription request. 720func (client EventSubscriptionsClient) ListGlobalBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { 721 pathParameters := map[string]interface{}{ 722 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 723 } 724 725 const APIVersion = "2018-09-15-preview" 726 queryParameters := map[string]interface{}{ 727 "api-version": APIVersion, 728 } 729 730 preparer := autorest.CreatePreparer( 731 autorest.AsGet(), 732 autorest.WithBaseURL(client.BaseURI), 733 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions", pathParameters), 734 autorest.WithQueryParameters(queryParameters)) 735 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 736} 737 738// ListGlobalBySubscriptionSender sends the ListGlobalBySubscription request. The method will close the 739// http.Response Body if it receives an error. 740func (client EventSubscriptionsClient) ListGlobalBySubscriptionSender(req *http.Request) (*http.Response, error) { 741 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 742} 743 744// ListGlobalBySubscriptionResponder handles the response to the ListGlobalBySubscription request. The method always 745// closes the http.Response Body. 746func (client EventSubscriptionsClient) ListGlobalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 747 err = autorest.Respond( 748 resp, 749 client.ByInspecting(), 750 azure.WithErrorUnlessStatusCode(http.StatusOK), 751 autorest.ByUnmarshallingJSON(&result), 752 autorest.ByClosing()) 753 result.Response = autorest.Response{Response: resp} 754 return 755} 756 757// ListGlobalBySubscriptionForTopicType list all global event subscriptions under an Azure subscription for a topic 758// type. 759// Parameters: 760// topicTypeName - name of the topic type 761func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicType(ctx context.Context, topicTypeName string) (result EventSubscriptionsListResult, err error) { 762 if tracing.IsEnabled() { 763 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListGlobalBySubscriptionForTopicType") 764 defer func() { 765 sc := -1 766 if result.Response.Response != nil { 767 sc = result.Response.Response.StatusCode 768 } 769 tracing.EndSpan(ctx, sc, err) 770 }() 771 } 772 req, err := client.ListGlobalBySubscriptionForTopicTypePreparer(ctx, topicTypeName) 773 if err != nil { 774 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", nil, "Failure preparing request") 775 return 776 } 777 778 resp, err := client.ListGlobalBySubscriptionForTopicTypeSender(req) 779 if err != nil { 780 result.Response = autorest.Response{Response: resp} 781 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure sending request") 782 return 783 } 784 785 result, err = client.ListGlobalBySubscriptionForTopicTypeResponder(resp) 786 if err != nil { 787 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListGlobalBySubscriptionForTopicType", resp, "Failure responding to request") 788 } 789 790 return 791} 792 793// ListGlobalBySubscriptionForTopicTypePreparer prepares the ListGlobalBySubscriptionForTopicType request. 794func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypePreparer(ctx context.Context, topicTypeName string) (*http.Request, error) { 795 pathParameters := map[string]interface{}{ 796 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 797 "topicTypeName": autorest.Encode("path", topicTypeName), 798 } 799 800 const APIVersion = "2018-09-15-preview" 801 queryParameters := map[string]interface{}{ 802 "api-version": APIVersion, 803 } 804 805 preparer := autorest.CreatePreparer( 806 autorest.AsGet(), 807 autorest.WithBaseURL(client.BaseURI), 808 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 809 autorest.WithQueryParameters(queryParameters)) 810 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 811} 812 813// ListGlobalBySubscriptionForTopicTypeSender sends the ListGlobalBySubscriptionForTopicType request. The method will close the 814// http.Response Body if it receives an error. 815func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) { 816 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 817} 818 819// ListGlobalBySubscriptionForTopicTypeResponder handles the response to the ListGlobalBySubscriptionForTopicType request. The method always 820// closes the http.Response Body. 821func (client EventSubscriptionsClient) ListGlobalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 822 err = autorest.Respond( 823 resp, 824 client.ByInspecting(), 825 azure.WithErrorUnlessStatusCode(http.StatusOK), 826 autorest.ByUnmarshallingJSON(&result), 827 autorest.ByClosing()) 828 result.Response = autorest.Response{Response: resp} 829 return 830} 831 832// ListRegionalByResourceGroup list all event subscriptions from the given location under a specific Azure subscription 833// and resource group 834// Parameters: 835// resourceGroupName - the name of the resource group within the user's subscription. 836// location - name of the location 837func (client EventSubscriptionsClient) ListRegionalByResourceGroup(ctx context.Context, resourceGroupName string, location string) (result EventSubscriptionsListResult, err error) { 838 if tracing.IsEnabled() { 839 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroup") 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.ListRegionalByResourceGroupPreparer(ctx, resourceGroupName, location) 849 if err != nil { 850 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", nil, "Failure preparing request") 851 return 852 } 853 854 resp, err := client.ListRegionalByResourceGroupSender(req) 855 if err != nil { 856 result.Response = autorest.Response{Response: resp} 857 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure sending request") 858 return 859 } 860 861 result, err = client.ListRegionalByResourceGroupResponder(resp) 862 if err != nil { 863 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroup", resp, "Failure responding to request") 864 } 865 866 return 867} 868 869// ListRegionalByResourceGroupPreparer prepares the ListRegionalByResourceGroup request. 870func (client EventSubscriptionsClient) ListRegionalByResourceGroupPreparer(ctx context.Context, resourceGroupName string, location 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 } 876 877 const APIVersion = "2018-09-15-preview" 878 queryParameters := map[string]interface{}{ 879 "api-version": APIVersion, 880 } 881 882 preparer := autorest.CreatePreparer( 883 autorest.AsGet(), 884 autorest.WithBaseURL(client.BaseURI), 885 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters), 886 autorest.WithQueryParameters(queryParameters)) 887 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 888} 889 890// ListRegionalByResourceGroupSender sends the ListRegionalByResourceGroup request. The method will close the 891// http.Response Body if it receives an error. 892func (client EventSubscriptionsClient) ListRegionalByResourceGroupSender(req *http.Request) (*http.Response, error) { 893 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 894} 895 896// ListRegionalByResourceGroupResponder handles the response to the ListRegionalByResourceGroup request. The method always 897// closes the http.Response Body. 898func (client EventSubscriptionsClient) ListRegionalByResourceGroupResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 899 err = autorest.Respond( 900 resp, 901 client.ByInspecting(), 902 azure.WithErrorUnlessStatusCode(http.StatusOK), 903 autorest.ByUnmarshallingJSON(&result), 904 autorest.ByClosing()) 905 result.Response = autorest.Response{Response: resp} 906 return 907} 908 909// ListRegionalByResourceGroupForTopicType list all event subscriptions from the given location under a specific Azure 910// subscription and resource group and topic type 911// Parameters: 912// resourceGroupName - the name of the resource group within the user's subscription. 913// location - name of the location 914// topicTypeName - name of the topic type 915func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicType(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 916 if tracing.IsEnabled() { 917 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalByResourceGroupForTopicType") 918 defer func() { 919 sc := -1 920 if result.Response.Response != nil { 921 sc = result.Response.Response.StatusCode 922 } 923 tracing.EndSpan(ctx, sc, err) 924 }() 925 } 926 req, err := client.ListRegionalByResourceGroupForTopicTypePreparer(ctx, resourceGroupName, location, topicTypeName) 927 if err != nil { 928 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", nil, "Failure preparing request") 929 return 930 } 931 932 resp, err := client.ListRegionalByResourceGroupForTopicTypeSender(req) 933 if err != nil { 934 result.Response = autorest.Response{Response: resp} 935 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure sending request") 936 return 937 } 938 939 result, err = client.ListRegionalByResourceGroupForTopicTypeResponder(resp) 940 if err != nil { 941 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalByResourceGroupForTopicType", resp, "Failure responding to request") 942 } 943 944 return 945} 946 947// ListRegionalByResourceGroupForTopicTypePreparer prepares the ListRegionalByResourceGroupForTopicType request. 948func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypePreparer(ctx context.Context, resourceGroupName string, location string, topicTypeName string) (*http.Request, error) { 949 pathParameters := map[string]interface{}{ 950 "location": autorest.Encode("path", location), 951 "resourceGroupName": autorest.Encode("path", resourceGroupName), 952 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 953 "topicTypeName": autorest.Encode("path", topicTypeName), 954 } 955 956 const APIVersion = "2018-09-15-preview" 957 queryParameters := map[string]interface{}{ 958 "api-version": APIVersion, 959 } 960 961 preparer := autorest.CreatePreparer( 962 autorest.AsGet(), 963 autorest.WithBaseURL(client.BaseURI), 964 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 965 autorest.WithQueryParameters(queryParameters)) 966 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 967} 968 969// ListRegionalByResourceGroupForTopicTypeSender sends the ListRegionalByResourceGroupForTopicType request. The method will close the 970// http.Response Body if it receives an error. 971func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeSender(req *http.Request) (*http.Response, error) { 972 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 973} 974 975// ListRegionalByResourceGroupForTopicTypeResponder handles the response to the ListRegionalByResourceGroupForTopicType request. The method always 976// closes the http.Response Body. 977func (client EventSubscriptionsClient) ListRegionalByResourceGroupForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 978 err = autorest.Respond( 979 resp, 980 client.ByInspecting(), 981 azure.WithErrorUnlessStatusCode(http.StatusOK), 982 autorest.ByUnmarshallingJSON(&result), 983 autorest.ByClosing()) 984 result.Response = autorest.Response{Response: resp} 985 return 986} 987 988// ListRegionalBySubscription list all event subscriptions from the given location under a specific Azure subscription 989// Parameters: 990// location - name of the location 991func (client EventSubscriptionsClient) ListRegionalBySubscription(ctx context.Context, location string) (result EventSubscriptionsListResult, err error) { 992 if tracing.IsEnabled() { 993 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscription") 994 defer func() { 995 sc := -1 996 if result.Response.Response != nil { 997 sc = result.Response.Response.StatusCode 998 } 999 tracing.EndSpan(ctx, sc, err) 1000 }() 1001 } 1002 req, err := client.ListRegionalBySubscriptionPreparer(ctx, location) 1003 if err != nil { 1004 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", nil, "Failure preparing request") 1005 return 1006 } 1007 1008 resp, err := client.ListRegionalBySubscriptionSender(req) 1009 if err != nil { 1010 result.Response = autorest.Response{Response: resp} 1011 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure sending request") 1012 return 1013 } 1014 1015 result, err = client.ListRegionalBySubscriptionResponder(resp) 1016 if err != nil { 1017 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscription", resp, "Failure responding to request") 1018 } 1019 1020 return 1021} 1022 1023// ListRegionalBySubscriptionPreparer prepares the ListRegionalBySubscription request. 1024func (client EventSubscriptionsClient) ListRegionalBySubscriptionPreparer(ctx context.Context, location string) (*http.Request, error) { 1025 pathParameters := map[string]interface{}{ 1026 "location": autorest.Encode("path", location), 1027 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1028 } 1029 1030 const APIVersion = "2018-09-15-preview" 1031 queryParameters := map[string]interface{}{ 1032 "api-version": APIVersion, 1033 } 1034 1035 preparer := autorest.CreatePreparer( 1036 autorest.AsGet(), 1037 autorest.WithBaseURL(client.BaseURI), 1038 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", pathParameters), 1039 autorest.WithQueryParameters(queryParameters)) 1040 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1041} 1042 1043// ListRegionalBySubscriptionSender sends the ListRegionalBySubscription request. The method will close the 1044// http.Response Body if it receives an error. 1045func (client EventSubscriptionsClient) ListRegionalBySubscriptionSender(req *http.Request) (*http.Response, error) { 1046 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1047} 1048 1049// ListRegionalBySubscriptionResponder handles the response to the ListRegionalBySubscription request. The method always 1050// closes the http.Response Body. 1051func (client EventSubscriptionsClient) ListRegionalBySubscriptionResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 1052 err = autorest.Respond( 1053 resp, 1054 client.ByInspecting(), 1055 azure.WithErrorUnlessStatusCode(http.StatusOK), 1056 autorest.ByUnmarshallingJSON(&result), 1057 autorest.ByClosing()) 1058 result.Response = autorest.Response{Response: resp} 1059 return 1060} 1061 1062// ListRegionalBySubscriptionForTopicType list all event subscriptions from the given location under a specific Azure 1063// subscription and topic type. 1064// Parameters: 1065// location - name of the location 1066// topicTypeName - name of the topic type 1067func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicType(ctx context.Context, location string, topicTypeName string) (result EventSubscriptionsListResult, err error) { 1068 if tracing.IsEnabled() { 1069 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.ListRegionalBySubscriptionForTopicType") 1070 defer func() { 1071 sc := -1 1072 if result.Response.Response != nil { 1073 sc = result.Response.Response.StatusCode 1074 } 1075 tracing.EndSpan(ctx, sc, err) 1076 }() 1077 } 1078 req, err := client.ListRegionalBySubscriptionForTopicTypePreparer(ctx, location, topicTypeName) 1079 if err != nil { 1080 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", nil, "Failure preparing request") 1081 return 1082 } 1083 1084 resp, err := client.ListRegionalBySubscriptionForTopicTypeSender(req) 1085 if err != nil { 1086 result.Response = autorest.Response{Response: resp} 1087 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure sending request") 1088 return 1089 } 1090 1091 result, err = client.ListRegionalBySubscriptionForTopicTypeResponder(resp) 1092 if err != nil { 1093 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "ListRegionalBySubscriptionForTopicType", resp, "Failure responding to request") 1094 } 1095 1096 return 1097} 1098 1099// ListRegionalBySubscriptionForTopicTypePreparer prepares the ListRegionalBySubscriptionForTopicType request. 1100func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypePreparer(ctx context.Context, location string, topicTypeName string) (*http.Request, error) { 1101 pathParameters := map[string]interface{}{ 1102 "location": autorest.Encode("path", location), 1103 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1104 "topicTypeName": autorest.Encode("path", topicTypeName), 1105 } 1106 1107 const APIVersion = "2018-09-15-preview" 1108 queryParameters := map[string]interface{}{ 1109 "api-version": APIVersion, 1110 } 1111 1112 preparer := autorest.CreatePreparer( 1113 autorest.AsGet(), 1114 autorest.WithBaseURL(client.BaseURI), 1115 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", pathParameters), 1116 autorest.WithQueryParameters(queryParameters)) 1117 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1118} 1119 1120// ListRegionalBySubscriptionForTopicTypeSender sends the ListRegionalBySubscriptionForTopicType request. The method will close the 1121// http.Response Body if it receives an error. 1122func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeSender(req *http.Request) (*http.Response, error) { 1123 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 1124} 1125 1126// ListRegionalBySubscriptionForTopicTypeResponder handles the response to the ListRegionalBySubscriptionForTopicType request. The method always 1127// closes the http.Response Body. 1128func (client EventSubscriptionsClient) ListRegionalBySubscriptionForTopicTypeResponder(resp *http.Response) (result EventSubscriptionsListResult, err error) { 1129 err = autorest.Respond( 1130 resp, 1131 client.ByInspecting(), 1132 azure.WithErrorUnlessStatusCode(http.StatusOK), 1133 autorest.ByUnmarshallingJSON(&result), 1134 autorest.ByClosing()) 1135 result.Response = autorest.Response{Response: resp} 1136 return 1137} 1138 1139// Update asynchronously updates an existing event subscription. 1140// Parameters: 1141// scope - the scope of existing event subscription. The scope can be a subscription, or a resource group, or a 1142// top level resource belonging to a resource provider namespace, or an EventGrid topic. For example, use 1143// '/subscriptions/{subscriptionId}/' for a subscription, 1144// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and 1145// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' 1146// for a resource, and 1147// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' 1148// for an EventGrid topic. 1149// eventSubscriptionName - name of the event subscription to be updated 1150// eventSubscriptionUpdateParameters - updated event subscription information 1151func (client EventSubscriptionsClient) Update(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (result EventSubscriptionsUpdateFuture, err error) { 1152 if tracing.IsEnabled() { 1153 ctx = tracing.StartSpan(ctx, fqdn+"/EventSubscriptionsClient.Update") 1154 defer func() { 1155 sc := -1 1156 if result.Response() != nil { 1157 sc = result.Response().StatusCode 1158 } 1159 tracing.EndSpan(ctx, sc, err) 1160 }() 1161 } 1162 req, err := client.UpdatePreparer(ctx, scope, eventSubscriptionName, eventSubscriptionUpdateParameters) 1163 if err != nil { 1164 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", nil, "Failure preparing request") 1165 return 1166 } 1167 1168 result, err = client.UpdateSender(req) 1169 if err != nil { 1170 err = autorest.NewErrorWithError(err, "eventgrid.EventSubscriptionsClient", "Update", result.Response(), "Failure sending request") 1171 return 1172 } 1173 1174 return 1175} 1176 1177// UpdatePreparer prepares the Update request. 1178func (client EventSubscriptionsClient) UpdatePreparer(ctx context.Context, scope string, eventSubscriptionName string, eventSubscriptionUpdateParameters EventSubscriptionUpdateParameters) (*http.Request, error) { 1179 pathParameters := map[string]interface{}{ 1180 "eventSubscriptionName": autorest.Encode("path", eventSubscriptionName), 1181 "scope": scope, 1182 } 1183 1184 const APIVersion = "2018-09-15-preview" 1185 queryParameters := map[string]interface{}{ 1186 "api-version": APIVersion, 1187 } 1188 1189 preparer := autorest.CreatePreparer( 1190 autorest.AsContentType("application/json; charset=utf-8"), 1191 autorest.AsPatch(), 1192 autorest.WithBaseURL(client.BaseURI), 1193 autorest.WithPathParameters("/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}", pathParameters), 1194 autorest.WithJSON(eventSubscriptionUpdateParameters), 1195 autorest.WithQueryParameters(queryParameters)) 1196 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1197} 1198 1199// UpdateSender sends the Update request. The method will close the 1200// http.Response Body if it receives an error. 1201func (client EventSubscriptionsClient) UpdateSender(req *http.Request) (future EventSubscriptionsUpdateFuture, err error) { 1202 var resp *http.Response 1203 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1204 if err != nil { 1205 return 1206 } 1207 future.Future, err = azure.NewFutureFromResponse(resp) 1208 return 1209} 1210 1211// UpdateResponder handles the response to the Update request. The method always 1212// closes the http.Response Body. 1213func (client EventSubscriptionsClient) UpdateResponder(resp *http.Response) (result EventSubscription, err error) { 1214 err = autorest.Respond( 1215 resp, 1216 client.ByInspecting(), 1217 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 1218 autorest.ByUnmarshallingJSON(&result), 1219 autorest.ByClosing()) 1220 result.Response = autorest.Response{Response: resp} 1221 return 1222} 1223