diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md new file mode 100644 index 000000000000..f3d80a0b8362 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-10-26) + +- Initial preview release. diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/LICENSE.txt b/sdk/resourcemanager/notificationhubs/armnotificationhubs/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md new file mode 100644 index 000000000000..cd89580b6d4c --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/README.md @@ -0,0 +1,76 @@ +# Azure Notification Hubs Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs) + +The `armnotificationhubs` module provides operations for working with Azure Notification Hubs. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/notificationhubs/armnotificationhubs) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Notification Hubs module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Notification Hubs. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Notification Hubs + +Once you have a credential, create a connection to the desired ARM endpoint. The `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` package provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := arm.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +## Clients + +Azure Notification Hubs modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `arm.Connection`. + +```go +client := armnotificationhubs.NewNamespacesClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Notification Hubs` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md b/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md new file mode 100644 index 000000000000..736ea5635b05 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/2a5304178ab7416e40622808dea5b630fb7854d9/specification/notificationhubs/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/2a5304178ab7416e40622808dea5b630fb7854d9/specification/notificationhubs/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/build.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/build.go new file mode 100644 index 000000000000..ef40cac7a0be --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/notificationhubs/armnotificationhubs + +package armnotificationhubs diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/ci.yml b/sdk/resourcemanager/notificationhubs/armnotificationhubs/ci.yml new file mode 100644 index 000000000000..9a81b4dbf54c --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/notificationhubs/armnotificationhubs/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/notificationhubs/armnotificationhubs/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/notificationhubs/armnotificationhubs' diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod new file mode 100644 index 000000000000..cc384ed9ddc4 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/notificationhubs/armnotificationhubs + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v58.2.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 +) diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum new file mode 100644 index 000000000000..c8ff7a2143ad --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go.sum @@ -0,0 +1,30 @@ +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible h1:iCb2tuoEm3N7ZpUDOvu1Yxl1B3iOVDmaD6weaRuIPzs= +github.com/Azure/azure-sdk-for-go v58.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0 h1:lhSJz9RMbJcTgxifR1hUNJnn6CNYtbgEDtQV22/9RBA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0 h1:v9p9TfTbf7AwNb5NYQt7hI41IfPoLFiFkLtb+bmGjT0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/go_mod_tidy_hack.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go_mod_tidy_hack.go new file mode 100644 index 000000000000..2bcc2cf5f694 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armnotificationhubs + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go new file mode 100644 index 000000000000..e176cf786403 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_constants.go @@ -0,0 +1,80 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +const ( + module = "armnotificationhubs" + version = "v0.1.0" +) + +type AccessRights string + +const ( + AccessRightsManage AccessRights = "Manage" + AccessRightsSend AccessRights = "Send" + AccessRightsListen AccessRights = "Listen" +) + +// PossibleAccessRightsValues returns the possible values for the AccessRights const type. +func PossibleAccessRightsValues() []AccessRights { + return []AccessRights{ + AccessRightsManage, + AccessRightsSend, + AccessRightsListen, + } +} + +// ToPtr returns a *AccessRights pointing to the current value. +func (c AccessRights) ToPtr() *AccessRights { + return &c +} + +// NamespaceType - The namespace type. +type NamespaceType string + +const ( + NamespaceTypeMessaging NamespaceType = "Messaging" + NamespaceTypeNotificationHub NamespaceType = "NotificationHub" +) + +// PossibleNamespaceTypeValues returns the possible values for the NamespaceType const type. +func PossibleNamespaceTypeValues() []NamespaceType { + return []NamespaceType{ + NamespaceTypeMessaging, + NamespaceTypeNotificationHub, + } +} + +// ToPtr returns a *NamespaceType pointing to the current value. +func (c NamespaceType) ToPtr() *NamespaceType { + return &c +} + +// SKUName - Name of the notification hub sku +type SKUName string + +const ( + SKUNameBasic SKUName = "Basic" + SKUNameFree SKUName = "Free" + SKUNameStandard SKUName = "Standard" +) + +// PossibleSKUNameValues returns the possible values for the SKUName const type. +func PossibleSKUNameValues() []SKUName { + return []SKUName{ + SKUNameBasic, + SKUNameFree, + SKUNameStandard, + } +} + +// ToPtr returns a *SKUName pointing to the current value. +func (c SKUName) ToPtr() *SKUName { + return &c +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go new file mode 100644 index 000000000000..ac991cbc4e13 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_models.go @@ -0,0 +1,939 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "encoding/json" + "reflect" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// AdmCredential - Description of a NotificationHub AdmCredential. +type AdmCredential struct { + // Properties of NotificationHub AdmCredential. + Properties *AdmCredentialProperties `json:"properties,omitempty"` +} + +// AdmCredentialProperties - Description of a NotificationHub AdmCredential. +type AdmCredentialProperties struct { + // The URL of the authorization token. + AuthTokenURL *string `json:"authTokenUrl,omitempty"` + + // The client identifier. + ClientID *string `json:"clientId,omitempty"` + + // The credential secret access key. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// ApnsCredential - Description of a NotificationHub ApnsCredential. +type ApnsCredential struct { + // Properties of NotificationHub ApnsCredential. + Properties *ApnsCredentialProperties `json:"properties,omitempty"` +} + +// ApnsCredentialProperties - Description of a NotificationHub ApnsCredential. Note that there is no explicit switch between Certificate and Token Authentication +// Modes. The mode is determined based on the properties passed in. +type ApnsCredentialProperties struct { + // The APNS certificate. Specify if using Certificate Authentication Mode. + ApnsCertificate *string `json:"apnsCertificate,omitempty"` + + // The issuer (iss) registered claim key. The value is a 10-character TeamId, obtained from your developer account. Specify if using Token Authentication + // Mode. + AppID *string `json:"appId,omitempty"` + + // The name of the application or BundleId. Specify if using Token Authentication Mode. + AppName *string `json:"appName,omitempty"` + + // The APNS certificate password if it exists. + CertificateKey *string `json:"certificateKey,omitempty"` + + // The APNS endpoint of this credential. If using Certificate Authentication Mode and Sandbox specify 'gateway.sandbox.push.apple.com'. If using Certificate + // Authentication Mode and Production specify + // 'gateway.push.apple.com'. If using Token Authentication Mode and Sandbox specify 'https://api.development.push.apple.com:443/3/device'. If using Token + // Authentication Mode and Production specify + // 'https://api.push.apple.com:443/3/device'. + Endpoint *string `json:"endpoint,omitempty"` + + // A 10-character key identifier (kid) key, obtained from your developer account. Specify if using Token Authentication Mode. + KeyID *string `json:"keyId,omitempty"` + + // The APNS certificate thumbprint. Specify if using Certificate Authentication Mode. + Thumbprint *string `json:"thumbprint,omitempty"` + + // Provider Authentication Token, obtained through your developer account. Specify if using Token Authentication Mode. + Token *string `json:"token,omitempty"` +} + +// BaiduCredential - Description of a NotificationHub BaiduCredential. +type BaiduCredential struct { + // Properties of NotificationHub BaiduCredential. + Properties *BaiduCredentialProperties `json:"properties,omitempty"` +} + +// BaiduCredentialProperties - Description of a NotificationHub BaiduCredential. +type BaiduCredentialProperties struct { + // Baidu Api Key. + BaiduAPIKey *string `json:"baiduApiKey,omitempty"` + + // Baidu Endpoint. + BaiduEndPoint *string `json:"baiduEndPoint,omitempty"` + + // Baidu Secret Key + BaiduSecretKey *string `json:"baiduSecretKey,omitempty"` +} + +// CheckAvailabilityParameters - Parameters supplied to the Check Name Availability for Namespace and NotificationHubs. +type CheckAvailabilityParameters struct { + // REQUIRED; Resource name + Name *string `json:"name,omitempty"` + + // True if the name is available and can be used to create new Namespace/NotificationHub. Otherwise false. + IsAvailiable *bool `json:"isAvailiable,omitempty"` + + // Resource location + Location *string `json:"location,omitempty"` + + // The sku of the created namespace + SKU *SKU `json:"sku,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CheckAvailabilityParameters. +func (c CheckAvailabilityParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", c.ID) + populate(objectMap, "isAvailiable", c.IsAvailiable) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// CheckAvailabilityResult - Description of a CheckAvailability resource. +type CheckAvailabilityResult struct { + Resource + // True if the name is available and can be used to create new Namespace/NotificationHub. Otherwise false. + IsAvailiable *bool `json:"isAvailiable,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CheckAvailabilityResult. +func (c CheckAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "isAvailiable", c.IsAvailiable) + return json.Marshal(objectMap) +} + +// DebugSendResponse - Description of a NotificationHub Resource. +type DebugSendResponse struct { + Resource + // Properties of the NotificationHub. + Properties *DebugSendResult `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DebugSendResponse. +func (d DebugSendResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +type DebugSendResult struct { + // send failure + Failure *float32 `json:"failure,omitempty"` + + // actual failure description + Results map[string]interface{} `json:"results,omitempty"` + + // successful send + Success *float32 `json:"success,omitempty"` +} + +// ErrorResponse - Error response indicates NotificationHubs service is not able to process the incoming request. The reason is provided in the error message. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // Error code. + Code *string `json:"code,omitempty"` + + // Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// GCMCredential - Description of a NotificationHub GcmCredential. +type GCMCredential struct { + // Properties of NotificationHub GcmCredential. + Properties *GCMCredentialProperties `json:"properties,omitempty"` +} + +// GCMCredentialProperties - Description of a NotificationHub GcmCredential. +type GCMCredentialProperties struct { + // The FCM legacy endpoint. Default value is 'https://fcm.googleapis.com/fcm/send' + GCMEndpoint *string `json:"gcmEndpoint,omitempty"` + + // The Google API key. + GoogleAPIKey *string `json:"googleApiKey,omitempty"` +} + +// MpnsCredential - Description of a NotificationHub MpnsCredential. +type MpnsCredential struct { + // Properties of NotificationHub MpnsCredential. + Properties *MpnsCredentialProperties `json:"properties,omitempty"` +} + +// MpnsCredentialProperties - Description of a NotificationHub MpnsCredential. +type MpnsCredentialProperties struct { + // The certificate key for this credential. + CertificateKey *string `json:"certificateKey,omitempty"` + + // The MPNS certificate. + MpnsCertificate *string `json:"mpnsCertificate,omitempty"` + + // The MPNS certificate Thumbprint + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// NamespaceCreateOrUpdateParameters - Parameters supplied to the CreateOrUpdate Namespace operation. +type NamespaceCreateOrUpdateParameters struct { + Resource + // Properties of the Namespace. + Properties *NamespaceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceCreateOrUpdateParameters. +func (n NamespaceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + n.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NamespaceListResult - The response of the List Namespace operation. +type NamespaceListResult struct { + // Link to the next set of results. Not empty if Value contains incomplete list of Namespaces + NextLink *string `json:"nextLink,omitempty"` + + // Result of the List Namespace operation. + Value []*NamespaceResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceListResult. +func (n NamespaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NamespacePatchParameters - Parameters supplied to the Patch Namespace operation. +type NamespacePatchParameters struct { + // The sku of the created namespace + SKU *SKU `json:"sku,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamespacePatchParameters. +func (n NamespacePatchParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "sku", n.SKU) + populate(objectMap, "tags", n.Tags) + return json.Marshal(objectMap) +} + +// NamespaceProperties - Namespace properties. +type NamespaceProperties struct { + // The time the namespace was created. + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // Whether or not the namespace is set as Critical. + Critical *bool `json:"critical,omitempty"` + + // Data center for the namespace + DataCenter *string `json:"dataCenter,omitempty"` + + // Whether or not the namespace is currently enabled. + Enabled *bool `json:"enabled,omitempty"` + + // The name of the namespace. + Name *string `json:"name,omitempty"` + + // The namespace type. + NamespaceType *NamespaceType `json:"namespaceType,omitempty"` + + // Provisioning state of the Namespace. + ProvisioningState *string `json:"provisioningState,omitempty"` + + // Specifies the targeted region in which the namespace should be created. It can be any of the following values: Australia East, Australia Southeast, Central + // US, East US, East US 2, West US, North + // Central US, South Central US, East Asia, Southeast Asia, Brazil South, Japan East, Japan West, North Europe, West Europe + Region *string `json:"region,omitempty"` + + // ScaleUnit where the namespace gets created + ScaleUnit *string `json:"scaleUnit,omitempty"` + + // Endpoint you can use to perform NotificationHub operations. + ServiceBusEndpoint *string `json:"serviceBusEndpoint,omitempty"` + + // Status of the namespace. It can be any of these values:1 = Created/Active2 = Creating3 = Suspended4 = Deleting + Status *string `json:"status,omitempty"` + + // The Id of the Azure subscription associated with the namespace. + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // The time the namespace was updated. + UpdatedAt *time.Time `json:"updatedAt,omitempty"` + + // READ-ONLY; Identifier for Azure Insights metrics + MetricID *string `json:"metricId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceProperties. +func (n NamespaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", (*timeRFC3339)(n.CreatedAt)) + populate(objectMap, "critical", n.Critical) + populate(objectMap, "dataCenter", n.DataCenter) + populate(objectMap, "enabled", n.Enabled) + populate(objectMap, "metricId", n.MetricID) + populate(objectMap, "name", n.Name) + populate(objectMap, "namespaceType", n.NamespaceType) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "region", n.Region) + populate(objectMap, "scaleUnit", n.ScaleUnit) + populate(objectMap, "serviceBusEndpoint", n.ServiceBusEndpoint) + populate(objectMap, "status", n.Status) + populate(objectMap, "subscriptionId", n.SubscriptionID) + populate(objectMap, "updatedAt", (*timeRFC3339)(n.UpdatedAt)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamespaceProperties. +func (n *NamespaceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + n.CreatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "critical": + err = unpopulate(val, &n.Critical) + delete(rawMsg, key) + case "dataCenter": + err = unpopulate(val, &n.DataCenter) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, &n.Enabled) + delete(rawMsg, key) + case "metricId": + err = unpopulate(val, &n.MetricID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &n.Name) + delete(rawMsg, key) + case "namespaceType": + err = unpopulate(val, &n.NamespaceType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &n.ProvisioningState) + delete(rawMsg, key) + case "region": + err = unpopulate(val, &n.Region) + delete(rawMsg, key) + case "scaleUnit": + err = unpopulate(val, &n.ScaleUnit) + delete(rawMsg, key) + case "serviceBusEndpoint": + err = unpopulate(val, &n.ServiceBusEndpoint) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &n.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, &n.SubscriptionID) + delete(rawMsg, key) + case "updatedAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + n.UpdatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// NamespaceResource - Description of a Namespace resource. +type NamespaceResource struct { + Resource + // Properties of the Namespace. + Properties *NamespaceProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamespaceResource. +func (n NamespaceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + n.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NamespacesBeginDeleteOptions contains the optional parameters for the Namespaces.BeginDelete method. +type NamespacesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// NamespacesCheckAvailabilityOptions contains the optional parameters for the Namespaces.CheckAvailability method. +type NamespacesCheckAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// NamespacesCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the Namespaces.CreateOrUpdateAuthorizationRule method. +type NamespacesCreateOrUpdateAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NamespacesCreateOrUpdateOptions contains the optional parameters for the Namespaces.CreateOrUpdate method. +type NamespacesCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// NamespacesDeleteAuthorizationRuleOptions contains the optional parameters for the Namespaces.DeleteAuthorizationRule method. +type NamespacesDeleteAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NamespacesGetAuthorizationRuleOptions contains the optional parameters for the Namespaces.GetAuthorizationRule method. +type NamespacesGetAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NamespacesGetOptions contains the optional parameters for the Namespaces.Get method. +type NamespacesGetOptions struct { + // placeholder for future optional parameters +} + +// NamespacesListAllOptions contains the optional parameters for the Namespaces.ListAll method. +type NamespacesListAllOptions struct { + // placeholder for future optional parameters +} + +// NamespacesListAuthorizationRulesOptions contains the optional parameters for the Namespaces.ListAuthorizationRules method. +type NamespacesListAuthorizationRulesOptions struct { + // placeholder for future optional parameters +} + +// NamespacesListKeysOptions contains the optional parameters for the Namespaces.ListKeys method. +type NamespacesListKeysOptions struct { + // placeholder for future optional parameters +} + +// NamespacesListOptions contains the optional parameters for the Namespaces.List method. +type NamespacesListOptions struct { + // placeholder for future optional parameters +} + +// NamespacesPatchOptions contains the optional parameters for the Namespaces.Patch method. +type NamespacesPatchOptions struct { + // placeholder for future optional parameters +} + +// NamespacesRegenerateKeysOptions contains the optional parameters for the Namespaces.RegenerateKeys method. +type NamespacesRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubCreateOrUpdateParameters - Parameters supplied to the CreateOrUpdate NotificationHub operation. +type NotificationHubCreateOrUpdateParameters struct { + Resource + // REQUIRED; Properties of the NotificationHub. + Properties *NotificationHubProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubCreateOrUpdateParameters. +func (n NotificationHubCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + n.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NotificationHubListResult - The response of the List NotificationHub operation. +type NotificationHubListResult struct { + // Link to the next set of results. Not empty if Value contains incomplete list of NotificationHub + NextLink *string `json:"nextLink,omitempty"` + + // Result of the List NotificationHub operation. + Value []*NotificationHubResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubListResult. +func (n NotificationHubListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NotificationHubPatchParameters - Parameters supplied to the patch NotificationHub operation. +type NotificationHubPatchParameters struct { + Resource + // Properties of the NotificationHub. + Properties *NotificationHubProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubPatchParameters. +func (n NotificationHubPatchParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + n.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NotificationHubProperties - NotificationHub properties. +type NotificationHubProperties struct { + // The AdmCredential of the created NotificationHub + AdmCredential *AdmCredential `json:"admCredential,omitempty"` + + // The ApnsCredential of the created NotificationHub + ApnsCredential *ApnsCredential `json:"apnsCredential,omitempty"` + + // The AuthorizationRules of the created NotificationHub + AuthorizationRules []*SharedAccessAuthorizationRuleProperties `json:"authorizationRules,omitempty"` + + // The BaiduCredential of the created NotificationHub + BaiduCredential *BaiduCredential `json:"baiduCredential,omitempty"` + + // The GcmCredential of the created NotificationHub + GCMCredential *GCMCredential `json:"gcmCredential,omitempty"` + + // The MpnsCredential of the created NotificationHub + MpnsCredential *MpnsCredential `json:"mpnsCredential,omitempty"` + + // The NotificationHub name. + Name *string `json:"name,omitempty"` + + // The RegistrationTtl of the created NotificationHub + RegistrationTTL *string `json:"registrationTtl,omitempty"` + + // The WnsCredential of the created NotificationHub + WnsCredential *WnsCredential `json:"wnsCredential,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubProperties. +func (n NotificationHubProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "admCredential", n.AdmCredential) + populate(objectMap, "apnsCredential", n.ApnsCredential) + populate(objectMap, "authorizationRules", n.AuthorizationRules) + populate(objectMap, "baiduCredential", n.BaiduCredential) + populate(objectMap, "gcmCredential", n.GCMCredential) + populate(objectMap, "mpnsCredential", n.MpnsCredential) + populate(objectMap, "name", n.Name) + populate(objectMap, "registrationTtl", n.RegistrationTTL) + populate(objectMap, "wnsCredential", n.WnsCredential) + return json.Marshal(objectMap) +} + +// NotificationHubResource - Description of a NotificationHub Resource. +type NotificationHubResource struct { + Resource + // Properties of the NotificationHub. + Properties *NotificationHubProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationHubResource. +func (n NotificationHubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + n.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NotificationHubsCheckNotificationHubAvailabilityOptions contains the optional parameters for the NotificationHubs.CheckNotificationHubAvailability method. +type NotificationHubsCheckNotificationHubAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsCreateOrUpdateAuthorizationRuleOptions contains the optional parameters for the NotificationHubs.CreateOrUpdateAuthorizationRule method. +type NotificationHubsCreateOrUpdateAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsCreateOrUpdateOptions contains the optional parameters for the NotificationHubs.CreateOrUpdate method. +type NotificationHubsCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsDebugSendOptions contains the optional parameters for the NotificationHubs.DebugSend method. +type NotificationHubsDebugSendOptions struct { + // Debug send parameters + Parameters map[string]interface{} +} + +// NotificationHubsDeleteAuthorizationRuleOptions contains the optional parameters for the NotificationHubs.DeleteAuthorizationRule method. +type NotificationHubsDeleteAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsDeleteOptions contains the optional parameters for the NotificationHubs.Delete method. +type NotificationHubsDeleteOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsGetAuthorizationRuleOptions contains the optional parameters for the NotificationHubs.GetAuthorizationRule method. +type NotificationHubsGetAuthorizationRuleOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsGetOptions contains the optional parameters for the NotificationHubs.Get method. +type NotificationHubsGetOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsGetPnsCredentialsOptions contains the optional parameters for the NotificationHubs.GetPnsCredentials method. +type NotificationHubsGetPnsCredentialsOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsListAuthorizationRulesOptions contains the optional parameters for the NotificationHubs.ListAuthorizationRules method. +type NotificationHubsListAuthorizationRulesOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsListKeysOptions contains the optional parameters for the NotificationHubs.ListKeys method. +type NotificationHubsListKeysOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsListOptions contains the optional parameters for the NotificationHubs.List method. +type NotificationHubsListOptions struct { + // placeholder for future optional parameters +} + +// NotificationHubsPatchOptions contains the optional parameters for the NotificationHubs.Patch method. +type NotificationHubsPatchOptions struct { + // Parameters supplied to patch a NotificationHub Resource. + Parameters *NotificationHubPatchParameters +} + +// NotificationHubsRegenerateKeysOptions contains the optional parameters for the NotificationHubs.RegenerateKeys method. +type NotificationHubsRegenerateKeysOptions struct { + // placeholder for future optional parameters +} + +// Operation - A NotificationHubs REST API operation +type Operation struct { + // The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty" azure:"ro"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // READ-ONLY; Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Service provider: Microsoft.NotificationHubs + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Resource on which the operation is performed: Invoice, etc. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// 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 { + // READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of NotificationHubs operations supported by the Microsoft.NotificationHubs resource provider. + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PnsCredentialsProperties - Description of a NotificationHub PNS Credentials. +type PnsCredentialsProperties struct { + // The AdmCredential of the created NotificationHub + AdmCredential *AdmCredential `json:"admCredential,omitempty"` + + // The ApnsCredential of the created NotificationHub + ApnsCredential *ApnsCredential `json:"apnsCredential,omitempty"` + + // The BaiduCredential of the created NotificationHub + BaiduCredential *BaiduCredential `json:"baiduCredential,omitempty"` + + // The GcmCredential of the created NotificationHub + GCMCredential *GCMCredential `json:"gcmCredential,omitempty"` + + // The MpnsCredential of the created NotificationHub + MpnsCredential *MpnsCredential `json:"mpnsCredential,omitempty"` + + // The WnsCredential of the created NotificationHub + WnsCredential *WnsCredential `json:"wnsCredential,omitempty"` +} + +// PnsCredentialsResource - Description of a NotificationHub PNS Credentials. +type PnsCredentialsResource struct { + Resource + // NotificationHub PNS Credentials. + Properties *PnsCredentialsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PnsCredentialsResource. +func (p PnsCredentialsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + p.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PolicykeyResource - Namespace/NotificationHub Regenerate Keys +type PolicykeyResource struct { + // Name of the key that has to be regenerated for the Namespace/Notification Hub Authorization Rule. The value can be Primary Key/Secondary Key. + PolicyKey *string `json:"policyKey,omitempty"` +} + +type Resource struct { + // Resource location + Location *string `json:"location,omitempty"` + + // The sku of the created namespace + SKU *SKU `json:"sku,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) +} + +// ResourceListKeys - Namespace/NotificationHub Connection String +type ResourceListKeys struct { + // KeyName of the created AuthorizationRule + KeyName *string `json:"keyName,omitempty"` + + // PrimaryConnectionString of the AuthorizationRule. + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + + // PrimaryKey of the created AuthorizationRule. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // SecondaryConnectionString of the created AuthorizationRule + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + + // SecondaryKey of the created AuthorizationRule + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// SKU - The Sku description for a namespace +type SKU struct { + // REQUIRED; Name of the notification hub sku + Name *SKUName `json:"name,omitempty"` + + // The capacity of the resource + Capacity *int32 `json:"capacity,omitempty"` + + // The Sku Family + Family *string `json:"family,omitempty"` + + // The Sku size + Size *string `json:"size,omitempty"` + + // The tier of particular sku + Tier *string `json:"tier,omitempty"` +} + +// SharedAccessAuthorizationRuleCreateOrUpdateParameters - Parameters supplied to the CreateOrUpdate Namespace AuthorizationRules. +type SharedAccessAuthorizationRuleCreateOrUpdateParameters struct { + // REQUIRED; Properties of the Namespace AuthorizationRules. + Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` +} + +// SharedAccessAuthorizationRuleListResult - The response of the List Namespace operation. +type SharedAccessAuthorizationRuleListResult struct { + // Link to the next set of results. Not empty if Value contains incomplete list of AuthorizationRules + NextLink *string `json:"nextLink,omitempty"` + + // Result of the List AuthorizationRules operation. + Value []*SharedAccessAuthorizationRuleResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleListResult. +func (s SharedAccessAuthorizationRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SharedAccessAuthorizationRuleProperties - SharedAccessAuthorizationRule properties. +type SharedAccessAuthorizationRuleProperties struct { + // The rights associated with the rule. + Rights []*AccessRights `json:"rights,omitempty"` + + // READ-ONLY; A string that describes the claim type + ClaimType *string `json:"claimType,omitempty" azure:"ro"` + + // READ-ONLY; A string that describes the claim value + ClaimValue *string `json:"claimValue,omitempty" azure:"ro"` + + // READ-ONLY; The created time for this rule + CreatedTime *string `json:"createdTime,omitempty" azure:"ro"` + + // READ-ONLY; A string that describes the authorization rule. + KeyName *string `json:"keyName,omitempty" azure:"ro"` + + // READ-ONLY; The last modified time for this rule + ModifiedTime *string `json:"modifiedTime,omitempty" azure:"ro"` + + // READ-ONLY; A base64-encoded 256-bit primary key for signing and validating the SAS token. + PrimaryKey *string `json:"primaryKey,omitempty" azure:"ro"` + + // READ-ONLY; The revision number for the rule + Revision *int32 `json:"revision,omitempty" azure:"ro"` + + // READ-ONLY; A base64-encoded 256-bit primary key for signing and validating the SAS token. + SecondaryKey *string `json:"secondaryKey,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleProperties. +func (s SharedAccessAuthorizationRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "claimType", s.ClaimType) + populate(objectMap, "claimValue", s.ClaimValue) + populate(objectMap, "createdTime", s.CreatedTime) + populate(objectMap, "keyName", s.KeyName) + populate(objectMap, "modifiedTime", s.ModifiedTime) + populate(objectMap, "primaryKey", s.PrimaryKey) + populate(objectMap, "revision", s.Revision) + populate(objectMap, "rights", s.Rights) + populate(objectMap, "secondaryKey", s.SecondaryKey) + return json.Marshal(objectMap) +} + +// SharedAccessAuthorizationRuleResource - Description of a Namespace AuthorizationRules. +type SharedAccessAuthorizationRuleResource struct { + Resource + // Properties of the Namespace AuthorizationRule. + Properties *SharedAccessAuthorizationRuleProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SharedAccessAuthorizationRuleResource. +func (s SharedAccessAuthorizationRuleResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.Resource.marshalInternal(objectMap) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +type SubResource struct { + // Resource Id + ID *string `json:"id,omitempty"` +} + +// WnsCredential - Description of a NotificationHub WnsCredential. +type WnsCredential struct { + // Properties of NotificationHub WnsCredential. + Properties *WnsCredentialProperties `json:"properties,omitempty"` +} + +// WnsCredentialProperties - Description of a NotificationHub WnsCredential. +type WnsCredentialProperties struct { + // The package ID for this credential. + PackageSid *string `json:"packageSid,omitempty"` + + // The secret key. + SecretKey *string `json:"secretKey,omitempty"` + + // The Windows Live endpoint. + WindowsLiveEndpoint *string `json:"windowsLiveEndpoint,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go new file mode 100644 index 000000000000..e010f011df4d --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_namespaces_client.go @@ -0,0 +1,859 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// NamespacesClient contains the methods for the Namespaces group. +// Don't use this type directly, use NewNamespacesClient() instead. +type NamespacesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewNamespacesClient creates a new instance of NamespacesClient with the specified values. +func NewNamespacesClient(con *arm.Connection, subscriptionID string) *NamespacesClient { + return &NamespacesClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: 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. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) CheckAvailability(ctx context.Context, parameters CheckAvailabilityParameters, options *NamespacesCheckAvailabilityOptions) (NamespacesCheckAvailabilityResponse, error) { + req, err := client.checkAvailabilityCreateRequest(ctx, parameters, options) + if err != nil { + return NamespacesCheckAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesCheckAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesCheckAvailabilityResponse{}, client.checkAvailabilityHandleError(resp) + } + return client.checkAvailabilityHandleResponse(resp) +} + +// checkAvailabilityCreateRequest creates the CheckAvailability request. +func (client *NamespacesClient) checkAvailabilityCreateRequest(ctx context.Context, parameters CheckAvailabilityParameters, options *NamespacesCheckAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// checkAvailabilityHandleResponse handles the CheckAvailability response. +func (client *NamespacesClient) checkAvailabilityHandleResponse(resp *http.Response) (NamespacesCheckAvailabilityResponse, error) { + result := NamespacesCheckAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAvailabilityResult); err != nil { + return NamespacesCheckAvailabilityResponse{}, err + } + return result, nil +} + +// checkAvailabilityHandleError handles the CheckAvailability error response. +func (client *NamespacesClient) checkAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// CreateOrUpdate - Creates/Updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, options *NamespacesCreateOrUpdateOptions) (NamespacesCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) + if err != nil { + return NamespacesCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return NamespacesCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NamespacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespaceCreateOrUpdateParameters, options *NamespacesCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *NamespacesClient) createOrUpdateHandleResponse(resp *http.Response) (NamespacesCreateOrUpdateResponse, error) { + result := NamespacesCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NamespaceResource); err != nil { + return NamespacesCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NamespacesClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// CreateOrUpdateAuthorizationRule - Creates an authorization rule for a namespace +// If the operation fails it returns a generic error. +func (client *NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *NamespacesCreateOrUpdateAuthorizationRuleOptions) (NamespacesCreateOrUpdateAuthorizationRuleResponse, error) { + req, err := client.createOrUpdateAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters, options) + if err != nil { + return NamespacesCreateOrUpdateAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesCreateOrUpdateAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesCreateOrUpdateAuthorizationRuleResponse{}, client.createOrUpdateAuthorizationRuleHandleError(resp) + } + return client.createOrUpdateAuthorizationRuleHandleResponse(resp) +} + +// createOrUpdateAuthorizationRuleCreateRequest creates the CreateOrUpdateAuthorizationRule request. +func (client *NamespacesClient) createOrUpdateAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *NamespacesCreateOrUpdateAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateAuthorizationRuleHandleResponse handles the CreateOrUpdateAuthorizationRule response. +func (client *NamespacesClient) createOrUpdateAuthorizationRuleHandleResponse(resp *http.Response) (NamespacesCreateOrUpdateAuthorizationRuleResponse, error) { + result := NamespacesCreateOrUpdateAuthorizationRuleResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleResource); err != nil { + return NamespacesCreateOrUpdateAuthorizationRuleResponse{}, err + } + return result, nil +} + +// createOrUpdateAuthorizationRuleHandleError handles the CreateOrUpdateAuthorizationRule error response. +func (client *NamespacesClient) createOrUpdateAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// BeginDelete - Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) BeginDelete(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesBeginDeleteOptions) (NamespacesDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, namespaceName, options) + if err != nil { + return NamespacesDeletePollerResponse{}, err + } + result := NamespacesDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("NamespacesClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return NamespacesDeletePollerResponse{}, err + } + result.Poller = &NamespacesDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes an existing namespace. This operation also removes all associated notificationHubs under the namespace. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) deleteOperation(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, namespaceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NamespacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *NamespacesClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// DeleteAuthorizationRule - Deletes a namespace authorization rule +// If the operation fails it returns a generic error. +func (client *NamespacesClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesDeleteAuthorizationRuleOptions) (NamespacesDeleteAuthorizationRuleResponse, error) { + req, err := client.deleteAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) + if err != nil { + return NamespacesDeleteAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesDeleteAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return NamespacesDeleteAuthorizationRuleResponse{}, client.deleteAuthorizationRuleHandleError(resp) + } + return NamespacesDeleteAuthorizationRuleResponse{RawResponse: resp}, nil +} + +// deleteAuthorizationRuleCreateRequest creates the DeleteAuthorizationRule request. +func (client *NamespacesClient) deleteAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesDeleteAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteAuthorizationRuleHandleError handles the DeleteAuthorizationRule error response. +func (client *NamespacesClient) deleteAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Get - Returns the description for the specified namespace. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesGetOptions) (NamespacesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, namespaceName, options) + if err != nil { + return NamespacesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *NamespacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NamespacesClient) getHandleResponse(resp *http.Response) (NamespacesGetResponse, error) { + result := NamespacesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NamespaceResource); err != nil { + return NamespacesGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *NamespacesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// GetAuthorizationRule - Gets an authorization rule for a namespace by name. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesGetAuthorizationRuleOptions) (NamespacesGetAuthorizationRuleResponse, error) { + req, err := client.getAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) + if err != nil { + return NamespacesGetAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesGetAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesGetAuthorizationRuleResponse{}, client.getAuthorizationRuleHandleError(resp) + } + return client.getAuthorizationRuleHandleResponse(resp) +} + +// getAuthorizationRuleCreateRequest creates the GetAuthorizationRule request. +func (client *NamespacesClient) getAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesGetAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getAuthorizationRuleHandleResponse handles the GetAuthorizationRule response. +func (client *NamespacesClient) getAuthorizationRuleHandleResponse(resp *http.Response) (NamespacesGetAuthorizationRuleResponse, error) { + result := NamespacesGetAuthorizationRuleResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleResource); err != nil { + return NamespacesGetAuthorizationRuleResponse{}, err + } + return result, nil +} + +// getAuthorizationRuleHandleError handles the GetAuthorizationRule error response. +func (client *NamespacesClient) getAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// List - Lists the available namespaces within a resourceGroup. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) List(resourceGroupName string, options *NamespacesListOptions) *NamespacesListPager { + return &NamespacesListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp NamespacesListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.NamespaceListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *NamespacesClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *NamespacesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *NamespacesClient) listHandleResponse(resp *http.Response) (NamespacesListResponse, error) { + result := NamespacesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NamespaceListResult); err != nil { + return NamespacesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *NamespacesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListAll - Lists all the available namespaces within the subscription irrespective of the resourceGroups. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) ListAll(options *NamespacesListAllOptions) *NamespacesListAllPager { + return &NamespacesListAllPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAllCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp NamespacesListAllResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.NamespaceListResult.NextLink) + }, + } +} + +// listAllCreateRequest creates the ListAll request. +func (client *NamespacesClient) listAllCreateRequest(ctx context.Context, options *NamespacesListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *NamespacesClient) listAllHandleResponse(resp *http.Response) (NamespacesListAllResponse, error) { + result := NamespacesListAllResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NamespaceListResult); err != nil { + return NamespacesListAllResponse{}, err + } + return result, nil +} + +// listAllHandleError handles the ListAll error response. +func (client *NamespacesClient) listAllHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListAuthorizationRules - Gets the authorization rules for a namespace. +// If the operation fails it returns a generic error. +func (client *NamespacesClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, options *NamespacesListAuthorizationRulesOptions) *NamespacesListAuthorizationRulesPager { + return &NamespacesListAuthorizationRulesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAuthorizationRulesCreateRequest(ctx, resourceGroupName, namespaceName, options) + }, + advancer: func(ctx context.Context, resp NamespacesListAuthorizationRulesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.SharedAccessAuthorizationRuleListResult.NextLink) + }, + } +} + +// listAuthorizationRulesCreateRequest creates the ListAuthorizationRules request. +func (client *NamespacesClient) listAuthorizationRulesCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, options *NamespacesListAuthorizationRulesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAuthorizationRulesHandleResponse handles the ListAuthorizationRules response. +func (client *NamespacesClient) listAuthorizationRulesHandleResponse(resp *http.Response) (NamespacesListAuthorizationRulesResponse, error) { + result := NamespacesListAuthorizationRulesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleListResult); err != nil { + return NamespacesListAuthorizationRulesResponse{}, err + } + return result, nil +} + +// listAuthorizationRulesHandleError handles the ListAuthorizationRules error response. +func (client *NamespacesClient) listAuthorizationRulesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListKeys - Gets the Primary and Secondary ConnectionStrings to the namespace +// If the operation fails it returns a generic error. +func (client *NamespacesClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesListKeysOptions) (NamespacesListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, options) + if err != nil { + return NamespacesListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *NamespacesClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, options *NamespacesListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *NamespacesClient) listKeysHandleResponse(resp *http.Response) (NamespacesListKeysResponse, error) { + result := NamespacesListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleListResult); err != nil { + return NamespacesListKeysResponse{}, err + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *NamespacesClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Patch - Patches the existing namespace +// If the operation fails it returns a generic error. +func (client *NamespacesClient) Patch(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespacePatchParameters, options *NamespacesPatchOptions) (NamespacesPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) + if err != nil { + return NamespacesPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesPatchResponse{}, client.patchHandleError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *NamespacesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, parameters NamespacePatchParameters, options *NamespacesPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// patchHandleResponse handles the Patch response. +func (client *NamespacesClient) patchHandleResponse(resp *http.Response) (NamespacesPatchResponse, error) { + result := NamespacesPatchResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NamespaceResource); err != nil { + return NamespacesPatchResponse{}, err + } + return result, nil +} + +// patchHandleError handles the Patch error response. +func (client *NamespacesClient) patchHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// RegenerateKeys - Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule +// If the operation fails it returns a generic error. +func (client *NamespacesClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters PolicykeyResource, options *NamespacesRegenerateKeysOptions) (NamespacesRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, namespaceName, authorizationRuleName, parameters, options) + if err != nil { + return NamespacesRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NamespacesRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NamespacesRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *NamespacesClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, authorizationRuleName string, parameters PolicykeyResource, options *NamespacesRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *NamespacesClient) regenerateKeysHandleResponse(resp *http.Response) (NamespacesRegenerateKeysResponse, error) { + result := NamespacesRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceListKeys); err != nil { + return NamespacesRegenerateKeysResponse{}, err + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *NamespacesClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_notificationhubs_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_notificationhubs_client.go new file mode 100644 index 000000000000..af12c9aa5965 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_notificationhubs_client.go @@ -0,0 +1,978 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "errors" + "net/http" + "net/url" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// NotificationHubsClient contains the methods for the NotificationHubs group. +// Don't use this type directly, use NewNotificationHubsClient() instead. +type NotificationHubsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewNotificationHubsClient creates a new instance of NotificationHubsClient with the specified values. +func NewNotificationHubsClient(con *arm.Connection, subscriptionID string) *NotificationHubsClient { + return &NotificationHubsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version), subscriptionID: subscriptionID} +} + +// CheckNotificationHubAvailability - Checks the availability of the given notificationHub in a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) CheckNotificationHubAvailability(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters, options *NotificationHubsCheckNotificationHubAvailabilityOptions) (NotificationHubsCheckNotificationHubAvailabilityResponse, error) { + req, err := client.checkNotificationHubAvailabilityCreateRequest(ctx, resourceGroupName, namespaceName, parameters, options) + if err != nil { + return NotificationHubsCheckNotificationHubAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsCheckNotificationHubAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsCheckNotificationHubAvailabilityResponse{}, client.checkNotificationHubAvailabilityHandleError(resp) + } + return client.checkNotificationHubAvailabilityHandleResponse(resp) +} + +// checkNotificationHubAvailabilityCreateRequest creates the CheckNotificationHubAvailability request. +func (client *NotificationHubsClient) checkNotificationHubAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, parameters CheckAvailabilityParameters, options *NotificationHubsCheckNotificationHubAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// checkNotificationHubAvailabilityHandleResponse handles the CheckNotificationHubAvailability response. +func (client *NotificationHubsClient) checkNotificationHubAvailabilityHandleResponse(resp *http.Response) (NotificationHubsCheckNotificationHubAvailabilityResponse, error) { + result := NotificationHubsCheckNotificationHubAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAvailabilityResult); err != nil { + return NotificationHubsCheckNotificationHubAvailabilityResponse{}, err + } + return result, nil +} + +// checkNotificationHubAvailabilityHandleError handles the CheckNotificationHubAvailability error response. +func (client *NotificationHubsClient) checkNotificationHubAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// CreateOrUpdate - Creates/Update a NotificationHub in a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters NotificationHubCreateOrUpdateParameters, options *NotificationHubsCreateOrUpdateOptions) (NotificationHubsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, parameters, options) + if err != nil { + return NotificationHubsCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return NotificationHubsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NotificationHubsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, parameters NotificationHubCreateOrUpdateParameters, options *NotificationHubsCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *NotificationHubsClient) createOrUpdateHandleResponse(resp *http.Response) (NotificationHubsCreateOrUpdateResponse, error) { + result := NotificationHubsCreateOrUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationHubResource); err != nil { + return NotificationHubsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NotificationHubsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// CreateOrUpdateAuthorizationRule - Creates/Updates an authorization rule for a NotificationHub +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *NotificationHubsCreateOrUpdateAuthorizationRuleOptions) (NotificationHubsCreateOrUpdateAuthorizationRuleResponse, error) { + req, err := client.createOrUpdateAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters, options) + if err != nil { + return NotificationHubsCreateOrUpdateAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsCreateOrUpdateAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsCreateOrUpdateAuthorizationRuleResponse{}, client.createOrUpdateAuthorizationRuleHandleError(resp) + } + return client.createOrUpdateAuthorizationRuleHandleResponse(resp) +} + +// createOrUpdateAuthorizationRuleCreateRequest creates the CreateOrUpdateAuthorizationRule request. +func (client *NotificationHubsClient) createOrUpdateAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters SharedAccessAuthorizationRuleCreateOrUpdateParameters, options *NotificationHubsCreateOrUpdateAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateAuthorizationRuleHandleResponse handles the CreateOrUpdateAuthorizationRule response. +func (client *NotificationHubsClient) createOrUpdateAuthorizationRuleHandleResponse(resp *http.Response) (NotificationHubsCreateOrUpdateAuthorizationRuleResponse, error) { + result := NotificationHubsCreateOrUpdateAuthorizationRuleResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleResource); err != nil { + return NotificationHubsCreateOrUpdateAuthorizationRuleResponse{}, err + } + return result, nil +} + +// createOrUpdateAuthorizationRuleHandleError handles the CreateOrUpdateAuthorizationRule error response. +func (client *NotificationHubsClient) createOrUpdateAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// DebugSend - test send a push notification +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) DebugSend(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsDebugSendOptions) (NotificationHubsDebugSendResponse, error) { + req, err := client.debugSendCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + if err != nil { + return NotificationHubsDebugSendResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsDebugSendResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return NotificationHubsDebugSendResponse{}, client.debugSendHandleError(resp) + } + return client.debugSendHandleResponse(resp) +} + +// debugSendCreateRequest creates the DebugSend request. +func (client *NotificationHubsClient) debugSendCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsDebugSendOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, options.Parameters) + } + return req, nil +} + +// debugSendHandleResponse handles the DebugSend response. +func (client *NotificationHubsClient) debugSendHandleResponse(resp *http.Response) (NotificationHubsDebugSendResponse, error) { + result := NotificationHubsDebugSendResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DebugSendResponse); err != nil { + return NotificationHubsDebugSendResponse{}, err + } + return result, nil +} + +// debugSendHandleError handles the DebugSend error response. +func (client *NotificationHubsClient) debugSendHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Delete - Deletes a notification hub associated with a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) Delete(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsDeleteOptions) (NotificationHubsDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + if err != nil { + return NotificationHubsDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsDeleteResponse{}, client.deleteHandleError(resp) + } + return NotificationHubsDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NotificationHubsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *NotificationHubsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// DeleteAuthorizationRule - Deletes a notificationHub authorization rule +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) DeleteAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsDeleteAuthorizationRuleOptions) (NotificationHubsDeleteAuthorizationRuleResponse, error) { + req, err := client.deleteAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) + if err != nil { + return NotificationHubsDeleteAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsDeleteAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return NotificationHubsDeleteAuthorizationRuleResponse{}, client.deleteAuthorizationRuleHandleError(resp) + } + return NotificationHubsDeleteAuthorizationRuleResponse{RawResponse: resp}, nil +} + +// deleteAuthorizationRuleCreateRequest creates the DeleteAuthorizationRule request. +func (client *NotificationHubsClient) deleteAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsDeleteAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteAuthorizationRuleHandleError handles the DeleteAuthorizationRule error response. +func (client *NotificationHubsClient) deleteAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Get - Lists the notification hubs associated with a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) Get(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsGetOptions) (NotificationHubsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + if err != nil { + return NotificationHubsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *NotificationHubsClient) getCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NotificationHubsClient) getHandleResponse(resp *http.Response) (NotificationHubsGetResponse, error) { + result := NotificationHubsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationHubResource); err != nil { + return NotificationHubsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *NotificationHubsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// GetAuthorizationRule - Gets an authorization rule for a NotificationHub by name. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) GetAuthorizationRule(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsGetAuthorizationRuleOptions) (NotificationHubsGetAuthorizationRuleResponse, error) { + req, err := client.getAuthorizationRuleCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) + if err != nil { + return NotificationHubsGetAuthorizationRuleResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsGetAuthorizationRuleResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsGetAuthorizationRuleResponse{}, client.getAuthorizationRuleHandleError(resp) + } + return client.getAuthorizationRuleHandleResponse(resp) +} + +// getAuthorizationRuleCreateRequest creates the GetAuthorizationRule request. +func (client *NotificationHubsClient) getAuthorizationRuleCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsGetAuthorizationRuleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getAuthorizationRuleHandleResponse handles the GetAuthorizationRule response. +func (client *NotificationHubsClient) getAuthorizationRuleHandleResponse(resp *http.Response) (NotificationHubsGetAuthorizationRuleResponse, error) { + result := NotificationHubsGetAuthorizationRuleResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleResource); err != nil { + return NotificationHubsGetAuthorizationRuleResponse{}, err + } + return result, nil +} + +// getAuthorizationRuleHandleError handles the GetAuthorizationRule error response. +func (client *NotificationHubsClient) getAuthorizationRuleHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// GetPnsCredentials - Lists the PNS Credentials associated with a notification hub . +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) GetPnsCredentials(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsGetPnsCredentialsOptions) (NotificationHubsGetPnsCredentialsResponse, error) { + req, err := client.getPnsCredentialsCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + if err != nil { + return NotificationHubsGetPnsCredentialsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsGetPnsCredentialsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsGetPnsCredentialsResponse{}, client.getPnsCredentialsHandleError(resp) + } + return client.getPnsCredentialsHandleResponse(resp) +} + +// getPnsCredentialsCreateRequest creates the GetPnsCredentials request. +func (client *NotificationHubsClient) getPnsCredentialsCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsGetPnsCredentialsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getPnsCredentialsHandleResponse handles the GetPnsCredentials response. +func (client *NotificationHubsClient) getPnsCredentialsHandleResponse(resp *http.Response) (NotificationHubsGetPnsCredentialsResponse, error) { + result := NotificationHubsGetPnsCredentialsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PnsCredentialsResource); err != nil { + return NotificationHubsGetPnsCredentialsResponse{}, err + } + return result, nil +} + +// getPnsCredentialsHandleError handles the GetPnsCredentials error response. +func (client *NotificationHubsClient) getPnsCredentialsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// List - Lists the notification hubs associated with a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) List(resourceGroupName string, namespaceName string, options *NotificationHubsListOptions) *NotificationHubsListPager { + return &NotificationHubsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, namespaceName, options) + }, + advancer: func(ctx context.Context, resp NotificationHubsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.NotificationHubListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *NotificationHubsClient) listCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, options *NotificationHubsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *NotificationHubsClient) listHandleResponse(resp *http.Response) (NotificationHubsListResponse, error) { + result := NotificationHubsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationHubListResult); err != nil { + return NotificationHubsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *NotificationHubsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListAuthorizationRules - Gets the authorization rules for a NotificationHub. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) ListAuthorizationRules(resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsListAuthorizationRulesOptions) *NotificationHubsListAuthorizationRulesPager { + return &NotificationHubsListAuthorizationRulesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listAuthorizationRulesCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + }, + advancer: func(ctx context.Context, resp NotificationHubsListAuthorizationRulesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.SharedAccessAuthorizationRuleListResult.NextLink) + }, + } +} + +// listAuthorizationRulesCreateRequest creates the ListAuthorizationRules request. +func (client *NotificationHubsClient) listAuthorizationRulesCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsListAuthorizationRulesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listAuthorizationRulesHandleResponse handles the ListAuthorizationRules response. +func (client *NotificationHubsClient) listAuthorizationRulesHandleResponse(resp *http.Response) (NotificationHubsListAuthorizationRulesResponse, error) { + result := NotificationHubsListAuthorizationRulesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.SharedAccessAuthorizationRuleListResult); err != nil { + return NotificationHubsListAuthorizationRulesResponse{}, err + } + return result, nil +} + +// listAuthorizationRulesHandleError handles the ListAuthorizationRules error response. +func (client *NotificationHubsClient) listAuthorizationRulesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// ListKeys - Gets the Primary and Secondary ConnectionStrings to the NotificationHub +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) ListKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsListKeysOptions) (NotificationHubsListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, options) + if err != nil { + return NotificationHubsListKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsListKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *NotificationHubsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, options *NotificationHubsListKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *NotificationHubsClient) listKeysHandleResponse(resp *http.Response) (NotificationHubsListKeysResponse, error) { + result := NotificationHubsListKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceListKeys); err != nil { + return NotificationHubsListKeysResponse{}, err + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *NotificationHubsClient) listKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// Patch - Patch a NotificationHub in a namespace. +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) Patch(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsPatchOptions) (NotificationHubsPatchResponse, error) { + req, err := client.patchCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, options) + if err != nil { + return NotificationHubsPatchResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsPatchResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsPatchResponse{}, client.patchHandleError(resp) + } + return client.patchHandleResponse(resp) +} + +// patchCreateRequest creates the Patch request. +func (client *NotificationHubsClient) patchCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, options *NotificationHubsPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, runtime.MarshalAsJSON(req, *options.Parameters) + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *NotificationHubsClient) patchHandleResponse(resp *http.Response) (NotificationHubsPatchResponse, error) { + result := NotificationHubsPatchResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.NotificationHubResource); err != nil { + return NotificationHubsPatchResponse{}, err + } + return result, nil +} + +// patchHandleError handles the Patch error response. +func (client *NotificationHubsClient) patchHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} + +// RegenerateKeys - Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule +// If the operation fails it returns a generic error. +func (client *NotificationHubsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource, options *NotificationHubsRegenerateKeysOptions) (NotificationHubsRegenerateKeysResponse, error) { + req, err := client.regenerateKeysCreateRequest(ctx, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName, parameters, options) + if err != nil { + return NotificationHubsRegenerateKeysResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NotificationHubsRegenerateKeysResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NotificationHubsRegenerateKeysResponse{}, client.regenerateKeysHandleError(resp) + } + return client.regenerateKeysHandleResponse(resp) +} + +// regenerateKeysCreateRequest creates the RegenerateKeys request. +func (client *NotificationHubsClient) regenerateKeysCreateRequest(ctx context.Context, resourceGroupName string, namespaceName string, notificationHubName string, authorizationRuleName string, parameters PolicykeyResource, options *NotificationHubsRegenerateKeysOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if namespaceName == "" { + return nil, errors.New("parameter namespaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namespaceName}", url.PathEscape(namespaceName)) + if notificationHubName == "" { + return nil, errors.New("parameter notificationHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationHubName}", url.PathEscape(notificationHubName)) + if authorizationRuleName == "" { + return nil, errors.New("parameter authorizationRuleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authorizationRuleName}", url.PathEscape(authorizationRuleName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// regenerateKeysHandleResponse handles the RegenerateKeys response. +func (client *NotificationHubsClient) regenerateKeysHandleResponse(resp *http.Response) (NotificationHubsRegenerateKeysResponse, error) { + result := NotificationHubsRegenerateKeysResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceListKeys); err != nil { + return NotificationHubsRegenerateKeysResponse{}, err + } + return result, nil +} + +// regenerateKeysHandleError handles the RegenerateKeys error response. +func (client *NotificationHubsClient) regenerateKeysHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + if len(body) == 0 { + return runtime.NewResponseError(errors.New(resp.Status), resp) + } + return runtime.NewResponseError(errors.New(string(body)), resp) +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go new file mode 100644 index 000000000000..4ba85102c070 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_operations_client.go @@ -0,0 +1,81 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *arm.Connection) *OperationsClient { + return &OperationsClient{ep: con.Endpoint(), pl: con.NewPipeline(module, version)} +} + +// List - Lists all of the available NotificationHubs REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.NotificationHubs/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2017-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pagers.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pagers.go new file mode 100644 index 000000000000..ebfc75754ca3 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pagers.go @@ -0,0 +1,342 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "net/http" + "reflect" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" +) + +// NamespacesListAllPager provides operations for iterating over paged responses. +type NamespacesListAllPager struct { + client *NamespacesClient + current NamespacesListAllResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, NamespacesListAllResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *NamespacesListAllPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *NamespacesListAllPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NamespaceListResult.NextLink == nil || len(*p.current.NamespaceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listAllHandleError(resp) + return false + } + result, err := p.client.listAllHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current NamespacesListAllResponse page. +func (p *NamespacesListAllPager) PageResponse() NamespacesListAllResponse { + return p.current +} + +// NamespacesListAuthorizationRulesPager provides operations for iterating over paged responses. +type NamespacesListAuthorizationRulesPager struct { + client *NamespacesClient + current NamespacesListAuthorizationRulesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, NamespacesListAuthorizationRulesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *NamespacesListAuthorizationRulesPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *NamespacesListAuthorizationRulesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SharedAccessAuthorizationRuleListResult.NextLink == nil || len(*p.current.SharedAccessAuthorizationRuleListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listAuthorizationRulesHandleError(resp) + return false + } + result, err := p.client.listAuthorizationRulesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current NamespacesListAuthorizationRulesResponse page. +func (p *NamespacesListAuthorizationRulesPager) PageResponse() NamespacesListAuthorizationRulesResponse { + return p.current +} + +// NamespacesListPager provides operations for iterating over paged responses. +type NamespacesListPager struct { + client *NamespacesClient + current NamespacesListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, NamespacesListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *NamespacesListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *NamespacesListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NamespaceListResult.NextLink == nil || len(*p.current.NamespaceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current NamespacesListResponse page. +func (p *NamespacesListPager) PageResponse() NamespacesListResponse { + return p.current +} + +// NotificationHubsListAuthorizationRulesPager provides operations for iterating over paged responses. +type NotificationHubsListAuthorizationRulesPager struct { + client *NotificationHubsClient + current NotificationHubsListAuthorizationRulesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, NotificationHubsListAuthorizationRulesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *NotificationHubsListAuthorizationRulesPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *NotificationHubsListAuthorizationRulesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SharedAccessAuthorizationRuleListResult.NextLink == nil || len(*p.current.SharedAccessAuthorizationRuleListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listAuthorizationRulesHandleError(resp) + return false + } + result, err := p.client.listAuthorizationRulesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current NotificationHubsListAuthorizationRulesResponse page. +func (p *NotificationHubsListAuthorizationRulesPager) PageResponse() NotificationHubsListAuthorizationRulesResponse { + return p.current +} + +// NotificationHubsListPager provides operations for iterating over paged responses. +type NotificationHubsListPager struct { + client *NotificationHubsClient + current NotificationHubsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, NotificationHubsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *NotificationHubsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *NotificationHubsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NotificationHubListResult.NextLink == nil || len(*p.current.NotificationHubListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current NotificationHubsListResponse page. +func (p *NotificationHubsListPager) PageResponse() NotificationHubsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pollers.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pollers.go new file mode 100644 index 000000000000..65e6ba7287e0 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_pollers.go @@ -0,0 +1,59 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" +) + +// NamespacesDeletePoller provides polling facilities until the operation reaches a terminal state. +type NamespacesDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *NamespacesDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *NamespacesDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final NamespacesDeleteResponse will be returned. +func (p *NamespacesDeletePoller) FinalResponse(ctx context.Context) (NamespacesDeleteResponse, error) { + respType := NamespacesDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return NamespacesDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *NamespacesDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go new file mode 100644 index 000000000000..dad4dff2930e --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_response_types.go @@ -0,0 +1,367 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "context" + "net/http" + "time" + + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" +) + +// NamespacesCheckAvailabilityResponse contains the response from method Namespaces.CheckAvailability. +type NamespacesCheckAvailabilityResponse struct { + NamespacesCheckAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesCheckAvailabilityResult contains the result from method Namespaces.CheckAvailability. +type NamespacesCheckAvailabilityResult struct { + CheckAvailabilityResult +} + +// NamespacesCreateOrUpdateAuthorizationRuleResponse contains the response from method Namespaces.CreateOrUpdateAuthorizationRule. +type NamespacesCreateOrUpdateAuthorizationRuleResponse struct { + NamespacesCreateOrUpdateAuthorizationRuleResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesCreateOrUpdateAuthorizationRuleResult contains the result from method Namespaces.CreateOrUpdateAuthorizationRule. +type NamespacesCreateOrUpdateAuthorizationRuleResult struct { + SharedAccessAuthorizationRuleResource +} + +// NamespacesCreateOrUpdateResponse contains the response from method Namespaces.CreateOrUpdate. +type NamespacesCreateOrUpdateResponse struct { + NamespacesCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesCreateOrUpdateResult contains the result from method Namespaces.CreateOrUpdate. +type NamespacesCreateOrUpdateResult struct { + NamespaceResource +} + +// NamespacesDeleteAuthorizationRuleResponse contains the response from method Namespaces.DeleteAuthorizationRule. +type NamespacesDeleteAuthorizationRuleResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesDeletePollerResponse contains the response from method Namespaces.Delete. +type NamespacesDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *NamespacesDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +func (l NamespacesDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (NamespacesDeleteResponse, error) { + respType := NamespacesDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a NamespacesDeletePollerResponse from the provided client and resume token. +func (l *NamespacesDeletePollerResponse) Resume(ctx context.Context, client *NamespacesClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("NamespacesClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &NamespacesDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// NamespacesDeleteResponse contains the response from method Namespaces.Delete. +type NamespacesDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesGetAuthorizationRuleResponse contains the response from method Namespaces.GetAuthorizationRule. +type NamespacesGetAuthorizationRuleResponse struct { + NamespacesGetAuthorizationRuleResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesGetAuthorizationRuleResult contains the result from method Namespaces.GetAuthorizationRule. +type NamespacesGetAuthorizationRuleResult struct { + SharedAccessAuthorizationRuleResource +} + +// NamespacesGetResponse contains the response from method Namespaces.Get. +type NamespacesGetResponse struct { + NamespacesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesGetResult contains the result from method Namespaces.Get. +type NamespacesGetResult struct { + NamespaceResource +} + +// NamespacesListAllResponse contains the response from method Namespaces.ListAll. +type NamespacesListAllResponse struct { + NamespacesListAllResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesListAllResult contains the result from method Namespaces.ListAll. +type NamespacesListAllResult struct { + NamespaceListResult +} + +// NamespacesListAuthorizationRulesResponse contains the response from method Namespaces.ListAuthorizationRules. +type NamespacesListAuthorizationRulesResponse struct { + NamespacesListAuthorizationRulesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesListAuthorizationRulesResult contains the result from method Namespaces.ListAuthorizationRules. +type NamespacesListAuthorizationRulesResult struct { + SharedAccessAuthorizationRuleListResult +} + +// NamespacesListKeysResponse contains the response from method Namespaces.ListKeys. +type NamespacesListKeysResponse struct { + NamespacesListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesListKeysResult contains the result from method Namespaces.ListKeys. +type NamespacesListKeysResult struct { + SharedAccessAuthorizationRuleListResult +} + +// NamespacesListResponse contains the response from method Namespaces.List. +type NamespacesListResponse struct { + NamespacesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesListResult contains the result from method Namespaces.List. +type NamespacesListResult struct { + NamespaceListResult +} + +// NamespacesPatchResponse contains the response from method Namespaces.Patch. +type NamespacesPatchResponse struct { + NamespacesPatchResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesPatchResult contains the result from method Namespaces.Patch. +type NamespacesPatchResult struct { + NamespaceResource +} + +// NamespacesRegenerateKeysResponse contains the response from method Namespaces.RegenerateKeys. +type NamespacesRegenerateKeysResponse struct { + NamespacesRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamespacesRegenerateKeysResult contains the result from method Namespaces.RegenerateKeys. +type NamespacesRegenerateKeysResult struct { + ResourceListKeys +} + +// NotificationHubsCheckNotificationHubAvailabilityResponse contains the response from method NotificationHubs.CheckNotificationHubAvailability. +type NotificationHubsCheckNotificationHubAvailabilityResponse struct { + NotificationHubsCheckNotificationHubAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsCheckNotificationHubAvailabilityResult contains the result from method NotificationHubs.CheckNotificationHubAvailability. +type NotificationHubsCheckNotificationHubAvailabilityResult struct { + CheckAvailabilityResult +} + +// NotificationHubsCreateOrUpdateAuthorizationRuleResponse contains the response from method NotificationHubs.CreateOrUpdateAuthorizationRule. +type NotificationHubsCreateOrUpdateAuthorizationRuleResponse struct { + NotificationHubsCreateOrUpdateAuthorizationRuleResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsCreateOrUpdateAuthorizationRuleResult contains the result from method NotificationHubs.CreateOrUpdateAuthorizationRule. +type NotificationHubsCreateOrUpdateAuthorizationRuleResult struct { + SharedAccessAuthorizationRuleResource +} + +// NotificationHubsCreateOrUpdateResponse contains the response from method NotificationHubs.CreateOrUpdate. +type NotificationHubsCreateOrUpdateResponse struct { + NotificationHubsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsCreateOrUpdateResult contains the result from method NotificationHubs.CreateOrUpdate. +type NotificationHubsCreateOrUpdateResult struct { + NotificationHubResource +} + +// NotificationHubsDebugSendResponse contains the response from method NotificationHubs.DebugSend. +type NotificationHubsDebugSendResponse struct { + NotificationHubsDebugSendResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsDebugSendResult contains the result from method NotificationHubs.DebugSend. +type NotificationHubsDebugSendResult struct { + DebugSendResponse +} + +// NotificationHubsDeleteAuthorizationRuleResponse contains the response from method NotificationHubs.DeleteAuthorizationRule. +type NotificationHubsDeleteAuthorizationRuleResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsDeleteResponse contains the response from method NotificationHubs.Delete. +type NotificationHubsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsGetAuthorizationRuleResponse contains the response from method NotificationHubs.GetAuthorizationRule. +type NotificationHubsGetAuthorizationRuleResponse struct { + NotificationHubsGetAuthorizationRuleResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsGetAuthorizationRuleResult contains the result from method NotificationHubs.GetAuthorizationRule. +type NotificationHubsGetAuthorizationRuleResult struct { + SharedAccessAuthorizationRuleResource +} + +// NotificationHubsGetPnsCredentialsResponse contains the response from method NotificationHubs.GetPnsCredentials. +type NotificationHubsGetPnsCredentialsResponse struct { + NotificationHubsGetPnsCredentialsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsGetPnsCredentialsResult contains the result from method NotificationHubs.GetPnsCredentials. +type NotificationHubsGetPnsCredentialsResult struct { + PnsCredentialsResource +} + +// NotificationHubsGetResponse contains the response from method NotificationHubs.Get. +type NotificationHubsGetResponse struct { + NotificationHubsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsGetResult contains the result from method NotificationHubs.Get. +type NotificationHubsGetResult struct { + NotificationHubResource +} + +// NotificationHubsListAuthorizationRulesResponse contains the response from method NotificationHubs.ListAuthorizationRules. +type NotificationHubsListAuthorizationRulesResponse struct { + NotificationHubsListAuthorizationRulesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsListAuthorizationRulesResult contains the result from method NotificationHubs.ListAuthorizationRules. +type NotificationHubsListAuthorizationRulesResult struct { + SharedAccessAuthorizationRuleListResult +} + +// NotificationHubsListKeysResponse contains the response from method NotificationHubs.ListKeys. +type NotificationHubsListKeysResponse struct { + NotificationHubsListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsListKeysResult contains the result from method NotificationHubs.ListKeys. +type NotificationHubsListKeysResult struct { + ResourceListKeys +} + +// NotificationHubsListResponse contains the response from method NotificationHubs.List. +type NotificationHubsListResponse struct { + NotificationHubsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsListResult contains the result from method NotificationHubs.List. +type NotificationHubsListResult struct { + NotificationHubListResult +} + +// NotificationHubsPatchResponse contains the response from method NotificationHubs.Patch. +type NotificationHubsPatchResponse struct { + NotificationHubsPatchResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsPatchResult contains the result from method NotificationHubs.Patch. +type NotificationHubsPatchResult struct { + NotificationHubResource +} + +// NotificationHubsRegenerateKeysResponse contains the response from method NotificationHubs.RegenerateKeys. +type NotificationHubsRegenerateKeysResponse struct { + NotificationHubsRegenerateKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationHubsRegenerateKeysResult contains the result from method NotificationHubs.RegenerateKeys. +type NotificationHubsRegenerateKeysResult struct { + ResourceListKeys +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..ffb676153bd9 --- /dev/null +++ b/sdk/resourcemanager/notificationhubs/armnotificationhubs/zz_generated_time_rfc3339.go @@ -0,0 +1,58 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnotificationhubs + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +}