From 843edc30c618744ae2aca9ef760aeef45a91f9eb Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 16 Dec 2020 03:52:48 +0000 Subject: [PATCH] CodeGen from PR 10996 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.DigitalTwins to add version stable/2020-12-01 (#10996) * Adds base for updating Microsoft.DigitalTwins from version stable/2020-10-31 to version 2020-12-01 * Updates readme * Updates API version in new specs and examples * Update swagger spec * Modify SDK build configs * Fix example filename reference * Rename example file * Fix validation errors * Updated examples * Revert change to behavior of async op * Modify discriminators * Enable two discriminators * Fix delete endpoint example * Attempted fix with discriminator * Added westus2, change discriminator enum type name * Decouple allOf from properties * Bugfixes * Modify response to fix validation errors * Fix examples * Change private link type names to be smaller * Fix validation errors in private links * Fix validation error related to private links * Reference private link example * Add public network access * Align with GA swagger * Update private links / private endpoints * Fix example to use actual response status code * Remove unused example * Unmark private endpoint connection to be an azure resource * Add type and name to private endpoint connection resource * Mark id as read-only * Fix return types for endpoint connections * Align return of DELETE * Fix validation errors * Fix version tag in python.md; remove body from DELETE endpoint connection DELETE responses * Synchronize swagger with 2020-10-31 version * Increase resource group name max length to 90 characters * Make publicNetworkAccess nullable * Add publicNetworkAccess flag to PATCH request * Fixed typo * Fix placing of example for endpoints * Update operation ids * Added suppression message --- .../mgmt/2020-12-01/digitaltwins/client.go | 52 + .../2020-12-01/digitaltwins/digitaltwins.go | 715 ++++++++ .../digitaltwinsapi/interfaces.go | 75 + .../mgmt/2020-12-01/digitaltwins/endpoint.go | 445 +++++ .../mgmt/2020-12-01/digitaltwins/enums.go | 201 +++ .../mgmt/2020-12-01/digitaltwins/models.go | 1594 +++++++++++++++++ .../2020-12-01/digitaltwins/operations.go | 151 ++ .../privateendpointconnections.go | 399 +++++ .../digitaltwins/privatelinkresources.go | 218 +++ .../mgmt/2020-12-01/digitaltwins/version.go | 30 + 10 files changed, 3880 insertions(+) create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/client.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwins.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwinsapi/interfaces.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/endpoint.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/enums.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/models.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/operations.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/privateendpointconnections.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/privatelinkresources.go create mode 100644 services/digitaltwins/mgmt/2020-12-01/digitaltwins/version.go diff --git a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/client.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/client.go new file mode 100644 index 000000000000..3cb68e8dc26b --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/client.go @@ -0,0 +1,52 @@ +// Package digitaltwins implements the Azure ARM Digitaltwins service API version 2020-12-01. +// +// Azure Digital Twins Client for managing DigitalTwinsInstance +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "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/2020-12-01/digitaltwins/digitaltwins.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwins.go new file mode 100644 index 000000000000..13847f8d55b8 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwins.go @@ -0,0 +1,715 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 = "2020-12-01" + 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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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/2020-12-01/digitaltwins/digitaltwinsapi/interfaces.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwinsapi/interfaces.go new file mode 100644 index 000000000000..b1fbefca9fe8 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/digitaltwinsapi/interfaces.go @@ -0,0 +1,75 @@ +package digitaltwinsapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/digitaltwins/mgmt/2020-12-01/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) diff --git a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/endpoint.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/endpoint.go new file mode 100644 index 000000000000..9301d94cebf5 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/endpoint.go @@ -0,0 +1,445 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/2020-12-01/digitaltwins/enums.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/enums.go new file mode 100644 index 000000000000..eee6e7afaa4e --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/enums.go @@ -0,0 +1,201 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// 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} +} + +// 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} +} diff --git a/services/digitaltwins/mgmt/2020-12-01/digitaltwins/models.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/models.go new file mode 100644 index 000000000000..a4573533bbf5 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/models.go @@ -0,0 +1,1594 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "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/2020-12-01/digitaltwins" + +// 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 *ConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + // GroupIds - The list of group ids for the private endpoint connection. + GroupIds *[]string `json:"groupIds,omitempty"` + 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) +} + +// ConnectionPropertiesPrivateEndpoint ... +type ConnectionPropertiesPrivateEndpoint struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` +} + +// ConnectionPropertiesPrivateLinkServiceConnectionState ... +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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// 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 + } + } + } + + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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"` +} + +// 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 + } + } + } + + 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. 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"` +} + +// 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. 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. 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"` +} + +// GroupIDInformation the group information for creating a private endpoint on Digital Twin. +type GroupIDInformation struct { + autorest.Response `json:"-"` + Properties *GroupIDInformationPropertiesModel `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"` +} + +// GroupIDInformationPropertiesModel ... +type GroupIDInformationPropertiesModel 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.Properties != nil { + objectMap["properties"] = pec.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties ... +type PrivateEndpointConnectionProperties struct { + // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + ProvisioningState ConnectionPropertiesProvisioningState `json:"provisioningState,omitempty"` + PrivateEndpoint *ConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + // GroupIds - The list of group ids for the private endpoint connection. + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *ConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pec PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pec.PrivateEndpoint + } + if pec.GroupIds != nil { + objectMap["groupIds"] = pec.GroupIds + } + if pec.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pec.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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 *[]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"` +} + +// 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. 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 +} + +// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type UpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +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 { + 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/2020-12-01/digitaltwins/operations.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/operations.go new file mode 100644 index 000000000000..f2dc6c028bbd --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/operations.go @@ -0,0 +1,151 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/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 = "2020-12-01" + 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/2020-12-01/digitaltwins/privateendpointconnections.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/privateendpointconnections.go new file mode 100644 index 000000000000..2ac26a664e4f --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/privateendpointconnections.go @@ -0,0 +1,399 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + privateEndpointConnection.ID = nil + privateEndpointConnection.Name = nil + privateEndpointConnection.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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.Response() != nil { + sc = result.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + 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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/2020-12-01/digitaltwins/privatelinkresources.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/privatelinkresources.go new file mode 100644 index 000000000000..2f7dc8d6f0f9 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/privatelinkresources.go @@ -0,0 +1,218 @@ +package digitaltwins + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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 = "2020-12-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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/2020-12-01/digitaltwins/version.go b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/version.go new file mode 100644 index 000000000000..7d19e2abd067 --- /dev/null +++ b/services/digitaltwins/mgmt/2020-12-01/digitaltwins/version.go @@ -0,0 +1,30 @@ +package digitaltwins + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " digitaltwins/2020-12-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}