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