From d9533f5ed512c5443278a3b3017082dd4fa1754d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 8 Jun 2022 01:30:56 +0000 Subject: [PATCH] CodeGen from PR 18728 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.DigitalTwins to add version stable/2022-05-31 (#18728) * Adds base for updating Microsoft.DigitalTwins from version preview/2021-06-30-preview to version 2022-05-31 * Updates readme * Updates API version in new specs and examples * Add additional provisioning states * Update examples to include LRO headers * Add SDK generation configurations --- .../mgmt/2020-10-31/digitaltwins/CHANGELOG.md | 2 +- .../mgmt/2020-10-31/digitaltwins/_meta.json | 2 +- .../mgmt/2020-12-01/digitaltwins/CHANGELOG.md | 2 +- .../mgmt/2020-12-01/digitaltwins/_meta.json | 2 +- .../mgmt/2022-05-31/digitaltwins/CHANGELOG.md | 2 + .../mgmt/2022-05-31/digitaltwins/_meta.json | 11 + .../mgmt/2022-05-31/digitaltwins/client.go | 41 + .../2022-05-31/digitaltwins/digitaltwins.go | 716 ++++++ .../digitaltwinsapi/interfaces.go | 75 + .../mgmt/2022-05-31/digitaltwins/endpoint.go | 442 ++++ .../mgmt/2022-05-31/digitaltwins/enums.go | 261 ++ .../mgmt/2022-05-31/digitaltwins/models.go | 2192 +++++++++++++++++ .../2022-05-31/digitaltwins/operations.go | 140 ++ .../privateendpointconnections.go | 397 +++ .../digitaltwins/privatelinkresources.go | 207 ++ .../timeseriesdatabaseconnections.go | 443 ++++ .../mgmt/2022-05-31/digitaltwins/version.go | 19 + .../digitaltwins/CHANGELOG.md | 2 +- .../digitaltwins/_meta.json | 2 +- .../digitaltwins/CHANGELOG.md | 2 + .../digitaltwins/_meta.json | 11 + .../2021-06-30-preview/digitaltwins/client.go | 41 + .../digitaltwins/digitaltwins.go | 716 ++++++ .../digitaltwinsapi/interfaces.go | 75 + .../digitaltwins/endpoint.go | 442 ++++ .../2021-06-30-preview/digitaltwins/enums.go | 257 ++ .../2021-06-30-preview/digitaltwins/models.go | 2192 +++++++++++++++++ .../digitaltwins/operations.go | 140 ++ .../privateendpointconnections.go | 397 +++ .../digitaltwins/privatelinkresources.go | 207 ++ .../timeseriesdatabaseconnections.go | 443 ++++ .../digitaltwins/version.go | 19 + 32 files changed, 9894 insertions(+), 6 deletions(-) create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/CHANGELOG.md create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/_meta.json create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/client.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwins.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwinsapi/interfaces.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/endpoint.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/enums.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/models.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/operations.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/privateendpointconnections.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/privatelinkresources.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/timeseriesdatabaseconnections.go create mode 100644 services/digitaltwins/mgmt/2022-05-31/digitaltwins/version.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/CHANGELOG.md create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/_meta.json create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/client.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwins.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwinsapi/interfaces.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/endpoint.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/enums.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/models.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/operations.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privateendpointconnections.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privatelinkresources.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/timeseriesdatabaseconnections.go create mode 100644 services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/version.go diff --git a/services/digitaltwins/mgmt/2020-10-31/digitaltwins/CHANGELOG.md b/services/digitaltwins/mgmt/2020-10-31/digitaltwins/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/digitaltwins/mgmt/2020-10-31/digitaltwins/CHANGELOG.md +++ b/services/digitaltwins/mgmt/2020-10-31/digitaltwins/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/digitaltwins/mgmt/2020-10-31/digitaltwins/_meta.json b/services/digitaltwins/mgmt/2020-10-31/digitaltwins/_meta.json index 3a116b1de2f4..8ec2b2885ca8 100644 --- a/services/digitaltwins/mgmt/2020-10-31/digitaltwins/_meta.json +++ b/services/digitaltwins/mgmt/2020-10-31/digitaltwins/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "360b1d56294cdc384a4f48d187c3da90f2826895", "readme": "/_/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md", "tag": "package-2020-10", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/CHANGELOG.md b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/CHANGELOG.md +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/_meta.json b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/_meta.json index 45dba55c3365..2a0c09806c3c 100644 --- a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/_meta.json +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/_meta.json @@ -1,5 +1,5 @@ { - "commit": "d9506558e6389e62926ae385f1d625a1376a0f9d", + "commit": "360b1d56294cdc384a4f48d187c3da90f2826895", "readme": "/_/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md", "tag": "package-2020-12", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/CHANGELOG.md b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/_meta.json b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/_meta.json new file mode 100644 index 000000000000..c88771ac7dd9 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "360b1d56294cdc384a4f48d187c3da90f2826895", + "readme": "/_/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md", + "tag": "package-2022-05", + "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-2022-05 --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/digitaltwins/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/digitaltwins/mgmt/2022-05-31/digitaltwins/client.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/client.go new file mode 100644 index 000000000000..30e461f1ccf3 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/client.go @@ -0,0 +1,41 @@ +// Package digitaltwins implements the Azure ARM Digitaltwins service API version 2022-05-31. +// +// Azure Digital Twins Client for managing DigitalTwinsInstance +package digitaltwins + +// 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 Digitaltwins + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Digitaltwins. +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/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwins.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwins.go new file mode 100644 index 000000000000..1c82886c5f53 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwins.go @@ -0,0 +1,716 @@ +package digitaltwins + +// 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" +) + +// Client is the azure Digital Twins Client for managing DigitalTwinsInstance +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client 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 NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability check if a DigitalTwinsInstance name is available. +// Parameters: +// location - location of DigitalTwinsInstance. +// digitalTwinsInstanceCheckName - set the name parameter in the DigitalTwinsInstanceCheckName structure to the +// name of the DigitalTwinsInstance to check. +func (client Client) CheckNameAvailability(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest) (result CheckNameResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNameAvailability") + 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: location, + Constraints: []validation.Constraint{{Target: "location", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: digitalTwinsInstanceCheckName, + Constraints: []validation.Constraint{{Target: "digitalTwinsInstanceCheckName.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "digitalTwinsInstanceCheckName.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, location, digitalTwinsInstanceCheckName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + 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.DigitalTwins/locations/{location}/checkNameAvailability", pathParameters), + autorest.WithJSON(digitalTwinsInstanceCheckName), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameResult, 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 a DigitalTwinsInstance. The usual pattern to modify a property is to +// retrieve the DigitalTwinsInstance and security metadata, and then combine them with the modified values in a new +// body to update the DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// digitalTwinsCreate - the DigitalTwinsInstance and security metadata. +func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate Description) (result CreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, digitalTwinsCreate) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate Description) (*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 = "2022-05-31" + 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.DigitalTwins/digitalTwinsInstances/{resourceName}", pathParameters), + autorest.WithJSON(digitalTwinsCreate), + 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 Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, 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 Client) CreateOrUpdateResponder(resp *http.Response) (result Description, 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 delete a DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result DeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", 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 Client) DeleteSender(req *http.Request) (future DeleteFuture, 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 Client) DeleteResponder(resp *http.Response) (result Description, 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 DigitalTwinsInstances resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client Client) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Description, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}", 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 Client) 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 Client) GetResponder(resp *http.Response) (result Description, 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 DigitalTwinsInstances in a subscription. +func (client Client) List(ctx context.Context) (result DescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client Client) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", 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 Client) 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 Client) ListResponder(resp *http.Response) (result DescriptionListResult, 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 Client) listNextResults(ctx context.Context, lastResults DescriptionListResult) (result DescriptionListResult, err error) { + req, err := lastResults.descriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.Client", "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, "digitaltwins.Client", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListComplete(ctx context.Context) (result DescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// ListByResourceGroup get all the DigitalTwinsInstances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) 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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", 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 Client) 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 Client) ListByResourceGroupResponder(resp *http.Response) (result DescriptionListResult, 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 Client) listByResourceGroupNextResults(ctx context.Context, lastResults DescriptionListResult) (result DescriptionListResult, err error) { + req, err := lastResults.descriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.Client", "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, "digitaltwins.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// Update update metadata of DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// digitalTwinsPatchDescription - the DigitalTwinsInstance and security metadata. +func (client Client) Update(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription PatchDescription) (result UpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, digitalTwinsPatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription PatchDescription) (*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 = "2022-05-31" + 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.DigitalTwins/digitalTwinsInstances/{resourceName}", pathParameters), + autorest.WithJSON(digitalTwinsPatchDescription), + 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 Client) UpdateSender(req *http.Request) (future UpdateFuture, 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 Client) UpdateResponder(resp *http.Response) (result Description, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwinsapi/interfaces.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwinsapi/interfaces.go new file mode 100644 index 000000000000..de3c87f5c86e --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/digitaltwinsapi/interfaces.go @@ -0,0 +1,75 @@ +package digitaltwinsapi + +// 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/digitaltwins/mgmt/2022-05-31/digitaltwins" +) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + CheckNameAvailability(ctx context.Context, location string, digitalTwinsInstanceCheckName digitaltwins.CheckNameRequest) (result digitaltwins.CheckNameResult, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate digitaltwins.Description) (result digitaltwins.CreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.DeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.Description, err error) + List(ctx context.Context) (result digitaltwins.DescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result digitaltwins.DescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result digitaltwins.DescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result digitaltwins.DescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription digitaltwins.PatchDescription) (result digitaltwins.UpdateFuture, err error) +} + +var _ ClientAPI = (*digitaltwins.Client)(nil) + +// EndpointClientAPI contains the set of methods on the EndpointClient type. +type EndpointClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription digitaltwins.EndpointResource) (result digitaltwins.EndpointCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result digitaltwins.EndpointDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result digitaltwins.EndpointResource, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.EndpointResourceListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.EndpointResourceListResultIterator, err error) +} + +var _ EndpointClientAPI = (*digitaltwins.EndpointClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result digitaltwins.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result digitaltwins.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*digitaltwins.OperationsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (result digitaltwins.GroupIDInformation, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.GroupIDInformationResponse, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*digitaltwins.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection digitaltwins.PrivateEndpointConnection) (result digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result digitaltwins.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result digitaltwins.PrivateEndpointConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.PrivateEndpointConnectionsResponse, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*digitaltwins.PrivateEndpointConnectionsClient)(nil) + +// TimeSeriesDatabaseConnectionsClientAPI contains the set of methods on the TimeSeriesDatabaseConnectionsClient type. +type TimeSeriesDatabaseConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription digitaltwins.TimeSeriesDatabaseConnection) (result digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result digitaltwins.TimeSeriesDatabaseConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.TimeSeriesDatabaseConnectionListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.TimeSeriesDatabaseConnectionListResultIterator, err error) +} + +var _ TimeSeriesDatabaseConnectionsClientAPI = (*digitaltwins.TimeSeriesDatabaseConnectionsClient)(nil) diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/endpoint.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/endpoint.go new file mode 100644 index 000000000000..f58c84c4333c --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/endpoint.go @@ -0,0 +1,442 @@ +package digitaltwins + +// 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" +) + +// EndpointClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type EndpointClient struct { + BaseClient +} + +// NewEndpointClient creates an instance of the EndpointClient client. +func NewEndpointClient(subscriptionID string) EndpointClient { + return NewEndpointClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEndpointClientWithBaseURI creates an instance of the EndpointClient 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 NewEndpointClientWithBaseURI(baseURI string, subscriptionID string) EndpointClient { + return EndpointClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update DigitalTwinsInstance endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +// endpointDescription - the DigitalTwinsInstance endpoint metadata and security metadata. +func (client EndpointClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription EndpointResource) (result EndpointCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, endpointName, endpointDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EndpointClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription EndpointResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + 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.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", pathParameters), + autorest.WithJSON(endpointDescription), + 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 EndpointClient) CreateOrUpdateSender(req *http.Request) (future EndpointCreateOrUpdateFuture, 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 EndpointClient) CreateOrUpdateResponder(resp *http.Response) (result EndpointResource, 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 delete a DigitalTwinsInstance endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +func (client EndpointClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result EndpointDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, endpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client EndpointClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", 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 EndpointClient) DeleteSender(req *http.Request) (future EndpointDeleteFuture, 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 EndpointClient) DeleteResponder(resp *http.Response) (result EndpointResource, 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 DigitalTwinsInstances Endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +func (client EndpointClient) Get(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result EndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, endpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EndpointClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", 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 EndpointClient) 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 EndpointClient) GetResponder(resp *http.Response) (result EndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get DigitalTwinsInstance Endpoints. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client EndpointClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result EndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.List") + defer func() { + sc := -1 + if result.erlr.Response.Response != nil { + sc = result.erlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.erlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", resp, "Failure sending request") + return + } + + result.erlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", resp, "Failure responding to request") + return + } + if result.erlr.hasNextLink() && result.erlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client EndpointClient) ListPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", 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 EndpointClient) 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 EndpointClient) ListResponder(resp *http.Response) (result EndpointResourceListResult, 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 EndpointClient) listNextResults(ctx context.Context, lastResults EndpointResourceListResult) (result EndpointResourceListResult, err error) { + req, err := lastResults.endpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "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, "digitaltwins.EndpointClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client EndpointClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result EndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.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, resourceGroupName, resourceName) + return +} diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/enums.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/enums.go new file mode 100644 index 000000000000..69cd4f4e9d28 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/enums.go @@ -0,0 +1,261 @@ +package digitaltwins + +// 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. + +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // IdentityBased ... + IdentityBased AuthenticationType = "IdentityBased" + // KeyBased ... + KeyBased AuthenticationType = "KeyBased" +) + +// PossibleAuthenticationTypeValues returns an array of possible values for the AuthenticationType const type. +func PossibleAuthenticationTypeValues() []AuthenticationType { + return []AuthenticationType{IdentityBased, KeyBased} +} + +// ConnectionPropertiesProvisioningState enumerates the values for connection properties provisioning state. +type ConnectionPropertiesProvisioningState string + +const ( + // Approved ... + Approved ConnectionPropertiesProvisioningState = "Approved" + // Disconnected ... + Disconnected ConnectionPropertiesProvisioningState = "Disconnected" + // Pending ... + Pending ConnectionPropertiesProvisioningState = "Pending" + // Rejected ... + Rejected ConnectionPropertiesProvisioningState = "Rejected" +) + +// PossibleConnectionPropertiesProvisioningStateValues returns an array of possible values for the ConnectionPropertiesProvisioningState const type. +func PossibleConnectionPropertiesProvisioningStateValues() []ConnectionPropertiesProvisioningState { + return []ConnectionPropertiesProvisioningState{Approved, Disconnected, Pending, Rejected} +} + +// ConnectionType enumerates the values for connection type. +type ConnectionType string + +const ( + // ConnectionTypeAzureDataExplorer ... + ConnectionTypeAzureDataExplorer ConnectionType = "AzureDataExplorer" + // ConnectionTypeTimeSeriesDatabaseConnectionProperties ... + ConnectionTypeTimeSeriesDatabaseConnectionProperties ConnectionType = "TimeSeriesDatabaseConnectionProperties" +) + +// PossibleConnectionTypeValues returns an array of possible values for the ConnectionType const type. +func PossibleConnectionTypeValues() []ConnectionType { + return []ConnectionType{ConnectionTypeAzureDataExplorer, ConnectionTypeTimeSeriesDatabaseConnectionProperties} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// EndpointProvisioningState enumerates the values for endpoint provisioning state. +type EndpointProvisioningState string + +const ( + // Canceled ... + Canceled EndpointProvisioningState = "Canceled" + // Deleted ... + Deleted EndpointProvisioningState = "Deleted" + // Deleting ... + Deleting EndpointProvisioningState = "Deleting" + // Disabled ... + Disabled EndpointProvisioningState = "Disabled" + // Failed ... + Failed EndpointProvisioningState = "Failed" + // Moving ... + Moving EndpointProvisioningState = "Moving" + // Provisioning ... + Provisioning EndpointProvisioningState = "Provisioning" + // Restoring ... + Restoring EndpointProvisioningState = "Restoring" + // Succeeded ... + Succeeded EndpointProvisioningState = "Succeeded" + // Suspending ... + Suspending EndpointProvisioningState = "Suspending" + // Updating ... + Updating EndpointProvisioningState = "Updating" + // Warning ... + Warning EndpointProvisioningState = "Warning" +) + +// PossibleEndpointProvisioningStateValues returns an array of possible values for the EndpointProvisioningState const type. +func PossibleEndpointProvisioningStateValues() []EndpointProvisioningState { + return []EndpointProvisioningState{Canceled, Deleted, Deleting, Disabled, Failed, Moving, Provisioning, Restoring, Succeeded, Suspending, Updating, Warning} +} + +// EndpointType enumerates the values for endpoint type. +type EndpointType string + +const ( + // EndpointTypeDigitalTwinsEndpointResourceProperties ... + EndpointTypeDigitalTwinsEndpointResourceProperties EndpointType = "DigitalTwinsEndpointResourceProperties" + // EndpointTypeEventGrid ... + EndpointTypeEventGrid EndpointType = "EventGrid" + // EndpointTypeEventHub ... + EndpointTypeEventHub EndpointType = "EventHub" + // EndpointTypeServiceBus ... + EndpointTypeServiceBus EndpointType = "ServiceBus" +) + +// PossibleEndpointTypeValues returns an array of possible values for the EndpointType const type. +func PossibleEndpointTypeValues() []EndpointType { + return []EndpointType{EndpointTypeDigitalTwinsEndpointResourceProperties, EndpointTypeEventGrid, EndpointTypeEventHub, EndpointTypeServiceBus} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // None ... + None IdentityType = "None" + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{None, SystemAssigned} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // PrivateLinkServiceConnectionStatusApproved ... + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + // PrivateLinkServiceConnectionStatusDisconnected ... + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // PrivateLinkServiceConnectionStatusPending ... + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + // PrivateLinkServiceConnectionStatusRejected ... + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{PrivateLinkServiceConnectionStatusApproved, PrivateLinkServiceConnectionStatusDisconnected, PrivateLinkServiceConnectionStatusPending, PrivateLinkServiceConnectionStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleted ... + ProvisioningStateDeleted ProvisioningState = "Deleted" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMoving ... + ProvisioningStateMoving ProvisioningState = "Moving" + // ProvisioningStateProvisioning ... + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateRestoring ... + ProvisioningStateRestoring ProvisioningState = "Restoring" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateSuspending ... + ProvisioningStateSuspending ProvisioningState = "Suspending" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateWarning ... + ProvisioningStateWarning ProvisioningState = "Warning" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateDeleted, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateMoving, ProvisioningStateProvisioning, ProvisioningStateRestoring, ProvisioningStateSucceeded, ProvisioningStateSuspending, ProvisioningStateUpdating, ProvisioningStateWarning} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled ... + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled ... + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{PublicNetworkAccessDisabled, PublicNetworkAccessEnabled} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // AlreadyExists ... + AlreadyExists Reason = "AlreadyExists" + // Invalid ... + Invalid Reason = "Invalid" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{AlreadyExists, Invalid} +} + +// TimeSeriesDatabaseConnectionState enumerates the values for time series database connection state. +type TimeSeriesDatabaseConnectionState string + +const ( + // TimeSeriesDatabaseConnectionStateCanceled ... + TimeSeriesDatabaseConnectionStateCanceled TimeSeriesDatabaseConnectionState = "Canceled" + // TimeSeriesDatabaseConnectionStateDeleted ... + TimeSeriesDatabaseConnectionStateDeleted TimeSeriesDatabaseConnectionState = "Deleted" + // TimeSeriesDatabaseConnectionStateDeleting ... + TimeSeriesDatabaseConnectionStateDeleting TimeSeriesDatabaseConnectionState = "Deleting" + // TimeSeriesDatabaseConnectionStateDisabled ... + TimeSeriesDatabaseConnectionStateDisabled TimeSeriesDatabaseConnectionState = "Disabled" + // TimeSeriesDatabaseConnectionStateFailed ... + TimeSeriesDatabaseConnectionStateFailed TimeSeriesDatabaseConnectionState = "Failed" + // TimeSeriesDatabaseConnectionStateMoving ... + TimeSeriesDatabaseConnectionStateMoving TimeSeriesDatabaseConnectionState = "Moving" + // TimeSeriesDatabaseConnectionStateProvisioning ... + TimeSeriesDatabaseConnectionStateProvisioning TimeSeriesDatabaseConnectionState = "Provisioning" + // TimeSeriesDatabaseConnectionStateRestoring ... + TimeSeriesDatabaseConnectionStateRestoring TimeSeriesDatabaseConnectionState = "Restoring" + // TimeSeriesDatabaseConnectionStateSucceeded ... + TimeSeriesDatabaseConnectionStateSucceeded TimeSeriesDatabaseConnectionState = "Succeeded" + // TimeSeriesDatabaseConnectionStateSuspending ... + TimeSeriesDatabaseConnectionStateSuspending TimeSeriesDatabaseConnectionState = "Suspending" + // TimeSeriesDatabaseConnectionStateUpdating ... + TimeSeriesDatabaseConnectionStateUpdating TimeSeriesDatabaseConnectionState = "Updating" + // TimeSeriesDatabaseConnectionStateWarning ... + TimeSeriesDatabaseConnectionStateWarning TimeSeriesDatabaseConnectionState = "Warning" +) + +// PossibleTimeSeriesDatabaseConnectionStateValues returns an array of possible values for the TimeSeriesDatabaseConnectionState const type. +func PossibleTimeSeriesDatabaseConnectionStateValues() []TimeSeriesDatabaseConnectionState { + return []TimeSeriesDatabaseConnectionState{TimeSeriesDatabaseConnectionStateCanceled, TimeSeriesDatabaseConnectionStateDeleted, TimeSeriesDatabaseConnectionStateDeleting, TimeSeriesDatabaseConnectionStateDisabled, TimeSeriesDatabaseConnectionStateFailed, TimeSeriesDatabaseConnectionStateMoving, TimeSeriesDatabaseConnectionStateProvisioning, TimeSeriesDatabaseConnectionStateRestoring, TimeSeriesDatabaseConnectionStateSucceeded, TimeSeriesDatabaseConnectionStateSuspending, TimeSeriesDatabaseConnectionStateUpdating, TimeSeriesDatabaseConnectionStateWarning} +} diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/models.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/models.go new file mode 100644 index 000000000000..1938cb7232f3 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/models.go @@ -0,0 +1,2192 @@ +package digitaltwins + +// 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/digitaltwins/mgmt/2022-05-31/digitaltwins" + +// AzureDataExplorerConnectionProperties properties of a time series database connection to Azure Data +// Explorer with data being sent via an EventHub. +type AzureDataExplorerConnectionProperties struct { + // AdxResourceID - The resource ID of the Azure Data Explorer cluster. + AdxResourceID *string `json:"adxResourceId,omitempty"` + // AdxEndpointURI - The URI of the Azure Data Explorer endpoint. + AdxEndpointURI *string `json:"adxEndpointUri,omitempty"` + // AdxDatabaseName - The name of the Azure Data Explorer database. + AdxDatabaseName *string `json:"adxDatabaseName,omitempty"` + // AdxTableName - The name of the Azure Data Explorer table. + AdxTableName *string `json:"adxTableName,omitempty"` + // EventHubEndpointURI - The URL of the EventHub namespace for identity-based authentication. It must include the protocol sb:// + EventHubEndpointURI *string `json:"eventHubEndpointUri,omitempty"` + // EventHubEntityPath - The EventHub name in the EventHub namespace for identity-based authentication. + EventHubEntityPath *string `json:"eventHubEntityPath,omitempty"` + // EventHubNamespaceResourceID - The resource ID of the EventHub namespace. + EventHubNamespaceResourceID *string `json:"eventHubNamespaceResourceId,omitempty"` + // EventHubConsumerGroup - The EventHub consumer group to use when ADX reads from EventHub. Defaults to $Default. + EventHubConsumerGroup *string `json:"eventHubConsumerGroup,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'TimeSeriesDatabaseConnectionStateProvisioning', 'TimeSeriesDatabaseConnectionStateDeleting', 'TimeSeriesDatabaseConnectionStateUpdating', 'TimeSeriesDatabaseConnectionStateSucceeded', 'TimeSeriesDatabaseConnectionStateFailed', 'TimeSeriesDatabaseConnectionStateCanceled', 'TimeSeriesDatabaseConnectionStateDeleted', 'TimeSeriesDatabaseConnectionStateWarning', 'TimeSeriesDatabaseConnectionStateSuspending', 'TimeSeriesDatabaseConnectionStateRestoring', 'TimeSeriesDatabaseConnectionStateMoving', 'TimeSeriesDatabaseConnectionStateDisabled' + ProvisioningState TimeSeriesDatabaseConnectionState `json:"provisioningState,omitempty"` + // ConnectionType - Possible values include: 'ConnectionTypeTimeSeriesDatabaseConnectionProperties', 'ConnectionTypeAzureDataExplorer' + ConnectionType ConnectionType `json:"connectionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) MarshalJSON() ([]byte, error) { + adecp.ConnectionType = ConnectionTypeAzureDataExplorer + objectMap := make(map[string]interface{}) + if adecp.AdxResourceID != nil { + objectMap["adxResourceId"] = adecp.AdxResourceID + } + if adecp.AdxEndpointURI != nil { + objectMap["adxEndpointUri"] = adecp.AdxEndpointURI + } + if adecp.AdxDatabaseName != nil { + objectMap["adxDatabaseName"] = adecp.AdxDatabaseName + } + if adecp.AdxTableName != nil { + objectMap["adxTableName"] = adecp.AdxTableName + } + if adecp.EventHubEndpointURI != nil { + objectMap["eventHubEndpointUri"] = adecp.EventHubEndpointURI + } + if adecp.EventHubEntityPath != nil { + objectMap["eventHubEntityPath"] = adecp.EventHubEntityPath + } + if adecp.EventHubNamespaceResourceID != nil { + objectMap["eventHubNamespaceResourceId"] = adecp.EventHubNamespaceResourceID + } + if adecp.EventHubConsumerGroup != nil { + objectMap["eventHubConsumerGroup"] = adecp.EventHubConsumerGroup + } + if adecp.ConnectionType != "" { + objectMap["connectionType"] = adecp.ConnectionType + } + return json.Marshal(objectMap) +} + +// AsAzureDataExplorerConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) { + return &adecp, true +} + +// AsTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) { + return nil, false +} + +// AsBasicTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsBasicTimeSeriesDatabaseConnectionProperties() (BasicTimeSeriesDatabaseConnectionProperties, bool) { + return &adecp, true +} + +// CheckNameRequest the result returned from a database check name availability request. +type CheckNameRequest struct { + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. + Type *string `json:"type,omitempty"` +} + +// CheckNameResult the result returned from a check name availability request. +type CheckNameResult struct { + autorest.Response `json:"-"` + // NameAvailable - Specifies a Boolean value that indicates if the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Message - Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. + Message *string `json:"message,omitempty"` + // Reason - Message providing the reason why the given name is invalid. Possible values include: 'Invalid', 'AlreadyExists' + Reason Reason `json:"reason,omitempty"` +} + +// ConnectionProperties the properties of a private endpoint connection. +type ConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + ProvisioningState ConnectionPropertiesProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - The private endpoint. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // GroupIds - The list of group ids for the private endpoint connection. + GroupIds *[]string `json:"groupIds,omitempty"` + // PrivateLinkServiceConnectionState - The connection state. + PrivateLinkServiceConnectionState *ConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionProperties. +func (cp ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = cp.PrivateEndpoint + } + if cp.GroupIds != nil { + objectMap["groupIds"] = cp.GroupIds + } + if cp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = cp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// ConnectionPropertiesPrivateLinkServiceConnectionState the connection state. +type ConnectionPropertiesPrivateLinkServiceConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + 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"` +} + +// ConnectionState the current state of a private endpoint connection. +type ConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + 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"` +} + +// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CreateOrUpdateFuture) 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 CreateOrUpdateFuture.Result. +func (future *CreateOrUpdateFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.CreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeleteFuture) 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 DeleteFuture.Result. +func (future *DeleteFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.DeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.DeleteResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// Description the description of the DigitalTwins service. +type Description struct { + autorest.Response `json:"-"` + // Properties - DigitalTwins instance properties. + *Properties `json:"properties,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"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the DigitalTwinsInstance. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for Description. +func (d Description) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.Properties != nil { + objectMap["properties"] = d.Properties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + if d.Identity != nil { + objectMap["identity"] = d.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Description struct. +func (d *Description) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + d.Properties = &properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + d.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + d.SystemData = &systemData + } + } + } + + return nil +} + +// DescriptionListResult a list of DigitalTwins description objects with a next link. +type DescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of DigitalTwins description objects. + Value *[]Description `json:"value,omitempty"` +} + +// DescriptionListResultIterator provides access to a complete listing of Description values. +type DescriptionListResultIterator struct { + i int + page DescriptionListResultPage +} + +// 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 *DescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultIterator.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 *DescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DescriptionListResultIterator) 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 DescriptionListResultIterator) Response() DescriptionListResult { + 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 DescriptionListResultIterator) Value() Description { + if !iter.page.NotDone() { + return Description{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DescriptionListResultIterator type. +func NewDescriptionListResultIterator(page DescriptionListResultPage) DescriptionListResultIterator { + return DescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DescriptionListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DescriptionListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// descriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DescriptionListResult) descriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DescriptionListResultPage contains a page of Description values. +type DescriptionListResultPage struct { + fn func(context.Context, DescriptionListResult) (DescriptionListResult, error) + dlr DescriptionListResult +} + +// 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 *DescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DescriptionListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DescriptionListResultPage) Response() DescriptionListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DescriptionListResultPage) Values() []Description { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DescriptionListResultPage type. +func NewDescriptionListResultPage(cur DescriptionListResult, getNextPage func(context.Context, DescriptionListResult) (DescriptionListResult, error)) DescriptionListResultPage { + return DescriptionListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// EndpointCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EndpointClient) (EndpointResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EndpointCreateOrUpdateFuture) 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 EndpointCreateOrUpdateFuture.Result. +func (future *EndpointCreateOrUpdateFuture) result(client EndpointClient) (er EndpointResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + er.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { + er, err = client.CreateOrUpdateResponder(er.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", er.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EndpointClient) (EndpointResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EndpointDeleteFuture) 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 EndpointDeleteFuture.Result. +func (future *EndpointDeleteFuture) result(client EndpointClient) (er EndpointResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + er.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { + er, err = client.DeleteResponder(er.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", er.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointResource digitalTwinsInstance endpoint resource. +type EndpointResource struct { + autorest.Response `json:"-"` + // Properties - DigitalTwinsInstance endpoint resource properties. + Properties BasicEndpointResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for EndpointResource. +func (er EndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = er.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EndpointResource struct. +func (er *EndpointResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicEndpointResourceProperties(*v) + if err != nil { + return err + } + er.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + er.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + er.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + er.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + er.SystemData = &systemData + } + } + } + + return nil +} + +// EndpointResourceListResult a list of DigitalTwinsInstance Endpoints with a next link. +type EndpointResourceListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of DigitalTwinsInstance Endpoints. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of DigitalTwinsInstance Endpoints. + Value *[]EndpointResource `json:"value,omitempty"` +} + +// EndpointResourceListResultIterator provides access to a complete listing of EndpointResource values. +type EndpointResourceListResultIterator struct { + i int + page EndpointResourceListResultPage +} + +// 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 *EndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultIterator.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 *EndpointResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EndpointResourceListResultIterator) 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 EndpointResourceListResultIterator) Response() EndpointResourceListResult { + 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 EndpointResourceListResultIterator) Value() EndpointResource { + if !iter.page.NotDone() { + return EndpointResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EndpointResourceListResultIterator type. +func NewEndpointResourceListResultIterator(page EndpointResourceListResultPage) EndpointResourceListResultIterator { + return EndpointResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (erlr EndpointResourceListResult) IsEmpty() bool { + return erlr.Value == nil || len(*erlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (erlr EndpointResourceListResult) hasNextLink() bool { + return erlr.NextLink != nil && len(*erlr.NextLink) != 0 +} + +// endpointResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (erlr EndpointResourceListResult) endpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !erlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(erlr.NextLink))) +} + +// EndpointResourceListResultPage contains a page of EndpointResource values. +type EndpointResourceListResultPage struct { + fn func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error) + erlr EndpointResourceListResult +} + +// 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 *EndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultPage.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.erlr) + if err != nil { + return err + } + page.erlr = 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 *EndpointResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EndpointResourceListResultPage) NotDone() bool { + return !page.erlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EndpointResourceListResultPage) Response() EndpointResourceListResult { + return page.erlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EndpointResourceListResultPage) Values() []EndpointResource { + if page.erlr.IsEmpty() { + return nil + } + return *page.erlr.Value +} + +// Creates a new instance of the EndpointResourceListResultPage type. +func NewEndpointResourceListResultPage(cur EndpointResourceListResult, getNextPage func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error)) EndpointResourceListResultPage { + return EndpointResourceListResultPage{ + fn: getNextPage, + erlr: cur, + } +} + +// BasicEndpointResourceProperties properties related to Digital Twins Endpoint +type BasicEndpointResourceProperties interface { + AsServiceBus() (*ServiceBus, bool) + AsEventHub() (*EventHub, bool) + AsEventGrid() (*EventGrid, bool) + AsEndpointResourceProperties() (*EndpointResourceProperties, bool) +} + +// EndpointResourceProperties properties related to Digital Twins Endpoint +type EndpointResourceProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Updating', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +func unmarshalBasicEndpointResourceProperties(body []byte) (BasicEndpointResourceProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["endpointType"] { + case string(EndpointTypeServiceBus): + var sb ServiceBus + err := json.Unmarshal(body, &sb) + return sb, err + case string(EndpointTypeEventHub): + var eh EventHub + err := json.Unmarshal(body, &eh) + return eh, err + case string(EndpointTypeEventGrid): + var eg EventGrid + err := json.Unmarshal(body, &eg) + return eg, err + default: + var erp EndpointResourceProperties + err := json.Unmarshal(body, &erp) + return erp, err + } +} +func unmarshalBasicEndpointResourcePropertiesArray(body []byte) ([]BasicEndpointResourceProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + erpArray := make([]BasicEndpointResourceProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + erp, err := unmarshalBasicEndpointResourceProperties(*rawMessage) + if err != nil { + return nil, err + } + erpArray[index] = erp + } + return erpArray, nil +} + +// MarshalJSON is the custom marshaler for EndpointResourceProperties. +func (erp EndpointResourceProperties) MarshalJSON() ([]byte, error) { + erp.EndpointType = EndpointTypeDigitalTwinsEndpointResourceProperties + objectMap := make(map[string]interface{}) + if erp.AuthenticationType != "" { + objectMap["authenticationType"] = erp.AuthenticationType + } + if erp.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = erp.DeadLetterSecret + } + if erp.DeadLetterURI != nil { + objectMap["deadLetterUri"] = erp.DeadLetterURI + } + if erp.EndpointType != "" { + objectMap["endpointType"] = erp.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return &erp, true +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &erp, true +} + +// ErrorDefinition error definition. +type ErrorDefinition struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; Internal error details. + Details *[]ErrorDefinition `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDefinition. +func (ed ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse error response. +type ErrorResponse struct { + // Error - Error description + Error *ErrorDefinition `json:"error,omitempty"` +} + +// EventGrid properties related to EventGrid. +type EventGrid struct { + // TopicEndpoint - EventGrid Topic Endpoint. + TopicEndpoint *string `json:"TopicEndpoint,omitempty"` + // AccessKey1 - EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey1 *string `json:"accessKey1,omitempty"` + // AccessKey2 - EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey2 *string `json:"accessKey2,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Updating', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventGrid. +func (eg EventGrid) MarshalJSON() ([]byte, error) { + eg.EndpointType = EndpointTypeEventGrid + objectMap := make(map[string]interface{}) + if eg.TopicEndpoint != nil { + objectMap["TopicEndpoint"] = eg.TopicEndpoint + } + if eg.AccessKey1 != nil { + objectMap["accessKey1"] = eg.AccessKey1 + } + if eg.AccessKey2 != nil { + objectMap["accessKey2"] = eg.AccessKey2 + } + if eg.AuthenticationType != "" { + objectMap["authenticationType"] = eg.AuthenticationType + } + if eg.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = eg.DeadLetterSecret + } + if eg.DeadLetterURI != nil { + objectMap["deadLetterUri"] = eg.DeadLetterURI + } + if eg.EndpointType != "" { + objectMap["endpointType"] = eg.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEventGrid() (*EventGrid, bool) { + return &eg, true +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &eg, true +} + +// EventHub properties related to EventHub. +type EventHub struct { + // ConnectionStringPrimaryKey - PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringPrimaryKey *string `json:"connectionStringPrimaryKey,omitempty"` + // ConnectionStringSecondaryKey - SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringSecondaryKey *string `json:"connectionStringSecondaryKey,omitempty"` + // EndpointURI - The URL of the EventHub namespace for identity-based authentication. It must include the protocol 'sb://'. + EndpointURI *string `json:"endpointUri,omitempty"` + // EntityPath - The EventHub name in the EventHub namespace for identity-based authentication. + EntityPath *string `json:"entityPath,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Updating', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventHub. +func (eh EventHub) MarshalJSON() ([]byte, error) { + eh.EndpointType = EndpointTypeEventHub + objectMap := make(map[string]interface{}) + if eh.ConnectionStringPrimaryKey != nil { + objectMap["connectionStringPrimaryKey"] = eh.ConnectionStringPrimaryKey + } + if eh.ConnectionStringSecondaryKey != nil { + objectMap["connectionStringSecondaryKey"] = eh.ConnectionStringSecondaryKey + } + if eh.EndpointURI != nil { + objectMap["endpointUri"] = eh.EndpointURI + } + if eh.EntityPath != nil { + objectMap["entityPath"] = eh.EntityPath + } + if eh.AuthenticationType != "" { + objectMap["authenticationType"] = eh.AuthenticationType + } + if eh.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = eh.DeadLetterSecret + } + if eh.DeadLetterURI != nil { + objectMap["deadLetterUri"] = eh.DeadLetterURI + } + if eh.EndpointType != "" { + objectMap["endpointType"] = eh.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEventHub() (*EventHub, bool) { + return &eh, true +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &eh, true +} + +// ExternalResource definition of a resource. +type ExternalResource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExternalResource. +func (er ExternalResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GroupIDInformation the group information for creating a private endpoint on Digital Twin. +type GroupIDInformation struct { + autorest.Response `json:"-"` + // Properties - The group information properties. + Properties *GroupIDInformationProperties `json:"properties,omitempty"` + // ID - 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"` +} + +// 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 + } + if gii.ID != nil { + objectMap["id"] = gii.ID + } + 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"` +} + +// GroupIDInformationResponse the available private link resources for a Digital Twin. +type GroupIDInformationResponse struct { + autorest.Response `json:"-"` + // Value - The list of available private link resources for a Digital Twin. + Value *[]GroupIDInformation `json:"value,omitempty"` +} + +// Identity the managed identity for the DigitalTwinsInstance. +type Identity struct { + // Type - The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is supported. Possible values include: 'None', 'SystemAssigned' + Type IdentityType `json:"type,omitempty"` + // PrincipalID - READ-ONLY; The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a systemAssigned(implicit) identity + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a systemAssigned(implicit) identity + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + return json.Marshal(objectMap) +} + +// Operation digitalTwins service REST API operation +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // Display - Operation properties display + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. + Origin *string `json:"origin,omitempty"` + // IsDataAction - READ-ONLY; If the operation is a data action (for data plane rbac). + IsDataAction *bool `json:"isDataAction,omitempty"` + // Properties - READ-ONLY; Operation properties. + Properties map[string]interface{} `json:"properties"` +} + +// 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 DigitalTwins. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: DigitalTwinsInstances. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of DigitalTwins 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:"-"` + // NextLink - The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if olr.NextLink != nil { + objectMap["nextLink"] = olr.NextLink + } + 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, + } +} + +// PatchDescription the description of the DigitalTwins service. +type PatchDescription struct { + // Tags - Instance patch properties + Tags map[string]*string `json:"tags"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // Properties - Properties for the DigitalTwinsInstance. + Properties *PatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PatchDescription. +func (pd PatchDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pd.Tags != nil { + objectMap["tags"] = pd.Tags + } + if pd.Identity != nil { + objectMap["identity"] = pd.Identity + } + if pd.Properties != nil { + objectMap["properties"] = pd.Properties + } + return json.Marshal(objectMap) +} + +// PatchProperties the properties of a DigitalTwinsInstance. +type PatchProperties struct { + // PublicNetworkAccess - Public network access for the DigitalTwinsInstance. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// 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 Digital Twin. +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 connection properties. + Properties *ConnectionProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the private endpoint connection. + SystemData *SystemData `json:"systemData,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) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) 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 PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture") + 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.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) 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 PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsResponse the available private link connections for a Digital Twin. +type PrivateEndpointConnectionsResponse struct { + autorest.Response `json:"-"` + // Value - The list of available private link connections for a Digital Twin. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// Properties the properties of a DigitalTwinsInstance. +type Properties struct { + // CreatedTime - READ-ONLY; Time when DigitalTwinsInstance was created. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // LastUpdatedTime - READ-ONLY; Time when DigitalTwinsInstance was updated. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'ProvisioningStateProvisioning', 'ProvisioningStateDeleting', 'ProvisioningStateUpdating', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeleted', 'ProvisioningStateWarning', 'ProvisioningStateSuspending', 'ProvisioningStateRestoring', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // HostName - READ-ONLY; Api endpoint to work with DigitalTwinsInstance. + HostName *string `json:"hostName,omitempty"` + // PrivateEndpointConnections - The private endpoint connections. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Public network access for the DigitalTwinsInstance. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = p.PrivateEndpointConnections + } + if p.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = p.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// Resource the common properties of a DigitalTwinsInstance. +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"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the DigitalTwinsInstance. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// 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 + } + if r.Identity != nil { + objectMap["identity"] = r.Identity + } + return json.Marshal(objectMap) +} + +// ServiceBus properties related to ServiceBus. +type ServiceBus struct { + // PrimaryConnectionString - PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + // SecondaryConnectionString - SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + // EndpointURI - The URL of the ServiceBus namespace for identity-based authentication. It must include the protocol 'sb://'. + EndpointURI *string `json:"endpointUri,omitempty"` + // EntityPath - The ServiceBus Topic name for identity-based authentication. + EntityPath *string `json:"entityPath,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Updating', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceBus. +func (sb ServiceBus) MarshalJSON() ([]byte, error) { + sb.EndpointType = EndpointTypeServiceBus + objectMap := make(map[string]interface{}) + if sb.PrimaryConnectionString != nil { + objectMap["primaryConnectionString"] = sb.PrimaryConnectionString + } + if sb.SecondaryConnectionString != nil { + objectMap["secondaryConnectionString"] = sb.SecondaryConnectionString + } + if sb.EndpointURI != nil { + objectMap["endpointUri"] = sb.EndpointURI + } + if sb.EntityPath != nil { + objectMap["entityPath"] = sb.EntityPath + } + if sb.AuthenticationType != "" { + objectMap["authenticationType"] = sb.AuthenticationType + } + if sb.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = sb.DeadLetterSecret + } + if sb.DeadLetterURI != nil { + objectMap["deadLetterUri"] = sb.DeadLetterURI + } + if sb.EndpointType != "" { + objectMap["endpointType"] = sb.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsServiceBus() (*ServiceBus, bool) { + return &sb, true +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &sb, true +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TimeSeriesDatabaseConnection describes a time series database connection resource. +type TimeSeriesDatabaseConnection struct { + autorest.Response `json:"-"` + // Properties - Properties of a specific time series database connection. + Properties BasicTimeSeriesDatabaseConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for TimeSeriesDatabaseConnection. +func (tsdc TimeSeriesDatabaseConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = tsdc.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TimeSeriesDatabaseConnection struct. +func (tsdc *TimeSeriesDatabaseConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicTimeSeriesDatabaseConnectionProperties(*v) + if err != nil { + return err + } + tsdc.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsdc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsdc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsdc.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + tsdc.SystemData = &systemData + } + } + } + + return nil +} + +// TimeSeriesDatabaseConnectionListResult a pageable list of time series database connection resources. +type TimeSeriesDatabaseConnectionListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of results. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of time series database connection resources. + Value *[]TimeSeriesDatabaseConnection `json:"value,omitempty"` +} + +// TimeSeriesDatabaseConnectionListResultIterator provides access to a complete listing of +// TimeSeriesDatabaseConnection values. +type TimeSeriesDatabaseConnectionListResultIterator struct { + i int + page TimeSeriesDatabaseConnectionListResultPage +} + +// 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 *TimeSeriesDatabaseConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionListResultIterator.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 *TimeSeriesDatabaseConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TimeSeriesDatabaseConnectionListResultIterator) 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 TimeSeriesDatabaseConnectionListResultIterator) Response() TimeSeriesDatabaseConnectionListResult { + 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 TimeSeriesDatabaseConnectionListResultIterator) Value() TimeSeriesDatabaseConnection { + if !iter.page.NotDone() { + return TimeSeriesDatabaseConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TimeSeriesDatabaseConnectionListResultIterator type. +func NewTimeSeriesDatabaseConnectionListResultIterator(page TimeSeriesDatabaseConnectionListResultPage) TimeSeriesDatabaseConnectionListResultIterator { + return TimeSeriesDatabaseConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tsdclr TimeSeriesDatabaseConnectionListResult) IsEmpty() bool { + return tsdclr.Value == nil || len(*tsdclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tsdclr TimeSeriesDatabaseConnectionListResult) hasNextLink() bool { + return tsdclr.NextLink != nil && len(*tsdclr.NextLink) != 0 +} + +// timeSeriesDatabaseConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tsdclr TimeSeriesDatabaseConnectionListResult) timeSeriesDatabaseConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !tsdclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tsdclr.NextLink))) +} + +// TimeSeriesDatabaseConnectionListResultPage contains a page of TimeSeriesDatabaseConnection values. +type TimeSeriesDatabaseConnectionListResultPage struct { + fn func(context.Context, TimeSeriesDatabaseConnectionListResult) (TimeSeriesDatabaseConnectionListResult, error) + tsdclr TimeSeriesDatabaseConnectionListResult +} + +// 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 *TimeSeriesDatabaseConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionListResultPage.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.tsdclr) + if err != nil { + return err + } + page.tsdclr = 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 *TimeSeriesDatabaseConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TimeSeriesDatabaseConnectionListResultPage) NotDone() bool { + return !page.tsdclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TimeSeriesDatabaseConnectionListResultPage) Response() TimeSeriesDatabaseConnectionListResult { + return page.tsdclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TimeSeriesDatabaseConnectionListResultPage) Values() []TimeSeriesDatabaseConnection { + if page.tsdclr.IsEmpty() { + return nil + } + return *page.tsdclr.Value +} + +// Creates a new instance of the TimeSeriesDatabaseConnectionListResultPage type. +func NewTimeSeriesDatabaseConnectionListResultPage(cur TimeSeriesDatabaseConnectionListResult, getNextPage func(context.Context, TimeSeriesDatabaseConnectionListResult) (TimeSeriesDatabaseConnectionListResult, error)) TimeSeriesDatabaseConnectionListResultPage { + return TimeSeriesDatabaseConnectionListResultPage{ + fn: getNextPage, + tsdclr: cur, + } +} + +// BasicTimeSeriesDatabaseConnectionProperties properties of a time series database connection resource. +type BasicTimeSeriesDatabaseConnectionProperties interface { + AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) + AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) +} + +// TimeSeriesDatabaseConnectionProperties properties of a time series database connection resource. +type TimeSeriesDatabaseConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'TimeSeriesDatabaseConnectionStateProvisioning', 'TimeSeriesDatabaseConnectionStateDeleting', 'TimeSeriesDatabaseConnectionStateUpdating', 'TimeSeriesDatabaseConnectionStateSucceeded', 'TimeSeriesDatabaseConnectionStateFailed', 'TimeSeriesDatabaseConnectionStateCanceled', 'TimeSeriesDatabaseConnectionStateDeleted', 'TimeSeriesDatabaseConnectionStateWarning', 'TimeSeriesDatabaseConnectionStateSuspending', 'TimeSeriesDatabaseConnectionStateRestoring', 'TimeSeriesDatabaseConnectionStateMoving', 'TimeSeriesDatabaseConnectionStateDisabled' + ProvisioningState TimeSeriesDatabaseConnectionState `json:"provisioningState,omitempty"` + // ConnectionType - Possible values include: 'ConnectionTypeTimeSeriesDatabaseConnectionProperties', 'ConnectionTypeAzureDataExplorer' + ConnectionType ConnectionType `json:"connectionType,omitempty"` +} + +func unmarshalBasicTimeSeriesDatabaseConnectionProperties(body []byte) (BasicTimeSeriesDatabaseConnectionProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["connectionType"] { + case string(ConnectionTypeAzureDataExplorer): + var adecp AzureDataExplorerConnectionProperties + err := json.Unmarshal(body, &adecp) + return adecp, err + default: + var tsdcp TimeSeriesDatabaseConnectionProperties + err := json.Unmarshal(body, &tsdcp) + return tsdcp, err + } +} +func unmarshalBasicTimeSeriesDatabaseConnectionPropertiesArray(body []byte) ([]BasicTimeSeriesDatabaseConnectionProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + tsdcpArray := make([]BasicTimeSeriesDatabaseConnectionProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + tsdcp, err := unmarshalBasicTimeSeriesDatabaseConnectionProperties(*rawMessage) + if err != nil { + return nil, err + } + tsdcpArray[index] = tsdcp + } + return tsdcpArray, nil +} + +// MarshalJSON is the custom marshaler for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) MarshalJSON() ([]byte, error) { + tsdcp.ConnectionType = ConnectionTypeTimeSeriesDatabaseConnectionProperties + objectMap := make(map[string]interface{}) + if tsdcp.ConnectionType != "" { + objectMap["connectionType"] = tsdcp.ConnectionType + } + return json.Marshal(objectMap) +} + +// AsAzureDataExplorerConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) { + return nil, false +} + +// AsTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) { + return &tsdcp, true +} + +// AsBasicTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsBasicTimeSeriesDatabaseConnectionProperties() (BasicTimeSeriesDatabaseConnectionProperties, bool) { + return &tsdcp, true +} + +// TimeSeriesDatabaseConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type TimeSeriesDatabaseConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TimeSeriesDatabaseConnectionsClient) (TimeSeriesDatabaseConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TimeSeriesDatabaseConnectionsCreateOrUpdateFuture) 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 TimeSeriesDatabaseConnectionsCreateOrUpdateFuture.Result. +func (future *TimeSeriesDatabaseConnectionsCreateOrUpdateFuture) result(client TimeSeriesDatabaseConnectionsClient) (tsdc TimeSeriesDatabaseConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsdc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsdc.Response.Response, err = future.GetResult(sender); err == nil && tsdc.Response.Response.StatusCode != http.StatusNoContent { + tsdc, err = client.CreateOrUpdateResponder(tsdc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture", "Result", tsdc.Response.Response, "Failure responding to request") + } + } + return +} + +// TimeSeriesDatabaseConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TimeSeriesDatabaseConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TimeSeriesDatabaseConnectionsClient) (TimeSeriesDatabaseConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TimeSeriesDatabaseConnectionsDeleteFuture) 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 TimeSeriesDatabaseConnectionsDeleteFuture.Result. +func (future *TimeSeriesDatabaseConnectionsDeleteFuture) result(client TimeSeriesDatabaseConnectionsClient) (tsdc TimeSeriesDatabaseConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsdc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsdc.Response.Response, err = future.GetResult(sender); err == nil && tsdc.Response.Response.StatusCode != http.StatusNoContent { + tsdc, err = client.DeleteResponder(tsdc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture", "Result", tsdc.Response.Response, "Failure responding to request") + } + } + return +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *UpdateFuture) 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 UpdateFuture.Result. +func (future *UpdateFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.UpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/operations.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/operations.go new file mode 100644 index 000000000000..b61d5ec38932 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/operations.go @@ -0,0 +1,140 @@ +package digitaltwins + +// 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 azure Digital Twins Client for managing DigitalTwinsInstance +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 DigitalTwins service 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, "digitaltwins.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, "digitaltwins.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DigitalTwins/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, "digitaltwins.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, "digitaltwins.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.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/digitaltwins/mgmt/2022-05-31/digitaltwins/privateendpointconnections.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/privateendpointconnections.go new file mode 100644 index 000000000000..69fb5f0ca14c --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/privateendpointconnections.go @@ -0,0 +1,397 @@ +package digitaltwins + +// 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" +) + +// PrivateEndpointConnectionsClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient 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 NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the status of a private endpoint connection with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +// privateEndpointConnection - the private endpoint connection with updated properties. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateEndpointConnection, + Constraints: []validation.Constraint{{Target: "privateEndpointConnection.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + privateEndpointConnection.SystemData = 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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + 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 PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, 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 PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete private endpoint connection with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, 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 PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get private endpoint connection properties for the given private endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) 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 PrivateEndpointConnectionsClient) GetResponder(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 +} + +// List list private endpoint connection properties. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionsResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateEndpointConnectionsClient) ListPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) 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 PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionsResponse, 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/digitaltwins/mgmt/2022-05-31/digitaltwins/privatelinkresources.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/privatelinkresources.go new file mode 100644 index 000000000000..999498401c87 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/privatelinkresources.go @@ -0,0 +1,207 @@ +package digitaltwins + +// 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" +) + +// PrivateLinkResourcesClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient 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 NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the specified private link resource for the given Digital Twin. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// resourceID - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (result GroupIDInformation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, resourceID) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceId": autorest.Encode("path", resourceID), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", 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 PrivateLinkResourcesClient) 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 PrivateLinkResourcesClient) GetResponder(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 +} + +// List list private link resources for given Digital Twin. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result GroupIDInformationResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateLinkResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkResourcesClient) ListPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", 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 PrivateLinkResourcesClient) 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 PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result GroupIDInformationResponse, 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/digitaltwins/mgmt/2022-05-31/digitaltwins/timeseriesdatabaseconnections.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/timeseriesdatabaseconnections.go new file mode 100644 index 000000000000..3c184f4edbb1 --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/timeseriesdatabaseconnections.go @@ -0,0 +1,443 @@ +package digitaltwins + +// 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" +) + +// TimeSeriesDatabaseConnectionsClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type TimeSeriesDatabaseConnectionsClient struct { + BaseClient +} + +// NewTimeSeriesDatabaseConnectionsClient creates an instance of the TimeSeriesDatabaseConnectionsClient client. +func NewTimeSeriesDatabaseConnectionsClient(subscriptionID string) TimeSeriesDatabaseConnectionsClient { + return NewTimeSeriesDatabaseConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTimeSeriesDatabaseConnectionsClientWithBaseURI creates an instance of the TimeSeriesDatabaseConnectionsClient +// 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 NewTimeSeriesDatabaseConnectionsClientWithBaseURI(baseURI string, subscriptionID string) TimeSeriesDatabaseConnectionsClient { + return TimeSeriesDatabaseConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +// timeSeriesDatabaseConnectionDescription - the time series database connection description. +func (client TimeSeriesDatabaseConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription TimeSeriesDatabaseConnection) (result TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName, timeSeriesDatabaseConnectionDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TimeSeriesDatabaseConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription TimeSeriesDatabaseConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2022-05-31" + 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.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", pathParameters), + autorest.WithJSON(timeSeriesDatabaseConnectionDescription), + 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 TimeSeriesDatabaseConnectionsClient) CreateOrUpdateSender(req *http.Request) (future TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, 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 TimeSeriesDatabaseConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 delete a time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +func (client TimeSeriesDatabaseConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result TimeSeriesDatabaseConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client TimeSeriesDatabaseConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", 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 TimeSeriesDatabaseConnectionsClient) DeleteSender(req *http.Request) (future TimeSeriesDatabaseConnectionsDeleteFuture, 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 TimeSeriesDatabaseConnectionsClient) DeleteResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 description of an existing time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +func (client TimeSeriesDatabaseConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result TimeSeriesDatabaseConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TimeSeriesDatabaseConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", 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 TimeSeriesDatabaseConnectionsClient) 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 TimeSeriesDatabaseConnectionsClient) GetResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 existing time series database connections for this DigitalTwins instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client TimeSeriesDatabaseConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result TimeSeriesDatabaseConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.List") + defer func() { + sc := -1 + if result.tsdclr.Response.Response != nil { + sc = result.tsdclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tsdclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.tsdclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", resp, "Failure responding to request") + return + } + if result.tsdclr.hasNextLink() && result.tsdclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client TimeSeriesDatabaseConnectionsClient) ListPreparer(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 = "2022-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections", 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 TimeSeriesDatabaseConnectionsClient) 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 TimeSeriesDatabaseConnectionsClient) ListResponder(resp *http.Response) (result TimeSeriesDatabaseConnectionListResult, 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 TimeSeriesDatabaseConnectionsClient) listNextResults(ctx context.Context, lastResults TimeSeriesDatabaseConnectionListResult) (result TimeSeriesDatabaseConnectionListResult, err error) { + req, err := lastResults.timeSeriesDatabaseConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "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, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TimeSeriesDatabaseConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result TimeSeriesDatabaseConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.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, resourceGroupName, resourceName) + return +} diff --git a/services/digitaltwins/mgmt/2022-05-31/digitaltwins/version.go b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/version.go new file mode 100644 index 000000000000..1f69d118be0a --- /dev/null +++ b/services/digitaltwins/mgmt/2022-05-31/digitaltwins/version.go @@ -0,0 +1,19 @@ +package digitaltwins + +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() + " digitaltwins/2022-05-31" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/CHANGELOG.md b/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/CHANGELOG.md +++ b/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/_meta.json b/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/_meta.json index 3adb2523ec3e..a93118db39a6 100644 --- a/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/_meta.json +++ b/services/preview/digitaltwins/mgmt/2020-03-01-preview/digitaltwins/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "360b1d56294cdc384a4f48d187c3da90f2826895", "readme": "/_/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md", "tag": "package-2020-03-01-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/CHANGELOG.md b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/_meta.json b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/_meta.json new file mode 100644 index 000000000000..9d921409aedb --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "360b1d56294cdc384a4f48d187c3da90f2826895", + "readme": "/_/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md", + "tag": "package-2021-06-30-preview", + "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-2021-06-30-preview --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/digitaltwins/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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/client.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/client.go new file mode 100644 index 000000000000..108df72940df --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/client.go @@ -0,0 +1,41 @@ +// Package digitaltwins implements the Azure ARM Digitaltwins service API version 2021-06-30-preview. +// +// Azure Digital Twins Client for managing DigitalTwinsInstance +package digitaltwins + +// 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 Digitaltwins + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Digitaltwins. +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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwins.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwins.go new file mode 100644 index 000000000000..d3616015b7a4 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwins.go @@ -0,0 +1,716 @@ +package digitaltwins + +// 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" +) + +// Client is the azure Digital Twins Client for managing DigitalTwinsInstance +type Client struct { + BaseClient +} + +// NewClient creates an instance of the Client client. +func NewClient(subscriptionID string) Client { + return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewClientWithBaseURI creates an instance of the Client 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 NewClientWithBaseURI(baseURI string, subscriptionID string) Client { + return Client{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability check if a DigitalTwinsInstance name is available. +// Parameters: +// location - location of DigitalTwinsInstance. +// digitalTwinsInstanceCheckName - set the name parameter in the DigitalTwinsInstanceCheckName structure to the +// name of the DigitalTwinsInstance to check. +func (client Client) CheckNameAvailability(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest) (result CheckNameResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckNameAvailability") + 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: location, + Constraints: []validation.Constraint{{Target: "location", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: digitalTwinsInstanceCheckName, + Constraints: []validation.Constraint{{Target: "digitalTwinsInstanceCheckName.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "digitalTwinsInstanceCheckName.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, location, digitalTwinsInstanceCheckName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/locations/{location}/checkNameAvailability", pathParameters), + autorest.WithJSON(digitalTwinsInstanceCheckName), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client Client) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameResult, 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 a DigitalTwinsInstance. The usual pattern to modify a property is to +// retrieve the DigitalTwinsInstance and security metadata, and then combine them with the modified values in a new +// body to update the DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// digitalTwinsCreate - the DigitalTwinsInstance and security metadata. +func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate Description) (result CreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, digitalTwinsCreate) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate Description) (*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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}", pathParameters), + autorest.WithJSON(digitalTwinsCreate), + 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 Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, 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 Client) CreateOrUpdateResponder(resp *http.Response) (result Description, 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 delete a DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result DeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client Client) DeletePreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}", 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 Client) DeleteSender(req *http.Request) (future DeleteFuture, 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 Client) DeleteResponder(resp *http.Response) (result Description, 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 DigitalTwinsInstances resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client Client) Get(ctx context.Context, resourceGroupName string, resourceName string) (result Description, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client Client) GetPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}", 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 Client) 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 Client) GetResponder(resp *http.Response) (result Description, 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 DigitalTwinsInstances in a subscription. +func (client Client) List(ctx context.Context) (result DescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "List", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client Client) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances", 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 Client) 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 Client) ListResponder(resp *http.Response) (result DescriptionListResult, 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 Client) listNextResults(ctx context.Context, lastResults DescriptionListResult) (result DescriptionListResult, err error) { + req, err := lastResults.descriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.Client", "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, "digitaltwins.Client", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListComplete(ctx context.Context) (result DescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// ListByResourceGroup get all the DigitalTwinsInstances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup") + defer func() { + sc := -1 + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.dlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.dlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.dlr.hasNextLink() && result.dlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client Client) 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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances", 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 Client) 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 Client) ListByResourceGroupResponder(resp *http.Response) (result DescriptionListResult, 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 Client) listByResourceGroupNextResults(ctx context.Context, lastResults DescriptionListResult) (result DescriptionListResult, err error) { + req, err := lastResults.descriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.Client", "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, "digitaltwins.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.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 +} + +// Update update metadata of DigitalTwinsInstance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// digitalTwinsPatchDescription - the DigitalTwinsInstance and security metadata. +func (client Client) Update(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription PatchDescription) (result UpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.Client", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, digitalTwinsPatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.Client", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription PatchDescription) (*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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}", pathParameters), + autorest.WithJSON(digitalTwinsPatchDescription), + 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 Client) UpdateSender(req *http.Request) (future UpdateFuture, 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 Client) UpdateResponder(resp *http.Response) (result Description, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwinsapi/interfaces.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwinsapi/interfaces.go new file mode 100644 index 000000000000..9237b0d02ce7 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/digitaltwinsapi/interfaces.go @@ -0,0 +1,75 @@ +package digitaltwinsapi + +// 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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins" +) + +// ClientAPI contains the set of methods on the Client type. +type ClientAPI interface { + CheckNameAvailability(ctx context.Context, location string, digitalTwinsInstanceCheckName digitaltwins.CheckNameRequest) (result digitaltwins.CheckNameResult, err error) + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate digitaltwins.Description) (result digitaltwins.CreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.DeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.Description, err error) + List(ctx context.Context) (result digitaltwins.DescriptionListResultPage, err error) + ListComplete(ctx context.Context) (result digitaltwins.DescriptionListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result digitaltwins.DescriptionListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result digitaltwins.DescriptionListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription digitaltwins.PatchDescription) (result digitaltwins.UpdateFuture, err error) +} + +var _ ClientAPI = (*digitaltwins.Client)(nil) + +// EndpointClientAPI contains the set of methods on the EndpointClient type. +type EndpointClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription digitaltwins.EndpointResource) (result digitaltwins.EndpointCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result digitaltwins.EndpointDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result digitaltwins.EndpointResource, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.EndpointResourceListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.EndpointResourceListResultIterator, err error) +} + +var _ EndpointClientAPI = (*digitaltwins.EndpointClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result digitaltwins.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result digitaltwins.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*digitaltwins.OperationsClient)(nil) + +// PrivateLinkResourcesClientAPI contains the set of methods on the PrivateLinkResourcesClient type. +type PrivateLinkResourcesClientAPI interface { + Get(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (result digitaltwins.GroupIDInformation, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.GroupIDInformationResponse, err error) +} + +var _ PrivateLinkResourcesClientAPI = (*digitaltwins.PrivateLinkResourcesClient)(nil) + +// PrivateEndpointConnectionsClientAPI contains the set of methods on the PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection digitaltwins.PrivateEndpointConnection) (result digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result digitaltwins.PrivateEndpointConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result digitaltwins.PrivateEndpointConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.PrivateEndpointConnectionsResponse, err error) +} + +var _ PrivateEndpointConnectionsClientAPI = (*digitaltwins.PrivateEndpointConnectionsClient)(nil) + +// TimeSeriesDatabaseConnectionsClientAPI contains the set of methods on the TimeSeriesDatabaseConnectionsClient type. +type TimeSeriesDatabaseConnectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription digitaltwins.TimeSeriesDatabaseConnection) (result digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result digitaltwins.TimeSeriesDatabaseConnection, err error) + List(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.TimeSeriesDatabaseConnectionListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result digitaltwins.TimeSeriesDatabaseConnectionListResultIterator, err error) +} + +var _ TimeSeriesDatabaseConnectionsClientAPI = (*digitaltwins.TimeSeriesDatabaseConnectionsClient)(nil) diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/endpoint.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/endpoint.go new file mode 100644 index 000000000000..905ec695ccd8 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/endpoint.go @@ -0,0 +1,442 @@ +package digitaltwins + +// 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" +) + +// EndpointClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type EndpointClient struct { + BaseClient +} + +// NewEndpointClient creates an instance of the EndpointClient client. +func NewEndpointClient(subscriptionID string) EndpointClient { + return NewEndpointClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEndpointClientWithBaseURI creates an instance of the EndpointClient 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 NewEndpointClientWithBaseURI(baseURI string, subscriptionID string) EndpointClient { + return EndpointClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update DigitalTwinsInstance endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +// endpointDescription - the DigitalTwinsInstance endpoint metadata and security metadata. +func (client EndpointClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription EndpointResource) (result EndpointCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, endpointName, endpointDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client EndpointClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription EndpointResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", pathParameters), + autorest.WithJSON(endpointDescription), + 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 EndpointClient) CreateOrUpdateSender(req *http.Request) (future EndpointCreateOrUpdateFuture, 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 EndpointClient) CreateOrUpdateResponder(resp *http.Response) (result EndpointResource, 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 delete a DigitalTwinsInstance endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +func (client EndpointClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result EndpointDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, endpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client EndpointClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", 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 EndpointClient) DeleteSender(req *http.Request) (future EndpointDeleteFuture, 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 EndpointClient) DeleteResponder(resp *http.Response) (result EndpointResource, 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 DigitalTwinsInstances Endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// endpointName - name of Endpoint Resource. +func (client EndpointClient) Get(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (result EndpointResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: endpointName, + Constraints: []validation.Constraint{{Target: "endpointName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "endpointName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, endpointName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client EndpointClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, endpointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "endpointName": autorest.Encode("path", endpointName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}", 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 EndpointClient) 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 EndpointClient) GetResponder(resp *http.Response) (result EndpointResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get DigitalTwinsInstance Endpoints. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client EndpointClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result EndpointResourceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.List") + defer func() { + sc := -1 + if result.erlr.Response.Response != nil { + sc = result.erlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.EndpointClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.erlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", resp, "Failure sending request") + return + } + + result.erlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "List", resp, "Failure responding to request") + return + } + if result.erlr.hasNextLink() && result.erlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client EndpointClient) ListPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints", 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 EndpointClient) 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 EndpointClient) ListResponder(resp *http.Response) (result EndpointResourceListResult, 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 EndpointClient) listNextResults(ctx context.Context, lastResults EndpointResourceListResult) (result EndpointResourceListResult, err error) { + req, err := lastResults.endpointResourceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "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, "digitaltwins.EndpointClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client EndpointClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result EndpointResourceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointClient.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, resourceGroupName, resourceName) + return +} diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/enums.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/enums.go new file mode 100644 index 000000000000..f5117d901d94 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/enums.go @@ -0,0 +1,257 @@ +package digitaltwins + +// 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. + +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // IdentityBased ... + IdentityBased AuthenticationType = "IdentityBased" + // KeyBased ... + KeyBased AuthenticationType = "KeyBased" +) + +// PossibleAuthenticationTypeValues returns an array of possible values for the AuthenticationType const type. +func PossibleAuthenticationTypeValues() []AuthenticationType { + return []AuthenticationType{IdentityBased, KeyBased} +} + +// ConnectionPropertiesProvisioningState enumerates the values for connection properties provisioning state. +type ConnectionPropertiesProvisioningState string + +const ( + // Approved ... + Approved ConnectionPropertiesProvisioningState = "Approved" + // Disconnected ... + Disconnected ConnectionPropertiesProvisioningState = "Disconnected" + // Pending ... + Pending ConnectionPropertiesProvisioningState = "Pending" + // Rejected ... + Rejected ConnectionPropertiesProvisioningState = "Rejected" +) + +// PossibleConnectionPropertiesProvisioningStateValues returns an array of possible values for the ConnectionPropertiesProvisioningState const type. +func PossibleConnectionPropertiesProvisioningStateValues() []ConnectionPropertiesProvisioningState { + return []ConnectionPropertiesProvisioningState{Approved, Disconnected, Pending, Rejected} +} + +// ConnectionType enumerates the values for connection type. +type ConnectionType string + +const ( + // ConnectionTypeAzureDataExplorer ... + ConnectionTypeAzureDataExplorer ConnectionType = "AzureDataExplorer" + // ConnectionTypeTimeSeriesDatabaseConnectionProperties ... + ConnectionTypeTimeSeriesDatabaseConnectionProperties ConnectionType = "TimeSeriesDatabaseConnectionProperties" +) + +// PossibleConnectionTypeValues returns an array of possible values for the ConnectionType const type. +func PossibleConnectionTypeValues() []ConnectionType { + return []ConnectionType{ConnectionTypeAzureDataExplorer, ConnectionTypeTimeSeriesDatabaseConnectionProperties} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // Application ... + Application CreatedByType = "Application" + // Key ... + Key CreatedByType = "Key" + // ManagedIdentity ... + ManagedIdentity CreatedByType = "ManagedIdentity" + // User ... + User CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{Application, Key, ManagedIdentity, User} +} + +// EndpointProvisioningState enumerates the values for endpoint provisioning state. +type EndpointProvisioningState string + +const ( + // Canceled ... + Canceled EndpointProvisioningState = "Canceled" + // Deleted ... + Deleted EndpointProvisioningState = "Deleted" + // Deleting ... + Deleting EndpointProvisioningState = "Deleting" + // Disabled ... + Disabled EndpointProvisioningState = "Disabled" + // Failed ... + Failed EndpointProvisioningState = "Failed" + // Moving ... + Moving EndpointProvisioningState = "Moving" + // Provisioning ... + Provisioning EndpointProvisioningState = "Provisioning" + // Restoring ... + Restoring EndpointProvisioningState = "Restoring" + // Succeeded ... + Succeeded EndpointProvisioningState = "Succeeded" + // Suspending ... + Suspending EndpointProvisioningState = "Suspending" + // Warning ... + Warning EndpointProvisioningState = "Warning" +) + +// PossibleEndpointProvisioningStateValues returns an array of possible values for the EndpointProvisioningState const type. +func PossibleEndpointProvisioningStateValues() []EndpointProvisioningState { + return []EndpointProvisioningState{Canceled, Deleted, Deleting, Disabled, Failed, Moving, Provisioning, Restoring, Succeeded, Suspending, Warning} +} + +// EndpointType enumerates the values for endpoint type. +type EndpointType string + +const ( + // EndpointTypeDigitalTwinsEndpointResourceProperties ... + EndpointTypeDigitalTwinsEndpointResourceProperties EndpointType = "DigitalTwinsEndpointResourceProperties" + // EndpointTypeEventGrid ... + EndpointTypeEventGrid EndpointType = "EventGrid" + // EndpointTypeEventHub ... + EndpointTypeEventHub EndpointType = "EventHub" + // EndpointTypeServiceBus ... + EndpointTypeServiceBus EndpointType = "ServiceBus" +) + +// PossibleEndpointTypeValues returns an array of possible values for the EndpointType const type. +func PossibleEndpointTypeValues() []EndpointType { + return []EndpointType{EndpointTypeDigitalTwinsEndpointResourceProperties, EndpointTypeEventGrid, EndpointTypeEventHub, EndpointTypeServiceBus} +} + +// IdentityType enumerates the values for identity type. +type IdentityType string + +const ( + // None ... + None IdentityType = "None" + // SystemAssigned ... + SystemAssigned IdentityType = "SystemAssigned" +) + +// PossibleIdentityTypeValues returns an array of possible values for the IdentityType const type. +func PossibleIdentityTypeValues() []IdentityType { + return []IdentityType{None, SystemAssigned} +} + +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // PrivateLinkServiceConnectionStatusApproved ... + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + // PrivateLinkServiceConnectionStatusDisconnected ... + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // PrivateLinkServiceConnectionStatusPending ... + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + // PrivateLinkServiceConnectionStatusRejected ... + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{PrivateLinkServiceConnectionStatusApproved, PrivateLinkServiceConnectionStatusDisconnected, PrivateLinkServiceConnectionStatusPending, PrivateLinkServiceConnectionStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleted ... + ProvisioningStateDeleted ProvisioningState = "Deleted" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMoving ... + ProvisioningStateMoving ProvisioningState = "Moving" + // ProvisioningStateProvisioning ... + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateRestoring ... + ProvisioningStateRestoring ProvisioningState = "Restoring" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateSuspending ... + ProvisioningStateSuspending ProvisioningState = "Suspending" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateWarning ... + ProvisioningStateWarning ProvisioningState = "Warning" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateCanceled, ProvisioningStateDeleted, ProvisioningStateDeleting, ProvisioningStateFailed, ProvisioningStateMoving, ProvisioningStateProvisioning, ProvisioningStateRestoring, ProvisioningStateSucceeded, ProvisioningStateSuspending, ProvisioningStateUpdating, ProvisioningStateWarning} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled ... + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled ... + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{PublicNetworkAccessDisabled, PublicNetworkAccessEnabled} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // AlreadyExists ... + AlreadyExists Reason = "AlreadyExists" + // Invalid ... + Invalid Reason = "Invalid" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{AlreadyExists, Invalid} +} + +// TimeSeriesDatabaseConnectionState enumerates the values for time series database connection state. +type TimeSeriesDatabaseConnectionState string + +const ( + // TimeSeriesDatabaseConnectionStateCanceled ... + TimeSeriesDatabaseConnectionStateCanceled TimeSeriesDatabaseConnectionState = "Canceled" + // TimeSeriesDatabaseConnectionStateDeleted ... + TimeSeriesDatabaseConnectionStateDeleted TimeSeriesDatabaseConnectionState = "Deleted" + // TimeSeriesDatabaseConnectionStateDeleting ... + TimeSeriesDatabaseConnectionStateDeleting TimeSeriesDatabaseConnectionState = "Deleting" + // TimeSeriesDatabaseConnectionStateDisabled ... + TimeSeriesDatabaseConnectionStateDisabled TimeSeriesDatabaseConnectionState = "Disabled" + // TimeSeriesDatabaseConnectionStateFailed ... + TimeSeriesDatabaseConnectionStateFailed TimeSeriesDatabaseConnectionState = "Failed" + // TimeSeriesDatabaseConnectionStateMoving ... + TimeSeriesDatabaseConnectionStateMoving TimeSeriesDatabaseConnectionState = "Moving" + // TimeSeriesDatabaseConnectionStateProvisioning ... + TimeSeriesDatabaseConnectionStateProvisioning TimeSeriesDatabaseConnectionState = "Provisioning" + // TimeSeriesDatabaseConnectionStateRestoring ... + TimeSeriesDatabaseConnectionStateRestoring TimeSeriesDatabaseConnectionState = "Restoring" + // TimeSeriesDatabaseConnectionStateSucceeded ... + TimeSeriesDatabaseConnectionStateSucceeded TimeSeriesDatabaseConnectionState = "Succeeded" + // TimeSeriesDatabaseConnectionStateSuspending ... + TimeSeriesDatabaseConnectionStateSuspending TimeSeriesDatabaseConnectionState = "Suspending" + // TimeSeriesDatabaseConnectionStateWarning ... + TimeSeriesDatabaseConnectionStateWarning TimeSeriesDatabaseConnectionState = "Warning" +) + +// PossibleTimeSeriesDatabaseConnectionStateValues returns an array of possible values for the TimeSeriesDatabaseConnectionState const type. +func PossibleTimeSeriesDatabaseConnectionStateValues() []TimeSeriesDatabaseConnectionState { + return []TimeSeriesDatabaseConnectionState{TimeSeriesDatabaseConnectionStateCanceled, TimeSeriesDatabaseConnectionStateDeleted, TimeSeriesDatabaseConnectionStateDeleting, TimeSeriesDatabaseConnectionStateDisabled, TimeSeriesDatabaseConnectionStateFailed, TimeSeriesDatabaseConnectionStateMoving, TimeSeriesDatabaseConnectionStateProvisioning, TimeSeriesDatabaseConnectionStateRestoring, TimeSeriesDatabaseConnectionStateSucceeded, TimeSeriesDatabaseConnectionStateSuspending, TimeSeriesDatabaseConnectionStateWarning} +} diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/models.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/models.go new file mode 100644 index 000000000000..435534414c93 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/models.go @@ -0,0 +1,2192 @@ +package digitaltwins + +// 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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins" + +// AzureDataExplorerConnectionProperties properties of a time series database connection to Azure Data +// Explorer with data being sent via an EventHub. +type AzureDataExplorerConnectionProperties struct { + // AdxResourceID - The resource ID of the Azure Data Explorer cluster. + AdxResourceID *string `json:"adxResourceId,omitempty"` + // AdxEndpointURI - The URI of the Azure Data Explorer endpoint. + AdxEndpointURI *string `json:"adxEndpointUri,omitempty"` + // AdxDatabaseName - The name of the Azure Data Explorer database. + AdxDatabaseName *string `json:"adxDatabaseName,omitempty"` + // AdxTableName - The name of the Azure Data Explorer table. + AdxTableName *string `json:"adxTableName,omitempty"` + // EventHubEndpointURI - The URL of the EventHub namespace for identity-based authentication. It must include the protocol sb:// + EventHubEndpointURI *string `json:"eventHubEndpointUri,omitempty"` + // EventHubEntityPath - The EventHub name in the EventHub namespace for identity-based authentication. + EventHubEntityPath *string `json:"eventHubEntityPath,omitempty"` + // EventHubNamespaceResourceID - The resource ID of the EventHub namespace. + EventHubNamespaceResourceID *string `json:"eventHubNamespaceResourceId,omitempty"` + // EventHubConsumerGroup - The EventHub consumer group to use when ADX reads from EventHub. Defaults to $Default. + EventHubConsumerGroup *string `json:"eventHubConsumerGroup,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'TimeSeriesDatabaseConnectionStateProvisioning', 'TimeSeriesDatabaseConnectionStateDeleting', 'TimeSeriesDatabaseConnectionStateSucceeded', 'TimeSeriesDatabaseConnectionStateFailed', 'TimeSeriesDatabaseConnectionStateCanceled', 'TimeSeriesDatabaseConnectionStateDeleted', 'TimeSeriesDatabaseConnectionStateWarning', 'TimeSeriesDatabaseConnectionStateSuspending', 'TimeSeriesDatabaseConnectionStateRestoring', 'TimeSeriesDatabaseConnectionStateMoving', 'TimeSeriesDatabaseConnectionStateDisabled' + ProvisioningState TimeSeriesDatabaseConnectionState `json:"provisioningState,omitempty"` + // ConnectionType - Possible values include: 'ConnectionTypeTimeSeriesDatabaseConnectionProperties', 'ConnectionTypeAzureDataExplorer' + ConnectionType ConnectionType `json:"connectionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) MarshalJSON() ([]byte, error) { + adecp.ConnectionType = ConnectionTypeAzureDataExplorer + objectMap := make(map[string]interface{}) + if adecp.AdxResourceID != nil { + objectMap["adxResourceId"] = adecp.AdxResourceID + } + if adecp.AdxEndpointURI != nil { + objectMap["adxEndpointUri"] = adecp.AdxEndpointURI + } + if adecp.AdxDatabaseName != nil { + objectMap["adxDatabaseName"] = adecp.AdxDatabaseName + } + if adecp.AdxTableName != nil { + objectMap["adxTableName"] = adecp.AdxTableName + } + if adecp.EventHubEndpointURI != nil { + objectMap["eventHubEndpointUri"] = adecp.EventHubEndpointURI + } + if adecp.EventHubEntityPath != nil { + objectMap["eventHubEntityPath"] = adecp.EventHubEntityPath + } + if adecp.EventHubNamespaceResourceID != nil { + objectMap["eventHubNamespaceResourceId"] = adecp.EventHubNamespaceResourceID + } + if adecp.EventHubConsumerGroup != nil { + objectMap["eventHubConsumerGroup"] = adecp.EventHubConsumerGroup + } + if adecp.ConnectionType != "" { + objectMap["connectionType"] = adecp.ConnectionType + } + return json.Marshal(objectMap) +} + +// AsAzureDataExplorerConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) { + return &adecp, true +} + +// AsTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) { + return nil, false +} + +// AsBasicTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for AzureDataExplorerConnectionProperties. +func (adecp AzureDataExplorerConnectionProperties) AsBasicTimeSeriesDatabaseConnectionProperties() (BasicTimeSeriesDatabaseConnectionProperties, bool) { + return &adecp, true +} + +// CheckNameRequest the result returned from a database check name availability request. +type CheckNameRequest struct { + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - The type of resource, for instance Microsoft.DigitalTwins/digitalTwinsInstances. + Type *string `json:"type,omitempty"` +} + +// CheckNameResult the result returned from a check name availability request. +type CheckNameResult struct { + autorest.Response `json:"-"` + // NameAvailable - Specifies a Boolean value that indicates if the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Message - Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. + Message *string `json:"message,omitempty"` + // Reason - Message providing the reason why the given name is invalid. Possible values include: 'Invalid', 'AlreadyExists' + Reason Reason `json:"reason,omitempty"` +} + +// ConnectionProperties the properties of a private endpoint connection. +type ConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + ProvisioningState ConnectionPropertiesProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - The private endpoint. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // GroupIds - The list of group ids for the private endpoint connection. + GroupIds *[]string `json:"groupIds,omitempty"` + // PrivateLinkServiceConnectionState - The connection state. + PrivateLinkServiceConnectionState *ConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectionProperties. +func (cp ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = cp.PrivateEndpoint + } + if cp.GroupIds != nil { + objectMap["groupIds"] = cp.GroupIds + } + if cp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = cp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// ConnectionPropertiesPrivateLinkServiceConnectionState the connection state. +type ConnectionPropertiesPrivateLinkServiceConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + 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"` +} + +// ConnectionState the current state of a private endpoint connection. +type ConnectionState struct { + // Status - The status of a private endpoint connection. Possible values include: 'PrivateLinkServiceConnectionStatusPending', 'PrivateLinkServiceConnectionStatusApproved', 'PrivateLinkServiceConnectionStatusRejected', 'PrivateLinkServiceConnectionStatusDisconnected' + 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"` +} + +// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type CreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *CreateOrUpdateFuture) 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 CreateOrUpdateFuture.Result. +func (future *CreateOrUpdateFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.CreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.CreateOrUpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.CreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type DeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DeleteFuture) 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 DeleteFuture.Result. +func (future *DeleteFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.DeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.DeleteResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.DeleteFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} + +// Description the description of the DigitalTwins service. +type Description struct { + autorest.Response `json:"-"` + // Properties - DigitalTwins instance properties. + *Properties `json:"properties,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"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the DigitalTwinsInstance. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for Description. +func (d Description) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.Properties != nil { + objectMap["properties"] = d.Properties + } + if d.Location != nil { + objectMap["location"] = d.Location + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + if d.Identity != nil { + objectMap["identity"] = d.Identity + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Description struct. +func (d *Description) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + d.Properties = &properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + d.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + case "identity": + if v != nil { + var identity Identity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + d.Identity = &identity + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + d.SystemData = &systemData + } + } + } + + return nil +} + +// DescriptionListResult a list of DigitalTwins description objects with a next link. +type DescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of DigitalTwins description objects. + Value *[]Description `json:"value,omitempty"` +} + +// DescriptionListResultIterator provides access to a complete listing of Description values. +type DescriptionListResultIterator struct { + i int + page DescriptionListResultPage +} + +// 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 *DescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultIterator.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 *DescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DescriptionListResultIterator) 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 DescriptionListResultIterator) Response() DescriptionListResult { + 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 DescriptionListResultIterator) Value() Description { + if !iter.page.NotDone() { + return Description{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DescriptionListResultIterator type. +func NewDescriptionListResultIterator(page DescriptionListResultPage) DescriptionListResultIterator { + return DescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DescriptionListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dlr DescriptionListResult) hasNextLink() bool { + return dlr.NextLink != nil && len(*dlr.NextLink) != 0 +} + +// descriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DescriptionListResult) descriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !dlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DescriptionListResultPage contains a page of Description values. +type DescriptionListResultPage struct { + fn func(context.Context, DescriptionListResult) (DescriptionListResult, error) + dlr DescriptionListResult +} + +// 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 *DescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DescriptionListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DescriptionListResultPage) Response() DescriptionListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DescriptionListResultPage) Values() []Description { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DescriptionListResultPage type. +func NewDescriptionListResultPage(cur DescriptionListResult, getNextPage func(context.Context, DescriptionListResult) (DescriptionListResult, error)) DescriptionListResultPage { + return DescriptionListResultPage{ + fn: getNextPage, + dlr: cur, + } +} + +// EndpointCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EndpointClient) (EndpointResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EndpointCreateOrUpdateFuture) 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 EndpointCreateOrUpdateFuture.Result. +func (future *EndpointCreateOrUpdateFuture) result(client EndpointClient) (er EndpointResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + er.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { + er, err = client.CreateOrUpdateResponder(er.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointCreateOrUpdateFuture", "Result", er.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type EndpointDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(EndpointClient) (EndpointResource, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *EndpointDeleteFuture) 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 EndpointDeleteFuture.Result. +func (future *EndpointDeleteFuture) result(client EndpointClient) (er EndpointResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + er.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.EndpointDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if er.Response.Response, err = future.GetResult(sender); err == nil && er.Response.Response.StatusCode != http.StatusNoContent { + er, err = client.DeleteResponder(er.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.EndpointDeleteFuture", "Result", er.Response.Response, "Failure responding to request") + } + } + return +} + +// EndpointResource digitalTwinsInstance endpoint resource. +type EndpointResource struct { + autorest.Response `json:"-"` + // Properties - DigitalTwinsInstance endpoint resource properties. + Properties BasicEndpointResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for EndpointResource. +func (er EndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = er.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EndpointResource struct. +func (er *EndpointResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicEndpointResourceProperties(*v) + if err != nil { + return err + } + er.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + er.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + er.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + er.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + er.SystemData = &systemData + } + } + } + + return nil +} + +// EndpointResourceListResult a list of DigitalTwinsInstance Endpoints with a next link. +type EndpointResourceListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of DigitalTwinsInstance Endpoints. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of DigitalTwinsInstance Endpoints. + Value *[]EndpointResource `json:"value,omitempty"` +} + +// EndpointResourceListResultIterator provides access to a complete listing of EndpointResource values. +type EndpointResourceListResultIterator struct { + i int + page EndpointResourceListResultPage +} + +// 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 *EndpointResourceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultIterator.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 *EndpointResourceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EndpointResourceListResultIterator) 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 EndpointResourceListResultIterator) Response() EndpointResourceListResult { + 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 EndpointResourceListResultIterator) Value() EndpointResource { + if !iter.page.NotDone() { + return EndpointResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EndpointResourceListResultIterator type. +func NewEndpointResourceListResultIterator(page EndpointResourceListResultPage) EndpointResourceListResultIterator { + return EndpointResourceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (erlr EndpointResourceListResult) IsEmpty() bool { + return erlr.Value == nil || len(*erlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (erlr EndpointResourceListResult) hasNextLink() bool { + return erlr.NextLink != nil && len(*erlr.NextLink) != 0 +} + +// endpointResourceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (erlr EndpointResourceListResult) endpointResourceListResultPreparer(ctx context.Context) (*http.Request, error) { + if !erlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(erlr.NextLink))) +} + +// EndpointResourceListResultPage contains a page of EndpointResource values. +type EndpointResourceListResultPage struct { + fn func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error) + erlr EndpointResourceListResult +} + +// 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 *EndpointResourceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EndpointResourceListResultPage.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.erlr) + if err != nil { + return err + } + page.erlr = 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 *EndpointResourceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EndpointResourceListResultPage) NotDone() bool { + return !page.erlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EndpointResourceListResultPage) Response() EndpointResourceListResult { + return page.erlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EndpointResourceListResultPage) Values() []EndpointResource { + if page.erlr.IsEmpty() { + return nil + } + return *page.erlr.Value +} + +// Creates a new instance of the EndpointResourceListResultPage type. +func NewEndpointResourceListResultPage(cur EndpointResourceListResult, getNextPage func(context.Context, EndpointResourceListResult) (EndpointResourceListResult, error)) EndpointResourceListResultPage { + return EndpointResourceListResultPage{ + fn: getNextPage, + erlr: cur, + } +} + +// BasicEndpointResourceProperties properties related to Digital Twins Endpoint +type BasicEndpointResourceProperties interface { + AsServiceBus() (*ServiceBus, bool) + AsEventHub() (*EventHub, bool) + AsEventGrid() (*EventGrid, bool) + AsEndpointResourceProperties() (*EndpointResourceProperties, bool) +} + +// EndpointResourceProperties properties related to Digital Twins Endpoint +type EndpointResourceProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +func unmarshalBasicEndpointResourceProperties(body []byte) (BasicEndpointResourceProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["endpointType"] { + case string(EndpointTypeServiceBus): + var sb ServiceBus + err := json.Unmarshal(body, &sb) + return sb, err + case string(EndpointTypeEventHub): + var eh EventHub + err := json.Unmarshal(body, &eh) + return eh, err + case string(EndpointTypeEventGrid): + var eg EventGrid + err := json.Unmarshal(body, &eg) + return eg, err + default: + var erp EndpointResourceProperties + err := json.Unmarshal(body, &erp) + return erp, err + } +} +func unmarshalBasicEndpointResourcePropertiesArray(body []byte) ([]BasicEndpointResourceProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + erpArray := make([]BasicEndpointResourceProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + erp, err := unmarshalBasicEndpointResourceProperties(*rawMessage) + if err != nil { + return nil, err + } + erpArray[index] = erp + } + return erpArray, nil +} + +// MarshalJSON is the custom marshaler for EndpointResourceProperties. +func (erp EndpointResourceProperties) MarshalJSON() ([]byte, error) { + erp.EndpointType = EndpointTypeDigitalTwinsEndpointResourceProperties + objectMap := make(map[string]interface{}) + if erp.AuthenticationType != "" { + objectMap["authenticationType"] = erp.AuthenticationType + } + if erp.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = erp.DeadLetterSecret + } + if erp.DeadLetterURI != nil { + objectMap["deadLetterUri"] = erp.DeadLetterURI + } + if erp.EndpointType != "" { + objectMap["endpointType"] = erp.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return &erp, true +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EndpointResourceProperties. +func (erp EndpointResourceProperties) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &erp, true +} + +// ErrorDefinition error definition. +type ErrorDefinition struct { + // Code - READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Description of the error. + Message *string `json:"message,omitempty"` + // Details - READ-ONLY; Internal error details. + Details *[]ErrorDefinition `json:"details,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDefinition. +func (ed ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse error response. +type ErrorResponse struct { + // Error - Error description + Error *ErrorDefinition `json:"error,omitempty"` +} + +// EventGrid properties related to EventGrid. +type EventGrid struct { + // TopicEndpoint - EventGrid Topic Endpoint. + TopicEndpoint *string `json:"TopicEndpoint,omitempty"` + // AccessKey1 - EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey1 *string `json:"accessKey1,omitempty"` + // AccessKey2 - EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey2 *string `json:"accessKey2,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventGrid. +func (eg EventGrid) MarshalJSON() ([]byte, error) { + eg.EndpointType = EndpointTypeEventGrid + objectMap := make(map[string]interface{}) + if eg.TopicEndpoint != nil { + objectMap["TopicEndpoint"] = eg.TopicEndpoint + } + if eg.AccessKey1 != nil { + objectMap["accessKey1"] = eg.AccessKey1 + } + if eg.AccessKey2 != nil { + objectMap["accessKey2"] = eg.AccessKey2 + } + if eg.AuthenticationType != "" { + objectMap["authenticationType"] = eg.AuthenticationType + } + if eg.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = eg.DeadLetterSecret + } + if eg.DeadLetterURI != nil { + objectMap["deadLetterUri"] = eg.DeadLetterURI + } + if eg.EndpointType != "" { + objectMap["endpointType"] = eg.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEventGrid() (*EventGrid, bool) { + return &eg, true +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventGrid. +func (eg EventGrid) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &eg, true +} + +// EventHub properties related to EventHub. +type EventHub struct { + // ConnectionStringPrimaryKey - PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringPrimaryKey *string `json:"connectionStringPrimaryKey,omitempty"` + // ConnectionStringSecondaryKey - SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringSecondaryKey *string `json:"connectionStringSecondaryKey,omitempty"` + // EndpointURI - The URL of the EventHub namespace for identity-based authentication. It must include the protocol 'sb://'. + EndpointURI *string `json:"endpointUri,omitempty"` + // EntityPath - The EventHub name in the EventHub namespace for identity-based authentication. + EntityPath *string `json:"entityPath,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for EventHub. +func (eh EventHub) MarshalJSON() ([]byte, error) { + eh.EndpointType = EndpointTypeEventHub + objectMap := make(map[string]interface{}) + if eh.ConnectionStringPrimaryKey != nil { + objectMap["connectionStringPrimaryKey"] = eh.ConnectionStringPrimaryKey + } + if eh.ConnectionStringSecondaryKey != nil { + objectMap["connectionStringSecondaryKey"] = eh.ConnectionStringSecondaryKey + } + if eh.EndpointURI != nil { + objectMap["endpointUri"] = eh.EndpointURI + } + if eh.EntityPath != nil { + objectMap["entityPath"] = eh.EntityPath + } + if eh.AuthenticationType != "" { + objectMap["authenticationType"] = eh.AuthenticationType + } + if eh.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = eh.DeadLetterSecret + } + if eh.DeadLetterURI != nil { + objectMap["deadLetterUri"] = eh.DeadLetterURI + } + if eh.EndpointType != "" { + objectMap["endpointType"] = eh.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsServiceBus() (*ServiceBus, bool) { + return nil, false +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEventHub() (*EventHub, bool) { + return &eh, true +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for EventHub. +func (eh EventHub) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &eh, true +} + +// ExternalResource definition of a resource. +type ExternalResource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExternalResource. +func (er ExternalResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// GroupIDInformation the group information for creating a private endpoint on Digital Twin. +type GroupIDInformation struct { + autorest.Response `json:"-"` + // Properties - The group information properties. + Properties *GroupIDInformationProperties `json:"properties,omitempty"` + // ID - 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"` +} + +// 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 + } + if gii.ID != nil { + objectMap["id"] = gii.ID + } + 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"` +} + +// GroupIDInformationResponse the available private link resources for a Digital Twin. +type GroupIDInformationResponse struct { + autorest.Response `json:"-"` + // Value - The list of available private link resources for a Digital Twin. + Value *[]GroupIDInformation `json:"value,omitempty"` +} + +// Identity the managed identity for the DigitalTwinsInstance. +type Identity struct { + // Type - The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is supported. Possible values include: 'None', 'SystemAssigned' + Type IdentityType `json:"type,omitempty"` + // PrincipalID - READ-ONLY; The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a systemAssigned(implicit) identity + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-client-tenant-id header in the PUT request if the resource has a systemAssigned(implicit) identity + TenantID *string `json:"tenantId,omitempty"` +} + +// MarshalJSON is the custom marshaler for Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.Type != "" { + objectMap["type"] = i.Type + } + return json.Marshal(objectMap) +} + +// Operation digitalTwins service REST API operation +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty"` + // Display - Operation properties display + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; The intended executor of the operation. + Origin *string `json:"origin,omitempty"` + // IsDataAction - READ-ONLY; If the operation is a data action (for data plane rbac). + IsDataAction *bool `json:"isDataAction,omitempty"` + // Properties - READ-ONLY; Operation properties. + Properties map[string]interface{} `json:"properties"` +} + +// 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 DigitalTwins. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: DigitalTwinsInstances. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation. + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Friendly description for the operation. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult a list of DigitalTwins 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:"-"` + // NextLink - The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if olr.NextLink != nil { + objectMap["nextLink"] = olr.NextLink + } + 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, + } +} + +// PatchDescription the description of the DigitalTwins service. +type PatchDescription struct { + // Tags - Instance patch properties + Tags map[string]*string `json:"tags"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // Properties - Properties for the DigitalTwinsInstance. + Properties *PatchProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PatchDescription. +func (pd PatchDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pd.Tags != nil { + objectMap["tags"] = pd.Tags + } + if pd.Identity != nil { + objectMap["identity"] = pd.Identity + } + if pd.Properties != nil { + objectMap["properties"] = pd.Properties + } + return json.Marshal(objectMap) +} + +// PatchProperties the properties of a DigitalTwinsInstance. +type PatchProperties struct { + // PublicNetworkAccess - Public network access for the DigitalTwinsInstance. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// 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 Digital Twin. +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 connection properties. + Properties *ConnectionProperties `json:"properties,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the private endpoint connection. + SystemData *SystemData `json:"systemData,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) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) 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 PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pec PrivateEndpointConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pec.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture") + 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.CreateOrUpdateResponder(pec.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pec.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) 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 PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateEndpointConnectionsResponse the available private link connections for a Digital Twin. +type PrivateEndpointConnectionsResponse struct { + autorest.Response `json:"-"` + // Value - The list of available private link connections for a Digital Twin. + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// Properties the properties of a DigitalTwinsInstance. +type Properties struct { + // CreatedTime - READ-ONLY; Time when DigitalTwinsInstance was created. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // LastUpdatedTime - READ-ONLY; Time when DigitalTwinsInstance was updated. + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'ProvisioningStateProvisioning', 'ProvisioningStateDeleting', 'ProvisioningStateUpdating', 'ProvisioningStateSucceeded', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeleted', 'ProvisioningStateWarning', 'ProvisioningStateSuspending', 'ProvisioningStateRestoring', 'ProvisioningStateMoving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // HostName - READ-ONLY; Api endpoint to work with DigitalTwinsInstance. + HostName *string `json:"hostName,omitempty"` + // PrivateEndpointConnections - The private endpoint connections. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Public network access for the DigitalTwinsInstance. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = p.PrivateEndpointConnections + } + if p.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = p.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// Resource the common properties of a DigitalTwinsInstance. +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"` + // Identity - The managed identity for the DigitalTwinsInstance. + Identity *Identity `json:"identity,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the DigitalTwinsInstance. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// 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 + } + if r.Identity != nil { + objectMap["identity"] = r.Identity + } + return json.Marshal(objectMap) +} + +// ServiceBus properties related to ServiceBus. +type ServiceBus struct { + // PrimaryConnectionString - PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + // SecondaryConnectionString - SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` + // EndpointURI - The URL of the ServiceBus namespace for identity-based authentication. It must include the protocol 'sb://'. + EndpointURI *string `json:"endpointUri,omitempty"` + // EntityPath - The ServiceBus Topic name for identity-based authentication. + EntityPath *string `json:"entityPath,omitempty"` + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'Warning', 'Suspending', 'Restoring', 'Moving', 'Disabled' + ProvisioningState EndpointProvisioningState `json:"provisioningState,omitempty"` + // CreatedTime - READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *date.Time `json:"createdTime,omitempty"` + // AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. Defaults to 'KeyBased'. If 'KeyBased' is selected, a connection string must be specified (at least the primary connection string). If 'IdentityBased' is select, the endpointUri and entityPath properties must be specified. Possible values include: 'KeyBased', 'IdentityBased' + AuthenticationType AuthenticationType `json:"authenticationType,omitempty"` + // DeadLetterSecret - Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + // DeadLetterURI - Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + // EndpointType - Possible values include: 'EndpointTypeDigitalTwinsEndpointResourceProperties', 'EndpointTypeServiceBus', 'EndpointTypeEventHub', 'EndpointTypeEventGrid' + EndpointType EndpointType `json:"endpointType,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServiceBus. +func (sb ServiceBus) MarshalJSON() ([]byte, error) { + sb.EndpointType = EndpointTypeServiceBus + objectMap := make(map[string]interface{}) + if sb.PrimaryConnectionString != nil { + objectMap["primaryConnectionString"] = sb.PrimaryConnectionString + } + if sb.SecondaryConnectionString != nil { + objectMap["secondaryConnectionString"] = sb.SecondaryConnectionString + } + if sb.EndpointURI != nil { + objectMap["endpointUri"] = sb.EndpointURI + } + if sb.EntityPath != nil { + objectMap["entityPath"] = sb.EntityPath + } + if sb.AuthenticationType != "" { + objectMap["authenticationType"] = sb.AuthenticationType + } + if sb.DeadLetterSecret != nil { + objectMap["deadLetterSecret"] = sb.DeadLetterSecret + } + if sb.DeadLetterURI != nil { + objectMap["deadLetterUri"] = sb.DeadLetterURI + } + if sb.EndpointType != "" { + objectMap["endpointType"] = sb.EndpointType + } + return json.Marshal(objectMap) +} + +// AsServiceBus is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsServiceBus() (*ServiceBus, bool) { + return &sb, true +} + +// AsEventHub is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEventHub() (*EventHub, bool) { + return nil, false +} + +// AsEventGrid is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEventGrid() (*EventGrid, bool) { + return nil, false +} + +// AsEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsEndpointResourceProperties() (*EndpointResourceProperties, bool) { + return nil, false +} + +// AsBasicEndpointResourceProperties is the BasicEndpointResourceProperties implementation for ServiceBus. +func (sb ServiceBus) AsBasicEndpointResourceProperties() (BasicEndpointResourceProperties, bool) { + return &sb, true +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TimeSeriesDatabaseConnection describes a time series database connection resource. +type TimeSeriesDatabaseConnection struct { + autorest.Response `json:"-"` + // Properties - Properties of a specific time series database connection. + Properties BasicTimeSeriesDatabaseConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for TimeSeriesDatabaseConnection. +func (tsdc TimeSeriesDatabaseConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + objectMap["properties"] = tsdc.Properties + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for TimeSeriesDatabaseConnection struct. +func (tsdc *TimeSeriesDatabaseConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + properties, err := unmarshalBasicTimeSeriesDatabaseConnectionProperties(*v) + if err != nil { + return err + } + tsdc.Properties = properties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + tsdc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + tsdc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + tsdc.Type = &typeVar + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + tsdc.SystemData = &systemData + } + } + } + + return nil +} + +// TimeSeriesDatabaseConnectionListResult a pageable list of time series database connection resources. +type TimeSeriesDatabaseConnectionListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of results. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of time series database connection resources. + Value *[]TimeSeriesDatabaseConnection `json:"value,omitempty"` +} + +// TimeSeriesDatabaseConnectionListResultIterator provides access to a complete listing of +// TimeSeriesDatabaseConnection values. +type TimeSeriesDatabaseConnectionListResultIterator struct { + i int + page TimeSeriesDatabaseConnectionListResultPage +} + +// 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 *TimeSeriesDatabaseConnectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionListResultIterator.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 *TimeSeriesDatabaseConnectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TimeSeriesDatabaseConnectionListResultIterator) 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 TimeSeriesDatabaseConnectionListResultIterator) Response() TimeSeriesDatabaseConnectionListResult { + 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 TimeSeriesDatabaseConnectionListResultIterator) Value() TimeSeriesDatabaseConnection { + if !iter.page.NotDone() { + return TimeSeriesDatabaseConnection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TimeSeriesDatabaseConnectionListResultIterator type. +func NewTimeSeriesDatabaseConnectionListResultIterator(page TimeSeriesDatabaseConnectionListResultPage) TimeSeriesDatabaseConnectionListResultIterator { + return TimeSeriesDatabaseConnectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tsdclr TimeSeriesDatabaseConnectionListResult) IsEmpty() bool { + return tsdclr.Value == nil || len(*tsdclr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (tsdclr TimeSeriesDatabaseConnectionListResult) hasNextLink() bool { + return tsdclr.NextLink != nil && len(*tsdclr.NextLink) != 0 +} + +// timeSeriesDatabaseConnectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tsdclr TimeSeriesDatabaseConnectionListResult) timeSeriesDatabaseConnectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !tsdclr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tsdclr.NextLink))) +} + +// TimeSeriesDatabaseConnectionListResultPage contains a page of TimeSeriesDatabaseConnection values. +type TimeSeriesDatabaseConnectionListResultPage struct { + fn func(context.Context, TimeSeriesDatabaseConnectionListResult) (TimeSeriesDatabaseConnectionListResult, error) + tsdclr TimeSeriesDatabaseConnectionListResult +} + +// 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 *TimeSeriesDatabaseConnectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionListResultPage.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.tsdclr) + if err != nil { + return err + } + page.tsdclr = 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 *TimeSeriesDatabaseConnectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TimeSeriesDatabaseConnectionListResultPage) NotDone() bool { + return !page.tsdclr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TimeSeriesDatabaseConnectionListResultPage) Response() TimeSeriesDatabaseConnectionListResult { + return page.tsdclr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TimeSeriesDatabaseConnectionListResultPage) Values() []TimeSeriesDatabaseConnection { + if page.tsdclr.IsEmpty() { + return nil + } + return *page.tsdclr.Value +} + +// Creates a new instance of the TimeSeriesDatabaseConnectionListResultPage type. +func NewTimeSeriesDatabaseConnectionListResultPage(cur TimeSeriesDatabaseConnectionListResult, getNextPage func(context.Context, TimeSeriesDatabaseConnectionListResult) (TimeSeriesDatabaseConnectionListResult, error)) TimeSeriesDatabaseConnectionListResultPage { + return TimeSeriesDatabaseConnectionListResultPage{ + fn: getNextPage, + tsdclr: cur, + } +} + +// BasicTimeSeriesDatabaseConnectionProperties properties of a time series database connection resource. +type BasicTimeSeriesDatabaseConnectionProperties interface { + AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) + AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) +} + +// TimeSeriesDatabaseConnectionProperties properties of a time series database connection resource. +type TimeSeriesDatabaseConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'TimeSeriesDatabaseConnectionStateProvisioning', 'TimeSeriesDatabaseConnectionStateDeleting', 'TimeSeriesDatabaseConnectionStateSucceeded', 'TimeSeriesDatabaseConnectionStateFailed', 'TimeSeriesDatabaseConnectionStateCanceled', 'TimeSeriesDatabaseConnectionStateDeleted', 'TimeSeriesDatabaseConnectionStateWarning', 'TimeSeriesDatabaseConnectionStateSuspending', 'TimeSeriesDatabaseConnectionStateRestoring', 'TimeSeriesDatabaseConnectionStateMoving', 'TimeSeriesDatabaseConnectionStateDisabled' + ProvisioningState TimeSeriesDatabaseConnectionState `json:"provisioningState,omitempty"` + // ConnectionType - Possible values include: 'ConnectionTypeTimeSeriesDatabaseConnectionProperties', 'ConnectionTypeAzureDataExplorer' + ConnectionType ConnectionType `json:"connectionType,omitempty"` +} + +func unmarshalBasicTimeSeriesDatabaseConnectionProperties(body []byte) (BasicTimeSeriesDatabaseConnectionProperties, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["connectionType"] { + case string(ConnectionTypeAzureDataExplorer): + var adecp AzureDataExplorerConnectionProperties + err := json.Unmarshal(body, &adecp) + return adecp, err + default: + var tsdcp TimeSeriesDatabaseConnectionProperties + err := json.Unmarshal(body, &tsdcp) + return tsdcp, err + } +} +func unmarshalBasicTimeSeriesDatabaseConnectionPropertiesArray(body []byte) ([]BasicTimeSeriesDatabaseConnectionProperties, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + tsdcpArray := make([]BasicTimeSeriesDatabaseConnectionProperties, len(rawMessages)) + + for index, rawMessage := range rawMessages { + tsdcp, err := unmarshalBasicTimeSeriesDatabaseConnectionProperties(*rawMessage) + if err != nil { + return nil, err + } + tsdcpArray[index] = tsdcp + } + return tsdcpArray, nil +} + +// MarshalJSON is the custom marshaler for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) MarshalJSON() ([]byte, error) { + tsdcp.ConnectionType = ConnectionTypeTimeSeriesDatabaseConnectionProperties + objectMap := make(map[string]interface{}) + if tsdcp.ConnectionType != "" { + objectMap["connectionType"] = tsdcp.ConnectionType + } + return json.Marshal(objectMap) +} + +// AsAzureDataExplorerConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsAzureDataExplorerConnectionProperties() (*AzureDataExplorerConnectionProperties, bool) { + return nil, false +} + +// AsTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsTimeSeriesDatabaseConnectionProperties() (*TimeSeriesDatabaseConnectionProperties, bool) { + return &tsdcp, true +} + +// AsBasicTimeSeriesDatabaseConnectionProperties is the BasicTimeSeriesDatabaseConnectionProperties implementation for TimeSeriesDatabaseConnectionProperties. +func (tsdcp TimeSeriesDatabaseConnectionProperties) AsBasicTimeSeriesDatabaseConnectionProperties() (BasicTimeSeriesDatabaseConnectionProperties, bool) { + return &tsdcp, true +} + +// TimeSeriesDatabaseConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type TimeSeriesDatabaseConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TimeSeriesDatabaseConnectionsClient) (TimeSeriesDatabaseConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TimeSeriesDatabaseConnectionsCreateOrUpdateFuture) 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 TimeSeriesDatabaseConnectionsCreateOrUpdateFuture.Result. +func (future *TimeSeriesDatabaseConnectionsCreateOrUpdateFuture) result(client TimeSeriesDatabaseConnectionsClient) (tsdc TimeSeriesDatabaseConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsdc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsdc.Response.Response, err = future.GetResult(sender); err == nil && tsdc.Response.Response.StatusCode != http.StatusNoContent { + tsdc, err = client.CreateOrUpdateResponder(tsdc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsCreateOrUpdateFuture", "Result", tsdc.Response.Response, "Failure responding to request") + } + } + return +} + +// TimeSeriesDatabaseConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type TimeSeriesDatabaseConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(TimeSeriesDatabaseConnectionsClient) (TimeSeriesDatabaseConnection, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *TimeSeriesDatabaseConnectionsDeleteFuture) 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 TimeSeriesDatabaseConnectionsDeleteFuture.Result. +func (future *TimeSeriesDatabaseConnectionsDeleteFuture) result(client TimeSeriesDatabaseConnectionsClient) (tsdc TimeSeriesDatabaseConnection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + tsdc.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if tsdc.Response.Response, err = future.GetResult(sender); err == nil && tsdc.Response.Response.StatusCode != http.StatusNoContent { + tsdc, err = client.DeleteResponder(tsdc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsDeleteFuture", "Result", tsdc.Response.Response, "Failure responding to request") + } + } + return +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(Client) (Description, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *UpdateFuture) 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 UpdateFuture.Result. +func (future *UpdateFuture) result(client Client) (d Description, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + d.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("digitaltwins.UpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { + d, err = client.UpdateResponder(d.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.UpdateFuture", "Result", d.Response.Response, "Failure responding to request") + } + } + return +} diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/operations.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/operations.go new file mode 100644 index 000000000000..a3978f832358 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/operations.go @@ -0,0 +1,140 @@ +package digitaltwins + +// 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 azure Digital Twins Client for managing DigitalTwinsInstance +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 DigitalTwins service 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, "digitaltwins.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, "digitaltwins.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.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 = "2021-06-30-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.DigitalTwins/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, "digitaltwins.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, "digitaltwins.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privateendpointconnections.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privateendpointconnections.go new file mode 100644 index 000000000000..cd822190f06f --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privateendpointconnections.go @@ -0,0 +1,397 @@ +package digitaltwins + +// 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" +) + +// PrivateEndpointConnectionsClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient 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 NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the status of a private endpoint connection with the given name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +// privateEndpointConnection - the private endpoint connection with updated properties. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: privateEndpointConnection, + Constraints: []validation.Constraint{{Target: "privateEndpointConnection.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(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 = "2021-06-30-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + privateEndpointConnection.SystemData = 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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(privateEndpointConnection), + 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 PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, 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 PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete private endpoint connection with the specified name. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, 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 PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get private endpoint connection properties for the given private endpoint. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// privateEndpointConnectionName - the name of the private endpoint connection. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", 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 PrivateEndpointConnectionsClient) 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 PrivateEndpointConnectionsClient) GetResponder(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 +} + +// List list private endpoint connection properties. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionsResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.List") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateEndpointConnectionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateEndpointConnectionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateEndpointConnectionsClient) ListPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) 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 PrivateEndpointConnectionsClient) ListResponder(resp *http.Response) (result PrivateEndpointConnectionsResponse, 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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privatelinkresources.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privatelinkresources.go new file mode 100644 index 000000000000..2c77f07a9c23 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/privatelinkresources.go @@ -0,0 +1,207 @@ +package digitaltwins + +// 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" +) + +// PrivateLinkResourcesClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient 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 NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the specified private link resource for the given Digital Twin. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// resourceID - the name of the private link resource. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (result GroupIDInformation, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, resourceID) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, resourceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceId": autorest.Encode("path", resourceID), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}", 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 PrivateLinkResourcesClient) 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 PrivateLinkResourcesClient) GetResponder(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 +} + +// List list private link resources for given Digital Twin. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result GroupIDInformationResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.PrivateLinkResourcesClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkResourcesClient) ListPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources", 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 PrivateLinkResourcesClient) 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 PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result GroupIDInformationResponse, 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/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/timeseriesdatabaseconnections.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/timeseriesdatabaseconnections.go new file mode 100644 index 000000000000..f85a190df7fb --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/timeseriesdatabaseconnections.go @@ -0,0 +1,443 @@ +package digitaltwins + +// 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" +) + +// TimeSeriesDatabaseConnectionsClient is the azure Digital Twins Client for managing DigitalTwinsInstance +type TimeSeriesDatabaseConnectionsClient struct { + BaseClient +} + +// NewTimeSeriesDatabaseConnectionsClient creates an instance of the TimeSeriesDatabaseConnectionsClient client. +func NewTimeSeriesDatabaseConnectionsClient(subscriptionID string) TimeSeriesDatabaseConnectionsClient { + return NewTimeSeriesDatabaseConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTimeSeriesDatabaseConnectionsClientWithBaseURI creates an instance of the TimeSeriesDatabaseConnectionsClient +// 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 NewTimeSeriesDatabaseConnectionsClientWithBaseURI(baseURI string, subscriptionID string) TimeSeriesDatabaseConnectionsClient { + return TimeSeriesDatabaseConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +// timeSeriesDatabaseConnectionDescription - the time series database connection description. +func (client TimeSeriesDatabaseConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription TimeSeriesDatabaseConnection) (result TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName, timeSeriesDatabaseConnectionDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TimeSeriesDatabaseConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string, timeSeriesDatabaseConnectionDescription TimeSeriesDatabaseConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", pathParameters), + autorest.WithJSON(timeSeriesDatabaseConnectionDescription), + 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 TimeSeriesDatabaseConnectionsClient) CreateOrUpdateSender(req *http.Request) (future TimeSeriesDatabaseConnectionsCreateOrUpdateFuture, 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 TimeSeriesDatabaseConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 delete a time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +func (client TimeSeriesDatabaseConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result TimeSeriesDatabaseConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.Delete") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client TimeSeriesDatabaseConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", 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 TimeSeriesDatabaseConnectionsClient) DeleteSender(req *http.Request) (future TimeSeriesDatabaseConnectionsDeleteFuture, 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 TimeSeriesDatabaseConnectionsClient) DeleteResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 description of an existing time series database connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +// timeSeriesDatabaseConnectionName - name of time series database connection. +func (client TimeSeriesDatabaseConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (result TimeSeriesDatabaseConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.Get") + 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: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: timeSeriesDatabaseConnectionName, + Constraints: []validation.Constraint{{Target: "timeSeriesDatabaseConnectionName", Name: validation.MaxLength, Rule: 49, Chain: nil}, + {Target: "timeSeriesDatabaseConnectionName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, timeSeriesDatabaseConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client TimeSeriesDatabaseConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, timeSeriesDatabaseConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "timeSeriesDatabaseConnectionName": autorest.Encode("path", timeSeriesDatabaseConnectionName), + } + + const APIVersion = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections/{timeSeriesDatabaseConnectionName}", 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 TimeSeriesDatabaseConnectionsClient) 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 TimeSeriesDatabaseConnectionsClient) GetResponder(resp *http.Response) (result TimeSeriesDatabaseConnection, 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 existing time series database connections for this DigitalTwins instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the DigitalTwinsInstance. +// resourceName - the name of the DigitalTwinsInstance. +func (client TimeSeriesDatabaseConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result TimeSeriesDatabaseConnectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.List") + defer func() { + sc := -1 + if result.tsdclr.Response.Response != nil { + sc = result.tsdclr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 63, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.tsdclr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", resp, "Failure sending request") + return + } + + result.tsdclr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "List", resp, "Failure responding to request") + return + } + if result.tsdclr.hasNextLink() && result.tsdclr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client TimeSeriesDatabaseConnectionsClient) ListPreparer(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 = "2021-06-30-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.DigitalTwins/digitalTwinsInstances/{resourceName}/timeSeriesDatabaseConnections", 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 TimeSeriesDatabaseConnectionsClient) 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 TimeSeriesDatabaseConnectionsClient) ListResponder(resp *http.Response) (result TimeSeriesDatabaseConnectionListResult, 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 TimeSeriesDatabaseConnectionsClient) listNextResults(ctx context.Context, lastResults TimeSeriesDatabaseConnectionListResult) (result TimeSeriesDatabaseConnectionListResult, err error) { + req, err := lastResults.timeSeriesDatabaseConnectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "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, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "digitaltwins.TimeSeriesDatabaseConnectionsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TimeSeriesDatabaseConnectionsClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result TimeSeriesDatabaseConnectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TimeSeriesDatabaseConnectionsClient.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, resourceGroupName, resourceName) + return +} diff --git a/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/version.go b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/version.go new file mode 100644 index 000000000000..1ca36c2fccb6 --- /dev/null +++ b/services/preview/digitaltwins/mgmt/2021-06-30-preview/digitaltwins/version.go @@ -0,0 +1,19 @@ +package digitaltwins + +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() + " digitaltwins/2021-06-30-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}