1package notificationhubs 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// Client is the azure NotificationHub client 30type Client struct { 31 BaseClient 32} 33 34// NewClient creates an instance of the Client client. 35func NewClient(subscriptionID string) Client { 36 return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewClientWithBaseURI creates an instance of the Client client. 40func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { 41 return Client{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CheckNotificationHubAvailability checks the availability of the given notificationHub in a namespace. 45// Parameters: 46// resourceGroupName - the name of the resource group. 47// namespaceName - the namespace name. 48// parameters - the notificationHub name. 49func (client Client) CheckNotificationHubAvailability(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (result CheckAvailabilityResult, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNotificationHubAvailability") 52 defer func() { 53 sc := -1 54 if result.Response.Response != nil { 55 sc = result.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 if err := validation.Validate([]validation.Validation{ 61 {TargetValue: parameters, 62 Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 63 return result, validation.NewError("notificationhubs.Client", "CheckNotificationHubAvailability", err.Error()) 64 } 65 66 req, err := client.CheckNotificationHubAvailabilityPreparer(ctx, resourceGroupName, namespaceName, parameters) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", nil, "Failure preparing request") 69 return 70 } 71 72 resp, err := client.CheckNotificationHubAvailabilitySender(req) 73 if err != nil { 74 result.Response = autorest.Response{Response: resp} 75 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", resp, "Failure sending request") 76 return 77 } 78 79 result, err = client.CheckNotificationHubAvailabilityResponder(resp) 80 if err != nil { 81 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", resp, "Failure responding to request") 82 } 83 84 return 85} 86 87// CheckNotificationHubAvailabilityPreparer prepares the CheckNotificationHubAvailability request. 88func (client Client) CheckNotificationHubAvailabilityPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (*http.Request, error) { 89 pathParameters := map[string]interface{}{ 90 "namespaceName": autorest.Encode("path", namespaceName), 91 "resourceGroupName": autorest.Encode("path", resourceGroupName), 92 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 93 } 94 95 const APIVersion = "2017-04-01" 96 queryParameters := map[string]interface{}{ 97 "api-version": APIVersion, 98 } 99 100 parameters.ID = nil 101 parameters.Type = nil 102 preparer := autorest.CreatePreparer( 103 autorest.AsContentType("application/json; charset=utf-8"), 104 autorest.AsPost(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability", pathParameters), 107 autorest.WithJSON(parameters), 108 autorest.WithQueryParameters(queryParameters)) 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// CheckNotificationHubAvailabilitySender sends the CheckNotificationHubAvailability request. The method will close the 113// http.Response Body if it receives an error. 114func (client Client) CheckNotificationHubAvailabilitySender(req *http.Request) (*http.Response, error) { 115 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 116 return autorest.SendWithSender(client, req, sd...) 117} 118 119// CheckNotificationHubAvailabilityResponder handles the response to the CheckNotificationHubAvailability request. The method always 120// closes the http.Response Body. 121func (client Client) CheckNotificationHubAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResult, err error) { 122 err = autorest.Respond( 123 resp, 124 client.ByInspecting(), 125 azure.WithErrorUnlessStatusCode(http.StatusOK), 126 autorest.ByUnmarshallingJSON(&result), 127 autorest.ByClosing()) 128 result.Response = autorest.Response{Response: resp} 129 return 130} 131 132// CreateOrUpdate creates/Update a NotificationHub in a namespace. 133// Parameters: 134// resourceGroupName - the name of the resource group. 135// namespaceName - the namespace name. 136// notificationHubName - the notification hub name. 137// parameters - parameters supplied to the create/update a NotificationHub Resource. 138func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters CreateOrUpdateParameters) (result ResourceType, err error) { 139 if tracing.IsEnabled() { 140 ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") 141 defer func() { 142 sc := -1 143 if result.Response.Response != nil { 144 sc = result.Response.Response.StatusCode 145 } 146 tracing.EndSpan(ctx, sc, err) 147 }() 148 } 149 if err := validation.Validate([]validation.Validation{ 150 {TargetValue: parameters, 151 Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 152 return result, validation.NewError("notificationhubs.Client", "CreateOrUpdate", err.Error()) 153 } 154 155 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, namespaceName, notificationHubName, parameters) 156 if err != nil { 157 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdate", nil, "Failure preparing request") 158 return 159 } 160 161 resp, err := client.CreateOrUpdateSender(req) 162 if err != nil { 163 result.Response = autorest.Response{Response: resp} 164 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdate", resp, "Failure sending request") 165 return 166 } 167 168 result, err = client.CreateOrUpdateResponder(resp) 169 if err != nil { 170 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdate", resp, "Failure responding to request") 171 } 172 173 return 174} 175 176// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 177func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters CreateOrUpdateParameters) (*http.Request, error) { 178 pathParameters := map[string]interface{}{ 179 "namespaceName": autorest.Encode("path", namespaceName), 180 "notificationHubName": autorest.Encode("path", notificationHubName), 181 "resourceGroupName": autorest.Encode("path", resourceGroupName), 182 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 183 } 184 185 const APIVersion = "2017-04-01" 186 queryParameters := map[string]interface{}{ 187 "api-version": APIVersion, 188 } 189 190 preparer := autorest.CreatePreparer( 191 autorest.AsContentType("application/json; charset=utf-8"), 192 autorest.AsPut(), 193 autorest.WithBaseURL(client.BaseURI), 194 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters), 195 autorest.WithJSON(parameters), 196 autorest.WithQueryParameters(queryParameters)) 197 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 198} 199 200// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 201// http.Response Body if it receives an error. 202func (client Client) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 203 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 204 return autorest.SendWithSender(client, req, sd...) 205} 206 207// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 208// closes the http.Response Body. 209func (client Client) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) { 210 err = autorest.Respond( 211 resp, 212 client.ByInspecting(), 213 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 214 autorest.ByUnmarshallingJSON(&result), 215 autorest.ByClosing()) 216 result.Response = autorest.Response{Response: resp} 217 return 218} 219 220// CreateOrUpdateAuthorizationRule creates/Updates an authorization rule for a NotificationHub 221// Parameters: 222// resourceGroupName - the name of the resource group. 223// namespaceName - the namespace name. 224// notificationHubName - the notification hub name. 225// authorizationRuleName - authorization Rule Name. 226// parameters - the shared access authorization rule. 227func (client Client) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) { 228 if tracing.IsEnabled() { 229 ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdateAuthorizationRule") 230 defer func() { 231 sc := -1 232 if result.Response.Response != nil { 233 sc = result.Response.Response.StatusCode 234 } 235 tracing.EndSpan(ctx, sc, err) 236 }() 237 } 238 if err := validation.Validate([]validation.Validation{ 239 {TargetValue: parameters, 240 Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 241 return result, validation.NewError("notificationhubs.Client", "CreateOrUpdateAuthorizationRule", err.Error()) 242 } 243 244 req, err := client.CreateOrUpdateAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters) 245 if err != nil { 246 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") 247 return 248 } 249 250 resp, err := client.CreateOrUpdateAuthorizationRuleSender(req) 251 if err != nil { 252 result.Response = autorest.Response{Response: resp} 253 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request") 254 return 255 } 256 257 result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp) 258 if err != nil { 259 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request") 260 } 261 262 return 263} 264 265// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request. 266func (client Client) CreateOrUpdateAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) { 267 pathParameters := map[string]interface{}{ 268 "authorizationRuleName": autorest.Encode("path", authorizationRuleName), 269 "namespaceName": autorest.Encode("path", namespaceName), 270 "notificationHubName": autorest.Encode("path", notificationHubName), 271 "resourceGroupName": autorest.Encode("path", resourceGroupName), 272 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 273 } 274 275 const APIVersion = "2017-04-01" 276 queryParameters := map[string]interface{}{ 277 "api-version": APIVersion, 278 } 279 280 preparer := autorest.CreatePreparer( 281 autorest.AsContentType("application/json; charset=utf-8"), 282 autorest.AsPut(), 283 autorest.WithBaseURL(client.BaseURI), 284 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters), 285 autorest.WithJSON(parameters), 286 autorest.WithQueryParameters(queryParameters)) 287 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 288} 289 290// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the 291// http.Response Body if it receives an error. 292func (client Client) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) { 293 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 294 return autorest.SendWithSender(client, req, sd...) 295} 296 297// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always 298// closes the http.Response Body. 299func (client Client) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { 300 err = autorest.Respond( 301 resp, 302 client.ByInspecting(), 303 azure.WithErrorUnlessStatusCode(http.StatusOK), 304 autorest.ByUnmarshallingJSON(&result), 305 autorest.ByClosing()) 306 result.Response = autorest.Response{Response: resp} 307 return 308} 309 310// DebugSend test send a push notification 311// Parameters: 312// resourceGroupName - the name of the resource group. 313// namespaceName - the namespace name. 314// notificationHubName - the notification hub name. 315// parameters - debug send parameters 316func (client Client) DebugSend(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters *interface{}) (result DebugSendResponse, err error) { 317 if tracing.IsEnabled() { 318 ctx = tracing.StartSpan(ctx, fqdn+"/Client.DebugSend") 319 defer func() { 320 sc := -1 321 if result.Response.Response != nil { 322 sc = result.Response.Response.StatusCode 323 } 324 tracing.EndSpan(ctx, sc, err) 325 }() 326 } 327 req, err := client.DebugSendPreparer(ctx, resourceGroupName, namespaceName, notificationHubName, parameters) 328 if err != nil { 329 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DebugSend", nil, "Failure preparing request") 330 return 331 } 332 333 resp, err := client.DebugSendSender(req) 334 if err != nil { 335 result.Response = autorest.Response{Response: resp} 336 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DebugSend", resp, "Failure sending request") 337 return 338 } 339 340 result, err = client.DebugSendResponder(resp) 341 if err != nil { 342 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DebugSend", resp, "Failure responding to request") 343 } 344 345 return 346} 347 348// DebugSendPreparer prepares the DebugSend request. 349func (client Client) DebugSendPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters *interface{}) (*http.Request, error) { 350 pathParameters := map[string]interface{}{ 351 "namespaceName": autorest.Encode("path", namespaceName), 352 "notificationHubName": autorest.Encode("path", notificationHubName), 353 "resourceGroupName": autorest.Encode("path", resourceGroupName), 354 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 355 } 356 357 const APIVersion = "2017-04-01" 358 queryParameters := map[string]interface{}{ 359 "api-version": APIVersion, 360 } 361 362 preparer := autorest.CreatePreparer( 363 autorest.AsContentType("application/json; charset=utf-8"), 364 autorest.AsPost(), 365 autorest.WithBaseURL(client.BaseURI), 366 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend", pathParameters), 367 autorest.WithQueryParameters(queryParameters)) 368 if parameters != nil { 369 preparer = autorest.DecoratePreparer(preparer, 370 autorest.WithJSON(parameters)) 371 } 372 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 373} 374 375// DebugSendSender sends the DebugSend request. The method will close the 376// http.Response Body if it receives an error. 377func (client Client) DebugSendSender(req *http.Request) (*http.Response, error) { 378 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 379 return autorest.SendWithSender(client, req, sd...) 380} 381 382// DebugSendResponder handles the response to the DebugSend request. The method always 383// closes the http.Response Body. 384func (client Client) DebugSendResponder(resp *http.Response) (result DebugSendResponse, err error) { 385 err = autorest.Respond( 386 resp, 387 client.ByInspecting(), 388 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 389 autorest.ByUnmarshallingJSON(&result), 390 autorest.ByClosing()) 391 result.Response = autorest.Response{Response: resp} 392 return 393} 394 395// Delete deletes a notification hub associated with a namespace. 396// Parameters: 397// resourceGroupName - the name of the resource group. 398// namespaceName - the namespace name. 399// notificationHubName - the notification hub name. 400func (client Client) Delete(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (result autorest.Response, err error) { 401 if tracing.IsEnabled() { 402 ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") 403 defer func() { 404 sc := -1 405 if result.Response != nil { 406 sc = result.Response.StatusCode 407 } 408 tracing.EndSpan(ctx, sc, err) 409 }() 410 } 411 req, err := client.DeletePreparer(ctx, resourceGroupName, namespaceName, notificationHubName) 412 if err != nil { 413 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Delete", nil, "Failure preparing request") 414 return 415 } 416 417 resp, err := client.DeleteSender(req) 418 if err != nil { 419 result.Response = resp 420 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Delete", resp, "Failure sending request") 421 return 422 } 423 424 result, err = client.DeleteResponder(resp) 425 if err != nil { 426 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Delete", resp, "Failure responding to request") 427 } 428 429 return 430} 431 432// DeletePreparer prepares the Delete request. 433func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) { 434 pathParameters := map[string]interface{}{ 435 "namespaceName": autorest.Encode("path", namespaceName), 436 "notificationHubName": autorest.Encode("path", notificationHubName), 437 "resourceGroupName": autorest.Encode("path", resourceGroupName), 438 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 439 } 440 441 const APIVersion = "2017-04-01" 442 queryParameters := map[string]interface{}{ 443 "api-version": APIVersion, 444 } 445 446 preparer := autorest.CreatePreparer( 447 autorest.AsDelete(), 448 autorest.WithBaseURL(client.BaseURI), 449 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters), 450 autorest.WithQueryParameters(queryParameters)) 451 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 452} 453 454// DeleteSender sends the Delete request. The method will close the 455// http.Response Body if it receives an error. 456func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { 457 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 458 return autorest.SendWithSender(client, req, sd...) 459} 460 461// DeleteResponder handles the response to the Delete request. The method always 462// closes the http.Response Body. 463func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 464 err = autorest.Respond( 465 resp, 466 client.ByInspecting(), 467 azure.WithErrorUnlessStatusCode(http.StatusOK), 468 autorest.ByClosing()) 469 result.Response = resp 470 return 471} 472 473// DeleteAuthorizationRule deletes a notificationHub authorization rule 474// Parameters: 475// resourceGroupName - the name of the resource group. 476// namespaceName - the namespace name. 477// notificationHubName - the notification hub name. 478// authorizationRuleName - authorization Rule Name. 479func (client Client) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result autorest.Response, err error) { 480 if tracing.IsEnabled() { 481 ctx = tracing.StartSpan(ctx, fqdn+"/Client.DeleteAuthorizationRule") 482 defer func() { 483 sc := -1 484 if result.Response != nil { 485 sc = result.Response.StatusCode 486 } 487 tracing.EndSpan(ctx, sc, err) 488 }() 489 } 490 req, err := client.DeleteAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName) 491 if err != nil { 492 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DeleteAuthorizationRule", nil, "Failure preparing request") 493 return 494 } 495 496 resp, err := client.DeleteAuthorizationRuleSender(req) 497 if err != nil { 498 result.Response = resp 499 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DeleteAuthorizationRule", resp, "Failure sending request") 500 return 501 } 502 503 result, err = client.DeleteAuthorizationRuleResponder(resp) 504 if err != nil { 505 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "DeleteAuthorizationRule", resp, "Failure responding to request") 506 } 507 508 return 509} 510 511// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request. 512func (client Client) DeleteAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) { 513 pathParameters := map[string]interface{}{ 514 "authorizationRuleName": autorest.Encode("path", authorizationRuleName), 515 "namespaceName": autorest.Encode("path", namespaceName), 516 "notificationHubName": autorest.Encode("path", notificationHubName), 517 "resourceGroupName": autorest.Encode("path", resourceGroupName), 518 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 519 } 520 521 const APIVersion = "2017-04-01" 522 queryParameters := map[string]interface{}{ 523 "api-version": APIVersion, 524 } 525 526 preparer := autorest.CreatePreparer( 527 autorest.AsDelete(), 528 autorest.WithBaseURL(client.BaseURI), 529 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters), 530 autorest.WithQueryParameters(queryParameters)) 531 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 532} 533 534// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the 535// http.Response Body if it receives an error. 536func (client Client) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) { 537 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 538 return autorest.SendWithSender(client, req, sd...) 539} 540 541// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always 542// closes the http.Response Body. 543func (client Client) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) { 544 err = autorest.Respond( 545 resp, 546 client.ByInspecting(), 547 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 548 autorest.ByClosing()) 549 result.Response = resp 550 return 551} 552 553// Get lists the notification hubs associated with a namespace. 554// Parameters: 555// resourceGroupName - the name of the resource group. 556// namespaceName - the namespace name. 557// notificationHubName - the notification hub name. 558func (client Client) Get(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (result ResourceType, err error) { 559 if tracing.IsEnabled() { 560 ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") 561 defer func() { 562 sc := -1 563 if result.Response.Response != nil { 564 sc = result.Response.Response.StatusCode 565 } 566 tracing.EndSpan(ctx, sc, err) 567 }() 568 } 569 req, err := client.GetPreparer(ctx, resourceGroupName, namespaceName, notificationHubName) 570 if err != nil { 571 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Get", nil, "Failure preparing request") 572 return 573 } 574 575 resp, err := client.GetSender(req) 576 if err != nil { 577 result.Response = autorest.Response{Response: resp} 578 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Get", resp, "Failure sending request") 579 return 580 } 581 582 result, err = client.GetResponder(resp) 583 if err != nil { 584 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Get", resp, "Failure responding to request") 585 } 586 587 return 588} 589 590// GetPreparer prepares the Get request. 591func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) { 592 pathParameters := map[string]interface{}{ 593 "namespaceName": autorest.Encode("path", namespaceName), 594 "notificationHubName": autorest.Encode("path", notificationHubName), 595 "resourceGroupName": autorest.Encode("path", resourceGroupName), 596 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 597 } 598 599 const APIVersion = "2017-04-01" 600 queryParameters := map[string]interface{}{ 601 "api-version": APIVersion, 602 } 603 604 preparer := autorest.CreatePreparer( 605 autorest.AsGet(), 606 autorest.WithBaseURL(client.BaseURI), 607 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters), 608 autorest.WithQueryParameters(queryParameters)) 609 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 610} 611 612// GetSender sends the Get request. The method will close the 613// http.Response Body if it receives an error. 614func (client Client) GetSender(req *http.Request) (*http.Response, error) { 615 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 616 return autorest.SendWithSender(client, req, sd...) 617} 618 619// GetResponder handles the response to the Get request. The method always 620// closes the http.Response Body. 621func (client Client) GetResponder(resp *http.Response) (result ResourceType, err error) { 622 err = autorest.Respond( 623 resp, 624 client.ByInspecting(), 625 azure.WithErrorUnlessStatusCode(http.StatusOK), 626 autorest.ByUnmarshallingJSON(&result), 627 autorest.ByClosing()) 628 result.Response = autorest.Response{Response: resp} 629 return 630} 631 632// GetAuthorizationRule gets an authorization rule for a NotificationHub by name. 633// Parameters: 634// resourceGroupName - the name of the resource group. 635// namespaceName - the namespace name 636// notificationHubName - the notification hub name. 637// authorizationRuleName - authorization rule name. 638func (client Client) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) { 639 if tracing.IsEnabled() { 640 ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetAuthorizationRule") 641 defer func() { 642 sc := -1 643 if result.Response.Response != nil { 644 sc = result.Response.Response.StatusCode 645 } 646 tracing.EndSpan(ctx, sc, err) 647 }() 648 } 649 req, err := client.GetAuthorizationRulePreparer(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName) 650 if err != nil { 651 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetAuthorizationRule", nil, "Failure preparing request") 652 return 653 } 654 655 resp, err := client.GetAuthorizationRuleSender(req) 656 if err != nil { 657 result.Response = autorest.Response{Response: resp} 658 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetAuthorizationRule", resp, "Failure sending request") 659 return 660 } 661 662 result, err = client.GetAuthorizationRuleResponder(resp) 663 if err != nil { 664 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetAuthorizationRule", resp, "Failure responding to request") 665 } 666 667 return 668} 669 670// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request. 671func (client Client) GetAuthorizationRulePreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) { 672 pathParameters := map[string]interface{}{ 673 "authorizationRuleName": autorest.Encode("path", authorizationRuleName), 674 "namespaceName": autorest.Encode("path", namespaceName), 675 "notificationHubName": autorest.Encode("path", notificationHubName), 676 "resourceGroupName": autorest.Encode("path", resourceGroupName), 677 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 678 } 679 680 const APIVersion = "2017-04-01" 681 queryParameters := map[string]interface{}{ 682 "api-version": APIVersion, 683 } 684 685 preparer := autorest.CreatePreparer( 686 autorest.AsGet(), 687 autorest.WithBaseURL(client.BaseURI), 688 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters), 689 autorest.WithQueryParameters(queryParameters)) 690 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 691} 692 693// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the 694// http.Response Body if it receives an error. 695func (client Client) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) { 696 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 697 return autorest.SendWithSender(client, req, sd...) 698} 699 700// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always 701// closes the http.Response Body. 702func (client Client) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) { 703 err = autorest.Respond( 704 resp, 705 client.ByInspecting(), 706 azure.WithErrorUnlessStatusCode(http.StatusOK), 707 autorest.ByUnmarshallingJSON(&result), 708 autorest.ByClosing()) 709 result.Response = autorest.Response{Response: resp} 710 return 711} 712 713// GetPnsCredentials lists the PNS Credentials associated with a notification hub . 714// Parameters: 715// resourceGroupName - the name of the resource group. 716// namespaceName - the namespace name. 717// notificationHubName - the notification hub name. 718func (client Client) GetPnsCredentials(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (result PnsCredentialsResource, err error) { 719 if tracing.IsEnabled() { 720 ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetPnsCredentials") 721 defer func() { 722 sc := -1 723 if result.Response.Response != nil { 724 sc = result.Response.Response.StatusCode 725 } 726 tracing.EndSpan(ctx, sc, err) 727 }() 728 } 729 req, err := client.GetPnsCredentialsPreparer(ctx, resourceGroupName, namespaceName, notificationHubName) 730 if err != nil { 731 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetPnsCredentials", nil, "Failure preparing request") 732 return 733 } 734 735 resp, err := client.GetPnsCredentialsSender(req) 736 if err != nil { 737 result.Response = autorest.Response{Response: resp} 738 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetPnsCredentials", resp, "Failure sending request") 739 return 740 } 741 742 result, err = client.GetPnsCredentialsResponder(resp) 743 if err != nil { 744 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "GetPnsCredentials", resp, "Failure responding to request") 745 } 746 747 return 748} 749 750// GetPnsCredentialsPreparer prepares the GetPnsCredentials request. 751func (client Client) GetPnsCredentialsPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) { 752 pathParameters := map[string]interface{}{ 753 "namespaceName": autorest.Encode("path", namespaceName), 754 "notificationHubName": autorest.Encode("path", notificationHubName), 755 "resourceGroupName": autorest.Encode("path", resourceGroupName), 756 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 757 } 758 759 const APIVersion = "2017-04-01" 760 queryParameters := map[string]interface{}{ 761 "api-version": APIVersion, 762 } 763 764 preparer := autorest.CreatePreparer( 765 autorest.AsPost(), 766 autorest.WithBaseURL(client.BaseURI), 767 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials", pathParameters), 768 autorest.WithQueryParameters(queryParameters)) 769 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 770} 771 772// GetPnsCredentialsSender sends the GetPnsCredentials request. The method will close the 773// http.Response Body if it receives an error. 774func (client Client) GetPnsCredentialsSender(req *http.Request) (*http.Response, error) { 775 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 776 return autorest.SendWithSender(client, req, sd...) 777} 778 779// GetPnsCredentialsResponder handles the response to the GetPnsCredentials request. The method always 780// closes the http.Response Body. 781func (client Client) GetPnsCredentialsResponder(resp *http.Response) (result PnsCredentialsResource, err error) { 782 err = autorest.Respond( 783 resp, 784 client.ByInspecting(), 785 azure.WithErrorUnlessStatusCode(http.StatusOK), 786 autorest.ByUnmarshallingJSON(&result), 787 autorest.ByClosing()) 788 result.Response = autorest.Response{Response: resp} 789 return 790} 791 792// List lists the notification hubs associated with a namespace. 793// Parameters: 794// resourceGroupName - the name of the resource group. 795// namespaceName - the namespace name. 796func (client Client) List(ctx context.Context, resourceGroupName string, namespaceName string) (result ListResultPage, err error) { 797 if tracing.IsEnabled() { 798 ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") 799 defer func() { 800 sc := -1 801 if result.lr.Response.Response != nil { 802 sc = result.lr.Response.Response.StatusCode 803 } 804 tracing.EndSpan(ctx, sc, err) 805 }() 806 } 807 result.fn = client.listNextResults 808 req, err := client.ListPreparer(ctx, resourceGroupName, namespaceName) 809 if err != nil { 810 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "List", nil, "Failure preparing request") 811 return 812 } 813 814 resp, err := client.ListSender(req) 815 if err != nil { 816 result.lr.Response = autorest.Response{Response: resp} 817 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "List", resp, "Failure sending request") 818 return 819 } 820 821 result.lr, err = client.ListResponder(resp) 822 if err != nil { 823 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "List", resp, "Failure responding to request") 824 } 825 826 return 827} 828 829// ListPreparer prepares the List request. 830func (client Client) ListPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { 831 pathParameters := map[string]interface{}{ 832 "namespaceName": autorest.Encode("path", namespaceName), 833 "resourceGroupName": autorest.Encode("path", resourceGroupName), 834 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 835 } 836 837 const APIVersion = "2017-04-01" 838 queryParameters := map[string]interface{}{ 839 "api-version": APIVersion, 840 } 841 842 preparer := autorest.CreatePreparer( 843 autorest.AsGet(), 844 autorest.WithBaseURL(client.BaseURI), 845 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs", pathParameters), 846 autorest.WithQueryParameters(queryParameters)) 847 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 848} 849 850// ListSender sends the List request. The method will close the 851// http.Response Body if it receives an error. 852func (client Client) ListSender(req *http.Request) (*http.Response, error) { 853 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 854 return autorest.SendWithSender(client, req, sd...) 855} 856 857// ListResponder handles the response to the List request. The method always 858// closes the http.Response Body. 859func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) { 860 err = autorest.Respond( 861 resp, 862 client.ByInspecting(), 863 azure.WithErrorUnlessStatusCode(http.StatusOK), 864 autorest.ByUnmarshallingJSON(&result), 865 autorest.ByClosing()) 866 result.Response = autorest.Response{Response: resp} 867 return 868} 869 870// listNextResults retrieves the next set of results, if any. 871func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { 872 req, err := lastResults.listResultPreparer(ctx) 873 if err != nil { 874 return result, autorest.NewErrorWithError(err, "notificationhubs.Client", "listNextResults", nil, "Failure preparing next results request") 875 } 876 if req == nil { 877 return 878 } 879 resp, err := client.ListSender(req) 880 if err != nil { 881 result.Response = autorest.Response{Response: resp} 882 return result, autorest.NewErrorWithError(err, "notificationhubs.Client", "listNextResults", resp, "Failure sending next results request") 883 } 884 result, err = client.ListResponder(resp) 885 if err != nil { 886 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "listNextResults", resp, "Failure responding to next results request") 887 } 888 return 889} 890 891// ListComplete enumerates all values, automatically crossing page boundaries as required. 892func (client Client) ListComplete(ctx context.Context, resourceGroupName string, namespaceName string) (result ListResultIterator, err error) { 893 if tracing.IsEnabled() { 894 ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") 895 defer func() { 896 sc := -1 897 if result.Response().Response.Response != nil { 898 sc = result.page.Response().Response.Response.StatusCode 899 } 900 tracing.EndSpan(ctx, sc, err) 901 }() 902 } 903 result.page, err = client.List(ctx, resourceGroupName, namespaceName) 904 return 905} 906 907// ListAuthorizationRules gets the authorization rules for a NotificationHub. 908// Parameters: 909// resourceGroupName - the name of the resource group. 910// namespaceName - the namespace name 911// notificationHubName - the notification hub name. 912func (client Client) ListAuthorizationRules(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (result SharedAccessAuthorizationRuleListResultPage, err error) { 913 if tracing.IsEnabled() { 914 ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListAuthorizationRules") 915 defer func() { 916 sc := -1 917 if result.saarlr.Response.Response != nil { 918 sc = result.saarlr.Response.Response.StatusCode 919 } 920 tracing.EndSpan(ctx, sc, err) 921 }() 922 } 923 result.fn = client.listAuthorizationRulesNextResults 924 req, err := client.ListAuthorizationRulesPreparer(ctx, resourceGroupName, namespaceName, notificationHubName) 925 if err != nil { 926 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListAuthorizationRules", nil, "Failure preparing request") 927 return 928 } 929 930 resp, err := client.ListAuthorizationRulesSender(req) 931 if err != nil { 932 result.saarlr.Response = autorest.Response{Response: resp} 933 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListAuthorizationRules", resp, "Failure sending request") 934 return 935 } 936 937 result.saarlr, err = client.ListAuthorizationRulesResponder(resp) 938 if err != nil { 939 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListAuthorizationRules", resp, "Failure responding to request") 940 } 941 942 return 943} 944 945// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request. 946func (client Client) ListAuthorizationRulesPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) { 947 pathParameters := map[string]interface{}{ 948 "namespaceName": autorest.Encode("path", namespaceName), 949 "notificationHubName": autorest.Encode("path", notificationHubName), 950 "resourceGroupName": autorest.Encode("path", resourceGroupName), 951 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 952 } 953 954 const APIVersion = "2017-04-01" 955 queryParameters := map[string]interface{}{ 956 "api-version": APIVersion, 957 } 958 959 preparer := autorest.CreatePreparer( 960 autorest.AsGet(), 961 autorest.WithBaseURL(client.BaseURI), 962 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules", pathParameters), 963 autorest.WithQueryParameters(queryParameters)) 964 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 965} 966 967// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the 968// http.Response Body if it receives an error. 969func (client Client) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) { 970 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 971 return autorest.SendWithSender(client, req, sd...) 972} 973 974// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always 975// closes the http.Response Body. 976func (client Client) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { 977 err = autorest.Respond( 978 resp, 979 client.ByInspecting(), 980 azure.WithErrorUnlessStatusCode(http.StatusOK), 981 autorest.ByUnmarshallingJSON(&result), 982 autorest.ByClosing()) 983 result.Response = autorest.Response{Response: resp} 984 return 985} 986 987// listAuthorizationRulesNextResults retrieves the next set of results, if any. 988func (client Client) listAuthorizationRulesNextResults(ctx context.Context, lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) { 989 req, err := lastResults.sharedAccessAuthorizationRuleListResultPreparer(ctx) 990 if err != nil { 991 return result, autorest.NewErrorWithError(err, "notificationhubs.Client", "listAuthorizationRulesNextResults", nil, "Failure preparing next results request") 992 } 993 if req == nil { 994 return 995 } 996 resp, err := client.ListAuthorizationRulesSender(req) 997 if err != nil { 998 result.Response = autorest.Response{Response: resp} 999 return result, autorest.NewErrorWithError(err, "notificationhubs.Client", "listAuthorizationRulesNextResults", resp, "Failure sending next results request") 1000 } 1001 result, err = client.ListAuthorizationRulesResponder(resp) 1002 if err != nil { 1003 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "listAuthorizationRulesNextResults", resp, "Failure responding to next results request") 1004 } 1005 return 1006} 1007 1008// ListAuthorizationRulesComplete enumerates all values, automatically crossing page boundaries as required. 1009func (client Client) ListAuthorizationRulesComplete(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string) (result SharedAccessAuthorizationRuleListResultIterator, err error) { 1010 if tracing.IsEnabled() { 1011 ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListAuthorizationRules") 1012 defer func() { 1013 sc := -1 1014 if result.Response().Response.Response != nil { 1015 sc = result.page.Response().Response.Response.StatusCode 1016 } 1017 tracing.EndSpan(ctx, sc, err) 1018 }() 1019 } 1020 result.page, err = client.ListAuthorizationRules(ctx, resourceGroupName, namespaceName, notificationHubName) 1021 return 1022} 1023 1024// ListKeys gets the Primary and Secondary ConnectionStrings to the NotificationHub 1025// Parameters: 1026// resourceGroupName - the name of the resource group. 1027// namespaceName - the namespace name. 1028// notificationHubName - the notification hub name. 1029// authorizationRuleName - the connection string of the NotificationHub for the specified authorizationRule. 1030func (client Client) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result ResourceListKeys, err error) { 1031 if tracing.IsEnabled() { 1032 ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListKeys") 1033 defer func() { 1034 sc := -1 1035 if result.Response.Response != nil { 1036 sc = result.Response.Response.StatusCode 1037 } 1038 tracing.EndSpan(ctx, sc, err) 1039 }() 1040 } 1041 req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName) 1042 if err != nil { 1043 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListKeys", nil, "Failure preparing request") 1044 return 1045 } 1046 1047 resp, err := client.ListKeysSender(req) 1048 if err != nil { 1049 result.Response = autorest.Response{Response: resp} 1050 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListKeys", resp, "Failure sending request") 1051 return 1052 } 1053 1054 result, err = client.ListKeysResponder(resp) 1055 if err != nil { 1056 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "ListKeys", resp, "Failure responding to request") 1057 } 1058 1059 return 1060} 1061 1062// ListKeysPreparer prepares the ListKeys request. 1063func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) { 1064 pathParameters := map[string]interface{}{ 1065 "authorizationRuleName": autorest.Encode("path", authorizationRuleName), 1066 "namespaceName": autorest.Encode("path", namespaceName), 1067 "notificationHubName": autorest.Encode("path", notificationHubName), 1068 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1069 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1070 } 1071 1072 const APIVersion = "2017-04-01" 1073 queryParameters := map[string]interface{}{ 1074 "api-version": APIVersion, 1075 } 1076 1077 preparer := autorest.CreatePreparer( 1078 autorest.AsPost(), 1079 autorest.WithBaseURL(client.BaseURI), 1080 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys", pathParameters), 1081 autorest.WithQueryParameters(queryParameters)) 1082 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1083} 1084 1085// ListKeysSender sends the ListKeys request. The method will close the 1086// http.Response Body if it receives an error. 1087func (client Client) ListKeysSender(req *http.Request) (*http.Response, error) { 1088 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1089 return autorest.SendWithSender(client, req, sd...) 1090} 1091 1092// ListKeysResponder handles the response to the ListKeys request. The method always 1093// closes the http.Response Body. 1094func (client Client) ListKeysResponder(resp *http.Response) (result ResourceListKeys, err error) { 1095 err = autorest.Respond( 1096 resp, 1097 client.ByInspecting(), 1098 azure.WithErrorUnlessStatusCode(http.StatusOK), 1099 autorest.ByUnmarshallingJSON(&result), 1100 autorest.ByClosing()) 1101 result.Response = autorest.Response{Response: resp} 1102 return 1103} 1104 1105// Patch patch a NotificationHub in a namespace. 1106// Parameters: 1107// resourceGroupName - the name of the resource group. 1108// namespaceName - the namespace name. 1109// notificationHubName - the notification hub name. 1110// parameters - parameters supplied to patch a NotificationHub Resource. 1111func (client Client) Patch(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters *PatchParameters) (result ResourceType, err error) { 1112 if tracing.IsEnabled() { 1113 ctx = tracing.StartSpan(ctx, fqdn+"/Client.Patch") 1114 defer func() { 1115 sc := -1 1116 if result.Response.Response != nil { 1117 sc = result.Response.Response.StatusCode 1118 } 1119 tracing.EndSpan(ctx, sc, err) 1120 }() 1121 } 1122 req, err := client.PatchPreparer(ctx, resourceGroupName, namespaceName, notificationHubName, parameters) 1123 if err != nil { 1124 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Patch", nil, "Failure preparing request") 1125 return 1126 } 1127 1128 resp, err := client.PatchSender(req) 1129 if err != nil { 1130 result.Response = autorest.Response{Response: resp} 1131 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Patch", resp, "Failure sending request") 1132 return 1133 } 1134 1135 result, err = client.PatchResponder(resp) 1136 if err != nil { 1137 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "Patch", resp, "Failure responding to request") 1138 } 1139 1140 return 1141} 1142 1143// PatchPreparer prepares the Patch request. 1144func (client Client) PatchPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters *PatchParameters) (*http.Request, error) { 1145 pathParameters := map[string]interface{}{ 1146 "namespaceName": autorest.Encode("path", namespaceName), 1147 "notificationHubName": autorest.Encode("path", notificationHubName), 1148 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1149 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1150 } 1151 1152 const APIVersion = "2017-04-01" 1153 queryParameters := map[string]interface{}{ 1154 "api-version": APIVersion, 1155 } 1156 1157 preparer := autorest.CreatePreparer( 1158 autorest.AsContentType("application/json; charset=utf-8"), 1159 autorest.AsPatch(), 1160 autorest.WithBaseURL(client.BaseURI), 1161 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters), 1162 autorest.WithQueryParameters(queryParameters)) 1163 if parameters != nil { 1164 preparer = autorest.DecoratePreparer(preparer, 1165 autorest.WithJSON(parameters)) 1166 } 1167 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1168} 1169 1170// PatchSender sends the Patch request. The method will close the 1171// http.Response Body if it receives an error. 1172func (client Client) PatchSender(req *http.Request) (*http.Response, error) { 1173 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1174 return autorest.SendWithSender(client, req, sd...) 1175} 1176 1177// PatchResponder handles the response to the Patch request. The method always 1178// closes the http.Response Body. 1179func (client Client) PatchResponder(resp *http.Response) (result ResourceType, err error) { 1180 err = autorest.Respond( 1181 resp, 1182 client.ByInspecting(), 1183 azure.WithErrorUnlessStatusCode(http.StatusOK), 1184 autorest.ByUnmarshallingJSON(&result), 1185 autorest.ByClosing()) 1186 result.Response = autorest.Response{Response: resp} 1187 return 1188} 1189 1190// RegenerateKeys regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule 1191// Parameters: 1192// resourceGroupName - the name of the resource group. 1193// namespaceName - the namespace name. 1194// notificationHubName - the notification hub name. 1195// authorizationRuleName - the connection string of the NotificationHub for the specified authorizationRule. 1196// parameters - parameters supplied to regenerate the NotificationHub Authorization Rule Key. 1197func (client Client) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource) (result ResourceListKeys, err error) { 1198 if tracing.IsEnabled() { 1199 ctx = tracing.StartSpan(ctx, fqdn+"/Client.RegenerateKeys") 1200 defer func() { 1201 sc := -1 1202 if result.Response.Response != nil { 1203 sc = result.Response.Response.StatusCode 1204 } 1205 tracing.EndSpan(ctx, sc, err) 1206 }() 1207 } 1208 req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters) 1209 if err != nil { 1210 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "RegenerateKeys", nil, "Failure preparing request") 1211 return 1212 } 1213 1214 resp, err := client.RegenerateKeysSender(req) 1215 if err != nil { 1216 result.Response = autorest.Response{Response: resp} 1217 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "RegenerateKeys", resp, "Failure sending request") 1218 return 1219 } 1220 1221 result, err = client.RegenerateKeysResponder(resp) 1222 if err != nil { 1223 err = autorest.NewErrorWithError(err, "notificationhubs.Client", "RegenerateKeys", resp, "Failure responding to request") 1224 } 1225 1226 return 1227} 1228 1229// RegenerateKeysPreparer prepares the RegenerateKeys request. 1230func (client Client) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource) (*http.Request, error) { 1231 pathParameters := map[string]interface{}{ 1232 "authorizationRuleName": autorest.Encode("path", authorizationRuleName), 1233 "namespaceName": autorest.Encode("path", namespaceName), 1234 "notificationHubName": autorest.Encode("path", notificationHubName), 1235 "resourceGroupName": autorest.Encode("path", resourceGroupName), 1236 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 1237 } 1238 1239 const APIVersion = "2017-04-01" 1240 queryParameters := map[string]interface{}{ 1241 "api-version": APIVersion, 1242 } 1243 1244 preparer := autorest.CreatePreparer( 1245 autorest.AsContentType("application/json; charset=utf-8"), 1246 autorest.AsPost(), 1247 autorest.WithBaseURL(client.BaseURI), 1248 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters), 1249 autorest.WithJSON(parameters), 1250 autorest.WithQueryParameters(queryParameters)) 1251 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1252} 1253 1254// RegenerateKeysSender sends the RegenerateKeys request. The method will close the 1255// http.Response Body if it receives an error. 1256func (client Client) RegenerateKeysSender(req *http.Request) (*http.Response, error) { 1257 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 1258 return autorest.SendWithSender(client, req, sd...) 1259} 1260 1261// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always 1262// closes the http.Response Body. 1263func (client Client) RegenerateKeysResponder(resp *http.Response) (result ResourceListKeys, err error) { 1264 err = autorest.Respond( 1265 resp, 1266 client.ByInspecting(), 1267 azure.WithErrorUnlessStatusCode(http.StatusOK), 1268 autorest.ByUnmarshallingJSON(&result), 1269 autorest.ByClosing()) 1270 result.Response = autorest.Response{Response: resp} 1271 return 1272} 1273