diff --git a/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/CHANGELOG.md b/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/CHANGELOG.md +++ b/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/_meta.json b/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/_meta.json index ccaa71270c58..bff588d78e77 100644 --- a/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/_meta.json +++ b/services/preview/provisioningservices/mgmt/2017-08-21-preview/iothub/_meta.json @@ -1,10 +1,10 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", - "tag": "package-2017-08", + "tag": "package-preview-2017-08", "use": "@microsoft.azure/autorest.go@2.1.187", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2017-08 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-preview-2017-08 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", "additional_properties": { "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" } diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/CHANGELOG.md b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/_meta.json b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/_meta.json new file mode 100644 index 000000000000..cb8e12259aea --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", + "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "tag": "package-preview-2020-09", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-preview-2020-09 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/client.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/client.go new file mode 100644 index 000000000000..29f628f9d54c --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/client.go @@ -0,0 +1,41 @@ +// Package iothub implements the Azure ARM Iothub service API version 2020-09-01-preview. +// +// API for using the Azure IoT Hub Device Provisioning Service features. +package iothub + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Iothub + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Iothub. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/dpscertificate.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/dpscertificate.go new file mode 100644 index 000000000000..e0852d72ac66 --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/dpscertificate.go @@ -0,0 +1,628 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DpsCertificateClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type DpsCertificateClient struct { + BaseClient +} + +// NewDpsCertificateClient creates an instance of the DpsCertificateClient client. +func NewDpsCertificateClient(subscriptionID string) DpsCertificateClient { + return NewDpsCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDpsCertificateClientWithBaseURI creates an instance of the DpsCertificateClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDpsCertificateClientWithBaseURI(baseURI string, subscriptionID string) DpsCertificateClient { + return DpsCertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate add new certificate or update an existing certificate. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - the name of the provisioning service. +// certificateName - the name of the certificate create or update. +// certificateDescription - the certificate body. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +func (client DpsCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: certificateName, + Constraints: []validation.Constraint{{Target: "certificateName", Name: validation.MaxLength, Rule: 256, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.DpsCertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DpsCertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(certificateDescription), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) CreateOrUpdateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified certificate associated with the Provisioning Service +// Parameters: +// resourceGroupName - resource group identifier. +// ifMatch - eTag of the certificate +// provisioningServiceName - the name of the provisioning service. +// certificateName - this is a mandatory field, and is the logical name of the certificate that the +// provisioning service will access by. +// certificatename - this is optional, and it is the Common Name of the certificate. +// certificaterawBytes - raw data within the certificate. +// certificateisVerified - indicates if certificate has been verified by owner of the private key. +// certificatepurpose - a description that mentions the purpose of the certificate. +// certificatecreated - time the certificate is created. +// certificatelastUpdated - time the certificate is last updated. +// certificatehasPrivateKey - indicates if the certificate contains a private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DpsCertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateVerificationCode generate verification code for Proof of Possession. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - description mentioning the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result VerificationCodeResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.GenerateVerificationCode") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateVerificationCodePreparer(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateVerificationCodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure sending request") + return + } + + result, err = client.GenerateVerificationCodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure responding to request") + return + } + + return +} + +// GenerateVerificationCodePreparer prepares the GenerateVerificationCode request. +func (client DpsCertificateClient) GenerateVerificationCodePreparer(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateVerificationCodeSender sends the GenerateVerificationCode request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GenerateVerificationCodeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateVerificationCodeResponder handles the response to the GenerateVerificationCode request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GenerateVerificationCodeResponder(resp *http.Response) (result VerificationCodeResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the certificate from the provisioning service. +// Parameters: +// certificateName - name of the certificate to retrieve. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of the provisioning service the certificate is associated with. +// ifMatch - eTag of the certificate. +func (client DpsCertificateClient) Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, certificateName, resourceGroupName, provisioningServiceName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DpsCertificateClient) GetPreparer(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GetResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the certificates tied to the provisioning service. +// Parameters: +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service to retrieve certificates for. +func (client DpsCertificateClient) List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result CertificateListDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, provisioningServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DpsCertificateClient) ListPreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) ListResponder(resp *http.Response) (result CertificateListDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// VerifyCertificate verifies the certificate's private key possession by providing the leaf cert issued by the +// verifying pre uploaded certificate. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. +// request - the name of the certificate +// resourceGroupName - resource group name. +// provisioningServiceName - provisioning service name. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - describe the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.VerifyCertificate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.VerifyCertificatePreparer(ctx, certificateName, ifMatch, request, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.VerifyCertificateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure sending request") + return + } + + result, err = client.VerifyCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure responding to request") + return + } + + return +} + +// VerifyCertificatePreparer prepares the VerifyCertificate request. +func (client DpsCertificateClient) VerifyCertificatePreparer(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify", pathParameters), + autorest.WithJSON(request), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// VerifyCertificateSender sends the VerifyCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) VerifyCertificateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// VerifyCertificateResponder handles the response to the VerifyCertificate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) VerifyCertificateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/enums.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/enums.go new file mode 100644 index 000000000000..05353e81391a --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/enums.go @@ -0,0 +1,191 @@ +package iothub + +// 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. + +// AccessRightsDescription enumerates the values for access rights description. +type AccessRightsDescription string + +const ( + // DeviceConnect ... + DeviceConnect AccessRightsDescription = "DeviceConnect" + // EnrollmentRead ... + EnrollmentRead AccessRightsDescription = "EnrollmentRead" + // EnrollmentWrite ... + EnrollmentWrite AccessRightsDescription = "EnrollmentWrite" + // RegistrationStatusRead ... + RegistrationStatusRead AccessRightsDescription = "RegistrationStatusRead" + // RegistrationStatusWrite ... + RegistrationStatusWrite AccessRightsDescription = "RegistrationStatusWrite" + // ServiceConfig ... + ServiceConfig AccessRightsDescription = "ServiceConfig" +) + +// PossibleAccessRightsDescriptionValues returns an array of possible values for the AccessRightsDescription const type. +func PossibleAccessRightsDescriptionValues() []AccessRightsDescription { + return []AccessRightsDescription{DeviceConnect, EnrollmentRead, EnrollmentWrite, RegistrationStatusRead, RegistrationStatusWrite, ServiceConfig} +} + +// AllocationPolicy enumerates the values for allocation policy. +type AllocationPolicy string + +const ( + // GeoLatency ... + GeoLatency AllocationPolicy = "GeoLatency" + // Hashed ... + Hashed AllocationPolicy = "Hashed" + // Static ... + Static AllocationPolicy = "Static" +) + +// PossibleAllocationPolicyValues returns an array of possible values for the AllocationPolicy const type. +func PossibleAllocationPolicyValues() []AllocationPolicy { + return []AllocationPolicy{GeoLatency, Hashed, Static} +} + +// CertificatePurpose enumerates the values for certificate purpose. +type CertificatePurpose string + +const ( + // ClientAuthentication ... + ClientAuthentication CertificatePurpose = "clientAuthentication" + // ServerAuthentication ... + ServerAuthentication CertificatePurpose = "serverAuthentication" +) + +// PossibleCertificatePurposeValues returns an array of possible values for the CertificatePurpose const type. +func PossibleCertificatePurposeValues() []CertificatePurpose { + return []CertificatePurpose{ClientAuthentication, ServerAuthentication} +} + +// IotDpsSku enumerates the values for iot dps sku. +type IotDpsSku string + +const ( + // S1 ... + S1 IotDpsSku = "S1" +) + +// PossibleIotDpsSkuValues returns an array of possible values for the IotDpsSku const type. +func PossibleIotDpsSkuValues() []IotDpsSku { + return []IotDpsSku{S1} +} + +// IPFilterActionType enumerates the values for ip filter action type. +type IPFilterActionType string + +const ( + // Accept ... + Accept IPFilterActionType = "Accept" + // Reject ... + Reject IPFilterActionType = "Reject" +) + +// PossibleIPFilterActionTypeValues returns an array of possible values for the IPFilterActionType const type. +func PossibleIPFilterActionTypeValues() []IPFilterActionType { + return []IPFilterActionType{Accept, Reject} +} + +// IPFilterTargetType enumerates the values for ip filter target type. +type IPFilterTargetType string + +const ( + // All ... + All IPFilterTargetType = "all" + // DeviceAPI ... + DeviceAPI IPFilterTargetType = "deviceApi" + // ServiceAPI ... + ServiceAPI IPFilterTargetType = "serviceApi" +) + +// PossibleIPFilterTargetTypeValues returns an array of possible values for the IPFilterTargetType const type. +func PossibleIPFilterTargetTypeValues() []IPFilterTargetType { + return []IPFilterTargetType{All, DeviceAPI, ServiceAPI} +} + +// NameUnavailabilityReason enumerates the values for name unavailability reason. +type NameUnavailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists NameUnavailabilityReason = "AlreadyExists" + // Invalid ... + Invalid NameUnavailabilityReason = "Invalid" +) + +// PossibleNameUnavailabilityReasonValues returns an array of possible values for the NameUnavailabilityReason const type. +func PossibleNameUnavailabilityReasonValues() []NameUnavailabilityReason { + return []NameUnavailabilityReason{AlreadyExists, Invalid} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateLinkServiceConnectionStatus = "Approved" + // Disconnected ... + Disconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // Pending ... + Pending PrivateLinkServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{Approved, Disconnected, Pending, Rejected} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} + +// State enumerates the values for state. +type State string + +const ( + // Activating ... + Activating State = "Activating" + // ActivationFailed ... + ActivationFailed State = "ActivationFailed" + // Active ... + Active State = "Active" + // Deleted ... + Deleted State = "Deleted" + // Deleting ... + Deleting State = "Deleting" + // DeletionFailed ... + DeletionFailed State = "DeletionFailed" + // FailingOver ... + FailingOver State = "FailingOver" + // FailoverFailed ... + FailoverFailed State = "FailoverFailed" + // Resuming ... + Resuming State = "Resuming" + // Suspended ... + Suspended State = "Suspended" + // Suspending ... + Suspending State = "Suspending" + // Transitioning ... + Transitioning State = "Transitioning" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Activating, ActivationFailed, Active, Deleted, Deleting, DeletionFailed, FailingOver, FailoverFailed, Resuming, Suspended, Suspending, Transitioning} +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iotdpsresource.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iotdpsresource.go new file mode 100644 index 000000000000..7b0b8b5fca5a --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iotdpsresource.go @@ -0,0 +1,1553 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotDpsResourceClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type IotDpsResourceClient struct { + BaseClient +} + +// NewIotDpsResourceClient creates an instance of the IotDpsResourceClient client. +func NewIotDpsResourceClient(subscriptionID string) IotDpsResourceClient { + return NewIotDpsResourceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIotDpsResourceClientWithBaseURI creates an instance of the IotDpsResourceClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotDpsResourceClientWithBaseURI(baseURI string, subscriptionID string) IotDpsResourceClient { + return IotDpsResourceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckProvisioningServiceNameAvailability check if a provisioning service name is available. This will validate if +// the name is syntactically valid and if the name is usable +// Parameters: +// arguments - set the name parameter in the OperationInputs structure to the name of the provisioning service +// to check. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, arguments OperationInputs) (result NameAvailabilityInfo, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CheckProvisioningServiceNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: arguments, + Constraints: []validation.Constraint{{Target: "arguments.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", err.Error()) + } + + req, err := client.CheckProvisioningServiceNameAvailabilityPreparer(ctx, arguments) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckProvisioningServiceNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckProvisioningServiceNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckProvisioningServiceNameAvailabilityPreparer prepares the CheckProvisioningServiceNameAvailability request. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityPreparer(ctx context.Context, arguments OperationInputs) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", pathParameters), + autorest.WithJSON(arguments), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckProvisioningServiceNameAvailabilitySender sends the CheckProvisioningServiceNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckProvisioningServiceNameAvailabilityResponder handles the response to the CheckProvisioningServiceNameAvailability request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityInfo, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update the metadata of the provisioning service. The usual pattern to modify a property is +// to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values +// in a new body to update the provisioning service. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// iotDpsDescription - description of the provisioning service to create or update. +func (client IotDpsResourceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (result IotDpsResourceCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: iotDpsDescription, + Constraints: []validation.Constraint{{Target: "iotDpsDescription.Properties", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotDpsDescription.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, iotDpsDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotDpsResourceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(iotDpsDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CreateOrUpdateSender(req *http.Request) (future IotDpsResourceCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CreateOrUpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdatePrivateEndpointConnection create or update the status of a private endpoint connection with the +// specified name +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +// privateEndpointConnection - the private endpoint connection with updated properties +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (result IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CreateOrUpdatePrivateEndpointConnection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: privateEndpointConnection, + Constraints: []validation.Constraint{{Target: "privateEndpointConnection.Properties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateEndpointConnection.Properties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateEndpointConnection.Properties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", err.Error()) + } + + req, err := client.CreateOrUpdatePrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdatePrivateEndpointConnectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePrivateEndpointConnectionPreparer prepares the CreateOrUpdatePrivateEndpointConnection request. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdatePrivateEndpointConnectionSender sends the CreateOrUpdatePrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionSender(req *http.Request) (future IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdatePrivateEndpointConnectionResponder handles the response to the CreateOrUpdatePrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Provisioning Service. +// Parameters: +// provisioningServiceName - name of provisioning service to delete. +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsResourceDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotDpsResourceClient) DeletePreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) DeleteSender(req *http.Request) (future IotDpsResourceDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeletePrivateEndpointConnection delete private endpoint connection with the specified name +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +func (client IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.DeletePrivateEndpointConnection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") + return + } + + result, err = client.DeletePrivateEndpointConnectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "DeletePrivateEndpointConnection", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePrivateEndpointConnectionPreparer prepares the DeletePrivateEndpointConnection request. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeletePrivateEndpointConnectionSender sends the DeletePrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionSender(req *http.Request) (future IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeletePrivateEndpointConnectionResponder handles the response to the DeletePrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the metadata of the provisioning service without SAS keys. +// Parameters: +// provisioningServiceName - name of the provisioning service to retrieve. +// resourceGroupName - resource group name. +func (client IotDpsResourceClient) Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result ProvisioningServiceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotDpsResourceClient) GetPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOperationResult gets the status of a long running operation, such as create, update or delete a provisioning +// service. +// Parameters: +// operationID - operation id corresponding to long running operation. Use this to poll for the status. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service that the operation is running on. +// asyncinfo - async header used to poll on the status of the operation, obtained while creating the long +// running operation. +func (client IotDpsResourceClient) GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result AsyncOperationResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetOperationResult") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetOperationResultPreparer(ctx, operationID, resourceGroupName, provisioningServiceName, asyncinfo) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", nil, "Failure preparing request") + return + } + + resp, err := client.GetOperationResultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure sending request") + return + } + + result, err = client.GetOperationResultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure responding to request") + return + } + + return +} + +// GetOperationResultPreparer prepares the GetOperationResult request. +func (client IotDpsResourceClient) GetOperationResultPreparer(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "asyncinfo": autorest.Encode("query", asyncinfo), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOperationResultSender sends the GetOperationResult request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetOperationResultSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetOperationResultResponder handles the response to the GetOperationResult request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetOperationResultResponder(resp *http.Response) (result AsyncOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPrivateEndpointConnection get private endpoint connection properties +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +func (client IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetPrivateEndpointConnection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") + return + } + + resp, err := client.GetPrivateEndpointConnectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", resp, "Failure sending request") + return + } + + result, err = client.GetPrivateEndpointConnectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", resp, "Failure responding to request") + return + } + + return +} + +// GetPrivateEndpointConnectionPreparer prepares the GetPrivateEndpointConnection request. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPrivateEndpointConnectionSender sends the GetPrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPrivateEndpointConnectionResponder handles the response to the GetPrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPrivateLinkResources get the specified private link resource for the given provisioning service +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// groupID - the name of the private link resource +func (client IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (result GroupIDInformation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetPrivateLinkResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPrivateLinkResourcesPreparer(ctx, resourceGroupName, resourceName, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", nil, "Failure preparing request") + return + } + + resp, err := client.GetPrivateLinkResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", resp, "Failure sending request") + return + } + + result, err = client.GetPrivateLinkResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", resp, "Failure responding to request") + return + } + + return +} + +// GetPrivateLinkResourcesPreparer prepares the GetPrivateLinkResources request. +func (client IotDpsResourceClient) GetPrivateLinkResourcesPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPrivateLinkResourcesSender sends the GetPrivateLinkResources request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetPrivateLinkResourcesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPrivateLinkResourcesResponder handles the response to the GetPrivateLinkResources request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetPrivateLinkResourcesResponder(resp *http.Response) (result GroupIDInformation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all provisioning services in the given resource group. +// Parameters: +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client IotDpsResourceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListByResourceGroupResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription list all the provisioning services for a given subscription id. +func (client IotDpsResourceClient) ListBySubscription(ctx context.Context) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client IotDpsResourceClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListBySubscriptionResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listBySubscriptionNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListKeys list the primary and secondary keys for a provisioning service. +// Parameters: +// provisioningServiceName - the provisioning service name to get the shared access keys for. +// resourceGroupName - resource group name +func (client IotDpsResourceClient) ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.sasarlr.Response.Response != nil { + sc = result.sasarlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listKeysNextResults + req, err := client.ListKeysPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.sasarlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure sending request") + return + } + + result.sasarlr, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure responding to request") + return + } + if result.sasarlr.hasNextLink() && result.sasarlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client IotDpsResourceClient) ListKeysPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listKeysNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listKeysNextResults(ctx context.Context, lastResults SharedAccessSignatureAuthorizationRuleListResult) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + req, err := lastResults.sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure sending next results request") + } + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListKeysComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListKeys(ctx, provisioningServiceName, resourceGroupName) + return +} + +// ListKeysForKeyName list primary and secondary keys for a specific key name +// Parameters: +// provisioningServiceName - name of the provisioning service. +// keyName - logical key name to get key-values for. +// resourceGroupName - the name of the resource group that contains the provisioning service. +func (client IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeysForKeyName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysForKeyNamePreparer(ctx, provisioningServiceName, keyName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysForKeyNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure sending request") + return + } + + result, err = client.ListKeysForKeyNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysForKeyNamePreparer prepares the ListKeysForKeyName request. +func (client IotDpsResourceClient) ListKeysForKeyNamePreparer(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysForKeyNameSender sends the ListKeysForKeyName request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysForKeyNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysForKeyNameResponder handles the response to the ListKeysForKeyName request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysForKeyNameResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListPrivateEndpointConnections list private endpoint connection properties +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +func (client IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, resourceGroupName string, resourceName string) (result ListPrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListPrivateEndpointConnections") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPrivateEndpointConnectionsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", nil, "Failure preparing request") + return + } + + resp, err := client.ListPrivateEndpointConnectionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", resp, "Failure sending request") + return + } + + result, err = client.ListPrivateEndpointConnectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", resp, "Failure responding to request") + return + } + + return +} + +// ListPrivateEndpointConnectionsPreparer prepares the ListPrivateEndpointConnections request. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPrivateEndpointConnectionsSender sends the ListPrivateEndpointConnections request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPrivateEndpointConnectionsResponder handles the response to the ListPrivateEndpointConnections request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsResponder(resp *http.Response) (result ListPrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListPrivateLinkResources list private link resources for the given provisioning service +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +func (client IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResources, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListPrivateLinkResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPrivateLinkResourcesPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", nil, "Failure preparing request") + return + } + + resp, err := client.ListPrivateLinkResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", resp, "Failure sending request") + return + } + + result, err = client.ListPrivateLinkResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", resp, "Failure responding to request") + return + } + + return +} + +// ListPrivateLinkResourcesPreparer prepares the ListPrivateLinkResources request. +func (client IotDpsResourceClient) ListPrivateLinkResourcesPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPrivateLinkResourcesSender sends the ListPrivateLinkResources request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListPrivateLinkResourcesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPrivateLinkResourcesResponder handles the response to the ListPrivateLinkResources request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListPrivateLinkResourcesResponder(resp *http.Response) (result PrivateLinkResources, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListValidSkus gets the list of valid SKUs and tiers for a provisioning service. +// Parameters: +// provisioningServiceName - name of provisioning service. +// resourceGroupName - name of resource group. +func (client IotDpsResourceClient) ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.idsdlr.Response.Response != nil { + sc = result.idsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listValidSkusNextResults + req, err := client.ListValidSkusPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.idsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure sending request") + return + } + + result.idsdlr, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure responding to request") + return + } + if result.idsdlr.hasNextLink() && result.idsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListValidSkusPreparer prepares the ListValidSkus request. +func (client IotDpsResourceClient) ListValidSkusPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListValidSkusSender sends the ListValidSkus request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListValidSkusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListValidSkusResponder handles the response to the ListValidSkus request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListValidSkusResponder(resp *http.Response) (result IotDpsSkuDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listValidSkusNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listValidSkusNextResults(ctx context.Context, lastResults IotDpsSkuDefinitionListResult) (result IotDpsSkuDefinitionListResult, err error) { + req, err := lastResults.iotDpsSkuDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListValidSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListValidSkus(ctx, provisioningServiceName, resourceGroupName) + return +} + +// Update update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// provisioningServiceTags - updated tag information to set into the provisioning service instance. +func (client IotDpsResourceClient) Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (result IotDpsResourceUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, provisioningServiceName, provisioningServiceTags) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotDpsResourceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(provisioningServiceTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) UpdateSender(req *http.Request) (future IotDpsResourceUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) UpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iothubapi/interfaces.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iothubapi/interfaces.go new file mode 100644 index 000000000000..cdeb03dfc96c --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/iothubapi/interfaces.go @@ -0,0 +1,61 @@ +package iothubapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result iothub.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result iothub.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*iothub.OperationsClient)(nil) + +// DpsCertificateClientAPI contains the set of methods on the DpsCertificateClient type. +type DpsCertificateClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription iothub.CertificateBodyDescription, ifMatch string) (result iothub.CertificateResponse, err error) + Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) + GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.VerificationCodeResponse, err error) + Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result iothub.CertificateResponse, err error) + List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result iothub.CertificateListDescription, err error) + VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request iothub.VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.CertificateResponse, err error) +} + +var _ DpsCertificateClientAPI = (*iothub.DpsCertificateClient)(nil) + +// IotDpsResourceClientAPI contains the set of methods on the IotDpsResourceClient type. +type IotDpsResourceClientAPI interface { + CheckProvisioningServiceNameAvailability(ctx context.Context, arguments iothub.OperationInputs) (result iothub.NameAvailabilityInfo, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription iothub.ProvisioningServiceDescription) (result iothub.IotDpsResourceCreateOrUpdateFuture, err error) + CreateOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection iothub.PrivateEndpointConnection) (result iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) + Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsResourceDeleteFuture, err error) + DeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) + Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.ProvisioningServiceDescription, err error) + GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result iothub.AsyncOperationResult, err error) + GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result iothub.PrivateEndpointConnection, err error) + GetPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (result iothub.GroupIDInformation, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListBySubscription(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultPage, err error) + ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultIterator, err error) + ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) + ListPrivateEndpointConnections(ctx context.Context, resourceGroupName string, resourceName string) (result iothub.ListPrivateEndpointConnection, err error) + ListPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string) (result iothub.PrivateLinkResources, err error) + ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultPage, err error) + ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags iothub.TagsResource) (result iothub.IotDpsResourceUpdateFuture, err error) +} + +var _ IotDpsResourceClientAPI = (*iothub.IotDpsResourceClient)(nil) diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/models.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/models.go new file mode 100644 index 000000000000..b0018cbbc55c --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/models.go @@ -0,0 +1,1491 @@ +package iothub + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub" + +// ArmIdentity the set of ARM identities associated with the IoT DPS resource. +type ArmIdentity struct { + // PrincipalID - READ-ONLY; Principal Id + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; Tenant Id + TenantID *string `json:"tenantId,omitempty"` + // IdentityType - Identity type. Only allowed values are SystemAssigned and UserAssigned. Comma separated if both for ex: SystemAssigned,UserAssigned. + IdentityType *string `json:"identityType,omitempty"` + // UserAssignedIdentities - The set of UserAssigned identities associated with the IoT DPS resource. + UserAssignedIdentities map[string]*ArmUserIdentity `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ArmIdentity. +func (ai ArmIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ai.IdentityType != nil { + objectMap["identityType"] = ai.IdentityType + } + if ai.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = ai.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ArmUserIdentity the ARM UserAssigned identity information +type ArmUserIdentity struct { + // PrincipalID - READ-ONLY; Principal Id + PrincipalID *string `json:"principalId,omitempty"` + // ClientID - READ-ONLY; Client Id + ClientID *string `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for ArmUserIdentity. +func (aui ArmUserIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// AsyncOperationResult result of a long running operation. +type AsyncOperationResult struct { + autorest.Response `json:"-"` + // Status - current status of a long running operation. + Status *string `json:"status,omitempty"` + // Error - Error message containing code, description and details + Error *ErrorMesssage `json:"error,omitempty"` +} + +// CertificateBodyDescription the JSON-serialized X509 Certificate. +type CertificateBodyDescription struct { + // Certificate - Base-64 representation of the X509 leaf certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` +} + +// CertificateListDescription the JSON-serialized array of Certificate objects. +type CertificateListDescription struct { + autorest.Response `json:"-"` + // Value - The array of Certificate objects. + Value *[]CertificateResponse `json:"value,omitempty"` +} + +// CertificateProperties the description of an X509 CA Certificate. +type CertificateProperties struct { + // Subject - READ-ONLY; The certificate's subject name. + Subject *string `json:"subject,omitempty"` + // Expiry - READ-ONLY; The certificate's expiration date and time. + Expiry *date.TimeRFC1123 `json:"expiry,omitempty"` + // Thumbprint - READ-ONLY; The certificate's thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - READ-ONLY; Determines whether certificate has been verified. + IsVerified *bool `json:"isVerified,omitempty"` + // Created - READ-ONLY; The certificate's creation date and time. + Created *date.TimeRFC1123 `json:"created,omitempty"` + // Updated - READ-ONLY; The certificate's last update date and time. + Updated *date.TimeRFC1123 `json:"updated,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateProperties. +func (cp CertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CertificateResponse the X509 Certificate. +type CertificateResponse struct { + autorest.Response `json:"-"` + // Properties - properties of a certificate + Properties *CertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; The entity tag. + Etag *string `json:"etag,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateResponse. +func (cr CertificateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Properties != nil { + objectMap["properties"] = cr.Properties + } + return json.Marshal(objectMap) +} + +// DefinitionDescription description of the IoT hub. +type DefinitionDescription struct { + // ApplyAllocationPolicy - flag for applying allocationPolicy or not for a given iot hub. + ApplyAllocationPolicy *bool `json:"applyAllocationPolicy,omitempty"` + // AllocationWeight - weight to apply for a given iot h. + AllocationWeight *int32 `json:"allocationWeight,omitempty"` + // Name - READ-ONLY; Host name of the IoT hub. + Name *string `json:"name,omitempty"` + // ConnectionString - Connection string of the IoT hub. + ConnectionString *string `json:"connectionString,omitempty"` + // Location - ARM region of the IoT hub. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DefinitionDescription. +func (dd DefinitionDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dd.ApplyAllocationPolicy != nil { + objectMap["applyAllocationPolicy"] = dd.ApplyAllocationPolicy + } + if dd.AllocationWeight != nil { + objectMap["allocationWeight"] = dd.AllocationWeight + } + if dd.ConnectionString != nil { + objectMap["connectionString"] = dd.ConnectionString + } + if dd.Location != nil { + objectMap["location"] = dd.Location + } + return json.Marshal(objectMap) +} + +// EncryptionKeyIdentity the properties of the identity used to access the key encryption key in KeyVault. +type EncryptionKeyIdentity struct { + // UserAssignedIdentity - The user assigned identity. + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} + +// EncryptionPropertiesDescription the customer-managed encryption key (CMK) properties for the IoT DPS +// instance. +type EncryptionPropertiesDescription struct { + // KeySource - The source of the encryption key. Typically, Microsoft.KeyVault + KeySource *string `json:"keySource,omitempty"` + // KeyVaultProperties - The properties of the encryption key configured in KeyVault. + KeyVaultProperties *[]KeyVaultKeyProperties `json:"keyVaultProperties,omitempty"` + // Identity - The identity used to access the encryption key in KeyVault. + Identity *EncryptionKeyIdentity `json:"identity,omitempty"` +} + +// ErrorDetails error details. +type ErrorDetails struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // HTTPStatusCode - READ-ONLY; The HTTP status code. + HTTPStatusCode *string `json:"httpStatusCode,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; The error details. + Details *string `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorMesssage error response containing message and code. +type ErrorMesssage struct { + // Code - standard error code + Code *string `json:"code,omitempty"` + // Message - standard error description + Message *string `json:"message,omitempty"` + // Details - detailed summary of error + Details *string `json:"details,omitempty"` +} + +// GroupIDInformation the group information for creating a private endpoint on a provisioning service +type GroupIDInformation struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Properties - The properties for a group information object + Properties *GroupIDInformationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupIDInformation. +func (gii GroupIDInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gii.Properties != nil { + objectMap["properties"] = gii.Properties + } + return json.Marshal(objectMap) +} + +// GroupIDInformationProperties the properties for a group information object +type GroupIDInformationProperties struct { + // GroupID - The group id + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - The required members for a specific group id + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - The required DNS zones for a specific group id + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// IotDpsPropertiesDescription the service specific properties of a provisioning service, including keys, +// linked iot hubs, current state, and system generated properties such as hostname and idScope +type IotDpsPropertiesDescription struct { + // State - Current state of the provisioning service. Possible values include: 'Activating', 'Active', 'Deleting', 'Deleted', 'ActivationFailed', 'DeletionFailed', 'Transitioning', 'Suspending', 'Suspended', 'Resuming', 'FailingOver', 'FailoverFailed' + State State `json:"state,omitempty"` + // Encryption - The encryption properties for the IoT DPS instance. + Encryption *EncryptionPropertiesDescription `json:"encryption,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // IPFilterRules - The IP filter rules. + IPFilterRules *[]IPFilterRule `json:"ipFilterRules,omitempty"` + // PrivateEndpointConnections - Private endpoint connections created on this IotHub + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // ProvisioningState - The ARM provisioning state of the provisioning service. + ProvisioningState *string `json:"provisioningState,omitempty"` + // IotHubs - List of IoT hubs associated with this provisioning service. + IotHubs *[]DefinitionDescription `json:"iotHubs,omitempty"` + // AllocationPolicy - Allocation policy to be used by this provisioning service. Possible values include: 'Hashed', 'GeoLatency', 'Static' + AllocationPolicy AllocationPolicy `json:"allocationPolicy,omitempty"` + // ServiceOperationsHostName - READ-ONLY; Service endpoint for provisioning service. + ServiceOperationsHostName *string `json:"serviceOperationsHostName,omitempty"` + // DeviceProvisioningHostName - READ-ONLY; Device endpoint for this provisioning service. + DeviceProvisioningHostName *string `json:"deviceProvisioningHostName,omitempty"` + // IDScope - READ-ONLY; Unique identifier of this provisioning service. + IDScope *string `json:"idScope,omitempty"` + // AuthorizationPolicies - List of authorization keys for a provisioning service. + AuthorizationPolicies *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"authorizationPolicies,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsPropertiesDescription. +func (idpd IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idpd.State != "" { + objectMap["state"] = idpd.State + } + if idpd.Encryption != nil { + objectMap["encryption"] = idpd.Encryption + } + if idpd.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = idpd.PublicNetworkAccess + } + if idpd.IPFilterRules != nil { + objectMap["ipFilterRules"] = idpd.IPFilterRules + } + if idpd.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = idpd.PrivateEndpointConnections + } + if idpd.ProvisioningState != nil { + objectMap["provisioningState"] = idpd.ProvisioningState + } + if idpd.IotHubs != nil { + objectMap["iotHubs"] = idpd.IotHubs + } + if idpd.AllocationPolicy != "" { + objectMap["allocationPolicy"] = idpd.AllocationPolicy + } + if idpd.AuthorizationPolicies != nil { + objectMap["authorizationPolicies"] = idpd.AuthorizationPolicies + } + return json.Marshal(objectMap) +} + +// IotDpsResourceCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type IotDpsResourceCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceCreateOrUpdateFuture.Result. +func (future *IotDpsResourceCreateOrUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.CreateOrUpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture.Result. +func (future *IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture) result(client IotDpsResourceClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdatePrivateEndpointConnectionResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceDeleteFuture.Result. +func (future *IotDpsResourceDeleteFuture) result(client IotDpsResourceClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// IotDpsResourceDeletePrivateEndpointConnectionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type IotDpsResourceDeletePrivateEndpointConnectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceDeletePrivateEndpointConnectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceDeletePrivateEndpointConnectionFuture.Result. +func (future *IotDpsResourceDeletePrivateEndpointConnectionFuture) result(client IotDpsResourceClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.DeletePrivateEndpointConnectionResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceUpdateFuture.Result. +func (future *IotDpsResourceUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.UpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsSkuDefinition available SKUs of tier and units. +type IotDpsSkuDefinition struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` +} + +// IotDpsSkuDefinitionListResult list of available SKUs. +type IotDpsSkuDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of SKUs + Value *[]IotDpsSkuDefinition `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuDefinitionListResult. +func (idsdlr IotDpsSkuDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsdlr.Value != nil { + objectMap["value"] = idsdlr.Value + } + return json.Marshal(objectMap) +} + +// IotDpsSkuDefinitionListResultIterator provides access to a complete listing of IotDpsSkuDefinition +// values. +type IotDpsSkuDefinitionListResultIterator struct { + i int + page IotDpsSkuDefinitionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotDpsSkuDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotDpsSkuDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotDpsSkuDefinitionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotDpsSkuDefinitionListResultIterator) Response() IotDpsSkuDefinitionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotDpsSkuDefinitionListResultIterator) Value() IotDpsSkuDefinition { + if !iter.page.NotDone() { + return IotDpsSkuDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultIterator type. +func NewIotDpsSkuDefinitionListResultIterator(page IotDpsSkuDefinitionListResultPage) IotDpsSkuDefinitionListResultIterator { + return IotDpsSkuDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (idsdlr IotDpsSkuDefinitionListResult) IsEmpty() bool { + return idsdlr.Value == nil || len(*idsdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (idsdlr IotDpsSkuDefinitionListResult) hasNextLink() bool { + return idsdlr.NextLink != nil && len(*idsdlr.NextLink) != 0 +} + +// iotDpsSkuDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (idsdlr IotDpsSkuDefinitionListResult) iotDpsSkuDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !idsdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(idsdlr.NextLink))) +} + +// IotDpsSkuDefinitionListResultPage contains a page of IotDpsSkuDefinition values. +type IotDpsSkuDefinitionListResultPage struct { + fn func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error) + idsdlr IotDpsSkuDefinitionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotDpsSkuDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.idsdlr) + if err != nil { + return err + } + page.idsdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotDpsSkuDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotDpsSkuDefinitionListResultPage) NotDone() bool { + return !page.idsdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotDpsSkuDefinitionListResultPage) Response() IotDpsSkuDefinitionListResult { + return page.idsdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotDpsSkuDefinitionListResultPage) Values() []IotDpsSkuDefinition { + if page.idsdlr.IsEmpty() { + return nil + } + return *page.idsdlr.Value +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultPage type. +func NewIotDpsSkuDefinitionListResultPage(cur IotDpsSkuDefinitionListResult, getNextPage func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error)) IotDpsSkuDefinitionListResultPage { + return IotDpsSkuDefinitionListResultPage{ + fn: getNextPage, + idsdlr: cur, + } +} + +// IotDpsSkuInfo list of possible provisioning service SKUs. +type IotDpsSkuInfo struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` + // Tier - READ-ONLY; Pricing tier name of the provisioning service. + Tier *string `json:"tier,omitempty"` + // Capacity - The number of units to provision + Capacity *int64 `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuInfo. +func (idsi IotDpsSkuInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsi.Name != "" { + objectMap["name"] = idsi.Name + } + if idsi.Capacity != nil { + objectMap["capacity"] = idsi.Capacity + } + return json.Marshal(objectMap) +} + +// IPFilterRule the IP filter rules for a provisioning Service. +type IPFilterRule struct { + // FilterName - The name of the IP filter rule. + FilterName *string `json:"filterName,omitempty"` + // Action - The desired action for requests captured by this rule. Possible values include: 'Accept', 'Reject' + Action IPFilterActionType `json:"action,omitempty"` + // IPMask - A string that contains the IP address range in CIDR notation for the rule. + IPMask *string `json:"ipMask,omitempty"` + // Target - Target for requests captured by this rule. Possible values include: 'All', 'ServiceAPI', 'DeviceAPI' + Target IPFilterTargetType `json:"target,omitempty"` +} + +// KeyVaultKeyProperties the properties of the KeyVault key. +type KeyVaultKeyProperties struct { + // KeyIdentifier - The identifier of the key. + KeyIdentifier *string `json:"keyIdentifier,omitempty"` +} + +// ListPrivateEndpointConnection ... +type ListPrivateEndpointConnection struct { + autorest.Response `json:"-"` + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// NameAvailabilityInfo description of name availability. +type NameAvailabilityInfo struct { + autorest.Response `json:"-"` + // NameAvailable - specifies if a name is available or not + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - specifies the reason a name is unavailable. Possible values include: 'Invalid', 'AlreadyExists' + Reason NameUnavailabilityReason `json:"reason,omitempty"` + // Message - message containing a detailed reason name is unavailable + Message *string `json:"message,omitempty"` +} + +// Operation provisioning Service REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft Devices. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: ProvisioningServices. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation. + Operation *string `json:"operation,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationInputs input values for operation results call. +type OperationInputs struct { + // Name - The name of the Provisioning Service to check. + Name *string `json:"name,omitempty"` +} + +// OperationListResult result of the request to list provisioning service operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Provisioning service operations supported by the Microsoft.Devices resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PrivateEndpoint the private endpoint property of a private endpoint connection +type PrivateEndpoint struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpoint. +func (peVar PrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection the private endpoint connection of a provisioning service +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Properties - The properties of a private endpoint connection + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.Properties != nil { + objectMap["properties"] = pec.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties the properties of a private endpoint connection +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The private endpoint property of a private endpoint connection + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - The current state of a private endpoint connection + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// PrivateLinkResources the available private link resources for a provisioning service +type PrivateLinkResources struct { + autorest.Response `json:"-"` + // Value - The list of available private link resources for a provisioning service + Value *[]GroupIDInformation `json:"value,omitempty"` +} + +// PrivateLinkServiceConnectionState the current state of a private endpoint connection +type PrivateLinkServiceConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The description for the current state of a private endpoint connection + Description *string `json:"description,omitempty"` + // ActionsRequired - Actions required for a private endpoint connection + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// ProvisioningServiceDescription the description of the provisioning service. +type ProvisioningServiceDescription struct { + autorest.Response `json:"-"` + // Etag - The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. + Etag *string `json:"etag,omitempty"` + // Properties - Service specific properties for a provisioning service + Properties *IotDpsPropertiesDescription `json:"properties,omitempty"` + // Sku - Sku info for a provisioning Service. + Sku *IotDpsSkuInfo `json:"sku,omitempty"` + // Identity - The managed identities for the IotDps instance. + Identity *ArmIdentity `json:"identity,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescription. +func (psd ProvisioningServiceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psd.Etag != nil { + objectMap["etag"] = psd.Etag + } + if psd.Properties != nil { + objectMap["properties"] = psd.Properties + } + if psd.Sku != nil { + objectMap["sku"] = psd.Sku + } + if psd.Identity != nil { + objectMap["identity"] = psd.Identity + } + if psd.Location != nil { + objectMap["location"] = psd.Location + } + if psd.Tags != nil { + objectMap["tags"] = psd.Tags + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResult list of provisioning service descriptions. +type ProvisioningServiceDescriptionListResult struct { + autorest.Response `json:"-"` + // Value - List of provisioning service descriptions. + Value *[]ProvisioningServiceDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; the next link + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescriptionListResult. +func (psdlr ProvisioningServiceDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psdlr.Value != nil { + objectMap["value"] = psdlr.Value + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResultIterator provides access to a complete listing of +// ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultIterator struct { + i int + page ProvisioningServiceDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProvisioningServiceDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProvisioningServiceDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProvisioningServiceDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProvisioningServiceDescriptionListResultIterator) Response() ProvisioningServiceDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProvisioningServiceDescriptionListResultIterator) Value() ProvisioningServiceDescription { + if !iter.page.NotDone() { + return ProvisioningServiceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultIterator type. +func NewProvisioningServiceDescriptionListResultIterator(page ProvisioningServiceDescriptionListResultPage) ProvisioningServiceDescriptionListResultIterator { + return ProvisioningServiceDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (psdlr ProvisioningServiceDescriptionListResult) IsEmpty() bool { + return psdlr.Value == nil || len(*psdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (psdlr ProvisioningServiceDescriptionListResult) hasNextLink() bool { + return psdlr.NextLink != nil && len(*psdlr.NextLink) != 0 +} + +// provisioningServiceDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (psdlr ProvisioningServiceDescriptionListResult) provisioningServiceDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !psdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(psdlr.NextLink))) +} + +// ProvisioningServiceDescriptionListResultPage contains a page of ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultPage struct { + fn func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error) + psdlr ProvisioningServiceDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProvisioningServiceDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.psdlr) + if err != nil { + return err + } + page.psdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProvisioningServiceDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProvisioningServiceDescriptionListResultPage) NotDone() bool { + return !page.psdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProvisioningServiceDescriptionListResultPage) Response() ProvisioningServiceDescriptionListResult { + return page.psdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProvisioningServiceDescriptionListResultPage) Values() []ProvisioningServiceDescription { + if page.psdlr.IsEmpty() { + return nil + } + return *page.psdlr.Value +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultPage type. +func NewProvisioningServiceDescriptionListResultPage(cur ProvisioningServiceDescriptionListResult, getNextPage func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error)) ProvisioningServiceDescriptionListResultPage { + return ProvisioningServiceDescriptionListResultPage{ + fn: getNextPage, + psdlr: cur, + } +} + +// Resource the common properties of an Azure resource. +type Resource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription description of the shared access key. +type SharedAccessSignatureAuthorizationRuleAccessRightsDescription struct { + autorest.Response `json:"-"` + // KeyName - Name of the key. + KeyName *string `json:"keyName,omitempty"` + // PrimaryKey - Primary SAS key value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary SAS key value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // Rights - Rights that this key has. Possible values include: 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', 'DeviceConnect', 'RegistrationStatusRead', 'RegistrationStatusWrite' + Rights AccessRightsDescription `json:"rights,omitempty"` +} + +// SharedAccessSignatureAuthorizationRuleListResult list of shared access keys. +type SharedAccessSignatureAuthorizationRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of shared access policies. + Value *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedAccessSignatureAuthorizationRuleListResult. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sasarlr.Value != nil { + objectMap["value"] = sasarlr.Value + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleListResultIterator provides access to a complete listing of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultIterator struct { + i int + page SharedAccessSignatureAuthorizationRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Response() SharedAccessSignatureAuthorizationRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Value() SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if !iter.page.NotDone() { + return SharedAccessSignatureAuthorizationRuleAccessRightsDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultIterator type. +func NewSharedAccessSignatureAuthorizationRuleListResultIterator(page SharedAccessSignatureAuthorizationRuleListResultPage) SharedAccessSignatureAuthorizationRuleListResultIterator { + return SharedAccessSignatureAuthorizationRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) IsEmpty() bool { + return sasarlr.Value == nil || len(*sasarlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) hasNextLink() bool { + return sasarlr.NextLink != nil && len(*sasarlr.NextLink) != 0 +} + +// sharedAccessSignatureAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sasarlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sasarlr.NextLink))) +} + +// SharedAccessSignatureAuthorizationRuleListResultPage contains a page of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultPage struct { + fn func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error) + sasarlr SharedAccessSignatureAuthorizationRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sasarlr) + if err != nil { + return err + } + page.sasarlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) NotDone() bool { + return !page.sasarlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Response() SharedAccessSignatureAuthorizationRuleListResult { + return page.sasarlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Values() []SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if page.sasarlr.IsEmpty() { + return nil + } + return *page.sasarlr.Value +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultPage type. +func NewSharedAccessSignatureAuthorizationRuleListResultPage(cur SharedAccessSignatureAuthorizationRuleListResult, getNextPage func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error)) SharedAccessSignatureAuthorizationRuleListResultPage { + return SharedAccessSignatureAuthorizationRuleListResultPage{ + fn: getNextPage, + sasarlr: cur, + } +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// Provisioning Service instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// VerificationCodeRequest the JSON-serialized leaf certificate +type VerificationCodeRequest struct { + // Certificate - base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` +} + +// VerificationCodeResponse description of the response of the verification code. +type VerificationCodeResponse struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Name of certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; Request etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + Properties *VerificationCodeResponseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VerificationCodeResponse. +func (vcr VerificationCodeResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcr.Properties != nil { + objectMap["properties"] = vcr.Properties + } + return json.Marshal(objectMap) +} + +// VerificationCodeResponseProperties ... +type VerificationCodeResponseProperties struct { + // VerificationCode - Verification code. + VerificationCode *string `json:"verificationCode,omitempty"` + // Subject - Certificate subject. + Subject *string `json:"subject,omitempty"` + // Expiry - Code expiry. + Expiry *string `json:"expiry,omitempty"` + // Thumbprint - Certificate thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - Indicate if the certificate is verified by owner of private key. + IsVerified *bool `json:"isVerified,omitempty"` + // Created - Certificate created time. + Created *string `json:"created,omitempty"` + // Updated - Certificate updated time. + Updated *string `json:"updated,omitempty"` +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/operations.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/operations.go new file mode 100644 index 000000000000..14d80b77f70a --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/operations.go @@ -0,0 +1,140 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Microsoft.Devices REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Devices/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/version.go b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/version.go new file mode 100644 index 000000000000..2dc44aa2663c --- /dev/null +++ b/services/preview/provisioningservices/mgmt/2020-09-01-preview/iothub/version.go @@ -0,0 +1,19 @@ +package iothub + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " iothub/2020-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/provisioningservices/mgmt/2017-11-15/iothub/CHANGELOG.md b/services/provisioningservices/mgmt/2017-11-15/iothub/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/provisioningservices/mgmt/2017-11-15/iothub/CHANGELOG.md +++ b/services/provisioningservices/mgmt/2017-11-15/iothub/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/provisioningservices/mgmt/2017-11-15/iothub/_meta.json b/services/provisioningservices/mgmt/2017-11-15/iothub/_meta.json index 1140217ffcdd..976714d7fe0f 100644 --- a/services/provisioningservices/mgmt/2017-11-15/iothub/_meta.json +++ b/services/provisioningservices/mgmt/2017-11-15/iothub/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", "tag": "package-2017-11", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/provisioningservices/mgmt/2018-01-22/iothub/CHANGELOG.md b/services/provisioningservices/mgmt/2018-01-22/iothub/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/provisioningservices/mgmt/2018-01-22/iothub/CHANGELOG.md +++ b/services/provisioningservices/mgmt/2018-01-22/iothub/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/provisioningservices/mgmt/2018-01-22/iothub/_meta.json b/services/provisioningservices/mgmt/2018-01-22/iothub/_meta.json index 0fb95f15c411..d1626a3b1c6e 100644 --- a/services/provisioningservices/mgmt/2018-01-22/iothub/_meta.json +++ b/services/provisioningservices/mgmt/2018-01-22/iothub/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", "tag": "package-2018-01", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/CHANGELOG.md b/services/provisioningservices/mgmt/2020-01-01/iothub/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/_meta.json b/services/provisioningservices/mgmt/2020-01-01/iothub/_meta.json new file mode 100644 index 000000000000..871fa4d490f3 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", + "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "tag": "package-2020-01", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2020-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/client.go b/services/provisioningservices/mgmt/2020-01-01/iothub/client.go new file mode 100644 index 000000000000..391422bbc9e2 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/client.go @@ -0,0 +1,41 @@ +// Package iothub implements the Azure ARM Iothub service API version 2020-01-01. +// +// API for using the Azure IoT Hub Device Provisioning Service features. +package iothub + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Iothub + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Iothub. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/dpscertificate.go b/services/provisioningservices/mgmt/2020-01-01/iothub/dpscertificate.go new file mode 100644 index 000000000000..f5783b22045f --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/dpscertificate.go @@ -0,0 +1,628 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DpsCertificateClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type DpsCertificateClient struct { + BaseClient +} + +// NewDpsCertificateClient creates an instance of the DpsCertificateClient client. +func NewDpsCertificateClient(subscriptionID string) DpsCertificateClient { + return NewDpsCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDpsCertificateClientWithBaseURI creates an instance of the DpsCertificateClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDpsCertificateClientWithBaseURI(baseURI string, subscriptionID string) DpsCertificateClient { + return DpsCertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate add new certificate or update an existing certificate. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - the name of the provisioning service. +// certificateName - the name of the certificate create or update. +// certificateDescription - the certificate body. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +func (client DpsCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: certificateName, + Constraints: []validation.Constraint{{Target: "certificateName", Name: validation.MaxLength, Rule: 256, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.DpsCertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DpsCertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(certificateDescription), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) CreateOrUpdateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified certificate associated with the Provisioning Service +// Parameters: +// resourceGroupName - resource group identifier. +// ifMatch - eTag of the certificate +// provisioningServiceName - the name of the provisioning service. +// certificateName - this is a mandatory field, and is the logical name of the certificate that the +// provisioning service will access by. +// certificatename - this is optional, and it is the Common Name of the certificate. +// certificaterawBytes - raw data within the certificate. +// certificateisVerified - indicates if certificate has been verified by owner of the private key. +// certificatepurpose - a description that mentions the purpose of the certificate. +// certificatecreated - time the certificate is created. +// certificatelastUpdated - time the certificate is last updated. +// certificatehasPrivateKey - indicates if the certificate contains a private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DpsCertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateVerificationCode generate verification code for Proof of Possession. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - description mentioning the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result VerificationCodeResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.GenerateVerificationCode") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateVerificationCodePreparer(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateVerificationCodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure sending request") + return + } + + result, err = client.GenerateVerificationCodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure responding to request") + return + } + + return +} + +// GenerateVerificationCodePreparer prepares the GenerateVerificationCode request. +func (client DpsCertificateClient) GenerateVerificationCodePreparer(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateVerificationCodeSender sends the GenerateVerificationCode request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GenerateVerificationCodeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateVerificationCodeResponder handles the response to the GenerateVerificationCode request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GenerateVerificationCodeResponder(resp *http.Response) (result VerificationCodeResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the certificate from the provisioning service. +// Parameters: +// certificateName - name of the certificate to retrieve. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of the provisioning service the certificate is associated with. +// ifMatch - eTag of the certificate. +func (client DpsCertificateClient) Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, certificateName, resourceGroupName, provisioningServiceName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DpsCertificateClient) GetPreparer(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GetResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the certificates tied to the provisioning service. +// Parameters: +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service to retrieve certificates for. +func (client DpsCertificateClient) List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result CertificateListDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, provisioningServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DpsCertificateClient) ListPreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) ListResponder(resp *http.Response) (result CertificateListDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// VerifyCertificate verifies the certificate's private key possession by providing the leaf cert issued by the +// verifying pre uploaded certificate. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. +// request - the name of the certificate +// resourceGroupName - resource group name. +// provisioningServiceName - provisioning service name. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - describe the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.VerifyCertificate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.VerifyCertificatePreparer(ctx, certificateName, ifMatch, request, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.VerifyCertificateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure sending request") + return + } + + result, err = client.VerifyCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure responding to request") + return + } + + return +} + +// VerifyCertificatePreparer prepares the VerifyCertificate request. +func (client DpsCertificateClient) VerifyCertificatePreparer(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify", pathParameters), + autorest.WithJSON(request), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// VerifyCertificateSender sends the VerifyCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) VerifyCertificateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// VerifyCertificateResponder handles the response to the VerifyCertificate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) VerifyCertificateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/enums.go b/services/provisioningservices/mgmt/2020-01-01/iothub/enums.go new file mode 100644 index 000000000000..2f4f1ff61443 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/enums.go @@ -0,0 +1,157 @@ +package iothub + +// 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. + +// AccessRightsDescription enumerates the values for access rights description. +type AccessRightsDescription string + +const ( + // DeviceConnect ... + DeviceConnect AccessRightsDescription = "DeviceConnect" + // EnrollmentRead ... + EnrollmentRead AccessRightsDescription = "EnrollmentRead" + // EnrollmentWrite ... + EnrollmentWrite AccessRightsDescription = "EnrollmentWrite" + // RegistrationStatusRead ... + RegistrationStatusRead AccessRightsDescription = "RegistrationStatusRead" + // RegistrationStatusWrite ... + RegistrationStatusWrite AccessRightsDescription = "RegistrationStatusWrite" + // ServiceConfig ... + ServiceConfig AccessRightsDescription = "ServiceConfig" +) + +// PossibleAccessRightsDescriptionValues returns an array of possible values for the AccessRightsDescription const type. +func PossibleAccessRightsDescriptionValues() []AccessRightsDescription { + return []AccessRightsDescription{DeviceConnect, EnrollmentRead, EnrollmentWrite, RegistrationStatusRead, RegistrationStatusWrite, ServiceConfig} +} + +// AllocationPolicy enumerates the values for allocation policy. +type AllocationPolicy string + +const ( + // GeoLatency ... + GeoLatency AllocationPolicy = "GeoLatency" + // Hashed ... + Hashed AllocationPolicy = "Hashed" + // Static ... + Static AllocationPolicy = "Static" +) + +// PossibleAllocationPolicyValues returns an array of possible values for the AllocationPolicy const type. +func PossibleAllocationPolicyValues() []AllocationPolicy { + return []AllocationPolicy{GeoLatency, Hashed, Static} +} + +// CertificatePurpose enumerates the values for certificate purpose. +type CertificatePurpose string + +const ( + // ClientAuthentication ... + ClientAuthentication CertificatePurpose = "clientAuthentication" + // ServerAuthentication ... + ServerAuthentication CertificatePurpose = "serverAuthentication" +) + +// PossibleCertificatePurposeValues returns an array of possible values for the CertificatePurpose const type. +func PossibleCertificatePurposeValues() []CertificatePurpose { + return []CertificatePurpose{ClientAuthentication, ServerAuthentication} +} + +// IotDpsSku enumerates the values for iot dps sku. +type IotDpsSku string + +const ( + // S1 ... + S1 IotDpsSku = "S1" +) + +// PossibleIotDpsSkuValues returns an array of possible values for the IotDpsSku const type. +func PossibleIotDpsSkuValues() []IotDpsSku { + return []IotDpsSku{S1} +} + +// IPFilterActionType enumerates the values for ip filter action type. +type IPFilterActionType string + +const ( + // Accept ... + Accept IPFilterActionType = "Accept" + // Reject ... + Reject IPFilterActionType = "Reject" +) + +// PossibleIPFilterActionTypeValues returns an array of possible values for the IPFilterActionType const type. +func PossibleIPFilterActionTypeValues() []IPFilterActionType { + return []IPFilterActionType{Accept, Reject} +} + +// IPFilterTargetType enumerates the values for ip filter target type. +type IPFilterTargetType string + +const ( + // All ... + All IPFilterTargetType = "all" + // DeviceAPI ... + DeviceAPI IPFilterTargetType = "deviceApi" + // ServiceAPI ... + ServiceAPI IPFilterTargetType = "serviceApi" +) + +// PossibleIPFilterTargetTypeValues returns an array of possible values for the IPFilterTargetType const type. +func PossibleIPFilterTargetTypeValues() []IPFilterTargetType { + return []IPFilterTargetType{All, DeviceAPI, ServiceAPI} +} + +// NameUnavailabilityReason enumerates the values for name unavailability reason. +type NameUnavailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists NameUnavailabilityReason = "AlreadyExists" + // Invalid ... + Invalid NameUnavailabilityReason = "Invalid" +) + +// PossibleNameUnavailabilityReasonValues returns an array of possible values for the NameUnavailabilityReason const type. +func PossibleNameUnavailabilityReasonValues() []NameUnavailabilityReason { + return []NameUnavailabilityReason{AlreadyExists, Invalid} +} + +// State enumerates the values for state. +type State string + +const ( + // Activating ... + Activating State = "Activating" + // ActivationFailed ... + ActivationFailed State = "ActivationFailed" + // Active ... + Active State = "Active" + // Deleted ... + Deleted State = "Deleted" + // Deleting ... + Deleting State = "Deleting" + // DeletionFailed ... + DeletionFailed State = "DeletionFailed" + // FailingOver ... + FailingOver State = "FailingOver" + // FailoverFailed ... + FailoverFailed State = "FailoverFailed" + // Resuming ... + Resuming State = "Resuming" + // Suspended ... + Suspended State = "Suspended" + // Suspending ... + Suspending State = "Suspending" + // Transitioning ... + Transitioning State = "Transitioning" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Activating, ActivationFailed, Active, Deleted, Deleting, DeletionFailed, FailingOver, FailoverFailed, Resuming, Suspended, Suspending, Transitioning} +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/iotdpsresource.go b/services/provisioningservices/mgmt/2020-01-01/iothub/iotdpsresource.go new file mode 100644 index 000000000000..46540a6ccbea --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/iotdpsresource.go @@ -0,0 +1,1067 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotDpsResourceClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type IotDpsResourceClient struct { + BaseClient +} + +// NewIotDpsResourceClient creates an instance of the IotDpsResourceClient client. +func NewIotDpsResourceClient(subscriptionID string) IotDpsResourceClient { + return NewIotDpsResourceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIotDpsResourceClientWithBaseURI creates an instance of the IotDpsResourceClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotDpsResourceClientWithBaseURI(baseURI string, subscriptionID string) IotDpsResourceClient { + return IotDpsResourceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckProvisioningServiceNameAvailability check if a provisioning service name is available. This will validate if +// the name is syntactically valid and if the name is usable +// Parameters: +// arguments - set the name parameter in the OperationInputs structure to the name of the provisioning service +// to check. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, arguments OperationInputs) (result NameAvailabilityInfo, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CheckProvisioningServiceNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: arguments, + Constraints: []validation.Constraint{{Target: "arguments.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", err.Error()) + } + + req, err := client.CheckProvisioningServiceNameAvailabilityPreparer(ctx, arguments) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckProvisioningServiceNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckProvisioningServiceNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckProvisioningServiceNameAvailabilityPreparer prepares the CheckProvisioningServiceNameAvailability request. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityPreparer(ctx context.Context, arguments OperationInputs) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", pathParameters), + autorest.WithJSON(arguments), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckProvisioningServiceNameAvailabilitySender sends the CheckProvisioningServiceNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckProvisioningServiceNameAvailabilityResponder handles the response to the CheckProvisioningServiceNameAvailability request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityInfo, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update the metadata of the provisioning service. The usual pattern to modify a property is +// to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values +// in a new body to update the provisioning service. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// iotDpsDescription - description of the provisioning service to create or update. +func (client IotDpsResourceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (result IotDpsResourceCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: iotDpsDescription, + Constraints: []validation.Constraint{{Target: "iotDpsDescription.Properties", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotDpsDescription.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, iotDpsDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotDpsResourceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(iotDpsDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CreateOrUpdateSender(req *http.Request) (future IotDpsResourceCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CreateOrUpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Provisioning Service. +// Parameters: +// provisioningServiceName - name of provisioning service to delete. +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsResourceDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotDpsResourceClient) DeletePreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) DeleteSender(req *http.Request) (future IotDpsResourceDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of the provisioning service without SAS keys. +// Parameters: +// provisioningServiceName - name of the provisioning service to retrieve. +// resourceGroupName - resource group name. +func (client IotDpsResourceClient) Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result ProvisioningServiceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotDpsResourceClient) GetPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOperationResult gets the status of a long running operation, such as create, update or delete a provisioning +// service. +// Parameters: +// operationID - operation id corresponding to long running operation. Use this to poll for the status. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service that the operation is running on. +// asyncinfo - async header used to poll on the status of the operation, obtained while creating the long +// running operation. +func (client IotDpsResourceClient) GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result AsyncOperationResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetOperationResult") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetOperationResultPreparer(ctx, operationID, resourceGroupName, provisioningServiceName, asyncinfo) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", nil, "Failure preparing request") + return + } + + resp, err := client.GetOperationResultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure sending request") + return + } + + result, err = client.GetOperationResultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure responding to request") + return + } + + return +} + +// GetOperationResultPreparer prepares the GetOperationResult request. +func (client IotDpsResourceClient) GetOperationResultPreparer(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "asyncinfo": autorest.Encode("query", asyncinfo), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOperationResultSender sends the GetOperationResult request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetOperationResultSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetOperationResultResponder handles the response to the GetOperationResult request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetOperationResultResponder(resp *http.Response) (result AsyncOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all provisioning services in the given resource group. +// Parameters: +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client IotDpsResourceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListByResourceGroupResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription list all the provisioning services for a given subscription id. +func (client IotDpsResourceClient) ListBySubscription(ctx context.Context) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client IotDpsResourceClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListBySubscriptionResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listBySubscriptionNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListKeys list the primary and secondary keys for a provisioning service. +// Parameters: +// provisioningServiceName - the provisioning service name to get the shared access keys for. +// resourceGroupName - resource group name +func (client IotDpsResourceClient) ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.sasarlr.Response.Response != nil { + sc = result.sasarlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listKeysNextResults + req, err := client.ListKeysPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.sasarlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure sending request") + return + } + + result.sasarlr, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure responding to request") + return + } + if result.sasarlr.hasNextLink() && result.sasarlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client IotDpsResourceClient) ListKeysPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listKeysNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listKeysNextResults(ctx context.Context, lastResults SharedAccessSignatureAuthorizationRuleListResult) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + req, err := lastResults.sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure sending next results request") + } + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListKeysComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListKeys(ctx, provisioningServiceName, resourceGroupName) + return +} + +// ListKeysForKeyName list primary and secondary keys for a specific key name +// Parameters: +// provisioningServiceName - name of the provisioning service. +// keyName - logical key name to get key-values for. +// resourceGroupName - the name of the resource group that contains the provisioning service. +func (client IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeysForKeyName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysForKeyNamePreparer(ctx, provisioningServiceName, keyName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysForKeyNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure sending request") + return + } + + result, err = client.ListKeysForKeyNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysForKeyNamePreparer prepares the ListKeysForKeyName request. +func (client IotDpsResourceClient) ListKeysForKeyNamePreparer(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysForKeyNameSender sends the ListKeysForKeyName request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysForKeyNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysForKeyNameResponder handles the response to the ListKeysForKeyName request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysForKeyNameResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListValidSkus gets the list of valid SKUs and tiers for a provisioning service. +// Parameters: +// provisioningServiceName - name of provisioning service. +// resourceGroupName - name of resource group. +func (client IotDpsResourceClient) ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.idsdlr.Response.Response != nil { + sc = result.idsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listValidSkusNextResults + req, err := client.ListValidSkusPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.idsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure sending request") + return + } + + result.idsdlr, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure responding to request") + return + } + if result.idsdlr.hasNextLink() && result.idsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListValidSkusPreparer prepares the ListValidSkus request. +func (client IotDpsResourceClient) ListValidSkusPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListValidSkusSender sends the ListValidSkus request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListValidSkusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListValidSkusResponder handles the response to the ListValidSkus request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListValidSkusResponder(resp *http.Response) (result IotDpsSkuDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listValidSkusNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listValidSkusNextResults(ctx context.Context, lastResults IotDpsSkuDefinitionListResult) (result IotDpsSkuDefinitionListResult, err error) { + req, err := lastResults.iotDpsSkuDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListValidSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListValidSkus(ctx, provisioningServiceName, resourceGroupName) + return +} + +// Update update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// provisioningServiceTags - updated tag information to set into the provisioning service instance. +func (client IotDpsResourceClient) Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (result IotDpsResourceUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, provisioningServiceName, provisioningServiceTags) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotDpsResourceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(provisioningServiceTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) UpdateSender(req *http.Request) (future IotDpsResourceUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) UpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/iothubapi/interfaces.go b/services/provisioningservices/mgmt/2020-01-01/iothub/iothubapi/interfaces.go new file mode 100644 index 000000000000..466972efb6f7 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/iothubapi/interfaces.go @@ -0,0 +1,55 @@ +package iothubapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2020-01-01/iothub" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result iothub.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result iothub.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*iothub.OperationsClient)(nil) + +// DpsCertificateClientAPI contains the set of methods on the DpsCertificateClient type. +type DpsCertificateClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription iothub.CertificateBodyDescription, ifMatch string) (result iothub.CertificateResponse, err error) + Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) + GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.VerificationCodeResponse, err error) + Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result iothub.CertificateResponse, err error) + List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result iothub.CertificateListDescription, err error) + VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request iothub.VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.CertificateResponse, err error) +} + +var _ DpsCertificateClientAPI = (*iothub.DpsCertificateClient)(nil) + +// IotDpsResourceClientAPI contains the set of methods on the IotDpsResourceClient type. +type IotDpsResourceClientAPI interface { + CheckProvisioningServiceNameAvailability(ctx context.Context, arguments iothub.OperationInputs) (result iothub.NameAvailabilityInfo, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription iothub.ProvisioningServiceDescription) (result iothub.IotDpsResourceCreateOrUpdateFuture, err error) + Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsResourceDeleteFuture, err error) + Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.ProvisioningServiceDescription, err error) + GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result iothub.AsyncOperationResult, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListBySubscription(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultPage, err error) + ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultIterator, err error) + ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) + ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultPage, err error) + ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags iothub.TagsResource) (result iothub.IotDpsResourceUpdateFuture, err error) +} + +var _ IotDpsResourceClientAPI = (*iothub.IotDpsResourceClient)(nil) diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/models.go b/services/provisioningservices/mgmt/2020-01-01/iothub/models.go new file mode 100644 index 000000000000..7b0c8ac2c1cc --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/models.go @@ -0,0 +1,1229 @@ +package iothub + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2020-01-01/iothub" + +// AsyncOperationResult result of a long running operation. +type AsyncOperationResult struct { + autorest.Response `json:"-"` + // Status - current status of a long running operation. + Status *string `json:"status,omitempty"` + // Error - Error message containing code, description and details + Error *ErrorMesssage `json:"error,omitempty"` +} + +// CertificateBodyDescription the JSON-serialized X509 Certificate. +type CertificateBodyDescription struct { + // Certificate - Base-64 representation of the X509 leaf certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` +} + +// CertificateListDescription the JSON-serialized array of Certificate objects. +type CertificateListDescription struct { + autorest.Response `json:"-"` + // Value - The array of Certificate objects. + Value *[]CertificateResponse `json:"value,omitempty"` +} + +// CertificateProperties the description of an X509 CA Certificate. +type CertificateProperties struct { + // Subject - READ-ONLY; The certificate's subject name. + Subject *string `json:"subject,omitempty"` + // Expiry - READ-ONLY; The certificate's expiration date and time. + Expiry *date.TimeRFC1123 `json:"expiry,omitempty"` + // Thumbprint - READ-ONLY; The certificate's thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - READ-ONLY; Determines whether certificate has been verified. + IsVerified *bool `json:"isVerified,omitempty"` + // Certificate - READ-ONLY; base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *[]byte `json:"certificate,omitempty"` + // Created - READ-ONLY; The certificate's creation date and time. + Created *date.TimeRFC1123 `json:"created,omitempty"` + // Updated - READ-ONLY; The certificate's last update date and time. + Updated *date.TimeRFC1123 `json:"updated,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateProperties. +func (cp CertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CertificateResponse the X509 Certificate. +type CertificateResponse struct { + autorest.Response `json:"-"` + // Properties - properties of a certificate + Properties *CertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; The entity tag. + Etag *string `json:"etag,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateResponse. +func (cr CertificateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Properties != nil { + objectMap["properties"] = cr.Properties + } + return json.Marshal(objectMap) +} + +// DefinitionDescription description of the IoT hub. +type DefinitionDescription struct { + // ApplyAllocationPolicy - flag for applying allocationPolicy or not for a given iot hub. + ApplyAllocationPolicy *bool `json:"applyAllocationPolicy,omitempty"` + // AllocationWeight - weight to apply for a given iot h. + AllocationWeight *int32 `json:"allocationWeight,omitempty"` + // Name - READ-ONLY; Host name of the IoT hub. + Name *string `json:"name,omitempty"` + // ConnectionString - Connection string og the IoT hub. + ConnectionString *string `json:"connectionString,omitempty"` + // Location - ARM region of the IoT hub. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DefinitionDescription. +func (dd DefinitionDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dd.ApplyAllocationPolicy != nil { + objectMap["applyAllocationPolicy"] = dd.ApplyAllocationPolicy + } + if dd.AllocationWeight != nil { + objectMap["allocationWeight"] = dd.AllocationWeight + } + if dd.ConnectionString != nil { + objectMap["connectionString"] = dd.ConnectionString + } + if dd.Location != nil { + objectMap["location"] = dd.Location + } + return json.Marshal(objectMap) +} + +// ErrorDetails error details. +type ErrorDetails struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // HTTPStatusCode - READ-ONLY; The HTTP status code. + HTTPStatusCode *string `json:"httpStatusCode,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; The error details. + Details *string `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorMesssage error response containing message and code. +type ErrorMesssage struct { + // Code - standard error code + Code *string `json:"code,omitempty"` + // Message - standard error description + Message *string `json:"message,omitempty"` + // Details - detailed summary of error + Details *string `json:"details,omitempty"` +} + +// IotDpsPropertiesDescription the service specific properties of a provisioning service, including keys, +// linked iot hubs, current state, and system generated properties such as hostname and idScope +type IotDpsPropertiesDescription struct { + // State - Current state of the provisioning service. Possible values include: 'Activating', 'Active', 'Deleting', 'Deleted', 'ActivationFailed', 'DeletionFailed', 'Transitioning', 'Suspending', 'Suspended', 'Resuming', 'FailingOver', 'FailoverFailed' + State State `json:"state,omitempty"` + // IPFilterRules - The IP filter rules. + IPFilterRules *[]IPFilterRule `json:"ipFilterRules,omitempty"` + // ProvisioningState - The ARM provisioning state of the provisioning service. + ProvisioningState *string `json:"provisioningState,omitempty"` + // IotHubs - List of IoT hubs associated with this provisioning service. + IotHubs *[]DefinitionDescription `json:"iotHubs,omitempty"` + // AllocationPolicy - Allocation policy to be used by this provisioning service. Possible values include: 'Hashed', 'GeoLatency', 'Static' + AllocationPolicy AllocationPolicy `json:"allocationPolicy,omitempty"` + // ServiceOperationsHostName - READ-ONLY; Service endpoint for provisioning service. + ServiceOperationsHostName *string `json:"serviceOperationsHostName,omitempty"` + // DeviceProvisioningHostName - READ-ONLY; Device endpoint for this provisioning service. + DeviceProvisioningHostName *string `json:"deviceProvisioningHostName,omitempty"` + // IDScope - READ-ONLY; Unique identifier of this provisioning service. + IDScope *string `json:"idScope,omitempty"` + // AuthorizationPolicies - List of authorization keys for a provisioning service. + AuthorizationPolicies *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"authorizationPolicies,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsPropertiesDescription. +func (idpd IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idpd.State != "" { + objectMap["state"] = idpd.State + } + if idpd.IPFilterRules != nil { + objectMap["ipFilterRules"] = idpd.IPFilterRules + } + if idpd.ProvisioningState != nil { + objectMap["provisioningState"] = idpd.ProvisioningState + } + if idpd.IotHubs != nil { + objectMap["iotHubs"] = idpd.IotHubs + } + if idpd.AllocationPolicy != "" { + objectMap["allocationPolicy"] = idpd.AllocationPolicy + } + if idpd.AuthorizationPolicies != nil { + objectMap["authorizationPolicies"] = idpd.AuthorizationPolicies + } + return json.Marshal(objectMap) +} + +// IotDpsResourceCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type IotDpsResourceCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceCreateOrUpdateFuture.Result. +func (future *IotDpsResourceCreateOrUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.CreateOrUpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceDeleteFuture.Result. +func (future *IotDpsResourceDeleteFuture) result(client IotDpsResourceClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// IotDpsResourceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceUpdateFuture.Result. +func (future *IotDpsResourceUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.UpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsSkuDefinition available SKUs of tier and units. +type IotDpsSkuDefinition struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` +} + +// IotDpsSkuDefinitionListResult list of available SKUs. +type IotDpsSkuDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of SKUs + Value *[]IotDpsSkuDefinition `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuDefinitionListResult. +func (idsdlr IotDpsSkuDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsdlr.Value != nil { + objectMap["value"] = idsdlr.Value + } + return json.Marshal(objectMap) +} + +// IotDpsSkuDefinitionListResultIterator provides access to a complete listing of IotDpsSkuDefinition +// values. +type IotDpsSkuDefinitionListResultIterator struct { + i int + page IotDpsSkuDefinitionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotDpsSkuDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotDpsSkuDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotDpsSkuDefinitionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotDpsSkuDefinitionListResultIterator) Response() IotDpsSkuDefinitionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotDpsSkuDefinitionListResultIterator) Value() IotDpsSkuDefinition { + if !iter.page.NotDone() { + return IotDpsSkuDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultIterator type. +func NewIotDpsSkuDefinitionListResultIterator(page IotDpsSkuDefinitionListResultPage) IotDpsSkuDefinitionListResultIterator { + return IotDpsSkuDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (idsdlr IotDpsSkuDefinitionListResult) IsEmpty() bool { + return idsdlr.Value == nil || len(*idsdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (idsdlr IotDpsSkuDefinitionListResult) hasNextLink() bool { + return idsdlr.NextLink != nil && len(*idsdlr.NextLink) != 0 +} + +// iotDpsSkuDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (idsdlr IotDpsSkuDefinitionListResult) iotDpsSkuDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !idsdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(idsdlr.NextLink))) +} + +// IotDpsSkuDefinitionListResultPage contains a page of IotDpsSkuDefinition values. +type IotDpsSkuDefinitionListResultPage struct { + fn func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error) + idsdlr IotDpsSkuDefinitionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotDpsSkuDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.idsdlr) + if err != nil { + return err + } + page.idsdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotDpsSkuDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotDpsSkuDefinitionListResultPage) NotDone() bool { + return !page.idsdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotDpsSkuDefinitionListResultPage) Response() IotDpsSkuDefinitionListResult { + return page.idsdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotDpsSkuDefinitionListResultPage) Values() []IotDpsSkuDefinition { + if page.idsdlr.IsEmpty() { + return nil + } + return *page.idsdlr.Value +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultPage type. +func NewIotDpsSkuDefinitionListResultPage(cur IotDpsSkuDefinitionListResult, getNextPage func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error)) IotDpsSkuDefinitionListResultPage { + return IotDpsSkuDefinitionListResultPage{ + fn: getNextPage, + idsdlr: cur, + } +} + +// IotDpsSkuInfo list of possible provisioning service SKUs. +type IotDpsSkuInfo struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` + // Tier - READ-ONLY; Pricing tier name of the provisioning service. + Tier *string `json:"tier,omitempty"` + // Capacity - The number of units to provision + Capacity *int64 `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuInfo. +func (idsi IotDpsSkuInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsi.Name != "" { + objectMap["name"] = idsi.Name + } + if idsi.Capacity != nil { + objectMap["capacity"] = idsi.Capacity + } + return json.Marshal(objectMap) +} + +// IPFilterRule the IP filter rules for the IoT dps. +type IPFilterRule struct { + // FilterName - The name of the IP filter rule. + FilterName *string `json:"filterName,omitempty"` + // Action - The desired action for requests captured by this rule. Possible values include: 'Accept', 'Reject' + Action IPFilterActionType `json:"action,omitempty"` + // IPMask - A string that contains the IP address range in CIDR notation for the rule. + IPMask *string `json:"ipMask,omitempty"` + // Target - Target for requests captured by this rule. Possible values include: 'All', 'ServiceAPI', 'DeviceAPI' + Target IPFilterTargetType `json:"target,omitempty"` +} + +// NameAvailabilityInfo description of name availability. +type NameAvailabilityInfo struct { + autorest.Response `json:"-"` + // NameAvailable - specifies if a name is available or not + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - specifies the reason a name is unavailable. Possible values include: 'Invalid', 'AlreadyExists' + Reason NameUnavailabilityReason `json:"reason,omitempty"` + // Message - message containing a detailed reason name is unavailable + Message *string `json:"message,omitempty"` +} + +// Operation ioT Hub REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft Devices. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: ProvisioningServices. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation. + Operation *string `json:"operation,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationInputs input values for operation results call. +type OperationInputs struct { + // Name - The name of the Provisioning Service to check. + Name *string `json:"name,omitempty"` +} + +// OperationListResult result of the request to list IoT Hub operations. It contains a list of operations +// and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of IoT Hub operations supported by the Microsoft.Devices resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// ProvisioningServiceDescription the description of the provisioning service. +type ProvisioningServiceDescription struct { + autorest.Response `json:"-"` + // Etag - The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. + Etag *string `json:"etag,omitempty"` + // Properties - Service specific properties for a provisioning service + Properties *IotDpsPropertiesDescription `json:"properties,omitempty"` + // Sku - Sku info for a provisioning Service. + Sku *IotDpsSkuInfo `json:"sku,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescription. +func (psd ProvisioningServiceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psd.Etag != nil { + objectMap["etag"] = psd.Etag + } + if psd.Properties != nil { + objectMap["properties"] = psd.Properties + } + if psd.Sku != nil { + objectMap["sku"] = psd.Sku + } + if psd.Location != nil { + objectMap["location"] = psd.Location + } + if psd.Tags != nil { + objectMap["tags"] = psd.Tags + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResult list of provisioning service descriptions. +type ProvisioningServiceDescriptionListResult struct { + autorest.Response `json:"-"` + // Value - List of provisioning service descriptions. + Value *[]ProvisioningServiceDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; the next link + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescriptionListResult. +func (psdlr ProvisioningServiceDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psdlr.Value != nil { + objectMap["value"] = psdlr.Value + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResultIterator provides access to a complete listing of +// ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultIterator struct { + i int + page ProvisioningServiceDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProvisioningServiceDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProvisioningServiceDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProvisioningServiceDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProvisioningServiceDescriptionListResultIterator) Response() ProvisioningServiceDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProvisioningServiceDescriptionListResultIterator) Value() ProvisioningServiceDescription { + if !iter.page.NotDone() { + return ProvisioningServiceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultIterator type. +func NewProvisioningServiceDescriptionListResultIterator(page ProvisioningServiceDescriptionListResultPage) ProvisioningServiceDescriptionListResultIterator { + return ProvisioningServiceDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (psdlr ProvisioningServiceDescriptionListResult) IsEmpty() bool { + return psdlr.Value == nil || len(*psdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (psdlr ProvisioningServiceDescriptionListResult) hasNextLink() bool { + return psdlr.NextLink != nil && len(*psdlr.NextLink) != 0 +} + +// provisioningServiceDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (psdlr ProvisioningServiceDescriptionListResult) provisioningServiceDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !psdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(psdlr.NextLink))) +} + +// ProvisioningServiceDescriptionListResultPage contains a page of ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultPage struct { + fn func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error) + psdlr ProvisioningServiceDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProvisioningServiceDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.psdlr) + if err != nil { + return err + } + page.psdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProvisioningServiceDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProvisioningServiceDescriptionListResultPage) NotDone() bool { + return !page.psdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProvisioningServiceDescriptionListResultPage) Response() ProvisioningServiceDescriptionListResult { + return page.psdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProvisioningServiceDescriptionListResultPage) Values() []ProvisioningServiceDescription { + if page.psdlr.IsEmpty() { + return nil + } + return *page.psdlr.Value +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultPage type. +func NewProvisioningServiceDescriptionListResultPage(cur ProvisioningServiceDescriptionListResult, getNextPage func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error)) ProvisioningServiceDescriptionListResultPage { + return ProvisioningServiceDescriptionListResultPage{ + fn: getNextPage, + psdlr: cur, + } +} + +// Resource the common properties of an Azure resource. +type Resource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription description of the shared access key. +type SharedAccessSignatureAuthorizationRuleAccessRightsDescription struct { + autorest.Response `json:"-"` + // KeyName - Name of the key. + KeyName *string `json:"keyName,omitempty"` + // PrimaryKey - Primary SAS key value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary SAS key value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // Rights - Rights that this key has. Possible values include: 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', 'DeviceConnect', 'RegistrationStatusRead', 'RegistrationStatusWrite' + Rights AccessRightsDescription `json:"rights,omitempty"` +} + +// SharedAccessSignatureAuthorizationRuleListResult list of shared access keys. +type SharedAccessSignatureAuthorizationRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of shared access policies. + Value *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedAccessSignatureAuthorizationRuleListResult. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sasarlr.Value != nil { + objectMap["value"] = sasarlr.Value + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleListResultIterator provides access to a complete listing of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultIterator struct { + i int + page SharedAccessSignatureAuthorizationRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Response() SharedAccessSignatureAuthorizationRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Value() SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if !iter.page.NotDone() { + return SharedAccessSignatureAuthorizationRuleAccessRightsDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultIterator type. +func NewSharedAccessSignatureAuthorizationRuleListResultIterator(page SharedAccessSignatureAuthorizationRuleListResultPage) SharedAccessSignatureAuthorizationRuleListResultIterator { + return SharedAccessSignatureAuthorizationRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) IsEmpty() bool { + return sasarlr.Value == nil || len(*sasarlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) hasNextLink() bool { + return sasarlr.NextLink != nil && len(*sasarlr.NextLink) != 0 +} + +// sharedAccessSignatureAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sasarlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sasarlr.NextLink))) +} + +// SharedAccessSignatureAuthorizationRuleListResultPage contains a page of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultPage struct { + fn func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error) + sasarlr SharedAccessSignatureAuthorizationRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sasarlr) + if err != nil { + return err + } + page.sasarlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) NotDone() bool { + return !page.sasarlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Response() SharedAccessSignatureAuthorizationRuleListResult { + return page.sasarlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Values() []SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if page.sasarlr.IsEmpty() { + return nil + } + return *page.sasarlr.Value +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultPage type. +func NewSharedAccessSignatureAuthorizationRuleListResultPage(cur SharedAccessSignatureAuthorizationRuleListResult, getNextPage func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error)) SharedAccessSignatureAuthorizationRuleListResultPage { + return SharedAccessSignatureAuthorizationRuleListResultPage{ + fn: getNextPage, + sasarlr: cur, + } +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// Provisioning Service instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// VerificationCodeRequest the JSON-serialized leaf certificate +type VerificationCodeRequest struct { + // Certificate - base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` +} + +// VerificationCodeResponse description of the response of the verification code. +type VerificationCodeResponse struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Name of certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; Request etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + Properties *VerificationCodeResponseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VerificationCodeResponse. +func (vcr VerificationCodeResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcr.Properties != nil { + objectMap["properties"] = vcr.Properties + } + return json.Marshal(objectMap) +} + +// VerificationCodeResponseProperties ... +type VerificationCodeResponseProperties struct { + // VerificationCode - Verification code. + VerificationCode *string `json:"verificationCode,omitempty"` + // Subject - Certificate subject. + Subject *string `json:"subject,omitempty"` + // Expiry - Code expiry. + Expiry *string `json:"expiry,omitempty"` + // Thumbprint - Certificate thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - Indicate if the certificate is verified by owner of private key. + IsVerified *bool `json:"isVerified,omitempty"` + // Created - Certificate created time. + Created *string `json:"created,omitempty"` + // Updated - Certificate updated time. + Updated *string `json:"updated,omitempty"` +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/operations.go b/services/provisioningservices/mgmt/2020-01-01/iothub/operations.go new file mode 100644 index 000000000000..909e01794a78 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/operations.go @@ -0,0 +1,140 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Microsoft.Devices REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Devices/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/provisioningservices/mgmt/2020-01-01/iothub/version.go b/services/provisioningservices/mgmt/2020-01-01/iothub/version.go new file mode 100644 index 000000000000..d63642f96bee --- /dev/null +++ b/services/provisioningservices/mgmt/2020-01-01/iothub/version.go @@ -0,0 +1,19 @@ +package iothub + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " iothub/2020-01-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/CHANGELOG.md b/services/provisioningservices/mgmt/2020-03-01/iothub/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/_meta.json b/services/provisioningservices/mgmt/2020-03-01/iothub/_meta.json new file mode 100644 index 000000000000..05871e9ab59e --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", + "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "tag": "package-2020-03", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2020-03 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/client.go b/services/provisioningservices/mgmt/2020-03-01/iothub/client.go new file mode 100644 index 000000000000..8db18ea21541 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/client.go @@ -0,0 +1,41 @@ +// Package iothub implements the Azure ARM Iothub service API version 2020-03-01. +// +// API for using the Azure IoT Hub Device Provisioning Service features. +package iothub + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Iothub + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Iothub. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/dpscertificate.go b/services/provisioningservices/mgmt/2020-03-01/iothub/dpscertificate.go new file mode 100644 index 000000000000..31f7a9670bfa --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/dpscertificate.go @@ -0,0 +1,628 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DpsCertificateClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type DpsCertificateClient struct { + BaseClient +} + +// NewDpsCertificateClient creates an instance of the DpsCertificateClient client. +func NewDpsCertificateClient(subscriptionID string) DpsCertificateClient { + return NewDpsCertificateClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDpsCertificateClientWithBaseURI creates an instance of the DpsCertificateClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDpsCertificateClientWithBaseURI(baseURI string, subscriptionID string) DpsCertificateClient { + return DpsCertificateClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate add new certificate or update an existing certificate. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - the name of the provisioning service. +// certificateName - the name of the certificate create or update. +// certificateDescription - the certificate body. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +func (client DpsCertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: certificateName, + Constraints: []validation.Constraint{{Target: "certificateName", Name: validation.MaxLength, Rule: 256, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.DpsCertificateClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, certificateName, certificateDescription, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DpsCertificateClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription CertificateBodyDescription, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithJSON(certificateDescription), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) CreateOrUpdateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the specified certificate associated with the Provisioning Service +// Parameters: +// resourceGroupName - resource group identifier. +// ifMatch - eTag of the certificate +// provisioningServiceName - the name of the provisioning service. +// certificateName - this is a mandatory field, and is the logical name of the certificate that the +// provisioning service will access by. +// certificatename - this is optional, and it is the Common Name of the certificate. +// certificaterawBytes - raw data within the certificate. +// certificateisVerified - indicates if certificate has been verified by owner of the private key. +// certificatepurpose - a description that mentions the purpose of the certificate. +// certificatecreated - time the certificate is created. +// certificatelastUpdated - time the certificate is last updated. +// certificatehasPrivateKey - indicates if the certificate contains a private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, ifMatch, provisioningServiceName, certificateName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DpsCertificateClient) DeletePreparer(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// GenerateVerificationCode generate verification code for Proof of Possession. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. This is required to update an existing certificate, and ignored while +// creating a brand new certificate. +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - description mentioning the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result VerificationCodeResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.GenerateVerificationCode") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GenerateVerificationCodePreparer(ctx, certificateName, ifMatch, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request") + return + } + + resp, err := client.GenerateVerificationCodeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure sending request") + return + } + + result, err = client.GenerateVerificationCodeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "GenerateVerificationCode", resp, "Failure responding to request") + return + } + + return +} + +// GenerateVerificationCodePreparer prepares the GenerateVerificationCode request. +func (client DpsCertificateClient) GenerateVerificationCodePreparer(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode", pathParameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GenerateVerificationCodeSender sends the GenerateVerificationCode request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GenerateVerificationCodeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GenerateVerificationCodeResponder handles the response to the GenerateVerificationCode request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GenerateVerificationCodeResponder(resp *http.Response) (result VerificationCodeResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the certificate from the provisioning service. +// Parameters: +// certificateName - name of the certificate to retrieve. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of the provisioning service the certificate is associated with. +// ifMatch - eTag of the certificate. +func (client DpsCertificateClient) Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, certificateName, resourceGroupName, provisioningServiceName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DpsCertificateClient) GetPreparer(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) GetResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the certificates tied to the provisioning service. +// Parameters: +// resourceGroupName - name of resource group. +// provisioningServiceName - name of provisioning service to retrieve certificates for. +func (client DpsCertificateClient) List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result CertificateListDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, resourceGroupName, provisioningServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DpsCertificateClient) ListPreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) ListResponder(resp *http.Response) (result CertificateListDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// VerifyCertificate verifies the certificate's private key possession by providing the leaf cert issued by the +// verifying pre uploaded certificate. +// Parameters: +// certificateName - the mandatory logical name of the certificate, that the provisioning service uses to +// access. +// ifMatch - eTag of the certificate. +// request - the name of the certificate +// resourceGroupName - resource group name. +// provisioningServiceName - provisioning service name. +// certificatename - common Name for the certificate. +// certificaterawBytes - raw data of certificate. +// certificateisVerified - indicates if the certificate has been verified by owner of the private key. +// certificatepurpose - describe the purpose of the certificate. +// certificatecreated - certificate creation time. +// certificatelastUpdated - certificate last updated time. +// certificatehasPrivateKey - indicates if the certificate contains private key. +// certificatenonce - random number generated to indicate Proof of Possession. +func (client DpsCertificateClient) VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result CertificateResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DpsCertificateClient.VerifyCertificate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.VerifyCertificatePreparer(ctx, certificateName, ifMatch, request, resourceGroupName, provisioningServiceName, certificatename, certificaterawBytes, certificateisVerified, certificatepurpose, certificatecreated, certificatelastUpdated, certificatehasPrivateKey, certificatenonce) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.VerifyCertificateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure sending request") + return + } + + result, err = client.VerifyCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.DpsCertificateClient", "VerifyCertificate", resp, "Failure responding to request") + return + } + + return +} + +// VerifyCertificatePreparer prepares the VerifyCertificate request. +func (client DpsCertificateClient) VerifyCertificatePreparer(ctx context.Context, certificateName string, ifMatch string, request VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "certificateName": autorest.Encode("path", certificateName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(certificatename) > 0 { + queryParameters["certificate.name"] = autorest.Encode("query", certificatename) + } + if certificaterawBytes != nil && len(certificaterawBytes) > 0 { + queryParameters["certificate.rawBytes"] = autorest.Encode("query", certificaterawBytes) + } + if certificateisVerified != nil { + queryParameters["certificate.isVerified"] = autorest.Encode("query", *certificateisVerified) + } + if len(string(certificatepurpose)) > 0 { + queryParameters["certificate.purpose"] = autorest.Encode("query", certificatepurpose) + } + if certificatecreated != nil { + queryParameters["certificate.created"] = autorest.Encode("query", *certificatecreated) + } + if certificatelastUpdated != nil { + queryParameters["certificate.lastUpdated"] = autorest.Encode("query", *certificatelastUpdated) + } + if certificatehasPrivateKey != nil { + queryParameters["certificate.hasPrivateKey"] = autorest.Encode("query", *certificatehasPrivateKey) + } + if len(certificatenonce) > 0 { + queryParameters["certificate.nonce"] = autorest.Encode("query", certificatenonce) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify", pathParameters), + autorest.WithJSON(request), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// VerifyCertificateSender sends the VerifyCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client DpsCertificateClient) VerifyCertificateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// VerifyCertificateResponder handles the response to the VerifyCertificate request. The method always +// closes the http.Response Body. +func (client DpsCertificateClient) VerifyCertificateResponder(resp *http.Response) (result CertificateResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/enums.go b/services/provisioningservices/mgmt/2020-03-01/iothub/enums.go new file mode 100644 index 000000000000..05353e81391a --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/enums.go @@ -0,0 +1,191 @@ +package iothub + +// 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. + +// AccessRightsDescription enumerates the values for access rights description. +type AccessRightsDescription string + +const ( + // DeviceConnect ... + DeviceConnect AccessRightsDescription = "DeviceConnect" + // EnrollmentRead ... + EnrollmentRead AccessRightsDescription = "EnrollmentRead" + // EnrollmentWrite ... + EnrollmentWrite AccessRightsDescription = "EnrollmentWrite" + // RegistrationStatusRead ... + RegistrationStatusRead AccessRightsDescription = "RegistrationStatusRead" + // RegistrationStatusWrite ... + RegistrationStatusWrite AccessRightsDescription = "RegistrationStatusWrite" + // ServiceConfig ... + ServiceConfig AccessRightsDescription = "ServiceConfig" +) + +// PossibleAccessRightsDescriptionValues returns an array of possible values for the AccessRightsDescription const type. +func PossibleAccessRightsDescriptionValues() []AccessRightsDescription { + return []AccessRightsDescription{DeviceConnect, EnrollmentRead, EnrollmentWrite, RegistrationStatusRead, RegistrationStatusWrite, ServiceConfig} +} + +// AllocationPolicy enumerates the values for allocation policy. +type AllocationPolicy string + +const ( + // GeoLatency ... + GeoLatency AllocationPolicy = "GeoLatency" + // Hashed ... + Hashed AllocationPolicy = "Hashed" + // Static ... + Static AllocationPolicy = "Static" +) + +// PossibleAllocationPolicyValues returns an array of possible values for the AllocationPolicy const type. +func PossibleAllocationPolicyValues() []AllocationPolicy { + return []AllocationPolicy{GeoLatency, Hashed, Static} +} + +// CertificatePurpose enumerates the values for certificate purpose. +type CertificatePurpose string + +const ( + // ClientAuthentication ... + ClientAuthentication CertificatePurpose = "clientAuthentication" + // ServerAuthentication ... + ServerAuthentication CertificatePurpose = "serverAuthentication" +) + +// PossibleCertificatePurposeValues returns an array of possible values for the CertificatePurpose const type. +func PossibleCertificatePurposeValues() []CertificatePurpose { + return []CertificatePurpose{ClientAuthentication, ServerAuthentication} +} + +// IotDpsSku enumerates the values for iot dps sku. +type IotDpsSku string + +const ( + // S1 ... + S1 IotDpsSku = "S1" +) + +// PossibleIotDpsSkuValues returns an array of possible values for the IotDpsSku const type. +func PossibleIotDpsSkuValues() []IotDpsSku { + return []IotDpsSku{S1} +} + +// IPFilterActionType enumerates the values for ip filter action type. +type IPFilterActionType string + +const ( + // Accept ... + Accept IPFilterActionType = "Accept" + // Reject ... + Reject IPFilterActionType = "Reject" +) + +// PossibleIPFilterActionTypeValues returns an array of possible values for the IPFilterActionType const type. +func PossibleIPFilterActionTypeValues() []IPFilterActionType { + return []IPFilterActionType{Accept, Reject} +} + +// IPFilterTargetType enumerates the values for ip filter target type. +type IPFilterTargetType string + +const ( + // All ... + All IPFilterTargetType = "all" + // DeviceAPI ... + DeviceAPI IPFilterTargetType = "deviceApi" + // ServiceAPI ... + ServiceAPI IPFilterTargetType = "serviceApi" +) + +// PossibleIPFilterTargetTypeValues returns an array of possible values for the IPFilterTargetType const type. +func PossibleIPFilterTargetTypeValues() []IPFilterTargetType { + return []IPFilterTargetType{All, DeviceAPI, ServiceAPI} +} + +// NameUnavailabilityReason enumerates the values for name unavailability reason. +type NameUnavailabilityReason string + +const ( + // AlreadyExists ... + AlreadyExists NameUnavailabilityReason = "AlreadyExists" + // Invalid ... + Invalid NameUnavailabilityReason = "Invalid" +) + +// PossibleNameUnavailabilityReasonValues returns an array of possible values for the NameUnavailabilityReason const type. +func PossibleNameUnavailabilityReasonValues() []NameUnavailabilityReason { + return []NameUnavailabilityReason{AlreadyExists, Invalid} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateLinkServiceConnectionStatus = "Approved" + // Disconnected ... + Disconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // Pending ... + Pending PrivateLinkServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{Approved, Disconnected, Pending, Rejected} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // Disabled ... + Disabled PublicNetworkAccess = "Disabled" + // Enabled ... + Enabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{Disabled, Enabled} +} + +// State enumerates the values for state. +type State string + +const ( + // Activating ... + Activating State = "Activating" + // ActivationFailed ... + ActivationFailed State = "ActivationFailed" + // Active ... + Active State = "Active" + // Deleted ... + Deleted State = "Deleted" + // Deleting ... + Deleting State = "Deleting" + // DeletionFailed ... + DeletionFailed State = "DeletionFailed" + // FailingOver ... + FailingOver State = "FailingOver" + // FailoverFailed ... + FailoverFailed State = "FailoverFailed" + // Resuming ... + Resuming State = "Resuming" + // Suspended ... + Suspended State = "Suspended" + // Suspending ... + Suspending State = "Suspending" + // Transitioning ... + Transitioning State = "Transitioning" +) + +// PossibleStateValues returns an array of possible values for the State const type. +func PossibleStateValues() []State { + return []State{Activating, ActivationFailed, Active, Deleted, Deleting, DeletionFailed, FailingOver, FailoverFailed, Resuming, Suspended, Suspending, Transitioning} +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/iotdpsresource.go b/services/provisioningservices/mgmt/2020-03-01/iothub/iotdpsresource.go new file mode 100644 index 000000000000..535eb1495b3e --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/iotdpsresource.go @@ -0,0 +1,1553 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotDpsResourceClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type IotDpsResourceClient struct { + BaseClient +} + +// NewIotDpsResourceClient creates an instance of the IotDpsResourceClient client. +func NewIotDpsResourceClient(subscriptionID string) IotDpsResourceClient { + return NewIotDpsResourceClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIotDpsResourceClientWithBaseURI creates an instance of the IotDpsResourceClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotDpsResourceClientWithBaseURI(baseURI string, subscriptionID string) IotDpsResourceClient { + return IotDpsResourceClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckProvisioningServiceNameAvailability check if a provisioning service name is available. This will validate if +// the name is syntactically valid and if the name is usable +// Parameters: +// arguments - set the name parameter in the OperationInputs structure to the name of the provisioning service +// to check. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, arguments OperationInputs) (result NameAvailabilityInfo, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CheckProvisioningServiceNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: arguments, + Constraints: []validation.Constraint{{Target: "arguments.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", err.Error()) + } + + req, err := client.CheckProvisioningServiceNameAvailabilityPreparer(ctx, arguments) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckProvisioningServiceNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckProvisioningServiceNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckProvisioningServiceNameAvailabilityPreparer prepares the CheckProvisioningServiceNameAvailability request. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityPreparer(ctx context.Context, arguments OperationInputs) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", pathParameters), + autorest.WithJSON(arguments), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckProvisioningServiceNameAvailabilitySender sends the CheckProvisioningServiceNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckProvisioningServiceNameAvailabilityResponder handles the response to the CheckProvisioningServiceNameAvailability request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CheckProvisioningServiceNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityInfo, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update the metadata of the provisioning service. The usual pattern to modify a property is +// to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values +// in a new body to update the provisioning service. +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// iotDpsDescription - description of the provisioning service to create or update. +func (client IotDpsResourceClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (result IotDpsResourceCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: iotDpsDescription, + Constraints: []validation.Constraint{{Target: "iotDpsDescription.Properties", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotDpsDescription.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, provisioningServiceName, iotDpsDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotDpsResourceClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription ProvisioningServiceDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(iotDpsDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CreateOrUpdateSender(req *http.Request) (future IotDpsResourceCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CreateOrUpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdatePrivateEndpointConnection create or update the status of a private endpoint connection with the +// specified name +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +// privateEndpointConnection - the private endpoint connection with updated properties +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (result IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.CreateOrUpdatePrivateEndpointConnection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: privateEndpointConnection, + Constraints: []validation.Constraint{{Target: "privateEndpointConnection.Properties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateEndpointConnection.Properties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "privateEndpointConnection.Properties.PrivateLinkServiceConnectionState.Description", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { + return result, validation.NewError("iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", err.Error()) + } + + req, err := client.CreateOrUpdatePrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdatePrivateEndpointConnectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePrivateEndpointConnectionPreparer prepares the CreateOrUpdatePrivateEndpointConnection request. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdatePrivateEndpointConnectionSender sends the CreateOrUpdatePrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionSender(req *http.Request) (future IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdatePrivateEndpointConnectionResponder handles the response to the CreateOrUpdatePrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the Provisioning Service. +// Parameters: +// provisioningServiceName - name of provisioning service to delete. +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsResourceDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotDpsResourceClient) DeletePreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) DeleteSender(req *http.Request) (future IotDpsResourceDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeletePrivateEndpointConnection delete private endpoint connection with the specified name +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +func (client IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.DeletePrivateEndpointConnection") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") + return + } + + result, err = client.DeletePrivateEndpointConnectionSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "DeletePrivateEndpointConnection", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePrivateEndpointConnectionPreparer prepares the DeletePrivateEndpointConnection request. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeletePrivateEndpointConnectionSender sends the DeletePrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionSender(req *http.Request) (future IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeletePrivateEndpointConnectionResponder handles the response to the DeletePrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) DeletePrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the metadata of the provisioning service without SAS keys. +// Parameters: +// provisioningServiceName - name of the provisioning service to retrieve. +// resourceGroupName - resource group name. +func (client IotDpsResourceClient) Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result ProvisioningServiceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotDpsResourceClient) GetPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetOperationResult gets the status of a long running operation, such as create, update or delete a provisioning +// service. +// Parameters: +// operationID - operation id corresponding to long running operation. Use this to poll for the status. +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service that the operation is running on. +// asyncinfo - async header used to poll on the status of the operation, obtained while creating the long +// running operation. +func (client IotDpsResourceClient) GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result AsyncOperationResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetOperationResult") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetOperationResultPreparer(ctx, operationID, resourceGroupName, provisioningServiceName, asyncinfo) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", nil, "Failure preparing request") + return + } + + resp, err := client.GetOperationResultSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure sending request") + return + } + + result, err = client.GetOperationResultResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetOperationResult", resp, "Failure responding to request") + return + } + + return +} + +// GetOperationResultPreparer prepares the GetOperationResult request. +func (client IotDpsResourceClient) GetOperationResultPreparer(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "asyncinfo": autorest.Encode("query", asyncinfo), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetOperationResultSender sends the GetOperationResult request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetOperationResultSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetOperationResultResponder handles the response to the GetOperationResult request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetOperationResultResponder(resp *http.Response) (result AsyncOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPrivateEndpointConnection get private endpoint connection properties +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// privateEndpointConnectionName - the name of the private endpoint connection +func (client IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetPrivateEndpointConnection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPrivateEndpointConnectionPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") + return + } + + resp, err := client.GetPrivateEndpointConnectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", resp, "Failure sending request") + return + } + + result, err = client.GetPrivateEndpointConnectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateEndpointConnection", resp, "Failure responding to request") + return + } + + return +} + +// GetPrivateEndpointConnectionPreparer prepares the GetPrivateEndpointConnection request. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPrivateEndpointConnectionSender sends the GetPrivateEndpointConnection request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPrivateEndpointConnectionResponder handles the response to the GetPrivateEndpointConnection request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetPrivateEndpointConnectionResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPrivateLinkResources get the specified private link resource for the given provisioning service +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +// groupID - the name of the private link resource +func (client IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (result GroupIDInformation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.GetPrivateLinkResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPrivateLinkResourcesPreparer(ctx, resourceGroupName, resourceName, groupID) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", nil, "Failure preparing request") + return + } + + resp, err := client.GetPrivateLinkResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", resp, "Failure sending request") + return + } + + result, err = client.GetPrivateLinkResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "GetPrivateLinkResources", resp, "Failure responding to request") + return + } + + return +} + +// GetPrivateLinkResourcesPreparer prepares the GetPrivateLinkResources request. +func (client IotDpsResourceClient) GetPrivateLinkResourcesPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupId": autorest.Encode("path", groupID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetPrivateLinkResourcesSender sends the GetPrivateLinkResources request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) GetPrivateLinkResourcesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetPrivateLinkResourcesResponder handles the response to the GetPrivateLinkResources request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) GetPrivateLinkResourcesResponder(resp *http.Response) (result GroupIDInformation, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup get a list of all provisioning services in the given resource group. +// Parameters: +// resourceGroupName - resource group identifier. +func (client IotDpsResourceClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client IotDpsResourceClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListByResourceGroupResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listByResourceGroupNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription list all the provisioning services for a given subscription id. +func (client IotDpsResourceClient) ListBySubscription(ctx context.Context) (result ProvisioningServiceDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.psdlr.Response.Response != nil { + sc = result.psdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.psdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.psdlr, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.psdlr.hasNextLink() && result.psdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client IotDpsResourceClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListBySubscriptionResponder(resp *http.Response) (result ProvisioningServiceDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listBySubscriptionNextResults(ctx context.Context, lastResults ProvisioningServiceDescriptionListResult) (result ProvisioningServiceDescriptionListResult, err error) { + req, err := lastResults.provisioningServiceDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context) (result ProvisioningServiceDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// ListKeys list the primary and secondary keys for a provisioning service. +// Parameters: +// provisioningServiceName - the provisioning service name to get the shared access keys for. +// resourceGroupName - resource group name +func (client IotDpsResourceClient) ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.sasarlr.Response.Response != nil { + sc = result.sasarlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listKeysNextResults + req, err := client.ListKeysPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysSender(req) + if err != nil { + result.sasarlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure sending request") + return + } + + result.sasarlr, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeys", resp, "Failure responding to request") + return + } + if result.sasarlr.hasNextLink() && result.sasarlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListKeysPreparer prepares the ListKeys request. +func (client IotDpsResourceClient) ListKeysPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysSender sends the ListKeys request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysResponder handles the response to the ListKeys request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listKeysNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listKeysNextResults(ctx context.Context, lastResults SharedAccessSignatureAuthorizationRuleListResult) (result SharedAccessSignatureAuthorizationRuleListResult, err error) { + req, err := lastResults.sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListKeysSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure sending next results request") + } + result, err = client.ListKeysResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listKeysNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListKeysComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeys") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListKeys(ctx, provisioningServiceName, resourceGroupName) + return +} + +// ListKeysForKeyName list primary and secondary keys for a specific key name +// Parameters: +// provisioningServiceName - name of the provisioning service. +// keyName - logical key name to get key-values for. +// resourceGroupName - the name of the resource group that contains the provisioning service. +func (client IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListKeysForKeyName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListKeysForKeyNamePreparer(ctx, provisioningServiceName, keyName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", nil, "Failure preparing request") + return + } + + resp, err := client.ListKeysForKeyNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure sending request") + return + } + + result, err = client.ListKeysForKeyNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListKeysForKeyName", resp, "Failure responding to request") + return + } + + return +} + +// ListKeysForKeyNamePreparer prepares the ListKeysForKeyName request. +func (client IotDpsResourceClient) ListKeysForKeyNamePreparer(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListKeysForKeyNameSender sends the ListKeysForKeyName request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListKeysForKeyNameSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListKeysForKeyNameResponder handles the response to the ListKeysForKeyName request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListKeysForKeyNameResponder(resp *http.Response) (result SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListPrivateEndpointConnections list private endpoint connection properties +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +func (client IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, resourceGroupName string, resourceName string) (result ListPrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListPrivateEndpointConnections") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPrivateEndpointConnectionsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", nil, "Failure preparing request") + return + } + + resp, err := client.ListPrivateEndpointConnectionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", resp, "Failure sending request") + return + } + + result, err = client.ListPrivateEndpointConnectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateEndpointConnections", resp, "Failure responding to request") + return + } + + return +} + +// ListPrivateEndpointConnectionsPreparer prepares the ListPrivateEndpointConnections request. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPrivateEndpointConnectionsSender sends the ListPrivateEndpointConnections request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPrivateEndpointConnectionsResponder handles the response to the ListPrivateEndpointConnections request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListPrivateEndpointConnectionsResponder(resp *http.Response) (result ListPrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Value), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListPrivateLinkResources list private link resources for the given provisioning service +// Parameters: +// resourceGroupName - the name of the resource group that contains the provisioning service. +// resourceName - the name of the provisioning service. +func (client IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResources, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListPrivateLinkResources") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPrivateLinkResourcesPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", nil, "Failure preparing request") + return + } + + resp, err := client.ListPrivateLinkResourcesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", resp, "Failure sending request") + return + } + + result, err = client.ListPrivateLinkResourcesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListPrivateLinkResources", resp, "Failure responding to request") + return + } + + return +} + +// ListPrivateLinkResourcesPreparer prepares the ListPrivateLinkResources request. +func (client IotDpsResourceClient) ListPrivateLinkResourcesPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListPrivateLinkResourcesSender sends the ListPrivateLinkResources request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListPrivateLinkResourcesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListPrivateLinkResourcesResponder handles the response to the ListPrivateLinkResources request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListPrivateLinkResourcesResponder(resp *http.Response) (result PrivateLinkResources, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListValidSkus gets the list of valid SKUs and tiers for a provisioning service. +// Parameters: +// provisioningServiceName - name of provisioning service. +// resourceGroupName - name of resource group. +func (client IotDpsResourceClient) ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.idsdlr.Response.Response != nil { + sc = result.idsdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listValidSkusNextResults + req, err := client.ListValidSkusPreparer(ctx, provisioningServiceName, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") + return + } + + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.idsdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure sending request") + return + } + + result.idsdlr, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "ListValidSkus", resp, "Failure responding to request") + return + } + if result.idsdlr.hasNextLink() && result.idsdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListValidSkusPreparer prepares the ListValidSkus request. +func (client IotDpsResourceClient) ListValidSkusPreparer(ctx context.Context, provisioningServiceName string, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListValidSkusSender sends the ListValidSkus request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) ListValidSkusSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListValidSkusResponder handles the response to the ListValidSkus request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) ListValidSkusResponder(resp *http.Response) (result IotDpsSkuDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listValidSkusNextResults retrieves the next set of results, if any. +func (client IotDpsResourceClient) listValidSkusNextResults(ctx context.Context, lastResults IotDpsSkuDefinitionListResult) (result IotDpsSkuDefinitionListResult, err error) { + req, err := lastResults.iotDpsSkuDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListValidSkusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure sending next results request") + } + result, err = client.ListValidSkusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "listValidSkusNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListValidSkusComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result IotDpsSkuDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.ListValidSkus") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListValidSkus(ctx, provisioningServiceName, resourceGroupName) + return +} + +// Update update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method +// Parameters: +// resourceGroupName - resource group identifier. +// provisioningServiceName - name of provisioning service to create or update. +// provisioningServiceTags - updated tag information to set into the provisioning service instance. +func (client IotDpsResourceClient) Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (result IotDpsResourceUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsResourceClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, provisioningServiceName, provisioningServiceTags) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotDpsResourceClient) UpdatePreparer(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags TagsResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "provisioningServiceName": autorest.Encode("path", provisioningServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", pathParameters), + autorest.WithJSON(provisioningServiceTags), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotDpsResourceClient) UpdateSender(req *http.Request) (future IotDpsResourceUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotDpsResourceClient) UpdateResponder(resp *http.Response) (result ProvisioningServiceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/iothubapi/interfaces.go b/services/provisioningservices/mgmt/2020-03-01/iothub/iothubapi/interfaces.go new file mode 100644 index 000000000000..ad8b8db2392f --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/iothubapi/interfaces.go @@ -0,0 +1,61 @@ +package iothubapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2020-03-01/iothub" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result iothub.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result iothub.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*iothub.OperationsClient)(nil) + +// DpsCertificateClientAPI contains the set of methods on the DpsCertificateClient type. +type DpsCertificateClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, certificateName string, certificateDescription iothub.CertificateBodyDescription, ifMatch string) (result iothub.CertificateResponse, err error) + Delete(ctx context.Context, resourceGroupName string, ifMatch string, provisioningServiceName string, certificateName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result autorest.Response, err error) + GenerateVerificationCode(ctx context.Context, certificateName string, ifMatch string, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.VerificationCodeResponse, err error) + Get(ctx context.Context, certificateName string, resourceGroupName string, provisioningServiceName string, ifMatch string) (result iothub.CertificateResponse, err error) + List(ctx context.Context, resourceGroupName string, provisioningServiceName string) (result iothub.CertificateListDescription, err error) + VerifyCertificate(ctx context.Context, certificateName string, ifMatch string, request iothub.VerificationCodeRequest, resourceGroupName string, provisioningServiceName string, certificatename string, certificaterawBytes []byte, certificateisVerified *bool, certificatepurpose iothub.CertificatePurpose, certificatecreated *date.Time, certificatelastUpdated *date.Time, certificatehasPrivateKey *bool, certificatenonce string) (result iothub.CertificateResponse, err error) +} + +var _ DpsCertificateClientAPI = (*iothub.DpsCertificateClient)(nil) + +// IotDpsResourceClientAPI contains the set of methods on the IotDpsResourceClient type. +type IotDpsResourceClientAPI interface { + CheckProvisioningServiceNameAvailability(ctx context.Context, arguments iothub.OperationInputs) (result iothub.NameAvailabilityInfo, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, provisioningServiceName string, iotDpsDescription iothub.ProvisioningServiceDescription) (result iothub.IotDpsResourceCreateOrUpdateFuture, err error) + CreateOrUpdatePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection iothub.PrivateEndpointConnection) (result iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture, err error) + Delete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsResourceDeleteFuture, err error) + DeletePrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture, err error) + Get(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.ProvisioningServiceDescription, err error) + GetOperationResult(ctx context.Context, operationID string, resourceGroupName string, provisioningServiceName string, asyncinfo string) (result iothub.AsyncOperationResult, err error) + GetPrivateEndpointConnection(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result iothub.PrivateEndpointConnection, err error) + GetPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string, groupID string) (result iothub.GroupIDInformation, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListBySubscription(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultPage, err error) + ListBySubscriptionComplete(ctx context.Context) (result iothub.ProvisioningServiceDescriptionListResultIterator, err error) + ListKeys(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultPage, err error) + ListKeysComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleListResultIterator, err error) + ListKeysForKeyName(ctx context.Context, provisioningServiceName string, keyName string, resourceGroupName string) (result iothub.SharedAccessSignatureAuthorizationRuleAccessRightsDescription, err error) + ListPrivateEndpointConnections(ctx context.Context, resourceGroupName string, resourceName string) (result iothub.ListPrivateEndpointConnection, err error) + ListPrivateLinkResources(ctx context.Context, resourceGroupName string, resourceName string) (result iothub.PrivateLinkResources, err error) + ListValidSkus(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultPage, err error) + ListValidSkusComplete(ctx context.Context, provisioningServiceName string, resourceGroupName string) (result iothub.IotDpsSkuDefinitionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, provisioningServiceName string, provisioningServiceTags iothub.TagsResource) (result iothub.IotDpsResourceUpdateFuture, err error) +} + +var _ IotDpsResourceClientAPI = (*iothub.IotDpsResourceClient)(nil) diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/models.go b/services/provisioningservices/mgmt/2020-03-01/iothub/models.go new file mode 100644 index 000000000000..e2a3e5c682aa --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/models.go @@ -0,0 +1,1426 @@ +package iothub + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/provisioningservices/mgmt/2020-03-01/iothub" + +// AsyncOperationResult result of a long running operation. +type AsyncOperationResult struct { + autorest.Response `json:"-"` + // Status - current status of a long running operation. + Status *string `json:"status,omitempty"` + // Error - Error message containing code, description and details + Error *ErrorMesssage `json:"error,omitempty"` +} + +// CertificateBodyDescription the JSON-serialized X509 Certificate. +type CertificateBodyDescription struct { + // Certificate - Base-64 representation of the X509 leaf certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` + // IsVerified - True indicates that the certificate will be created in verified state and proof of possession will not be required. + IsVerified *bool `json:"isVerified,omitempty"` +} + +// CertificateListDescription the JSON-serialized array of Certificate objects. +type CertificateListDescription struct { + autorest.Response `json:"-"` + // Value - The array of Certificate objects. + Value *[]CertificateResponse `json:"value,omitempty"` +} + +// CertificateProperties the description of an X509 CA Certificate. +type CertificateProperties struct { + // Subject - READ-ONLY; The certificate's subject name. + Subject *string `json:"subject,omitempty"` + // Expiry - READ-ONLY; The certificate's expiration date and time. + Expiry *date.TimeRFC1123 `json:"expiry,omitempty"` + // Thumbprint - READ-ONLY; The certificate's thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - READ-ONLY; Determines whether certificate has been verified. + IsVerified *bool `json:"isVerified,omitempty"` + // Certificate - READ-ONLY; base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *[]byte `json:"certificate,omitempty"` + // Created - READ-ONLY; The certificate's creation date and time. + Created *date.TimeRFC1123 `json:"created,omitempty"` + // Updated - READ-ONLY; The certificate's last update date and time. + Updated *date.TimeRFC1123 `json:"updated,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateProperties. +func (cp CertificateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CertificateResponse the X509 Certificate. +type CertificateResponse struct { + autorest.Response `json:"-"` + // Properties - properties of a certificate + Properties *CertificateProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; The entity tag. + Etag *string `json:"etag,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CertificateResponse. +func (cr CertificateResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cr.Properties != nil { + objectMap["properties"] = cr.Properties + } + return json.Marshal(objectMap) +} + +// DefinitionDescription description of the IoT hub. +type DefinitionDescription struct { + // ApplyAllocationPolicy - flag for applying allocationPolicy or not for a given iot hub. + ApplyAllocationPolicy *bool `json:"applyAllocationPolicy,omitempty"` + // AllocationWeight - weight to apply for a given iot h. + AllocationWeight *int32 `json:"allocationWeight,omitempty"` + // Name - READ-ONLY; Host name of the IoT hub. + Name *string `json:"name,omitempty"` + // ConnectionString - Connection string of the IoT hub. + ConnectionString *string `json:"connectionString,omitempty"` + // Location - ARM region of the IoT hub. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for DefinitionDescription. +func (dd DefinitionDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dd.ApplyAllocationPolicy != nil { + objectMap["applyAllocationPolicy"] = dd.ApplyAllocationPolicy + } + if dd.AllocationWeight != nil { + objectMap["allocationWeight"] = dd.AllocationWeight + } + if dd.ConnectionString != nil { + objectMap["connectionString"] = dd.ConnectionString + } + if dd.Location != nil { + objectMap["location"] = dd.Location + } + return json.Marshal(objectMap) +} + +// ErrorDetails error details. +type ErrorDetails struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // HTTPStatusCode - READ-ONLY; The HTTP status code. + HTTPStatusCode *string `json:"httpStatusCode,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; The error details. + Details *string `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorMesssage error response containing message and code. +type ErrorMesssage struct { + // Code - standard error code + Code *string `json:"code,omitempty"` + // Message - standard error description + Message *string `json:"message,omitempty"` + // Details - detailed summary of error + Details *string `json:"details,omitempty"` +} + +// GroupIDInformation the group information for creating a private endpoint on a provisioning service +type GroupIDInformation struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Properties - The properties for a group information object + Properties *GroupIDInformationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GroupIDInformation. +func (gii GroupIDInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gii.Properties != nil { + objectMap["properties"] = gii.Properties + } + return json.Marshal(objectMap) +} + +// GroupIDInformationProperties the properties for a group information object +type GroupIDInformationProperties struct { + // GroupID - The group id + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - The required members for a specific group id + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - The required DNS zones for a specific group id + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// IotDpsPropertiesDescription the service specific properties of a provisioning service, including keys, +// linked iot hubs, current state, and system generated properties such as hostname and idScope +type IotDpsPropertiesDescription struct { + // State - Current state of the provisioning service. Possible values include: 'Activating', 'Active', 'Deleting', 'Deleted', 'ActivationFailed', 'DeletionFailed', 'Transitioning', 'Suspending', 'Suspended', 'Resuming', 'FailingOver', 'FailoverFailed' + State State `json:"state,omitempty"` + // PublicNetworkAccess - Whether requests from Public Network are allowed. Possible values include: 'Enabled', 'Disabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // IPFilterRules - The IP filter rules. + IPFilterRules *[]IPFilterRule `json:"ipFilterRules,omitempty"` + // PrivateEndpointConnections - Private endpoint connections created on this IotHub + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // ProvisioningState - The ARM provisioning state of the provisioning service. + ProvisioningState *string `json:"provisioningState,omitempty"` + // IotHubs - List of IoT hubs associated with this provisioning service. + IotHubs *[]DefinitionDescription `json:"iotHubs,omitempty"` + // AllocationPolicy - Allocation policy to be used by this provisioning service. Possible values include: 'Hashed', 'GeoLatency', 'Static' + AllocationPolicy AllocationPolicy `json:"allocationPolicy,omitempty"` + // ServiceOperationsHostName - READ-ONLY; Service endpoint for provisioning service. + ServiceOperationsHostName *string `json:"serviceOperationsHostName,omitempty"` + // DeviceProvisioningHostName - READ-ONLY; Device endpoint for this provisioning service. + DeviceProvisioningHostName *string `json:"deviceProvisioningHostName,omitempty"` + // IDScope - READ-ONLY; Unique identifier of this provisioning service. + IDScope *string `json:"idScope,omitempty"` + // AuthorizationPolicies - List of authorization keys for a provisioning service. + AuthorizationPolicies *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"authorizationPolicies,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsPropertiesDescription. +func (idpd IotDpsPropertiesDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idpd.State != "" { + objectMap["state"] = idpd.State + } + if idpd.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = idpd.PublicNetworkAccess + } + if idpd.IPFilterRules != nil { + objectMap["ipFilterRules"] = idpd.IPFilterRules + } + if idpd.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = idpd.PrivateEndpointConnections + } + if idpd.ProvisioningState != nil { + objectMap["provisioningState"] = idpd.ProvisioningState + } + if idpd.IotHubs != nil { + objectMap["iotHubs"] = idpd.IotHubs + } + if idpd.AllocationPolicy != "" { + objectMap["allocationPolicy"] = idpd.AllocationPolicy + } + if idpd.AuthorizationPolicies != nil { + objectMap["authorizationPolicies"] = idpd.AuthorizationPolicies + } + return json.Marshal(objectMap) +} + +// IotDpsResourceCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type IotDpsResourceCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceCreateOrUpdateFuture.Result. +func (future *IotDpsResourceCreateOrUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.CreateOrUpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture an abstraction for monitoring and retrieving +// the results of a long-running operation. +type IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture.Result. +func (future *IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture) result(client IotDpsResourceClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.CreateOrUpdatePrivateEndpointConnectionResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceCreateOrUpdatePrivateEndpointConnectionFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceDeleteFuture.Result. +func (future *IotDpsResourceDeleteFuture) result(client IotDpsResourceClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// IotDpsResourceDeletePrivateEndpointConnectionFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type IotDpsResourceDeletePrivateEndpointConnectionFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceDeletePrivateEndpointConnectionFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceDeletePrivateEndpointConnectionFuture.Result. +func (future *IotDpsResourceDeletePrivateEndpointConnectionFuture) result(client IotDpsResourceClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pec.Response.Response, err = future.GetResult(sender); err == nil && pec.Response.Response.StatusCode != http.StatusNoContent { + pec, err = client.DeletePrivateEndpointConnectionResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceDeletePrivateEndpointConnectionFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsResourceUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotDpsResourceUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotDpsResourceClient) (ProvisioningServiceDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotDpsResourceUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotDpsResourceUpdateFuture.Result. +func (future *IotDpsResourceUpdateFuture) result(client IotDpsResourceClient) (psd ProvisioningServiceDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + psd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("iothub.IotDpsResourceUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if psd.Response.Response, err = future.GetResult(sender); err == nil && psd.Response.Response.StatusCode != http.StatusNoContent { + psd, err = client.UpdateResponder(psd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.IotDpsResourceUpdateFuture", "Result", psd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDpsSkuDefinition available SKUs of tier and units. +type IotDpsSkuDefinition struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` +} + +// IotDpsSkuDefinitionListResult list of available SKUs. +type IotDpsSkuDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of SKUs + Value *[]IotDpsSkuDefinition `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuDefinitionListResult. +func (idsdlr IotDpsSkuDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsdlr.Value != nil { + objectMap["value"] = idsdlr.Value + } + return json.Marshal(objectMap) +} + +// IotDpsSkuDefinitionListResultIterator provides access to a complete listing of IotDpsSkuDefinition +// values. +type IotDpsSkuDefinitionListResultIterator struct { + i int + page IotDpsSkuDefinitionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotDpsSkuDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotDpsSkuDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotDpsSkuDefinitionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotDpsSkuDefinitionListResultIterator) Response() IotDpsSkuDefinitionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotDpsSkuDefinitionListResultIterator) Value() IotDpsSkuDefinition { + if !iter.page.NotDone() { + return IotDpsSkuDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultIterator type. +func NewIotDpsSkuDefinitionListResultIterator(page IotDpsSkuDefinitionListResultPage) IotDpsSkuDefinitionListResultIterator { + return IotDpsSkuDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (idsdlr IotDpsSkuDefinitionListResult) IsEmpty() bool { + return idsdlr.Value == nil || len(*idsdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (idsdlr IotDpsSkuDefinitionListResult) hasNextLink() bool { + return idsdlr.NextLink != nil && len(*idsdlr.NextLink) != 0 +} + +// iotDpsSkuDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (idsdlr IotDpsSkuDefinitionListResult) iotDpsSkuDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !idsdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(idsdlr.NextLink))) +} + +// IotDpsSkuDefinitionListResultPage contains a page of IotDpsSkuDefinition values. +type IotDpsSkuDefinitionListResultPage struct { + fn func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error) + idsdlr IotDpsSkuDefinitionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotDpsSkuDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotDpsSkuDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.idsdlr) + if err != nil { + return err + } + page.idsdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotDpsSkuDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotDpsSkuDefinitionListResultPage) NotDone() bool { + return !page.idsdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotDpsSkuDefinitionListResultPage) Response() IotDpsSkuDefinitionListResult { + return page.idsdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotDpsSkuDefinitionListResultPage) Values() []IotDpsSkuDefinition { + if page.idsdlr.IsEmpty() { + return nil + } + return *page.idsdlr.Value +} + +// Creates a new instance of the IotDpsSkuDefinitionListResultPage type. +func NewIotDpsSkuDefinitionListResultPage(cur IotDpsSkuDefinitionListResult, getNextPage func(context.Context, IotDpsSkuDefinitionListResult) (IotDpsSkuDefinitionListResult, error)) IotDpsSkuDefinitionListResultPage { + return IotDpsSkuDefinitionListResultPage{ + fn: getNextPage, + idsdlr: cur, + } +} + +// IotDpsSkuInfo list of possible provisioning service SKUs. +type IotDpsSkuInfo struct { + // Name - Sku name. Possible values include: 'S1' + Name IotDpsSku `json:"name,omitempty"` + // Tier - READ-ONLY; Pricing tier name of the provisioning service. + Tier *string `json:"tier,omitempty"` + // Capacity - The number of units to provision + Capacity *int64 `json:"capacity,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotDpsSkuInfo. +func (idsi IotDpsSkuInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if idsi.Name != "" { + objectMap["name"] = idsi.Name + } + if idsi.Capacity != nil { + objectMap["capacity"] = idsi.Capacity + } + return json.Marshal(objectMap) +} + +// IPFilterRule the IP filter rules for a provisioning Service. +type IPFilterRule struct { + // FilterName - The name of the IP filter rule. + FilterName *string `json:"filterName,omitempty"` + // Action - The desired action for requests captured by this rule. Possible values include: 'Accept', 'Reject' + Action IPFilterActionType `json:"action,omitempty"` + // IPMask - A string that contains the IP address range in CIDR notation for the rule. + IPMask *string `json:"ipMask,omitempty"` + // Target - Target for requests captured by this rule. Possible values include: 'All', 'ServiceAPI', 'DeviceAPI' + Target IPFilterTargetType `json:"target,omitempty"` +} + +// ListPrivateEndpointConnection ... +type ListPrivateEndpointConnection struct { + autorest.Response `json:"-"` + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// NameAvailabilityInfo description of name availability. +type NameAvailabilityInfo struct { + autorest.Response `json:"-"` + // NameAvailable - specifies if a name is available or not + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - specifies the reason a name is unavailable. Possible values include: 'Invalid', 'AlreadyExists' + Reason NameUnavailabilityReason `json:"reason,omitempty"` + // Message - message containing a detailed reason name is unavailable + Message *string `json:"message,omitempty"` +} + +// Operation provisioning Service REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft Devices. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: ProvisioningServices. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation. + Operation *string `json:"operation,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationInputs input values for operation results call. +type OperationInputs struct { + // Name - The name of the Provisioning Service to check. + Name *string `json:"name,omitempty"` +} + +// OperationListResult result of the request to list provisioning service operations. It contains a list of +// operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Provisioning service operations supported by the Microsoft.Devices resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PrivateEndpoint the private endpoint property of a private endpoint connection +type PrivateEndpoint struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpoint. +func (peVar PrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection the private endpoint connection of a provisioning service +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Properties - The properties of a private endpoint connection + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.Properties != nil { + objectMap["properties"] = pec.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties the properties of a private endpoint connection +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The private endpoint property of a private endpoint connection + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - The current state of a private endpoint connection + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// PrivateLinkResources the available private link resources for a provisioning service +type PrivateLinkResources struct { + autorest.Response `json:"-"` + // Value - The list of available private link resources for a provisioning service + Value *[]GroupIDInformation `json:"value,omitempty"` +} + +// PrivateLinkServiceConnectionState the current state of a private endpoint connection +type PrivateLinkServiceConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The description for the current state of a private endpoint connection + Description *string `json:"description,omitempty"` + // ActionsRequired - Actions required for a private endpoint connection + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// ProvisioningServiceDescription the description of the provisioning service. +type ProvisioningServiceDescription struct { + autorest.Response `json:"-"` + // Etag - The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. + Etag *string `json:"etag,omitempty"` + // Properties - Service specific properties for a provisioning service + Properties *IotDpsPropertiesDescription `json:"properties,omitempty"` + // Sku - Sku info for a provisioning Service. + Sku *IotDpsSkuInfo `json:"sku,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescription. +func (psd ProvisioningServiceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psd.Etag != nil { + objectMap["etag"] = psd.Etag + } + if psd.Properties != nil { + objectMap["properties"] = psd.Properties + } + if psd.Sku != nil { + objectMap["sku"] = psd.Sku + } + if psd.Location != nil { + objectMap["location"] = psd.Location + } + if psd.Tags != nil { + objectMap["tags"] = psd.Tags + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResult list of provisioning service descriptions. +type ProvisioningServiceDescriptionListResult struct { + autorest.Response `json:"-"` + // Value - List of provisioning service descriptions. + Value *[]ProvisioningServiceDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; the next link + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProvisioningServiceDescriptionListResult. +func (psdlr ProvisioningServiceDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if psdlr.Value != nil { + objectMap["value"] = psdlr.Value + } + return json.Marshal(objectMap) +} + +// ProvisioningServiceDescriptionListResultIterator provides access to a complete listing of +// ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultIterator struct { + i int + page ProvisioningServiceDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProvisioningServiceDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProvisioningServiceDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProvisioningServiceDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProvisioningServiceDescriptionListResultIterator) Response() ProvisioningServiceDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProvisioningServiceDescriptionListResultIterator) Value() ProvisioningServiceDescription { + if !iter.page.NotDone() { + return ProvisioningServiceDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultIterator type. +func NewProvisioningServiceDescriptionListResultIterator(page ProvisioningServiceDescriptionListResultPage) ProvisioningServiceDescriptionListResultIterator { + return ProvisioningServiceDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (psdlr ProvisioningServiceDescriptionListResult) IsEmpty() bool { + return psdlr.Value == nil || len(*psdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (psdlr ProvisioningServiceDescriptionListResult) hasNextLink() bool { + return psdlr.NextLink != nil && len(*psdlr.NextLink) != 0 +} + +// provisioningServiceDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (psdlr ProvisioningServiceDescriptionListResult) provisioningServiceDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !psdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(psdlr.NextLink))) +} + +// ProvisioningServiceDescriptionListResultPage contains a page of ProvisioningServiceDescription values. +type ProvisioningServiceDescriptionListResultPage struct { + fn func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error) + psdlr ProvisioningServiceDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProvisioningServiceDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProvisioningServiceDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.psdlr) + if err != nil { + return err + } + page.psdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProvisioningServiceDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProvisioningServiceDescriptionListResultPage) NotDone() bool { + return !page.psdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProvisioningServiceDescriptionListResultPage) Response() ProvisioningServiceDescriptionListResult { + return page.psdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProvisioningServiceDescriptionListResultPage) Values() []ProvisioningServiceDescription { + if page.psdlr.IsEmpty() { + return nil + } + return *page.psdlr.Value +} + +// Creates a new instance of the ProvisioningServiceDescriptionListResultPage type. +func NewProvisioningServiceDescriptionListResultPage(cur ProvisioningServiceDescriptionListResult, getNextPage func(context.Context, ProvisioningServiceDescriptionListResult) (ProvisioningServiceDescriptionListResult, error)) ProvisioningServiceDescriptionListResultPage { + return ProvisioningServiceDescriptionListResultPage{ + fn: getNextPage, + psdlr: cur, + } +} + +// Resource the common properties of an Azure resource. +type Resource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription description of the shared access key. +type SharedAccessSignatureAuthorizationRuleAccessRightsDescription struct { + autorest.Response `json:"-"` + // KeyName - Name of the key. + KeyName *string `json:"keyName,omitempty"` + // PrimaryKey - Primary SAS key value. + PrimaryKey *string `json:"primaryKey,omitempty"` + // SecondaryKey - Secondary SAS key value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + // Rights - Rights that this key has. Possible values include: 'ServiceConfig', 'EnrollmentRead', 'EnrollmentWrite', 'DeviceConnect', 'RegistrationStatusRead', 'RegistrationStatusWrite' + Rights AccessRightsDescription `json:"rights,omitempty"` +} + +// SharedAccessSignatureAuthorizationRuleListResult list of shared access keys. +type SharedAccessSignatureAuthorizationRuleListResult struct { + autorest.Response `json:"-"` + // Value - The list of shared access policies. + Value *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value,omitempty"` + // NextLink - READ-ONLY; The next link. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for SharedAccessSignatureAuthorizationRuleListResult. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sasarlr.Value != nil { + objectMap["value"] = sasarlr.Value + } + return json.Marshal(objectMap) +} + +// SharedAccessSignatureAuthorizationRuleListResultIterator provides access to a complete listing of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultIterator struct { + i int + page SharedAccessSignatureAuthorizationRuleListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SharedAccessSignatureAuthorizationRuleListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Response() SharedAccessSignatureAuthorizationRuleListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SharedAccessSignatureAuthorizationRuleListResultIterator) Value() SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if !iter.page.NotDone() { + return SharedAccessSignatureAuthorizationRuleAccessRightsDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultIterator type. +func NewSharedAccessSignatureAuthorizationRuleListResultIterator(page SharedAccessSignatureAuthorizationRuleListResultPage) SharedAccessSignatureAuthorizationRuleListResultIterator { + return SharedAccessSignatureAuthorizationRuleListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) IsEmpty() bool { + return sasarlr.Value == nil || len(*sasarlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) hasNextLink() bool { + return sasarlr.NextLink != nil && len(*sasarlr.NextLink) != 0 +} + +// sharedAccessSignatureAuthorizationRuleListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sasarlr SharedAccessSignatureAuthorizationRuleListResult) sharedAccessSignatureAuthorizationRuleListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sasarlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sasarlr.NextLink))) +} + +// SharedAccessSignatureAuthorizationRuleListResultPage contains a page of +// SharedAccessSignatureAuthorizationRuleAccessRightsDescription values. +type SharedAccessSignatureAuthorizationRuleListResultPage struct { + fn func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error) + sasarlr SharedAccessSignatureAuthorizationRuleListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SharedAccessSignatureAuthorizationRuleListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sasarlr) + if err != nil { + return err + } + page.sasarlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SharedAccessSignatureAuthorizationRuleListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) NotDone() bool { + return !page.sasarlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Response() SharedAccessSignatureAuthorizationRuleListResult { + return page.sasarlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SharedAccessSignatureAuthorizationRuleListResultPage) Values() []SharedAccessSignatureAuthorizationRuleAccessRightsDescription { + if page.sasarlr.IsEmpty() { + return nil + } + return *page.sasarlr.Value +} + +// Creates a new instance of the SharedAccessSignatureAuthorizationRuleListResultPage type. +func NewSharedAccessSignatureAuthorizationRuleListResultPage(cur SharedAccessSignatureAuthorizationRuleListResult, getNextPage func(context.Context, SharedAccessSignatureAuthorizationRuleListResult) (SharedAccessSignatureAuthorizationRuleListResult, error)) SharedAccessSignatureAuthorizationRuleListResultPage { + return SharedAccessSignatureAuthorizationRuleListResultPage{ + fn: getNextPage, + sasarlr: cur, + } +} + +// TagsResource a container holding only the Tags for a resource, allowing the user to update the tags on a +// Provisioning Service instance. +type TagsResource struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for TagsResource. +func (tr TagsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + return json.Marshal(objectMap) +} + +// VerificationCodeRequest the JSON-serialized leaf certificate +type VerificationCodeRequest struct { + // Certificate - base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *string `json:"certificate,omitempty"` +} + +// VerificationCodeResponse description of the response of the verification code. +type VerificationCodeResponse struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Name of certificate. + Name *string `json:"name,omitempty"` + // Etag - READ-ONLY; Request etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + Properties *VerificationCodeResponseProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for VerificationCodeResponse. +func (vcr VerificationCodeResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vcr.Properties != nil { + objectMap["properties"] = vcr.Properties + } + return json.Marshal(objectMap) +} + +// VerificationCodeResponseProperties ... +type VerificationCodeResponseProperties struct { + // VerificationCode - Verification code. + VerificationCode *string `json:"verificationCode,omitempty"` + // Subject - Certificate subject. + Subject *string `json:"subject,omitempty"` + // Expiry - Code expiry. + Expiry *string `json:"expiry,omitempty"` + // Thumbprint - Certificate thumbprint. + Thumbprint *string `json:"thumbprint,omitempty"` + // IsVerified - Indicate if the certificate is verified by owner of private key. + IsVerified *bool `json:"isVerified,omitempty"` + // Certificate - base-64 representation of X509 certificate .cer file or just .pem file content. + Certificate *[]byte `json:"certificate,omitempty"` + // Created - Certificate created time. + Created *string `json:"created,omitempty"` + // Updated - Certificate updated time. + Updated *string `json:"updated,omitempty"` +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/operations.go b/services/provisioningservices/mgmt/2020-03-01/iothub/operations.go new file mode 100644 index 000000000000..5b31e9f439ef --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/operations.go @@ -0,0 +1,140 @@ +package iothub + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the API for using the Azure IoT Hub Device Provisioning Service features. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Microsoft.Devices REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Devices/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "iothub.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/provisioningservices/mgmt/2020-03-01/iothub/version.go b/services/provisioningservices/mgmt/2020-03-01/iothub/version.go new file mode 100644 index 000000000000..8c5f95536e86 --- /dev/null +++ b/services/provisioningservices/mgmt/2020-03-01/iothub/version.go @@ -0,0 +1,19 @@ +package iothub + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " iothub/2020-03-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/provisioningservices/mgmt/2021-10-15/iothub/CHANGELOG.md b/services/provisioningservices/mgmt/2021-10-15/iothub/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/provisioningservices/mgmt/2021-10-15/iothub/CHANGELOG.md +++ b/services/provisioningservices/mgmt/2021-10-15/iothub/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/provisioningservices/mgmt/2021-10-15/iothub/_meta.json b/services/provisioningservices/mgmt/2021-10-15/iothub/_meta.json index a0f53f277699..b704cb9a351a 100644 --- a/services/provisioningservices/mgmt/2021-10-15/iothub/_meta.json +++ b/services/provisioningservices/mgmt/2021-10-15/iothub/_meta.json @@ -1,5 +1,5 @@ { - "commit": "932e261a870475e1a29115f62def7bb84e4d7b38", + "commit": "b16a1be91b895ef35d432b103d2e004efdb52e56", "readme": "/_/azure-rest-api-specs/specification/deviceprovisioningservices/resource-manager/readme.md", "tag": "package-2021-10", "use": "@microsoft.azure/autorest.go@2.1.187",