2017-08-05 18:30:20 +00:00
|
|
|
package notificationhubs
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
2017-08-05 18:30:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Azure/go-autorest/autorest"
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
"github.com/Azure/go-autorest/autorest/validation"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GroupClient is the azure NotificationHub client
|
|
|
|
type GroupClient struct {
|
|
|
|
ManagementClient
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGroupClient creates an instance of the GroupClient client.
|
|
|
|
func NewGroupClient(subscriptionID string) GroupClient {
|
|
|
|
return NewGroupClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewGroupClientWithBaseURI creates an instance of the GroupClient client.
|
|
|
|
func NewGroupClientWithBaseURI(baseURI string, subscriptionID string) GroupClient {
|
|
|
|
return GroupClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// CheckAvailability checks the availability of the given notificationHub in a namespace.
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. parameters is the
|
|
|
|
// notificationHub name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) CheckAvailability(resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (result CheckAvailabilityResult, err error) {
|
|
|
|
if err := validation.Validate([]validation.Validation{
|
|
|
|
{TargetValue: parameters,
|
|
|
|
Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil},
|
|
|
|
{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
|
|
return result, validation.NewErrorWithValidationError(err, "notificationhubs.GroupClient", "CheckAvailability")
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := client.CheckAvailabilityPreparer(resourceGroupName, namespaceName, parameters)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CheckAvailability", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.CheckAvailabilitySender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CheckAvailability", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.CheckAvailabilityResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CheckAvailability", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckAvailabilityPreparer prepares the CheckAvailability request.
|
|
|
|
func (client GroupClient) CheckAvailabilityPreparer(resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability", pathParameters),
|
|
|
|
autorest.WithJSON(parameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckAvailabilitySender sends the CheckAvailability request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) CheckAvailabilitySender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CheckAvailabilityResponder handles the response to the CheckAvailability request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) CheckAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResult, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdate creates/Update a NotificationHub in a namespace.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name. parameters is parameters supplied to the create/update a NotificationHub Resource.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) CreateOrUpdate(resourceGroupName string, namespaceName string, notificationHubName string, parameters CreateOrUpdateParameters) (result ResourceType, err error) {
|
|
|
|
if err := validation.Validate([]validation.Validation{
|
|
|
|
{TargetValue: parameters,
|
|
|
|
Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
|
|
return result, validation.NewErrorWithValidationError(err, "notificationhubs.GroupClient", "CreateOrUpdate")
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, namespaceName, notificationHubName, parameters)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdate", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.CreateOrUpdateSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdate", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.CreateOrUpdateResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdate", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
|
|
|
func (client GroupClient) CreateOrUpdatePreparer(resourceGroupName string, namespaceName string, notificationHubName string, parameters CreateOrUpdateParameters) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPut(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters),
|
|
|
|
autorest.WithJSON(parameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) CreateOrUpdateResponder(resp *http.Response) (result ResourceType, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// CreateOrUpdateAuthorizationRule creates/Updates an authorization rule for a NotificationHub
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name. authorizationRuleName is authorization Rule Name. parameters is the shared access
|
|
|
|
// authorization rule.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) CreateOrUpdateAuthorizationRule(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (result SharedAccessAuthorizationRuleResource, err error) {
|
|
|
|
if err := validation.Validate([]validation.Validation{
|
|
|
|
{TargetValue: parameters,
|
|
|
|
Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
|
|
return result, validation.NewErrorWithValidationError(err, "notificationhubs.GroupClient", "CreateOrUpdateAuthorizationRule")
|
|
|
|
}
|
|
|
|
|
|
|
|
req, err := client.CreateOrUpdateAuthorizationRulePreparer(resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.CreateOrUpdateAuthorizationRuleSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdateAuthorizationRule", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.CreateOrUpdateAuthorizationRuleResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "CreateOrUpdateAuthorizationRule", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdateAuthorizationRulePreparer prepares the CreateOrUpdateAuthorizationRule request.
|
|
|
|
func (client GroupClient) CreateOrUpdateAuthorizationRulePreparer(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPut(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
|
|
|
|
autorest.WithJSON(parameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdateAuthorizationRuleSender sends the CreateOrUpdateAuthorizationRule request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) CreateOrUpdateAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateOrUpdateAuthorizationRuleResponder handles the response to the CreateOrUpdateAuthorizationRule request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) CreateOrUpdateAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete deletes a notification hub associated with a namespace.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) Delete(resourceGroupName string, namespaceName string, notificationHubName string) (result autorest.Response, err error) {
|
|
|
|
req, err := client.DeletePreparer(resourceGroupName, namespaceName, notificationHubName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Delete", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = resp
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Delete", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Delete", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
|
|
func (client GroupClient) DeletePreparer(resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsDelete(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteResponder handles the response to the Delete request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = resp
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteAuthorizationRule deletes a notificationHub authorization rule
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name. authorizationRuleName is authorization Rule Name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) DeleteAuthorizationRule(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result autorest.Response, err error) {
|
|
|
|
req, err := client.DeleteAuthorizationRulePreparer(resourceGroupName, namespaceName, notificationHubName, authorizationRuleName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "DeleteAuthorizationRule", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.DeleteAuthorizationRuleSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = resp
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "DeleteAuthorizationRule", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.DeleteAuthorizationRuleResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "DeleteAuthorizationRule", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteAuthorizationRulePreparer prepares the DeleteAuthorizationRule request.
|
|
|
|
func (client GroupClient) DeleteAuthorizationRulePreparer(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsDelete(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteAuthorizationRuleSender sends the DeleteAuthorizationRule request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) DeleteAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteAuthorizationRuleResponder handles the response to the DeleteAuthorizationRule request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) DeleteAuthorizationRuleResponder(resp *http.Response) (result autorest.Response, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = resp
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get lists the notification hubs associated with a namespace.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) Get(resourceGroupName string, namespaceName string, notificationHubName string) (result ResourceType, err error) {
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, namespaceName, notificationHubName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Get", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.GetSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Get", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.GetResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "Get", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPreparer prepares the Get request.
|
|
|
|
func (client GroupClient) GetPreparer(resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSender sends the Get request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) GetSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) GetResponder(resp *http.Response) (result ResourceType, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// GetAuthorizationRule gets an authorization rule for a NotificationHub by name.
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name notificationHubName is the
|
|
|
|
// notification hub name. authorizationRuleName is authorization rule name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) GetAuthorizationRule(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleResource, err error) {
|
|
|
|
req, err := client.GetAuthorizationRulePreparer(resourceGroupName, namespaceName, notificationHubName, authorizationRuleName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetAuthorizationRule", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.GetAuthorizationRuleSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetAuthorizationRule", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.GetAuthorizationRuleResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetAuthorizationRule", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAuthorizationRulePreparer prepares the GetAuthorizationRule request.
|
|
|
|
func (client GroupClient) GetAuthorizationRulePreparer(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAuthorizationRuleSender sends the GetAuthorizationRule request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) GetAuthorizationRuleSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetAuthorizationRuleResponder handles the response to the GetAuthorizationRule request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) GetAuthorizationRuleResponder(resp *http.Response) (result SharedAccessAuthorizationRuleResource, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// GetPnsCredentials lists the PNS Credentials associated with a notification hub .
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) GetPnsCredentials(resourceGroupName string, namespaceName string, notificationHubName string) (result PnsCredentialsResource, err error) {
|
|
|
|
req, err := client.GetPnsCredentialsPreparer(resourceGroupName, namespaceName, notificationHubName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetPnsCredentials", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.GetPnsCredentialsSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetPnsCredentials", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.GetPnsCredentialsResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "GetPnsCredentials", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPnsCredentialsPreparer prepares the GetPnsCredentials request.
|
|
|
|
func (client GroupClient) GetPnsCredentialsPreparer(resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetPnsCredentialsSender sends the GetPnsCredentials request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) GetPnsCredentialsSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetPnsCredentialsResponder handles the response to the GetPnsCredentials request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) GetPnsCredentialsResponder(resp *http.Response) (result PnsCredentialsResource, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// List lists the notification hubs associated with a namespace.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) List(resourceGroupName string, namespaceName string) (result ListResult, err error) {
|
|
|
|
req, err := client.ListPreparer(resourceGroupName, namespaceName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListPreparer prepares the List request.
|
|
|
|
func (client GroupClient) ListPreparer(resourceGroupName string, namespaceName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListSender sends the List request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) ListSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ListResponder handles the response to the List request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) ListResponder(resp *http.Response) (result ListResult, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListNextResults retrieves the next set of results, if any.
|
|
|
|
func (client GroupClient) ListNextResults(lastResults ListResult) (result ListResult, err error) {
|
|
|
|
req, err := lastResults.ListResultPreparer()
|
|
|
|
if err != nil {
|
|
|
|
return result, autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", nil, "Failure preparing next results request")
|
|
|
|
}
|
|
|
|
if req == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return result, autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", resp, "Failure sending next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "List", resp, "Failure responding to next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ListComplete gets all elements from the list without paging.
|
|
|
|
func (client GroupClient) ListComplete(resourceGroupName string, namespaceName string, cancel <-chan struct{}) (<-chan ResourceType, <-chan error) {
|
|
|
|
resultChan := make(chan ResourceType)
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
go func() {
|
|
|
|
defer func() {
|
|
|
|
close(resultChan)
|
|
|
|
close(errChan)
|
|
|
|
}()
|
|
|
|
list, err := client.List(resourceGroupName, namespaceName)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for list.NextLink != nil {
|
|
|
|
list, err = client.ListNextResults(list)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return resultChan, errChan
|
|
|
|
}
|
|
|
|
|
2017-08-05 18:30:20 +00:00
|
|
|
// ListAuthorizationRules gets the authorization rules for a NotificationHub.
|
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name notificationHubName is the
|
|
|
|
// notification hub name.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, notificationHubName string) (result SharedAccessAuthorizationRuleListResult, err error) {
|
|
|
|
req, err := client.ListAuthorizationRulesPreparer(resourceGroupName, namespaceName, notificationHubName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListAuthorizationRulesSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListAuthorizationRulesResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListAuthorizationRulesPreparer prepares the ListAuthorizationRules request.
|
|
|
|
func (client GroupClient) ListAuthorizationRulesPreparer(resourceGroupName string, namespaceName string, notificationHubName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsGet(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListAuthorizationRulesSender sends the ListAuthorizationRules request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) ListAuthorizationRulesSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ListAuthorizationRulesResponder handles the response to the ListAuthorizationRules request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) ListAuthorizationRulesResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListAuthorizationRulesNextResults retrieves the next set of results, if any.
|
|
|
|
func (client GroupClient) ListAuthorizationRulesNextResults(lastResults SharedAccessAuthorizationRuleListResult) (result SharedAccessAuthorizationRuleListResult, err error) {
|
|
|
|
req, err := lastResults.SharedAccessAuthorizationRuleListResultPreparer()
|
|
|
|
if err != nil {
|
|
|
|
return result, autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", nil, "Failure preparing next results request")
|
|
|
|
}
|
|
|
|
if req == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListAuthorizationRulesSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return result, autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", resp, "Failure sending next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListAuthorizationRulesResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListAuthorizationRules", resp, "Failure responding to next results request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// ListAuthorizationRulesComplete gets all elements from the list without paging.
|
|
|
|
func (client GroupClient) ListAuthorizationRulesComplete(resourceGroupName string, namespaceName string, notificationHubName string, cancel <-chan struct{}) (<-chan SharedAccessAuthorizationRuleResource, <-chan error) {
|
|
|
|
resultChan := make(chan SharedAccessAuthorizationRuleResource)
|
|
|
|
errChan := make(chan error, 1)
|
|
|
|
go func() {
|
|
|
|
defer func() {
|
|
|
|
close(resultChan)
|
|
|
|
close(errChan)
|
|
|
|
}()
|
|
|
|
list, err := client.ListAuthorizationRules(resourceGroupName, namespaceName, notificationHubName)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for list.NextLink != nil {
|
|
|
|
list, err = client.ListAuthorizationRulesNextResults(list)
|
|
|
|
if err != nil {
|
|
|
|
errChan <- err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if list.Value != nil {
|
|
|
|
for _, item := range *list.Value {
|
|
|
|
select {
|
|
|
|
case <-cancel:
|
|
|
|
return
|
|
|
|
case resultChan <- item:
|
|
|
|
// Intentionally left blank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
return resultChan, errChan
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListKeys gets the Primary and Secondary ConnectionStrings to the NotificationHub
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name. authorizationRuleName is the connection string of the NotificationHub for the specified
|
|
|
|
// authorizationRule.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) ListKeys(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (result ResourceListKeys, err error) {
|
|
|
|
req, err := client.ListKeysPreparer(resourceGroupName, namespaceName, notificationHubName, authorizationRuleName)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListKeys", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.ListKeysSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListKeys", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.ListKeysResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "ListKeys", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListKeysPreparer prepares the ListKeys request.
|
|
|
|
func (client GroupClient) ListKeysPreparer(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys", pathParameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListKeysSender sends the ListKeys request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) ListKeysSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ListKeysResponder handles the response to the ListKeys request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) ListKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-10-01 08:13:39 +00:00
|
|
|
// RegenerateKeys regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule
|
2017-08-05 18:30:20 +00:00
|
|
|
//
|
2017-10-01 08:13:39 +00:00
|
|
|
// resourceGroupName is the name of the resource group. namespaceName is the namespace name. notificationHubName is the
|
|
|
|
// notification hub name. authorizationRuleName is the connection string of the NotificationHub for the specified
|
|
|
|
// authorizationRule. parameters is parameters supplied to regenerate the NotificationHub Authorization Rule Key.
|
2017-08-05 18:30:20 +00:00
|
|
|
func (client GroupClient) RegenerateKeys(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource) (result ResourceListKeys, err error) {
|
|
|
|
req, err := client.RegenerateKeysPreparer(resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "RegenerateKeys", nil, "Failure preparing request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := client.RegenerateKeysSender(req)
|
|
|
|
if err != nil {
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "RegenerateKeys", resp, "Failure sending request")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err = client.RegenerateKeysResponder(resp)
|
|
|
|
if err != nil {
|
|
|
|
err = autorest.NewErrorWithError(err, "notificationhubs.GroupClient", "RegenerateKeys", resp, "Failure responding to request")
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegenerateKeysPreparer prepares the RegenerateKeys request.
|
|
|
|
func (client GroupClient) RegenerateKeysPreparer(resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource) (*http.Request, error) {
|
|
|
|
pathParameters := map[string]interface{}{
|
|
|
|
"authorizationRuleName": autorest.Encode("path", authorizationRuleName),
|
|
|
|
"namespaceName": autorest.Encode("path", namespaceName),
|
|
|
|
"notificationHubName": autorest.Encode("path", notificationHubName),
|
|
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
|
|
}
|
|
|
|
|
|
|
|
const APIVersion = "2017-04-01"
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
"api-version": APIVersion,
|
|
|
|
}
|
|
|
|
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
|
|
autorest.AsJSON(),
|
|
|
|
autorest.AsPost(),
|
|
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", pathParameters),
|
|
|
|
autorest.WithJSON(parameters),
|
|
|
|
autorest.WithQueryParameters(queryParameters))
|
|
|
|
return preparer.Prepare(&http.Request{})
|
|
|
|
}
|
|
|
|
|
|
|
|
// RegenerateKeysSender sends the RegenerateKeys request. The method will close the
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
func (client GroupClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) {
|
2017-12-03 20:01:25 +00:00
|
|
|
return autorest.SendWithSender(client,
|
|
|
|
req,
|
|
|
|
azure.DoRetryWithRegistration(client.Client))
|
2017-08-05 18:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always
|
|
|
|
// closes the http.Response Body.
|
|
|
|
func (client GroupClient) RegenerateKeysResponder(resp *http.Response) (result ResourceListKeys, err error) {
|
|
|
|
err = autorest.Respond(
|
|
|
|
resp,
|
|
|
|
client.ByInspecting(),
|
|
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
|
|
autorest.ByClosing())
|
|
|
|
result.Response = autorest.Response{Response: resp}
|
|
|
|
return
|
|
|
|
}
|