diff --git a/profiles/latest/notificationhubs/mgmt/notificationhubs/models.go b/profiles/latest/notificationhubs/mgmt/notificationhubs/models.go index 8e85785d7bf5..887270844d81 100644 --- a/profiles/latest/notificationhubs/mgmt/notificationhubs/models.go +++ b/profiles/latest/notificationhubs/mgmt/notificationhubs/models.go @@ -26,7 +26,6 @@ const ( ) type BaseClient = original.BaseClient -type HubsClient = original.HubsClient type AccessRights = original.AccessRights const ( @@ -58,9 +57,8 @@ type BaiduCredential = original.BaiduCredential type BaiduCredentialProperties = original.BaiduCredentialProperties type CheckAvailabilityParameters = original.CheckAvailabilityParameters type CheckAvailabilityResult = original.CheckAvailabilityResult -type CheckNameAvailabilityRequestParameters = original.CheckNameAvailabilityRequestParameters -type CheckNameAvailabilityResponse = original.CheckNameAvailabilityResponse type CreateOrUpdateParameters = original.CreateOrUpdateParameters +type ErrorResponse = original.ErrorResponse type GcmCredential = original.GcmCredential type GcmCredentialProperties = original.GcmCredentialProperties type ListResult = original.ListResult @@ -76,6 +74,11 @@ type NamespacePatchParameters = original.NamespacePatchParameters type NamespaceProperties = original.NamespaceProperties type NamespaceResource = original.NamespaceResource type NamespacesDeleteFuture = original.NamespacesDeleteFuture +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage type PnsCredentialsProperties = original.PnsCredentialsProperties type PnsCredentialsResource = original.PnsCredentialsResource type PolicykeyResource = original.PolicykeyResource @@ -93,9 +96,9 @@ type Sku = original.Sku type SubResource = original.SubResource type WnsCredential = original.WnsCredential type WnsCredentialProperties = original.WnsCredentialProperties -type NameClient = original.NameClient type NamespacesClient = original.NamespacesClient type Client = original.Client +type OperationsClient = original.OperationsClient func New(subscriptionID string) BaseClient { return original.New(subscriptionID) @@ -103,12 +106,6 @@ func New(subscriptionID string) BaseClient { func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } -func NewHubsClient(subscriptionID string) HubsClient { - return original.NewHubsClient(subscriptionID) -} -func NewHubsClientWithBaseURI(baseURI string, subscriptionID string) HubsClient { - return original.NewHubsClientWithBaseURI(baseURI, subscriptionID) -} func PossibleAccessRightsValues() []AccessRights { return original.PossibleAccessRightsValues() } @@ -118,12 +115,6 @@ func PossibleNamespaceTypeValues() []NamespaceType { func PossibleSkuNameValues() []SkuName { return original.PossibleSkuNameValues() } -func NewNameClient(subscriptionID string) NameClient { - return original.NewNameClient(subscriptionID) -} -func NewNameClientWithBaseURI(baseURI string, subscriptionID string) NameClient { - return original.NewNameClientWithBaseURI(baseURI, subscriptionID) -} func NewNamespacesClient(subscriptionID string) NamespacesClient { return original.NewNamespacesClient(subscriptionID) } @@ -136,6 +127,12 @@ func NewClient(subscriptionID string) Client { func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { return original.NewClientWithBaseURI(baseURI, subscriptionID) } +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} func UserAgent() string { return original.UserAgent() + " profiles/latest" } diff --git a/profiles/preview/notificationhubs/mgmt/notificationhubs/models.go b/profiles/preview/notificationhubs/mgmt/notificationhubs/models.go index 36564a0d9a98..3e8fbef3a334 100644 --- a/profiles/preview/notificationhubs/mgmt/notificationhubs/models.go +++ b/profiles/preview/notificationhubs/mgmt/notificationhubs/models.go @@ -26,7 +26,6 @@ const ( ) type BaseClient = original.BaseClient -type HubsClient = original.HubsClient type AccessRights = original.AccessRights const ( @@ -58,9 +57,8 @@ type BaiduCredential = original.BaiduCredential type BaiduCredentialProperties = original.BaiduCredentialProperties type CheckAvailabilityParameters = original.CheckAvailabilityParameters type CheckAvailabilityResult = original.CheckAvailabilityResult -type CheckNameAvailabilityRequestParameters = original.CheckNameAvailabilityRequestParameters -type CheckNameAvailabilityResponse = original.CheckNameAvailabilityResponse type CreateOrUpdateParameters = original.CreateOrUpdateParameters +type ErrorResponse = original.ErrorResponse type GcmCredential = original.GcmCredential type GcmCredentialProperties = original.GcmCredentialProperties type ListResult = original.ListResult @@ -76,6 +74,11 @@ type NamespacePatchParameters = original.NamespacePatchParameters type NamespaceProperties = original.NamespaceProperties type NamespaceResource = original.NamespaceResource type NamespacesDeleteFuture = original.NamespacesDeleteFuture +type Operation = original.Operation +type OperationDisplay = original.OperationDisplay +type OperationListResult = original.OperationListResult +type OperationListResultIterator = original.OperationListResultIterator +type OperationListResultPage = original.OperationListResultPage type PnsCredentialsProperties = original.PnsCredentialsProperties type PnsCredentialsResource = original.PnsCredentialsResource type PolicykeyResource = original.PolicykeyResource @@ -93,9 +96,9 @@ type Sku = original.Sku type SubResource = original.SubResource type WnsCredential = original.WnsCredential type WnsCredentialProperties = original.WnsCredentialProperties -type NameClient = original.NameClient type NamespacesClient = original.NamespacesClient type Client = original.Client +type OperationsClient = original.OperationsClient func New(subscriptionID string) BaseClient { return original.New(subscriptionID) @@ -103,12 +106,6 @@ func New(subscriptionID string) BaseClient { func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } -func NewHubsClient(subscriptionID string) HubsClient { - return original.NewHubsClient(subscriptionID) -} -func NewHubsClientWithBaseURI(baseURI string, subscriptionID string) HubsClient { - return original.NewHubsClientWithBaseURI(baseURI, subscriptionID) -} func PossibleAccessRightsValues() []AccessRights { return original.PossibleAccessRightsValues() } @@ -118,12 +115,6 @@ func PossibleNamespaceTypeValues() []NamespaceType { func PossibleSkuNameValues() []SkuName { return original.PossibleSkuNameValues() } -func NewNameClient(subscriptionID string) NameClient { - return original.NewNameClient(subscriptionID) -} -func NewNameClientWithBaseURI(baseURI string, subscriptionID string) NameClient { - return original.NewNameClientWithBaseURI(baseURI, subscriptionID) -} func NewNamespacesClient(subscriptionID string) NamespacesClient { return original.NewNamespacesClient(subscriptionID) } @@ -136,6 +127,12 @@ func NewClient(subscriptionID string) Client { func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { return original.NewClientWithBaseURI(baseURI, subscriptionID) } +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/hubs.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/hubs.go deleted file mode 100644 index 0c1abcc4f5ba..000000000000 --- a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/hubs.go +++ /dev/null @@ -1,117 +0,0 @@ -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. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "net/http" -) - -// HubsClient is the azure NotificationHub client -type HubsClient struct { - BaseClient -} - -// NewHubsClient creates an instance of the HubsClient client. -func NewHubsClient(subscriptionID string) HubsClient { - return NewHubsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewHubsClientWithBaseURI creates an instance of the HubsClient client. -func NewHubsClientWithBaseURI(baseURI string, subscriptionID string) HubsClient { - return HubsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckAvailability checks the availability of the given notificationHub in a namespace. -// Parameters: -// resourceGroupName - the name of the resource group. -// namespaceName - the namespace name. -// parameters - the notificationHub name. -func (client HubsClient) CheckAvailability(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckNameAvailabilityRequestParameters) (result CheckNameAvailabilityResponse, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("notificationhubs.HubsClient", "CheckAvailability", err.Error()) - } - - req, err := client.CheckAvailabilityPreparer(ctx, resourceGroupName, namespaceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.HubsClient", "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.HubsClient", "CheckAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.HubsClient", "CheckAvailability", resp, "Failure responding to request") - } - - return -} - -// CheckAvailabilityPreparer prepares the CheckAvailability request. -func (client HubsClient) CheckAvailabilityPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckNameAvailabilityRequestParameters) (*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.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkHubAvailability", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckAvailabilitySender sends the CheckAvailability request. The method will close the -// http.Response Body if it receives an error. -func (client HubsClient) CheckAvailabilitySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CheckAvailabilityResponder handles the response to the CheckAvailability request. The method always -// closes the http.Response Body. -func (client HubsClient) CheckAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/models.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/models.go index d591cfe9195b..29e4860ea5a9 100644 --- a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/models.go +++ b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/models.go @@ -324,26 +324,6 @@ func (car CheckAvailabilityResult) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// CheckNameAvailabilityRequestParameters parameters supplied to the Check Name Availability for Namespace and -// NotificationHubs. -type CheckNameAvailabilityRequestParameters struct { - // Name - Resource name - Name *string `json:"Name,omitempty"` - // Type - Resource type - Type *string `json:"Type,omitempty"` -} - -// CheckNameAvailabilityResponse ... -type CheckNameAvailabilityResponse struct { - autorest.Response `json:"-"` - // NameAvailable - Checks if the namespace name is available - NameAvailable *bool `json:"NameAvailable,omitempty"` - // Reason - States the reason due to which the namespace name is not available - Reason *string `json:"Reason,omitempty"` - // Message - The messsage returned when checking for namespace name availability - Message *string `json:"Message,omitempty"` -} - // CreateOrUpdateParameters parameters supplied to the CreateOrUpdate NotificationHub operation. type CreateOrUpdateParameters struct { // Properties - Properties of the NotificationHub. @@ -467,6 +447,15 @@ func (coup *CreateOrUpdateParameters) UnmarshalJSON(body []byte) error { return nil } +// ErrorResponse error reponse indicates NotificationHubs service is not able to process the incoming request. The +// reason is provided in the error message. +type ErrorResponse struct { + // Code - Error code. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + // GcmCredential description of a NotificationHub GcmCredential. type GcmCredential struct { // GcmCredentialProperties - Properties of NotificationHub GcmCredential. @@ -918,10 +907,14 @@ type NamespaceProperties struct { ProvisioningState *string `json:"provisioningState,omitempty"` // Region - Specifies the targeted region in which the namespace should be created. It can be any of the following values: Australia EastAustralia SoutheastCentral USEast USEast US 2West USNorth Central USSouth Central USEast AsiaSoutheast AsiaBrazil SouthJapan EastJapan WestNorth EuropeWest Europe Region *string `json:"region,omitempty"` + // MetricID - Identifier for Azure Insights metrics + MetricID *string `json:"metricId,omitempty"` // Status - Status of the namespace. It can be any of these values:1 = Created/Active2 = Creating3 = Suspended4 = Deleting Status *string `json:"status,omitempty"` // CreatedAt - The time the namespace was created. CreatedAt *date.Time `json:"createdAt,omitempty"` + // UpdatedAt - The time the namespace was updated. + UpdatedAt *date.Time `json:"updatedAt,omitempty"` // ServiceBusEndpoint - Endpoint you can use to perform NotificationHub operations. ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` // SubscriptionID - The Id of the Azure subscription associated with the namespace. @@ -932,6 +925,8 @@ type NamespaceProperties struct { Enabled *bool `json:"enabled,omitempty"` // Critical - Whether or not the namespace is set as Critical. Critical *bool `json:"critical,omitempty"` + // DataCenter - Data center for the namespace + DataCenter *string `json:"dataCenter,omitempty"` // NamespaceType - The namespace type. Possible values include: 'Messaging', 'NotificationHub' NamespaceType NamespaceType `json:"namespaceType,omitempty"` } @@ -1108,6 +1103,127 @@ func (future NamespacesDeleteFuture) Result(client NamespacesClient) (ar autores return } +// Operation a NotificationHubs REST API operation +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider: Microsoft.NotificationHubs + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed: Invoice, etc. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult result of the request to list NotificationHubs operations. It contains a list of operations +// and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of NotificationHubs operations supported by the Microsoft.NotificationHubs resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) Next() error { + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err := iter.page.Next() + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) Next() error { + next, err := page.fn(page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + // PnsCredentialsProperties description of a NotificationHub PNS Credentials. type PnsCredentialsProperties struct { // ApnsCredential - The ApnsCredential of the created NotificationHub @@ -1460,45 +1576,6 @@ func (rt *ResourceType) UnmarshalJSON(body []byte) error { type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct { // Properties - Properties of the Namespace AuthorizationRules. Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` - // ID - Resource Id - ID *string `json:"id,omitempty"` - // Name - Resource name - Name *string `json:"name,omitempty"` - // Type - Resource type - Type *string `json:"type,omitempty"` - // Location - Resource location - Location *string `json:"location,omitempty"` - // Tags - Resource tags - Tags map[string]*string `json:"tags"` - // Sku - The sku of the created namespace - Sku *Sku `json:"sku,omitempty"` -} - -// MarshalJSON is the custom marshaler for SharedAccessAuthorizationRuleCreateOrUpdateParameters. -func (saarcoup SharedAccessAuthorizationRuleCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if saarcoup.Properties != nil { - objectMap["properties"] = saarcoup.Properties - } - if saarcoup.ID != nil { - objectMap["id"] = saarcoup.ID - } - if saarcoup.Name != nil { - objectMap["name"] = saarcoup.Name - } - if saarcoup.Type != nil { - objectMap["type"] = saarcoup.Type - } - if saarcoup.Location != nil { - objectMap["location"] = saarcoup.Location - } - if saarcoup.Tags != nil { - objectMap["tags"] = saarcoup.Tags - } - if saarcoup.Sku != nil { - objectMap["sku"] = saarcoup.Sku - } - return json.Marshal(objectMap) } // SharedAccessAuthorizationRuleListResult the response of the List Namespace operation. @@ -1608,6 +1685,22 @@ func (page SharedAccessAuthorizationRuleListResultPage) Values() []SharedAccessA type SharedAccessAuthorizationRuleProperties struct { // Rights - The rights associated with the rule. Rights *[]AccessRights `json:"rights,omitempty"` + // PrimaryKey - A base64-encoded 256-bit primary key for signing and validating the SAS token. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - A base64-encoded 256-bit primary key for signing and validating the SAS token. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // KeyName - A string that describes the authorization rule. + KeyName *string `json:"keyName,omitempty"` + // ClaimType - A string that describes the claim type + ClaimType *string `json:"claimType,omitempty"` + // ClaimValue - A string that describes the claim value + ClaimValue *string `json:"claimValue,omitempty"` + // ModifiedTime - The last modified time for this rule + ModifiedTime *string `json:"modifiedTime,omitempty"` + // CreatedTime - The created time for this rule + CreatedTime *string `json:"createdTime,omitempty"` + // Revision - The revision number for the rule + Revision *int32 `json:"revision,omitempty"` } // SharedAccessAuthorizationRuleResource description of a Namespace AuthorizationRules. diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/name.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/name.go deleted file mode 100644 index 470ffbb6040d..000000000000 --- a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/name.go +++ /dev/null @@ -1,114 +0,0 @@ -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. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "net/http" -) - -// NameClient is the azure NotificationHub client -type NameClient struct { - BaseClient -} - -// NewNameClient creates an instance of the NameClient client. -func NewNameClient(subscriptionID string) NameClient { - return NewNameClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewNameClientWithBaseURI creates an instance of the NameClient client. -func NewNameClientWithBaseURI(baseURI string, subscriptionID string) NameClient { - return NameClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CheckAvailability checks the availability of the given service namespace across all Azure subscriptions. This is -// useful because the domain name is created based on the service namespace name. -// Parameters: -// parameters - the namespace name. -func (client NameClient) CheckAvailability(ctx context.Context, parameters CheckNameAvailabilityRequestParameters) (result CheckNameAvailabilityResponse, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("notificationhubs.NameClient", "CheckAvailability", err.Error()) - } - - req, err := client.CheckAvailabilityPreparer(ctx, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.NameClient", "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.NameClient", "CheckAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.NameClient", "CheckAvailability", resp, "Failure responding to request") - } - - return -} - -// CheckAvailabilityPreparer prepares the CheckAvailability request. -func (client NameClient) CheckAvailabilityPreparer(ctx context.Context, parameters CheckNameAvailabilityRequestParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNameAvailability", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckAvailabilitySender sends the CheckAvailability request. The method will close the -// http.Response Body if it receives an error. -func (client NameClient) CheckAvailabilitySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CheckAvailabilityResponder handles the response to the CheckAvailability request. The method always -// closes the http.Response Body. -func (client NameClient) CheckAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/namespaces.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/namespaces.go index 4685b7a4d44d..4f42911bf2e2 100644 --- a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/namespaces.go +++ b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/namespaces.go @@ -820,7 +820,7 @@ func (client NamespacesClient) ListAuthorizationRulesComplete(ctx context.Contex // resourceGroupName - the name of the resource group. // namespaceName - the namespace name. // authorizationRuleName - the connection string of the namespace for the specified authorizationRule. -func (client NamespacesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result ResourceListKeys, err error) { +func (client NamespacesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string) (result SharedAccessAuthorizationRuleListResult, err error) { req, err := client.ListKeysPreparer(ctx, resourceGroupName, namespaceName, authorizationRuleName) if err != nil { err = autorest.NewErrorWithError(err, "notificationhubs.NamespacesClient", "ListKeys", nil, "Failure preparing request") @@ -873,7 +873,7 @@ func (client NamespacesClient) ListKeysSender(req *http.Request) (*http.Response // ListKeysResponder handles the response to the ListKeys request. The method always // closes the http.Response Body. -func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result ResourceListKeys, err error) { +func (client NamespacesClient) ListKeysResponder(resp *http.Response) (result SharedAccessAuthorizationRuleListResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/notificationhubs.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/notificationhubs.go index 2bc5a4f03f72..736636e46a45 100644 --- a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/notificationhubs.go +++ b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/notificationhubs.go @@ -40,42 +40,42 @@ func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { return Client{NewWithBaseURI(baseURI, subscriptionID)} } -// CheckAvailability checks the availability of the given notificationHub in a namespace. +// CheckNotificationHubAvailability checks the availability of the given notificationHub in a namespace. // Parameters: // resourceGroupName - the name of the resource group. // namespaceName - the namespace name. // parameters - the notificationHub name. -func (client Client) CheckAvailability(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (result CheckAvailabilityResult, err error) { +func (client Client) CheckNotificationHubAvailability(ctx context.Context, 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.NewError("notificationhubs.Client", "CheckAvailability", err.Error()) + return result, validation.NewError("notificationhubs.Client", "CheckNotificationHubAvailability", err.Error()) } - req, err := client.CheckAvailabilityPreparer(ctx, resourceGroupName, namespaceName, parameters) + req, err := client.CheckNotificationHubAvailabilityPreparer(ctx, resourceGroupName, namespaceName, parameters) if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckAvailability", nil, "Failure preparing request") + err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", nil, "Failure preparing request") return } - resp, err := client.CheckAvailabilitySender(req) + resp, err := client.CheckNotificationHubAvailabilitySender(req) if err != nil { result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckAvailability", resp, "Failure sending request") + err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", resp, "Failure sending request") return } - result, err = client.CheckAvailabilityResponder(resp) + result, err = client.CheckNotificationHubAvailabilityResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckAvailability", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "notificationhubs.Client", "CheckNotificationHubAvailability", resp, "Failure responding to request") } return } -// CheckAvailabilityPreparer prepares the CheckAvailability request. -func (client Client) CheckAvailabilityPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (*http.Request, error) { +// CheckNotificationHubAvailabilityPreparer prepares the CheckNotificationHubAvailability request. +func (client Client) CheckNotificationHubAvailabilityPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ "namespaceName": autorest.Encode("path", namespaceName), "resourceGroupName": autorest.Encode("path", resourceGroupName), @@ -97,16 +97,16 @@ func (client Client) CheckAvailabilityPreparer(ctx context.Context, resourceGrou return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// CheckAvailabilitySender sends the CheckAvailability request. The method will close the +// CheckNotificationHubAvailabilitySender sends the CheckNotificationHubAvailability request. The method will close the // http.Response Body if it receives an error. -func (client Client) CheckAvailabilitySender(req *http.Request) (*http.Response, error) { +func (client Client) CheckNotificationHubAvailabilitySender(req *http.Request) (*http.Response, error) { return autorest.SendWithSender(client, req, azure.DoRetryWithRegistration(client.Client)) } -// CheckAvailabilityResponder handles the response to the CheckAvailability request. The method always +// CheckNotificationHubAvailabilityResponder handles the response to the CheckNotificationHubAvailability request. The method always // closes the http.Response Body. -func (client Client) CheckAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResult, err error) { +func (client Client) CheckNotificationHubAvailabilityResponder(resp *http.Response) (result CheckAvailabilityResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/services/notificationhubs/mgmt/2017-04-01/notificationhubs/operations.go b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/operations.go new file mode 100644 index 000000000000..259076cc3409 --- /dev/null +++ b/services/notificationhubs/mgmt/2017-04-01/notificationhubs/operations.go @@ -0,0 +1,126 @@ +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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the azure NotificationHub client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available NotificationHubs REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "notificationhubs.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "notificationhubs.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "notificationhubs.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-04-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.NotificationHubs/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) listNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "notificationhubs.OperationsClient", "listNextResults", 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.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "notificationhubs.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + result.page, err = client.List(ctx) + return +}