diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/CHANGELOG.md b/sdk/resourcemanager/digitaltwins/armdigitaltwins/CHANGELOG.md new file mode 100644 index 000000000000..8b8db847a1a2 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-30) diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/LICENSE.txt b/sdk/resourcemanager/digitaltwins/armdigitaltwins/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/README.md b/sdk/resourcemanager/digitaltwins/armdigitaltwins/README.md new file mode 100644 index 000000000000..ccfef3ac3812 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/README.md @@ -0,0 +1,75 @@ +# Azure Digitaltwins Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/digitaltwins/armdigitaltwins)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/digitaltwins/armdigitaltwins) + +The `armdigitaltwins` module provides operations for working with Azure Digitaltwins. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/digitaltwins/armdigitaltwins) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Digitaltwins module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/digitaltwins/armdigitaltwins +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Digitaltwins. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Digitaltwins modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client := armdigitaltwins.NewDigitalTwinsClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options = arm.ClientOptions{ + Host: arm.AzureChina, +} +client := armdigitaltwins.NewDigitalTwinsClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Digitaltwins` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/autorest.md b/sdk/resourcemanager/digitaltwins/armdigitaltwins/autorest.md new file mode 100644 index 000000000000..2d703999926b --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/digitaltwins/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/build.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/build.go new file mode 100644 index 000000000000..12197163a5a0 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/digitaltwins/armdigitaltwins + +package armdigitaltwins diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/ci.yml b/sdk/resourcemanager/digitaltwins/armdigitaltwins/ci.yml new file mode 100644 index 000000000000..c842c33fa916 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/digitaltwins/armdigitaltwins/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/digitaltwins/armdigitaltwins/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/digitaltwins/armdigitaltwins' diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.mod b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.mod new file mode 100644 index 000000000000..f8a4c639ba59 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/digitaltwins/armdigitaltwins + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.sum b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.sum new file mode 100644 index 000000000000..aa6cc05eede2 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/go_mod_tidy_hack.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go_mod_tidy_hack.go new file mode 100644 index 000000000000..78431b4023dc --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armdigitaltwins + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_constants.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_constants.go new file mode 100644 index 000000000000..7f376fd690d8 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_constants.go @@ -0,0 +1,249 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +const ( + module = "armdigitaltwins" + version = "v0.1.0" +) + +// AuthenticationType - Specifies the authentication type being used for connecting to the endpoint. +type AuthenticationType string + +const ( + AuthenticationTypeIdentityBased AuthenticationType = "IdentityBased" + AuthenticationTypeKeyBased AuthenticationType = "KeyBased" +) + +// PossibleAuthenticationTypeValues returns the possible values for the AuthenticationType const type. +func PossibleAuthenticationTypeValues() []AuthenticationType { + return []AuthenticationType{ + AuthenticationTypeIdentityBased, + AuthenticationTypeKeyBased, + } +} + +// ToPtr returns a *AuthenticationType pointing to the current value. +func (c AuthenticationType) ToPtr() *AuthenticationType { + return &c +} + +// ConnectionPropertiesProvisioningState - The provisioning state. +type ConnectionPropertiesProvisioningState string + +const ( + ConnectionPropertiesProvisioningStateApproved ConnectionPropertiesProvisioningState = "Approved" + ConnectionPropertiesProvisioningStateDisconnected ConnectionPropertiesProvisioningState = "Disconnected" + ConnectionPropertiesProvisioningStatePending ConnectionPropertiesProvisioningState = "Pending" + ConnectionPropertiesProvisioningStateRejected ConnectionPropertiesProvisioningState = "Rejected" +) + +// PossibleConnectionPropertiesProvisioningStateValues returns the possible values for the ConnectionPropertiesProvisioningState const type. +func PossibleConnectionPropertiesProvisioningStateValues() []ConnectionPropertiesProvisioningState { + return []ConnectionPropertiesProvisioningState{ + ConnectionPropertiesProvisioningStateApproved, + ConnectionPropertiesProvisioningStateDisconnected, + ConnectionPropertiesProvisioningStatePending, + ConnectionPropertiesProvisioningStateRejected, + } +} + +// ToPtr returns a *ConnectionPropertiesProvisioningState pointing to the current value. +func (c ConnectionPropertiesProvisioningState) ToPtr() *ConnectionPropertiesProvisioningState { + return &c +} + +// DigitalTwinsIdentityType - The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is supported. +type DigitalTwinsIdentityType string + +const ( + DigitalTwinsIdentityTypeNone DigitalTwinsIdentityType = "None" + DigitalTwinsIdentityTypeSystemAssigned DigitalTwinsIdentityType = "SystemAssigned" +) + +// PossibleDigitalTwinsIdentityTypeValues returns the possible values for the DigitalTwinsIdentityType const type. +func PossibleDigitalTwinsIdentityTypeValues() []DigitalTwinsIdentityType { + return []DigitalTwinsIdentityType{ + DigitalTwinsIdentityTypeNone, + DigitalTwinsIdentityTypeSystemAssigned, + } +} + +// ToPtr returns a *DigitalTwinsIdentityType pointing to the current value. +func (c DigitalTwinsIdentityType) ToPtr() *DigitalTwinsIdentityType { + return &c +} + +// EndpointProvisioningState - The provisioning state. +type EndpointProvisioningState string + +const ( + EndpointProvisioningStateCanceled EndpointProvisioningState = "Canceled" + EndpointProvisioningStateDeleted EndpointProvisioningState = "Deleted" + EndpointProvisioningStateDeleting EndpointProvisioningState = "Deleting" + EndpointProvisioningStateDisabled EndpointProvisioningState = "Disabled" + EndpointProvisioningStateFailed EndpointProvisioningState = "Failed" + EndpointProvisioningStateMoving EndpointProvisioningState = "Moving" + EndpointProvisioningStateProvisioning EndpointProvisioningState = "Provisioning" + EndpointProvisioningStateRestoring EndpointProvisioningState = "Restoring" + EndpointProvisioningStateSucceeded EndpointProvisioningState = "Succeeded" + EndpointProvisioningStateSuspending EndpointProvisioningState = "Suspending" + EndpointProvisioningStateWarning EndpointProvisioningState = "Warning" +) + +// PossibleEndpointProvisioningStateValues returns the possible values for the EndpointProvisioningState const type. +func PossibleEndpointProvisioningStateValues() []EndpointProvisioningState { + return []EndpointProvisioningState{ + EndpointProvisioningStateCanceled, + EndpointProvisioningStateDeleted, + EndpointProvisioningStateDeleting, + EndpointProvisioningStateDisabled, + EndpointProvisioningStateFailed, + EndpointProvisioningStateMoving, + EndpointProvisioningStateProvisioning, + EndpointProvisioningStateRestoring, + EndpointProvisioningStateSucceeded, + EndpointProvisioningStateSuspending, + EndpointProvisioningStateWarning, + } +} + +// ToPtr returns a *EndpointProvisioningState pointing to the current value. +func (c EndpointProvisioningState) ToPtr() *EndpointProvisioningState { + return &c +} + +// EndpointType - The type of Digital Twins endpoint +type EndpointType string + +const ( + EndpointTypeEventGrid EndpointType = "EventGrid" + EndpointTypeEventHub EndpointType = "EventHub" + EndpointTypeServiceBus EndpointType = "ServiceBus" +) + +// PossibleEndpointTypeValues returns the possible values for the EndpointType const type. +func PossibleEndpointTypeValues() []EndpointType { + return []EndpointType{ + EndpointTypeEventGrid, + EndpointTypeEventHub, + EndpointTypeServiceBus, + } +} + +// ToPtr returns a *EndpointType pointing to the current value. +func (c EndpointType) ToPtr() *EndpointType { + return &c +} + +// PrivateLinkServiceConnectionStatus - The status of a private endpoint connection. +type PrivateLinkServiceConnectionStatus string + +const ( + PrivateLinkServiceConnectionStatusApproved PrivateLinkServiceConnectionStatus = "Approved" + PrivateLinkServiceConnectionStatusDisconnected PrivateLinkServiceConnectionStatus = "Disconnected" + PrivateLinkServiceConnectionStatusPending PrivateLinkServiceConnectionStatus = "Pending" + PrivateLinkServiceConnectionStatusRejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns the possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{ + PrivateLinkServiceConnectionStatusApproved, + PrivateLinkServiceConnectionStatusDisconnected, + PrivateLinkServiceConnectionStatusPending, + PrivateLinkServiceConnectionStatusRejected, + } +} + +// ToPtr returns a *PrivateLinkServiceConnectionStatus pointing to the current value. +func (c PrivateLinkServiceConnectionStatus) ToPtr() *PrivateLinkServiceConnectionStatus { + return &c +} + +// ProvisioningState - The provisioning state. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateRestoring ProvisioningState = "Restoring" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateSuspending ProvisioningState = "Suspending" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateWarning ProvisioningState = "Warning" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateMoving, + ProvisioningStateProvisioning, + ProvisioningStateRestoring, + ProvisioningStateSucceeded, + ProvisioningStateSuspending, + ProvisioningStateUpdating, + ProvisioningStateWarning, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - Public network access for the DigitalTwinsInstance. +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccess pointing to the current value. +func (c PublicNetworkAccess) ToPtr() *PublicNetworkAccess { + return &c +} + +// Reason - Message providing the reason why the given name is invalid. +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAlreadyExists, + ReasonInvalid, + } +} + +// ToPtr returns a *Reason pointing to the current value. +func (c Reason) ToPtr() *Reason { + return &c +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwins_client.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwins_client.go new file mode 100644 index 000000000000..84bdcb6d954d --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwins_client.go @@ -0,0 +1,513 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DigitalTwinsClient contains the methods for the DigitalTwins group. +// Don't use this type directly, use NewDigitalTwinsClient() instead. +type DigitalTwinsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDigitalTwinsClient creates a new instance of DigitalTwinsClient with the specified values. +func NewDigitalTwinsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DigitalTwinsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DigitalTwinsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// CheckNameAvailability - Check if a DigitalTwinsInstance name is available. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) CheckNameAvailability(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest, options *DigitalTwinsCheckNameAvailabilityOptions) (DigitalTwinsCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, location, digitalTwinsInstanceCheckName, options) + if err != nil { + return DigitalTwinsCheckNameAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DigitalTwinsCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DigitalTwinsCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *DigitalTwinsClient) checkNameAvailabilityCreateRequest(ctx context.Context, location string, digitalTwinsInstanceCheckName CheckNameRequest, options *DigitalTwinsCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/locations/{location}/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, digitalTwinsInstanceCheckName) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *DigitalTwinsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (DigitalTwinsCheckNameAvailabilityResponse, error) { + result := DigitalTwinsCheckNameAvailabilityResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameResult); err != nil { + return DigitalTwinsCheckNameAvailabilityResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *DigitalTwinsClient) checkNameAvailabilityHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginCreateOrUpdate - 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. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate DigitalTwinsDescription, options *DigitalTwinsBeginCreateOrUpdateOptions) (DigitalTwinsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, digitalTwinsCreate, options) + if err != nil { + return DigitalTwinsCreateOrUpdatePollerResponse{}, err + } + result := DigitalTwinsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DigitalTwinsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DigitalTwinsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DigitalTwinsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// 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. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate DigitalTwinsDescription, options *DigitalTwinsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, digitalTwinsCreate, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DigitalTwinsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsCreate DigitalTwinsDescription, options *DigitalTwinsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, digitalTwinsCreate) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DigitalTwinsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete a DigitalTwinsInstance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsBeginDeleteOptions) (DigitalTwinsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return DigitalTwinsDeletePollerResponse{}, err + } + result := DigitalTwinsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DigitalTwinsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DigitalTwinsDeletePollerResponse{}, err + } + result.Poller = &DigitalTwinsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a DigitalTwinsInstance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DigitalTwinsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DigitalTwinsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get DigitalTwinsInstances resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsGetOptions) (DigitalTwinsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return DigitalTwinsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DigitalTwinsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DigitalTwinsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DigitalTwinsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DigitalTwinsClient) getHandleResponse(resp *http.Response) (DigitalTwinsGetResponse, error) { + result := DigitalTwinsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DigitalTwinsDescription); err != nil { + return DigitalTwinsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DigitalTwinsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get all the DigitalTwinsInstances in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) List(options *DigitalTwinsListOptions) *DigitalTwinsListPager { + return &DigitalTwinsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp DigitalTwinsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.DigitalTwinsDescriptionListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *DigitalTwinsClient) listCreateRequest(ctx context.Context, options *DigitalTwinsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DigitalTwinsClient) listHandleResponse(resp *http.Response) (DigitalTwinsListResponse, error) { + result := DigitalTwinsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DigitalTwinsDescriptionListResult); err != nil { + return DigitalTwinsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DigitalTwinsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - Get all the DigitalTwinsInstances in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) ListByResourceGroup(resourceGroupName string, options *DigitalTwinsListByResourceGroupOptions) *DigitalTwinsListByResourceGroupPager { + return &DigitalTwinsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp DigitalTwinsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.DigitalTwinsDescriptionListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DigitalTwinsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DigitalTwinsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DigitalTwinsClient) listByResourceGroupHandleResponse(resp *http.Response) (DigitalTwinsListByResourceGroupResponse, error) { + result := DigitalTwinsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DigitalTwinsDescriptionListResult); err != nil { + return DigitalTwinsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *DigitalTwinsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Update metadata of DigitalTwinsInstance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) BeginUpdate(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription DigitalTwinsPatchDescription, options *DigitalTwinsBeginUpdateOptions) (DigitalTwinsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, resourceName, digitalTwinsPatchDescription, options) + if err != nil { + return DigitalTwinsUpdatePollerResponse{}, err + } + result := DigitalTwinsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DigitalTwinsClient.Update", "", resp, client.pl, client.updateHandleError) + if err != nil { + return DigitalTwinsUpdatePollerResponse{}, err + } + result.Poller = &DigitalTwinsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update metadata of DigitalTwinsInstance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsClient) update(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription DigitalTwinsPatchDescription, options *DigitalTwinsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, digitalTwinsPatchDescription, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DigitalTwinsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, digitalTwinsPatchDescription DigitalTwinsPatchDescription, options *DigitalTwinsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, digitalTwinsPatchDescription) +} + +// updateHandleError handles the Update error response. +func (client *DigitalTwinsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwinsendpoint_client.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwinsendpoint_client.go new file mode 100644 index 000000000000..658e0867a1c9 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_digitaltwinsendpoint_client.go @@ -0,0 +1,334 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DigitalTwinsEndpointClient contains the methods for the DigitalTwinsEndpoint group. +// Don't use this type directly, use NewDigitalTwinsEndpointClient() instead. +type DigitalTwinsEndpointClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewDigitalTwinsEndpointClient creates a new instance of DigitalTwinsEndpointClient with the specified values. +func NewDigitalTwinsEndpointClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *DigitalTwinsEndpointClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &DigitalTwinsEndpointClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update DigitalTwinsInstance endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription DigitalTwinsEndpointResource, options *DigitalTwinsEndpointBeginCreateOrUpdateOptions) (DigitalTwinsEndpointCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, endpointName, endpointDescription, options) + if err != nil { + return DigitalTwinsEndpointCreateOrUpdatePollerResponse{}, err + } + result := DigitalTwinsEndpointCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DigitalTwinsEndpointClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return DigitalTwinsEndpointCreateOrUpdatePollerResponse{}, err + } + result.Poller = &DigitalTwinsEndpointCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update DigitalTwinsInstance endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription DigitalTwinsEndpointResource, options *DigitalTwinsEndpointBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, endpointName, endpointDescription, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DigitalTwinsEndpointClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, endpointDescription DigitalTwinsEndpointResource, options *DigitalTwinsEndpointBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, endpointDescription) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DigitalTwinsEndpointClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete a DigitalTwinsInstance endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, options *DigitalTwinsEndpointBeginDeleteOptions) (DigitalTwinsEndpointDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, endpointName, options) + if err != nil { + return DigitalTwinsEndpointDeletePollerResponse{}, err + } + result := DigitalTwinsEndpointDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("DigitalTwinsEndpointClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return DigitalTwinsEndpointDeletePollerResponse{}, err + } + result.Poller = &DigitalTwinsEndpointDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete a DigitalTwinsInstance endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, options *DigitalTwinsEndpointBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, endpointName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DigitalTwinsEndpointClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, options *DigitalTwinsEndpointBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DigitalTwinsEndpointClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get DigitalTwinsInstances Endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) Get(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, options *DigitalTwinsEndpointGetOptions) (DigitalTwinsEndpointGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, endpointName, options) + if err != nil { + return DigitalTwinsEndpointGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DigitalTwinsEndpointGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DigitalTwinsEndpointGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DigitalTwinsEndpointClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, endpointName string, options *DigitalTwinsEndpointGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints/{endpointName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DigitalTwinsEndpointClient) getHandleResponse(resp *http.Response) (DigitalTwinsEndpointGetResponse, error) { + result := DigitalTwinsEndpointGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DigitalTwinsEndpointResource); err != nil { + return DigitalTwinsEndpointGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DigitalTwinsEndpointClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - Get DigitalTwinsInstance Endpoints. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DigitalTwinsEndpointClient) List(resourceGroupName string, resourceName string, options *DigitalTwinsEndpointListOptions) *DigitalTwinsEndpointListPager { + return &DigitalTwinsEndpointListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, resourceName, options) + }, + advancer: func(ctx context.Context, resp DigitalTwinsEndpointListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.DigitalTwinsEndpointResourceListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *DigitalTwinsEndpointClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *DigitalTwinsEndpointListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/endpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DigitalTwinsEndpointClient) listHandleResponse(resp *http.Response) (DigitalTwinsEndpointListResponse, error) { + result := DigitalTwinsEndpointListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.DigitalTwinsEndpointResourceListResult); err != nil { + return DigitalTwinsEndpointListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *DigitalTwinsEndpointClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_models.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_models.go new file mode 100644 index 000000000000..b6265f0c8e21 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_models.go @@ -0,0 +1,908 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// CheckNameRequest - The result returned from a database check name availability request. +type CheckNameRequest struct { + // REQUIRED; Resource name. + Name *string `json:"name,omitempty"` + + // REQUIRED; 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 { + // Message indicating an unavailable name due to a conflict, or a description of the naming rules that are violated. + Message *string `json:"message,omitempty"` + + // Specifies a Boolean value that indicates if the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // Message providing the reason why the given name is invalid. + Reason *Reason `json:"reason,omitempty"` +} + +// ConnectionProperties - The properties of a private endpoint connection. +type ConnectionProperties struct { + // The list of group ids for the private endpoint connection. + GroupIDs []*string `json:"groupIds,omitempty"` + PrivateEndpoint *ConnectionPropertiesPrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *ConnectionPropertiesPrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + + // READ-ONLY; The provisioning state. + ProvisioningState *ConnectionPropertiesProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectionProperties. +func (c ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (c ConnectionProperties) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "groupIds", c.GroupIDs) + populate(objectMap, "privateEndpoint", c.PrivateEndpoint) + populate(objectMap, "privateLinkServiceConnectionState", c.PrivateLinkServiceConnectionState) + populate(objectMap, "provisioningState", c.ProvisioningState) +} + +type ConnectionPropertiesPrivateEndpoint struct { + PrivateEndpoint +} + +type ConnectionPropertiesPrivateLinkServiceConnectionState struct { + ConnectionState +} + +// ConnectionState - The current state of a private endpoint connection. +type ConnectionState struct { + // REQUIRED; The description for the current state of a private endpoint connection. + Description *string `json:"description,omitempty"` + + // REQUIRED; The status of a private endpoint connection. + Status *PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + + // Actions required for a private endpoint connection. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// DigitalTwinsBeginCreateOrUpdateOptions contains the optional parameters for the DigitalTwins.BeginCreateOrUpdate method. +type DigitalTwinsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsBeginDeleteOptions contains the optional parameters for the DigitalTwins.BeginDelete method. +type DigitalTwinsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsBeginUpdateOptions contains the optional parameters for the DigitalTwins.BeginUpdate method. +type DigitalTwinsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsCheckNameAvailabilityOptions contains the optional parameters for the DigitalTwins.CheckNameAvailability method. +type DigitalTwinsCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsDescription - The description of the DigitalTwins service. +type DigitalTwinsDescription struct { + DigitalTwinsResource + // DigitalTwins instance properties. + Properties *DigitalTwinsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsDescription. +func (d DigitalTwinsDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.DigitalTwinsResource.marshalInternal(objectMap) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// DigitalTwinsDescriptionListResult - A list of DigitalTwins description objects with a next link. +type DigitalTwinsDescriptionListResult struct { + // The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + + // A list of DigitalTwins description objects. + Value []*DigitalTwinsDescription `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsDescriptionListResult. +func (d DigitalTwinsDescriptionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DigitalTwinsEndpointBeginCreateOrUpdateOptions contains the optional parameters for the DigitalTwinsEndpoint.BeginCreateOrUpdate method. +type DigitalTwinsEndpointBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsEndpointBeginDeleteOptions contains the optional parameters for the DigitalTwinsEndpoint.BeginDelete method. +type DigitalTwinsEndpointBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsEndpointGetOptions contains the optional parameters for the DigitalTwinsEndpoint.Get method. +type DigitalTwinsEndpointGetOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsEndpointListOptions contains the optional parameters for the DigitalTwinsEndpoint.List method. +type DigitalTwinsEndpointListOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsEndpointResource - DigitalTwinsInstance endpoint resource. +type DigitalTwinsEndpointResource struct { + ExternalResource + // REQUIRED; DigitalTwinsInstance endpoint resource properties. + Properties DigitalTwinsEndpointResourcePropertiesClassification `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsEndpointResource. +func (d DigitalTwinsEndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.ExternalResource.marshalInternal(objectMap) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DigitalTwinsEndpointResource. +func (d *DigitalTwinsEndpointResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + d.Properties, err = unmarshalDigitalTwinsEndpointResourcePropertiesClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := d.ExternalResource.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// DigitalTwinsEndpointResourceListResult - A list of DigitalTwinsInstance Endpoints with a next link. +type DigitalTwinsEndpointResourceListResult struct { + // The link used to get the next page of DigitalTwinsInstance Endpoints. + NextLink *string `json:"nextLink,omitempty"` + + // A list of DigitalTwinsInstance Endpoints. + Value []*DigitalTwinsEndpointResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsEndpointResourceListResult. +func (d DigitalTwinsEndpointResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DigitalTwinsEndpointResourcePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetDigitalTwinsEndpointResourceProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DigitalTwinsEndpointResourceProperties, *EventGrid, *EventHub, *ServiceBus +type DigitalTwinsEndpointResourcePropertiesClassification interface { + // GetDigitalTwinsEndpointResourceProperties returns the DigitalTwinsEndpointResourceProperties content of the underlying type. + GetDigitalTwinsEndpointResourceProperties() *DigitalTwinsEndpointResourceProperties +} + +// DigitalTwinsEndpointResourceProperties - Properties related to Digital Twins Endpoint +type DigitalTwinsEndpointResourceProperties struct { + // REQUIRED; The type of Digital Twins endpoint + EndpointType *EndpointType `json:"endpointType,omitempty"` + + // Specifies the authentication type being used for connecting to the endpoint. + AuthenticationType *AuthenticationType `json:"authenticationType,omitempty"` + + // Dead letter storage secret for key-based authentication. Will be obfuscated during read. + DeadLetterSecret *string `json:"deadLetterSecret,omitempty"` + + // Dead letter storage URL for identity-based authentication. + DeadLetterURI *string `json:"deadLetterUri,omitempty"` + + // READ-ONLY; Time when the Endpoint was added to DigitalTwinsInstance. + CreatedTime *time.Time `json:"createdTime,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state. + ProvisioningState *EndpointProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetDigitalTwinsEndpointResourceProperties implements the DigitalTwinsEndpointResourcePropertiesClassification interface for type DigitalTwinsEndpointResourceProperties. +func (d *DigitalTwinsEndpointResourceProperties) GetDigitalTwinsEndpointResourceProperties() *DigitalTwinsEndpointResourceProperties { + return d +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DigitalTwinsEndpointResourceProperties. +func (d *DigitalTwinsEndpointResourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return d.unmarshalInternal(rawMsg) +} + +func (d DigitalTwinsEndpointResourceProperties) marshalInternal(objectMap map[string]interface{}, discValue EndpointType) { + populate(objectMap, "authenticationType", d.AuthenticationType) + populateTimeRFC3339(objectMap, "createdTime", d.CreatedTime) + populate(objectMap, "deadLetterSecret", d.DeadLetterSecret) + populate(objectMap, "deadLetterUri", d.DeadLetterURI) + d.EndpointType = &discValue + objectMap["endpointType"] = d.EndpointType + populate(objectMap, "provisioningState", d.ProvisioningState) +} + +func (d *DigitalTwinsEndpointResourceProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "authenticationType": + err = unpopulate(val, &d.AuthenticationType) + delete(rawMsg, key) + case "createdTime": + err = unpopulateTimeRFC3339(val, &d.CreatedTime) + delete(rawMsg, key) + case "deadLetterSecret": + err = unpopulate(val, &d.DeadLetterSecret) + delete(rawMsg, key) + case "deadLetterUri": + err = unpopulate(val, &d.DeadLetterURI) + delete(rawMsg, key) + case "endpointType": + err = unpopulate(val, &d.EndpointType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &d.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DigitalTwinsGetOptions contains the optional parameters for the DigitalTwins.Get method. +type DigitalTwinsGetOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsIdentity - The managed identity for the DigitalTwinsInstance. +type DigitalTwinsIdentity struct { + // The type of Managed Identity used by the DigitalTwinsInstance. Only SystemAssigned is supported. + Type *DigitalTwinsIdentityType `json:"type,omitempty"` + + // 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" azure:"ro"` + + // 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" azure:"ro"` +} + +// DigitalTwinsListByResourceGroupOptions contains the optional parameters for the DigitalTwins.ListByResourceGroup method. +type DigitalTwinsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsListOptions contains the optional parameters for the DigitalTwins.List method. +type DigitalTwinsListOptions struct { + // placeholder for future optional parameters +} + +// DigitalTwinsPatchDescription - The description of the DigitalTwins service. +type DigitalTwinsPatchDescription struct { + // The managed identity for the DigitalTwinsInstance. + Identity *DigitalTwinsIdentity `json:"identity,omitempty"` + + // Properties for the DigitalTwinsInstance. + Properties *DigitalTwinsPatchProperties `json:"properties,omitempty"` + + // Instance patch properties + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsPatchDescription. +func (d DigitalTwinsPatchDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// DigitalTwinsPatchProperties - The properties of a DigitalTwinsInstance. +type DigitalTwinsPatchProperties struct { + // Public network access for the DigitalTwinsInstance. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// DigitalTwinsProperties - The properties of a DigitalTwinsInstance. +type DigitalTwinsProperties struct { + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + + // Public network access for the DigitalTwinsInstance. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // READ-ONLY; Time when DigitalTwinsInstance was created. + CreatedTime *time.Time `json:"createdTime,omitempty" azure:"ro"` + + // READ-ONLY; Api endpoint to work with DigitalTwinsInstance. + HostName *string `json:"hostName,omitempty" azure:"ro"` + + // READ-ONLY; Time when DigitalTwinsInstance was updated. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsProperties. +func (d DigitalTwinsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdTime", d.CreatedTime) + populate(objectMap, "hostName", d.HostName) + populateTimeRFC3339(objectMap, "lastUpdatedTime", d.LastUpdatedTime) + populate(objectMap, "privateEndpointConnections", d.PrivateEndpointConnections) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "publicNetworkAccess", d.PublicNetworkAccess) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DigitalTwinsProperties. +func (d *DigitalTwinsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdTime": + err = unpopulateTimeRFC3339(val, &d.CreatedTime) + delete(rawMsg, key) + case "hostName": + err = unpopulate(val, &d.HostName) + delete(rawMsg, key) + case "lastUpdatedTime": + err = unpopulateTimeRFC3339(val, &d.LastUpdatedTime) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, &d.PrivateEndpointConnections) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &d.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, &d.PublicNetworkAccess) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DigitalTwinsResource - The common properties of a DigitalTwinsInstance. +type DigitalTwinsResource struct { + // REQUIRED; The resource location. + Location *string `json:"location,omitempty"` + + // The managed identity for the DigitalTwinsInstance. + Identity *DigitalTwinsIdentity `json:"identity,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DigitalTwinsResource. +func (d DigitalTwinsResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + d.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (d DigitalTwinsResource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) +} + +// ErrorDefinition - Error definition. +type ErrorDefinition struct { + // READ-ONLY; Service specific error code which serves as the substatus for the HTTP error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Internal error details. + Details []*ErrorDefinition `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Description of the error. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// ErrorResponse - Error response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // Error description + InnerError *ErrorDefinition `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// EventGrid - Properties related to EventGrid. +type EventGrid struct { + DigitalTwinsEndpointResourceProperties + // REQUIRED; EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey1 *string `json:"accessKey1,omitempty"` + + // REQUIRED; EventGrid Topic Endpoint + TopicEndpoint *string `json:"TopicEndpoint,omitempty"` + + // EventGrid secondary accesskey. Will be obfuscated during read. + AccessKey2 *string `json:"accessKey2,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventGrid. +func (e EventGrid) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.DigitalTwinsEndpointResourceProperties.marshalInternal(objectMap, EndpointTypeEventGrid) + populate(objectMap, "accessKey1", e.AccessKey1) + populate(objectMap, "accessKey2", e.AccessKey2) + populate(objectMap, "TopicEndpoint", e.TopicEndpoint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventGrid. +func (e *EventGrid) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "accessKey1": + err = unpopulate(val, &e.AccessKey1) + delete(rawMsg, key) + case "accessKey2": + err = unpopulate(val, &e.AccessKey2) + delete(rawMsg, key) + case "TopicEndpoint": + err = unpopulate(val, &e.TopicEndpoint) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.DigitalTwinsEndpointResourceProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// EventHub - Properties related to EventHub. +type EventHub struct { + DigitalTwinsEndpointResourceProperties + // PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringPrimaryKey *string `json:"connectionStringPrimaryKey,omitempty"` + + // SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + ConnectionStringSecondaryKey *string `json:"connectionStringSecondaryKey,omitempty"` + + // The URL of the EventHub namespace for identity-based authentication. It must include the protocol sb:// + EndpointURI *string `json:"endpointUri,omitempty"` + + // The EventHub name in the EventHub namespace for identity-based authentication. + EntityPath *string `json:"entityPath,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventHub. +func (e EventHub) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.DigitalTwinsEndpointResourceProperties.marshalInternal(objectMap, EndpointTypeEventHub) + populate(objectMap, "connectionStringPrimaryKey", e.ConnectionStringPrimaryKey) + populate(objectMap, "connectionStringSecondaryKey", e.ConnectionStringSecondaryKey) + populate(objectMap, "endpointUri", e.EndpointURI) + populate(objectMap, "entityPath", e.EntityPath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHub. +func (e *EventHub) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "connectionStringPrimaryKey": + err = unpopulate(val, &e.ConnectionStringPrimaryKey) + delete(rawMsg, key) + case "connectionStringSecondaryKey": + err = unpopulate(val, &e.ConnectionStringSecondaryKey) + delete(rawMsg, key) + case "endpointUri": + err = unpopulate(val, &e.EndpointURI) + delete(rawMsg, key) + case "entityPath": + err = unpopulate(val, &e.EntityPath) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := e.DigitalTwinsEndpointResourceProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +// ExternalResource - Definition of a resource. +type ExternalResource struct { + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Extension resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExternalResource. +func (e ExternalResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalResource. +func (e *ExternalResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return e.unmarshalInternal(rawMsg) +} + +func (e ExternalResource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "type", e.Type) +} + +func (e *ExternalResource) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &e.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &e.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GroupIDInformation - The group information for creating a private endpoint on Digital Twin. +type GroupIDInformation struct { + // REQUIRED + Properties *GroupIDInformationProperties `json:"properties,omitempty"` + + // The resource identifier. + ID *string `json:"id,omitempty"` + + // READ-ONLY; The resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +type GroupIDInformationProperties struct { + GroupIDInformationPropertiesAutoGenerated +} + +// GroupIDInformationPropertiesAutoGenerated - The properties for a group information object. +type GroupIDInformationPropertiesAutoGenerated struct { + // The group id + GroupID *string `json:"groupId,omitempty"` + + // The required members for a specific group id. + RequiredMembers []*string `json:"requiredMembers,omitempty"` + + // The required DNS zones for a specific group id. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupIDInformationPropertiesAutoGenerated. +func (g GroupIDInformationPropertiesAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + g.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (g GroupIDInformationPropertiesAutoGenerated) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "groupId", g.GroupID) + populate(objectMap, "requiredMembers", g.RequiredMembers) + populate(objectMap, "requiredZoneNames", g.RequiredZoneNames) +} + +// GroupIDInformationResponse - The available private link resources for a Digital Twin. +type GroupIDInformationResponse struct { + // The list of available private link resources for a Digital Twin. + Value []*GroupIDInformation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupIDInformationResponse. +func (g GroupIDInformationResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// Operation - DigitalTwins service REST API operation +type Operation struct { + // Operation properties display + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; If the operation is a data action (for data plane rbac). + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation. + Origin *string `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - The object that represents the operation. +type OperationDisplay struct { + // READ-ONLY; Friendly description for the operation, + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Name of the operation + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Service provider: Microsoft DigitalTwins + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type: DigitalTwinsInstances + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// 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 { + // The link used to get the next page of DigitalTwins description objects. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; A list of DigitalTwins operations supported by the Microsoft.DigitalTwins resource provider. + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpoint - The private endpoint property of a private endpoint connection. +type PrivateEndpoint struct { + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` +} + +// PrivateEndpointConnection - The private endpoint connection of a Digital Twin. +type PrivateEndpointConnection struct { + // REQUIRED + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + + // READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The resource type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +type PrivateEndpointConnectionProperties struct { + ConnectionProperties +} + +// PrivateEndpointConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnections.BeginCreateOrUpdate method. +type PrivateEndpointConnectionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnections.BeginDelete method. +type PrivateEndpointConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsResponse - The available private link connections for a Digital Twin. +type PrivateEndpointConnectionsResponse struct { + // The list of available private link connections for a Digital Twin. + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionsResponse. +func (p PrivateEndpointConnectionsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourcesGetOptions contains the optional parameters for the PrivateLinkResources.Get method. +type PrivateLinkResourcesGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResourcesListOptions contains the optional parameters for the PrivateLinkResources.List method. +type PrivateLinkResourcesListOptions struct { + // placeholder for future optional parameters +} + +// ServiceBus - Properties related to ServiceBus. +type ServiceBus struct { + DigitalTwinsEndpointResourceProperties + // The URL of the ServiceBus namespace for identity-based authentication. It must include the protocol sb:// + EndpointURI *string `json:"endpointUri,omitempty"` + + // The ServiceBus Topic name for identity-based authentication + EntityPath *string `json:"entityPath,omitempty"` + + // PrimaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + PrimaryConnectionString *string `json:"primaryConnectionString,omitempty"` + + // SecondaryConnectionString of the endpoint for key-based authentication. Will be obfuscated during read. + SecondaryConnectionString *string `json:"secondaryConnectionString,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceBus. +func (s ServiceBus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + s.DigitalTwinsEndpointResourceProperties.marshalInternal(objectMap, EndpointTypeServiceBus) + populate(objectMap, "endpointUri", s.EndpointURI) + populate(objectMap, "entityPath", s.EntityPath) + populate(objectMap, "primaryConnectionString", s.PrimaryConnectionString) + populate(objectMap, "secondaryConnectionString", s.SecondaryConnectionString) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceBus. +func (s *ServiceBus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "endpointUri": + err = unpopulate(val, &s.EndpointURI) + delete(rawMsg, key) + case "entityPath": + err = unpopulate(val, &s.EntityPath) + delete(rawMsg, key) + case "primaryConnectionString": + err = unpopulate(val, &s.PrimaryConnectionString) + delete(rawMsg, key) + case "secondaryConnectionString": + err = unpopulate(val, &s.SecondaryConnectionString) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + if err := s.DigitalTwinsEndpointResourceProperties.unmarshalInternal(rawMsg); err != nil { + return err + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_operations_client.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_operations_client.go new file mode 100644 index 000000000000..290c7dea9c86 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_operations_client.go @@ -0,0 +1,89 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - Lists all of the available DigitalTwins service REST API operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(options *OperationsListOptions) *OperationsListPager { + return &OperationsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp OperationsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.DigitalTwins/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pagers.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pagers.go new file mode 100644 index 000000000000..288955c72fc4 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pagers.go @@ -0,0 +1,233 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// DigitalTwinsEndpointListPager provides operations for iterating over paged responses. +type DigitalTwinsEndpointListPager struct { + client *DigitalTwinsEndpointClient + current DigitalTwinsEndpointListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, DigitalTwinsEndpointListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *DigitalTwinsEndpointListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *DigitalTwinsEndpointListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DigitalTwinsEndpointResourceListResult.NextLink == nil || len(*p.current.DigitalTwinsEndpointResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current DigitalTwinsEndpointListResponse page. +func (p *DigitalTwinsEndpointListPager) PageResponse() DigitalTwinsEndpointListResponse { + return p.current +} + +// DigitalTwinsListByResourceGroupPager provides operations for iterating over paged responses. +type DigitalTwinsListByResourceGroupPager struct { + client *DigitalTwinsClient + current DigitalTwinsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, DigitalTwinsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *DigitalTwinsListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *DigitalTwinsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DigitalTwinsDescriptionListResult.NextLink == nil || len(*p.current.DigitalTwinsDescriptionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current DigitalTwinsListByResourceGroupResponse page. +func (p *DigitalTwinsListByResourceGroupPager) PageResponse() DigitalTwinsListByResourceGroupResponse { + return p.current +} + +// DigitalTwinsListPager provides operations for iterating over paged responses. +type DigitalTwinsListPager struct { + client *DigitalTwinsClient + current DigitalTwinsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, DigitalTwinsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *DigitalTwinsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *DigitalTwinsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DigitalTwinsDescriptionListResult.NextLink == nil || len(*p.current.DigitalTwinsDescriptionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current DigitalTwinsListResponse page. +func (p *DigitalTwinsListPager) PageResponse() DigitalTwinsListResponse { + return p.current +} + +// OperationsListPager provides operations for iterating over paged responses. +type OperationsListPager struct { + client *OperationsClient + current OperationsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, OperationsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *OperationsListPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *OperationsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current OperationsListResponse page. +func (p *OperationsListPager) PageResponse() OperationsListResponse { + return p.current +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pollers.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pollers.go new file mode 100644 index 000000000000..ea5250032560 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_pollers.go @@ -0,0 +1,316 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// DigitalTwinsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DigitalTwinsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DigitalTwinsCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *DigitalTwinsCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final DigitalTwinsCreateOrUpdateResponse will be returned. +func (p *DigitalTwinsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DigitalTwinsCreateOrUpdateResponse, error) { + respType := DigitalTwinsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DigitalTwinsDescription) + if err != nil { + return DigitalTwinsCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *DigitalTwinsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DigitalTwinsDeletePoller provides polling facilities until the operation reaches a terminal state. +type DigitalTwinsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DigitalTwinsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *DigitalTwinsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final DigitalTwinsDeleteResponse will be returned. +func (p *DigitalTwinsDeletePoller) FinalResponse(ctx context.Context) (DigitalTwinsDeleteResponse, error) { + respType := DigitalTwinsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DigitalTwinsDescription) + if err != nil { + return DigitalTwinsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *DigitalTwinsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DigitalTwinsEndpointCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DigitalTwinsEndpointCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DigitalTwinsEndpointCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *DigitalTwinsEndpointCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final DigitalTwinsEndpointCreateOrUpdateResponse will be returned. +func (p *DigitalTwinsEndpointCreateOrUpdatePoller) FinalResponse(ctx context.Context) (DigitalTwinsEndpointCreateOrUpdateResponse, error) { + respType := DigitalTwinsEndpointCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DigitalTwinsEndpointResource) + if err != nil { + return DigitalTwinsEndpointCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *DigitalTwinsEndpointCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DigitalTwinsEndpointDeletePoller provides polling facilities until the operation reaches a terminal state. +type DigitalTwinsEndpointDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DigitalTwinsEndpointDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *DigitalTwinsEndpointDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final DigitalTwinsEndpointDeleteResponse will be returned. +func (p *DigitalTwinsEndpointDeletePoller) FinalResponse(ctx context.Context) (DigitalTwinsEndpointDeleteResponse, error) { + respType := DigitalTwinsEndpointDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DigitalTwinsEndpointResource) + if err != nil { + return DigitalTwinsEndpointDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *DigitalTwinsEndpointDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// DigitalTwinsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type DigitalTwinsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *DigitalTwinsUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *DigitalTwinsUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final DigitalTwinsUpdateResponse will be returned. +func (p *DigitalTwinsUpdatePoller) FinalResponse(ctx context.Context) (DigitalTwinsUpdateResponse, error) { + respType := DigitalTwinsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DigitalTwinsDescription) + if err != nil { + return DigitalTwinsUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *DigitalTwinsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateEndpointConnectionsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final PrivateEndpointConnectionsCreateOrUpdateResponse will be returned. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + respType := PrivateEndpointConnectionsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *PrivateEndpointConnectionsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// PrivateEndpointConnectionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *PrivateEndpointConnectionsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *PrivateEndpointConnectionsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final PrivateEndpointConnectionsDeleteResponse will be returned. +func (p *PrivateEndpointConnectionsDeletePoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionsDeleteResponse, error) { + respType := PrivateEndpointConnectionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return PrivateEndpointConnectionsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *PrivateEndpointConnectionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..632a62564799 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_polymorphic_helpers.go @@ -0,0 +1,71 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import "encoding/json" + +func unmarshalDigitalTwinsEndpointResourcePropertiesClassification(rawMsg json.RawMessage) (DigitalTwinsEndpointResourcePropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DigitalTwinsEndpointResourcePropertiesClassification + switch m["endpointType"] { + case string(EndpointTypeEventGrid): + b = &EventGrid{} + case string(EndpointTypeEventHub): + b = &EventHub{} + case string(EndpointTypeServiceBus): + b = &ServiceBus{} + default: + b = &DigitalTwinsEndpointResourceProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalDigitalTwinsEndpointResourcePropertiesClassificationArray(rawMsg json.RawMessage) ([]DigitalTwinsEndpointResourcePropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]DigitalTwinsEndpointResourcePropertiesClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalDigitalTwinsEndpointResourcePropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalDigitalTwinsEndpointResourcePropertiesClassificationMap(rawMsg json.RawMessage) (map[string]DigitalTwinsEndpointResourcePropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages map[string]json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fMap := make(map[string]DigitalTwinsEndpointResourcePropertiesClassification, len(rawMessages)) + for key, rawMessage := range rawMessages { + f, err := unmarshalDigitalTwinsEndpointResourcePropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fMap[key] = f + } + return fMap, nil +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privateendpointconnections_client.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..1c68d3a2bb93 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,337 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateEndpointConnectionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateEndpointConnectionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Update the status of a private endpoint connection with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (PrivateEndpointConnectionsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdatePollerResponse{}, err + } + result := PrivateEndpointConnectionsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateEndpointConnectionsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &PrivateEndpointConnectionsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Update the status of a private endpoint connection with the given name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, privateEndpointConnection) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete private endpoint connection with the specified name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (PrivateEndpointConnectionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsDeletePollerResponse{}, err + } + result := PrivateEndpointConnectionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("PrivateEndpointConnectionsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return PrivateEndpointConnectionsDeletePollerResponse{}, err + } + result.Poller = &PrivateEndpointConnectionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete private endpoint connection with the specified name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get private endpoint connection properties for the given private endpoint. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Response) (PrivateEndpointConnectionsGetResponse, error) { + result := PrivateEndpointConnectionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnection); err != nil { + return PrivateEndpointConnectionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List private endpoint connection properties. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionsListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateEndpointConnectionsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateEndpointConnectionsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *http.Response) (PrivateEndpointConnectionsListResponse, error) { + result := PrivateEndpointConnectionsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.PrivateEndpointConnectionsResponse); err != nil { + return PrivateEndpointConnectionsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateEndpointConnectionsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privatelinkresources_client.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privatelinkresources_client.go new file mode 100644 index 000000000000..3651ccec3366 --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_privatelinkresources_client.go @@ -0,0 +1,177 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. +// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. +type PrivateLinkResourcesClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. +func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *PrivateLinkResourcesClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &PrivateLinkResourcesClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Get - Get the specified private link resource for the given Digital Twin. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, resourceID string, options *PrivateLinkResourcesGetOptions) (PrivateLinkResourcesGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, resourceID, options) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, resourceID string, options *PrivateLinkResourcesGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources/{resourceId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + if resourceID == "" { + return nil, errors.New("parameter resourceID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceId}", url.PathEscape(resourceID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) (PrivateLinkResourcesGetResponse, error) { + result := PrivateLinkResourcesGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GroupIDInformation); err != nil { + return PrivateLinkResourcesGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateLinkResourcesClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// List - List private link resources for given Digital Twin. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesListOptions) (PrivateLinkResourcesListResponse, error) { + req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PrivateLinkResourcesListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PrivateLinkResourcesListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DigitalTwins/digitalTwinsInstances/{resourceName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateLinkResourcesClient) listHandleResponse(resp *http.Response) (PrivateLinkResourcesListResponse, error) { + result := PrivateLinkResourcesListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.GroupIDInformationResponse); err != nil { + return PrivateLinkResourcesListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *PrivateLinkResourcesClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_response_types.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_response_types.go new file mode 100644 index 000000000000..9d2928fe087f --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_response_types.go @@ -0,0 +1,506 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// DigitalTwinsCheckNameAvailabilityResponse contains the response from method DigitalTwins.CheckNameAvailability. +type DigitalTwinsCheckNameAvailabilityResponse struct { + DigitalTwinsCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsCheckNameAvailabilityResult contains the result from method DigitalTwins.CheckNameAvailability. +type DigitalTwinsCheckNameAvailabilityResult struct { + CheckNameResult +} + +// DigitalTwinsCreateOrUpdatePollerResponse contains the response from method DigitalTwins.CreateOrUpdate. +type DigitalTwinsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DigitalTwinsCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DigitalTwinsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DigitalTwinsCreateOrUpdateResponse, error) { + respType := DigitalTwinsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DigitalTwinsDescription) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DigitalTwinsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DigitalTwinsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DigitalTwinsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DigitalTwinsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DigitalTwinsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DigitalTwinsCreateOrUpdateResponse contains the response from method DigitalTwins.CreateOrUpdate. +type DigitalTwinsCreateOrUpdateResponse struct { + DigitalTwinsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsCreateOrUpdateResult contains the result from method DigitalTwins.CreateOrUpdate. +type DigitalTwinsCreateOrUpdateResult struct { + DigitalTwinsDescription +} + +// DigitalTwinsDeletePollerResponse contains the response from method DigitalTwins.Delete. +type DigitalTwinsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DigitalTwinsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DigitalTwinsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DigitalTwinsDeleteResponse, error) { + respType := DigitalTwinsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DigitalTwinsDescription) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DigitalTwinsDeletePollerResponse from the provided client and resume token. +func (l *DigitalTwinsDeletePollerResponse) Resume(ctx context.Context, client *DigitalTwinsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DigitalTwinsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DigitalTwinsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DigitalTwinsDeleteResponse contains the response from method DigitalTwins.Delete. +type DigitalTwinsDeleteResponse struct { + DigitalTwinsDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsDeleteResult contains the result from method DigitalTwins.Delete. +type DigitalTwinsDeleteResult struct { + DigitalTwinsDescription +} + +// DigitalTwinsEndpointCreateOrUpdatePollerResponse contains the response from method DigitalTwinsEndpoint.CreateOrUpdate. +type DigitalTwinsEndpointCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DigitalTwinsEndpointCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DigitalTwinsEndpointCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DigitalTwinsEndpointCreateOrUpdateResponse, error) { + respType := DigitalTwinsEndpointCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DigitalTwinsEndpointResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DigitalTwinsEndpointCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *DigitalTwinsEndpointCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *DigitalTwinsEndpointClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DigitalTwinsEndpointClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &DigitalTwinsEndpointCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DigitalTwinsEndpointCreateOrUpdateResponse contains the response from method DigitalTwinsEndpoint.CreateOrUpdate. +type DigitalTwinsEndpointCreateOrUpdateResponse struct { + DigitalTwinsEndpointCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsEndpointCreateOrUpdateResult contains the result from method DigitalTwinsEndpoint.CreateOrUpdate. +type DigitalTwinsEndpointCreateOrUpdateResult struct { + DigitalTwinsEndpointResource +} + +// DigitalTwinsEndpointDeletePollerResponse contains the response from method DigitalTwinsEndpoint.Delete. +type DigitalTwinsEndpointDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *DigitalTwinsEndpointDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DigitalTwinsEndpointDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DigitalTwinsEndpointDeleteResponse, error) { + respType := DigitalTwinsEndpointDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DigitalTwinsEndpointResource) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DigitalTwinsEndpointDeletePollerResponse from the provided client and resume token. +func (l *DigitalTwinsEndpointDeletePollerResponse) Resume(ctx context.Context, client *DigitalTwinsEndpointClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DigitalTwinsEndpointClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &DigitalTwinsEndpointDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DigitalTwinsEndpointDeleteResponse contains the response from method DigitalTwinsEndpoint.Delete. +type DigitalTwinsEndpointDeleteResponse struct { + DigitalTwinsEndpointDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsEndpointDeleteResult contains the result from method DigitalTwinsEndpoint.Delete. +type DigitalTwinsEndpointDeleteResult struct { + DigitalTwinsEndpointResource +} + +// DigitalTwinsEndpointGetResponse contains the response from method DigitalTwinsEndpoint.Get. +type DigitalTwinsEndpointGetResponse struct { + DigitalTwinsEndpointGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsEndpointGetResult contains the result from method DigitalTwinsEndpoint.Get. +type DigitalTwinsEndpointGetResult struct { + DigitalTwinsEndpointResource +} + +// DigitalTwinsEndpointListResponse contains the response from method DigitalTwinsEndpoint.List. +type DigitalTwinsEndpointListResponse struct { + DigitalTwinsEndpointListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsEndpointListResult contains the result from method DigitalTwinsEndpoint.List. +type DigitalTwinsEndpointListResult struct { + DigitalTwinsEndpointResourceListResult +} + +// DigitalTwinsGetResponse contains the response from method DigitalTwins.Get. +type DigitalTwinsGetResponse struct { + DigitalTwinsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsGetResult contains the result from method DigitalTwins.Get. +type DigitalTwinsGetResult struct { + DigitalTwinsDescription +} + +// DigitalTwinsListByResourceGroupResponse contains the response from method DigitalTwins.ListByResourceGroup. +type DigitalTwinsListByResourceGroupResponse struct { + DigitalTwinsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsListByResourceGroupResult contains the result from method DigitalTwins.ListByResourceGroup. +type DigitalTwinsListByResourceGroupResult struct { + DigitalTwinsDescriptionListResult +} + +// DigitalTwinsListResponse contains the response from method DigitalTwins.List. +type DigitalTwinsListResponse struct { + DigitalTwinsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsListResult contains the result from method DigitalTwins.List. +type DigitalTwinsListResult struct { + DigitalTwinsDescriptionListResult +} + +// DigitalTwinsUpdatePollerResponse contains the response from method DigitalTwins.Update. +type DigitalTwinsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *DigitalTwinsUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l DigitalTwinsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (DigitalTwinsUpdateResponse, error) { + respType := DigitalTwinsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.DigitalTwinsDescription) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a DigitalTwinsUpdatePollerResponse from the provided client and resume token. +func (l *DigitalTwinsUpdatePollerResponse) Resume(ctx context.Context, client *DigitalTwinsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("DigitalTwinsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &DigitalTwinsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// DigitalTwinsUpdateResponse contains the response from method DigitalTwins.Update. +type DigitalTwinsUpdateResponse struct { + DigitalTwinsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DigitalTwinsUpdateResult contains the result from method DigitalTwins.Update. +type DigitalTwinsUpdateResult struct { + DigitalTwinsDescription +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} + +// PrivateEndpointConnectionsCreateOrUpdatePollerResponse contains the response from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateEndpointConnectionsCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l PrivateEndpointConnectionsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsCreateOrUpdateResponse, error) { + respType := PrivateEndpointConnectionsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.PrivateEndpointConnection) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateEndpointConnectionsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *PrivateEndpointConnectionsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *PrivateEndpointConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateEndpointConnectionsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &PrivateEndpointConnectionsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateEndpointConnectionsCreateOrUpdateResponse contains the response from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResponse struct { + PrivateEndpointConnectionsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsCreateOrUpdateResult contains the result from method PrivateEndpointConnections.CreateOrUpdate. +type PrivateEndpointConnectionsCreateOrUpdateResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsDeletePollerResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *PrivateEndpointConnectionsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l PrivateEndpointConnectionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionsDeleteResponse, error) { + respType := PrivateEndpointConnectionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a PrivateEndpointConnectionsDeletePollerResponse from the provided client and resume token. +func (l *PrivateEndpointConnectionsDeletePollerResponse) Resume(ctx context.Context, client *PrivateEndpointConnectionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("PrivateEndpointConnectionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &PrivateEndpointConnectionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// PrivateEndpointConnectionsDeleteResponse contains the response from method PrivateEndpointConnections.Delete. +type PrivateEndpointConnectionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResponse contains the response from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResponse struct { + PrivateEndpointConnectionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsGetResult contains the result from method PrivateEndpointConnections.Get. +type PrivateEndpointConnectionsGetResult struct { + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsListResponse contains the response from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResponse struct { + PrivateEndpointConnectionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionsListResult contains the result from method PrivateEndpointConnections.List. +type PrivateEndpointConnectionsListResult struct { + PrivateEndpointConnectionsResponse +} + +// PrivateLinkResourcesGetResponse contains the response from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResponse struct { + PrivateLinkResourcesGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesGetResult contains the result from method PrivateLinkResources.Get. +type PrivateLinkResourcesGetResult struct { + GroupIDInformation +} + +// PrivateLinkResourcesListResponse contains the response from method PrivateLinkResources.List. +type PrivateLinkResourcesListResponse struct { + PrivateLinkResourcesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourcesListResult contains the result from method PrivateLinkResources.List. +type PrivateLinkResourcesListResult struct { + GroupIDInformationResponse +} diff --git a/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_time_rfc3339.go b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..14b464a1607b --- /dev/null +++ b/sdk/resourcemanager/digitaltwins/armdigitaltwins/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdigitaltwins + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + *t = (*time.Time)(&aux) + return nil +}