diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md new file mode 100644 index 000000000000..6846c27ffeb7 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-24) diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/LICENSE.txt b/sdk/resourcemanager/containerinstance/armcontainerinstance/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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/containerinstance/armcontainerinstance/README.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md new file mode 100644 index 000000000000..970935e4c83b --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md @@ -0,0 +1,75 @@ +# Azure Containerinstance Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance) + +The `armcontainerinstance` module provides operations for working with Azure Containerinstance. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerinstance/armcontainerinstance) + +# 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 Containerinstance module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Containerinstance. 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 Containerinstance 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 := armcontainerinstance.NewContainerGroupsClient(, 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 := armcontainerinstance.NewContainerGroupsClient(, 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 `Containerinstance` 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/containerinstance/armcontainerinstance/autorest.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md new file mode 100644 index 000000000000..03f46630d6ba --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md @@ -0,0 +1,12 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/containerinstance/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/containerinstance/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/containerinstance/armcontainerinstance/build.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/build.go new file mode 100644 index 000000000000..0a0e35a3ed70 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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/containerinstance/armcontainerinstance + +package armcontainerinstance diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/ci.yml b/sdk/resourcemanager/containerinstance/armcontainerinstance/ci.yml new file mode 100644 index 000000000000..f9b9706a8bbf --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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/containerinstance/armcontainerinstance/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerinstance/armcontainerinstance/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/containerinstance/armcontainerinstance' diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod new file mode 100644 index 000000000000..72f78d2c493d --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.3.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum new file mode 100644 index 000000000000..76d3fa8fd576 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.3.0+incompatible h1:dPIm0BO4jsMXFcCI/sLTPkBtE7mk8WMuRHA0JeWhlcQ= +github.com/Azure/azure-sdk-for-go v59.3.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/containerinstance/armcontainerinstance/go_mod_tidy_hack.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/go_mod_tidy_hack.go new file mode 100644 index 000000000000..933075ccb230 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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 armcontainerinstance + +// 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/containerinstance/armcontainerinstance/zz_generated_constants.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_constants.go new file mode 100644 index 000000000000..cae471354b3e --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_constants.go @@ -0,0 +1,258 @@ +//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 armcontainerinstance + +const ( + module = "armcontainerinstance" + version = "v0.1.0" +) + +// ContainerGroupIPAddressType - Specifies if the IP is exposed to the public internet or private VNET. +type ContainerGroupIPAddressType string + +const ( + ContainerGroupIPAddressTypePrivate ContainerGroupIPAddressType = "Private" + ContainerGroupIPAddressTypePublic ContainerGroupIPAddressType = "Public" +) + +// PossibleContainerGroupIPAddressTypeValues returns the possible values for the ContainerGroupIPAddressType const type. +func PossibleContainerGroupIPAddressTypeValues() []ContainerGroupIPAddressType { + return []ContainerGroupIPAddressType{ + ContainerGroupIPAddressTypePrivate, + ContainerGroupIPAddressTypePublic, + } +} + +// ToPtr returns a *ContainerGroupIPAddressType pointing to the current value. +func (c ContainerGroupIPAddressType) ToPtr() *ContainerGroupIPAddressType { + return &c +} + +// ContainerGroupNetworkProtocol - The protocol associated with the port. +type ContainerGroupNetworkProtocol string + +const ( + ContainerGroupNetworkProtocolTCP ContainerGroupNetworkProtocol = "TCP" + ContainerGroupNetworkProtocolUDP ContainerGroupNetworkProtocol = "UDP" +) + +// PossibleContainerGroupNetworkProtocolValues returns the possible values for the ContainerGroupNetworkProtocol const type. +func PossibleContainerGroupNetworkProtocolValues() []ContainerGroupNetworkProtocol { + return []ContainerGroupNetworkProtocol{ + ContainerGroupNetworkProtocolTCP, + ContainerGroupNetworkProtocolUDP, + } +} + +// ToPtr returns a *ContainerGroupNetworkProtocol pointing to the current value. +func (c ContainerGroupNetworkProtocol) ToPtr() *ContainerGroupNetworkProtocol { + return &c +} + +// ContainerGroupRestartPolicy - Restart policy for all containers within the container group. +// * Always Always restart +// * OnFailure Restart on failure +// * Never Never restart +type ContainerGroupRestartPolicy string + +const ( + ContainerGroupRestartPolicyAlways ContainerGroupRestartPolicy = "Always" + ContainerGroupRestartPolicyNever ContainerGroupRestartPolicy = "Never" + ContainerGroupRestartPolicyOnFailure ContainerGroupRestartPolicy = "OnFailure" +) + +// PossibleContainerGroupRestartPolicyValues returns the possible values for the ContainerGroupRestartPolicy const type. +func PossibleContainerGroupRestartPolicyValues() []ContainerGroupRestartPolicy { + return []ContainerGroupRestartPolicy{ + ContainerGroupRestartPolicyAlways, + ContainerGroupRestartPolicyNever, + ContainerGroupRestartPolicyOnFailure, + } +} + +// ToPtr returns a *ContainerGroupRestartPolicy pointing to the current value. +func (c ContainerGroupRestartPolicy) ToPtr() *ContainerGroupRestartPolicy { + return &c +} + +// ContainerGroupSKU - The container group SKU. +type ContainerGroupSKU string + +const ( + ContainerGroupSKUDedicated ContainerGroupSKU = "Dedicated" + ContainerGroupSKUStandard ContainerGroupSKU = "Standard" +) + +// PossibleContainerGroupSKUValues returns the possible values for the ContainerGroupSKU const type. +func PossibleContainerGroupSKUValues() []ContainerGroupSKU { + return []ContainerGroupSKU{ + ContainerGroupSKUDedicated, + ContainerGroupSKUStandard, + } +} + +// ToPtr returns a *ContainerGroupSKU pointing to the current value. +func (c ContainerGroupSKU) ToPtr() *ContainerGroupSKU { + return &c +} + +// ContainerInstanceOperationsOrigin - The intended executor of the operation. +type ContainerInstanceOperationsOrigin string + +const ( + ContainerInstanceOperationsOriginSystem ContainerInstanceOperationsOrigin = "System" + ContainerInstanceOperationsOriginUser ContainerInstanceOperationsOrigin = "User" +) + +// PossibleContainerInstanceOperationsOriginValues returns the possible values for the ContainerInstanceOperationsOrigin const type. +func PossibleContainerInstanceOperationsOriginValues() []ContainerInstanceOperationsOrigin { + return []ContainerInstanceOperationsOrigin{ + ContainerInstanceOperationsOriginSystem, + ContainerInstanceOperationsOriginUser, + } +} + +// ToPtr returns a *ContainerInstanceOperationsOrigin pointing to the current value. +func (c ContainerInstanceOperationsOrigin) ToPtr() *ContainerInstanceOperationsOrigin { + return &c +} + +// ContainerNetworkProtocol - The protocol associated with the port. +type ContainerNetworkProtocol string + +const ( + ContainerNetworkProtocolTCP ContainerNetworkProtocol = "TCP" + ContainerNetworkProtocolUDP ContainerNetworkProtocol = "UDP" +) + +// PossibleContainerNetworkProtocolValues returns the possible values for the ContainerNetworkProtocol const type. +func PossibleContainerNetworkProtocolValues() []ContainerNetworkProtocol { + return []ContainerNetworkProtocol{ + ContainerNetworkProtocolTCP, + ContainerNetworkProtocolUDP, + } +} + +// ToPtr returns a *ContainerNetworkProtocol pointing to the current value. +func (c ContainerNetworkProtocol) ToPtr() *ContainerNetworkProtocol { + return &c +} + +// GpuSKU - The SKU of the GPU resource. +type GpuSKU string + +const ( + GpuSKUK80 GpuSKU = "K80" + GpuSKUP100 GpuSKU = "P100" + GpuSKUV100 GpuSKU = "V100" +) + +// PossibleGpuSKUValues returns the possible values for the GpuSKU const type. +func PossibleGpuSKUValues() []GpuSKU { + return []GpuSKU{ + GpuSKUK80, + GpuSKUP100, + GpuSKUV100, + } +} + +// ToPtr returns a *GpuSKU pointing to the current value. +func (c GpuSKU) ToPtr() *GpuSKU { + return &c +} + +// LogAnalyticsLogType - The log type to be used. +type LogAnalyticsLogType string + +const ( + LogAnalyticsLogTypeContainerInsights LogAnalyticsLogType = "ContainerInsights" + LogAnalyticsLogTypeContainerInstanceLogs LogAnalyticsLogType = "ContainerInstanceLogs" +) + +// PossibleLogAnalyticsLogTypeValues returns the possible values for the LogAnalyticsLogType const type. +func PossibleLogAnalyticsLogTypeValues() []LogAnalyticsLogType { + return []LogAnalyticsLogType{ + LogAnalyticsLogTypeContainerInsights, + LogAnalyticsLogTypeContainerInstanceLogs, + } +} + +// ToPtr returns a *LogAnalyticsLogType pointing to the current value. +func (c LogAnalyticsLogType) ToPtr() *LogAnalyticsLogType { + return &c +} + +// OperatingSystemTypes - The operating system type required by the containers in the container group. +type OperatingSystemTypes string + +const ( + OperatingSystemTypesLinux OperatingSystemTypes = "Linux" + OperatingSystemTypesWindows OperatingSystemTypes = "Windows" +) + +// PossibleOperatingSystemTypesValues returns the possible values for the OperatingSystemTypes const type. +func PossibleOperatingSystemTypesValues() []OperatingSystemTypes { + return []OperatingSystemTypes{ + OperatingSystemTypesLinux, + OperatingSystemTypesWindows, + } +} + +// ToPtr returns a *OperatingSystemTypes pointing to the current value. +func (c OperatingSystemTypes) ToPtr() *OperatingSystemTypes { + return &c +} + +// ResourceIdentityType - The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created +// identity and a set of user assigned identities. The type 'None' will +// remove any identities from the container group. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" + ResourceIdentityTypeNone ResourceIdentityType = "None" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeUserAssigned, + ResourceIdentityTypeSystemAssignedUserAssigned, + ResourceIdentityTypeNone, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} + +// Scheme - The scheme. +type Scheme string + +const ( + SchemeHTTP Scheme = "http" + SchemeHTTPS Scheme = "https" +) + +// PossibleSchemeValues returns the possible values for the Scheme const type. +func PossibleSchemeValues() []Scheme { + return []Scheme{ + SchemeHTTP, + SchemeHTTPS, + } +} + +// ToPtr returns a *Scheme pointing to the current value. +func (c Scheme) ToPtr() *Scheme { + return &c +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_containergroups_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_containergroups_client.go new file mode 100644 index 000000000000..bcc91a91d940 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_containergroups_client.go @@ -0,0 +1,719 @@ +//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 armcontainerinstance + +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" +) + +// ContainerGroupsClient contains the methods for the ContainerGroups group. +// Don't use this type directly, use NewContainerGroupsClient() instead. +type ContainerGroupsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewContainerGroupsClient creates a new instance of ContainerGroupsClient with the specified values. +func NewContainerGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ContainerGroupsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ContainerGroupsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Create or update container groups with specified configurations. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsBeginCreateOrUpdateOptions) (ContainerGroupsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, containerGroupName, containerGroup, options) + if err != nil { + return ContainerGroupsCreateOrUpdatePollerResponse{}, err + } + result := ContainerGroupsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContainerGroupsClient.CreateOrUpdate", "", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return ContainerGroupsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &ContainerGroupsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Create or update container groups with specified configurations. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) createOrUpdate(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, containerGroupName, containerGroup, 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 *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, containerGroup) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ContainerGroupsClient) createOrUpdateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 the specified container group in the specified subscription and resource group. The operation does not delete other resources provided +// by the user, such as volumes. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) BeginDelete(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginDeleteOptions) (ContainerGroupsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsDeletePollerResponse{}, err + } + result := ContainerGroupsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContainerGroupsClient.Delete", "", resp, client.pl, client.deleteHandleError) + if err != nil { + return ContainerGroupsDeletePollerResponse{}, err + } + result.Poller = &ContainerGroupsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete the specified container group in the specified subscription and resource group. The operation does not delete other resources provided +// by the user, such as volumes. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, containerGroupName, 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 *ContainerGroupsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-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 *ContainerGroupsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 - Gets the properties of the specified container group in the specified subscription and resource group. The operation returns the properties of +// each container group including containers, image registry +// credentials, restart policy, IP address type, OS type, state, and volumes. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) Get(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsGetOptions) (ContainerGroupsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainerGroupsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainerGroupsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContainerGroupsClient) getCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContainerGroupsClient) getHandleResponse(resp *http.Response) (ContainerGroupsGetResponse, error) { + result := ContainerGroupsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroup); err != nil { + return ContainerGroupsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ContainerGroupsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// GetOutboundNetworkDependenciesEndpoints - Gets all the network dependencies for this container group to allow complete control of network setting and +// configuration. For container groups, this will always be an empty list. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsGetOutboundNetworkDependenciesEndpointsOptions) (ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse, error) { + req, err := client.getOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse{}, client.getOutboundNetworkDependenciesEndpointsHandleError(resp) + } + return client.getOutboundNetworkDependenciesEndpointsHandleResponse(resp) +} + +// getOutboundNetworkDependenciesEndpointsCreateRequest creates the GetOutboundNetworkDependenciesEndpoints request. +func (client *ContainerGroupsClient) getOutboundNetworkDependenciesEndpointsCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsGetOutboundNetworkDependenciesEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/outboundNetworkDependenciesEndpoints" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getOutboundNetworkDependenciesEndpointsHandleResponse handles the GetOutboundNetworkDependenciesEndpoints response. +func (client *ContainerGroupsClient) getOutboundNetworkDependenciesEndpointsHandleResponse(resp *http.Response) (ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse, error) { + result := ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.StringArray); err != nil { + return ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getOutboundNetworkDependenciesEndpointsHandleError handles the GetOutboundNetworkDependenciesEndpoints error response. +func (client *ContainerGroupsClient) getOutboundNetworkDependenciesEndpointsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a list of container groups in the specified subscription. This operation returns properties of each container group including containers, +// image registry credentials, restart policy, IP address +// type, OS type, state, and volumes. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) List(options *ContainerGroupsListOptions) *ContainerGroupsListPager { + return &ContainerGroupsListPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ContainerGroupsListResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ContainerGroupListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ContainerGroupsClient) listCreateRequest(ctx context.Context, options *ContainerGroupsListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups" + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ContainerGroupsClient) listHandleResponse(resp *http.Response) (ContainerGroupsListResponse, error) { + result := ContainerGroupsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupListResult); err != nil { + return ContainerGroupsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ContainerGroupsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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 a list of container groups in a specified subscription and resource group. This operation returns properties of each container +// group including containers, image registry credentials, restart +// policy, IP address type, OS type, state, and volumes. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) ListByResourceGroup(resourceGroupName string, options *ContainerGroupsListByResourceGroupOptions) *ContainerGroupsListByResourceGroupPager { + return &ContainerGroupsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ContainerGroupsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ContainerGroupListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups" + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ContainerGroupsClient) listByResourceGroupHandleResponse(resp *http.Response) (ContainerGroupsListByResourceGroupResponse, error) { + result := ContainerGroupsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupListResult); err != nil { + return ContainerGroupsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ContainerGroupsClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginRestart - Restarts all containers in a container group in place. If container image has updates, new image will be downloaded. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) BeginRestart(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginRestartOptions) (ContainerGroupsRestartPollerResponse, error) { + resp, err := client.restart(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsRestartPollerResponse{}, err + } + result := ContainerGroupsRestartPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContainerGroupsClient.Restart", "", resp, client.pl, client.restartHandleError) + if err != nil { + return ContainerGroupsRestartPollerResponse{}, err + } + result.Poller = &ContainerGroupsRestartPoller{ + pt: pt, + } + return result, nil +} + +// Restart - Restarts all containers in a container group in place. If container image has updates, new image will be downloaded. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) restart(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginRestartOptions) (*http.Response, error) { + req, err := client.restartCreateRequest(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return nil, client.restartHandleError(resp) + } + return resp, nil +} + +// restartCreateRequest creates the Restart request. +func (client *ContainerGroupsClient) restartCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginRestartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// restartHandleError handles the Restart error response. +func (client *ContainerGroupsClient) restartHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// BeginStart - Starts all containers in a container group. Compute resources will be allocated and billing will start. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) BeginStart(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginStartOptions) (ContainerGroupsStartPollerResponse, error) { + resp, err := client.start(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsStartPollerResponse{}, err + } + result := ContainerGroupsStartPollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ContainerGroupsClient.Start", "", resp, client.pl, client.startHandleError) + if err != nil { + return ContainerGroupsStartPollerResponse{}, err + } + result.Poller = &ContainerGroupsStartPoller{ + pt: pt, + } + return result, nil +} + +// Start - Starts all containers in a container group. Compute resources will be allocated and billing will start. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) start(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginStartOptions) (*http.Response, error) { + req, err := client.startCreateRequest(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, client.startHandleError(resp) + } + return resp, nil +} + +// startCreateRequest creates the Start request. +func (client *ContainerGroupsClient) startCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/start" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// startHandleError handles the Start error response. +func (client *ContainerGroupsClient) startHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// Stop - Stops all containers in a container group. Compute resources will be deallocated and billing will stop. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) Stop(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsStopOptions) (ContainerGroupsStopResponse, error) { + req, err := client.stopCreateRequest(ctx, resourceGroupName, containerGroupName, options) + if err != nil { + return ContainerGroupsStopResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainerGroupsStopResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusNoContent) { + return ContainerGroupsStopResponse{}, client.stopHandleError(resp) + } + return ContainerGroupsStopResponse{RawResponse: resp}, nil +} + +// stopCreateRequest creates the Stop request. +func (client *ContainerGroupsClient) stopCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsStopOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// stopHandleError handles the Stop error response. +func (client *ContainerGroupsClient) stopHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// Update - Updates container group tags with specified values. +// If the operation fails it returns the *CloudError error type. +func (client *ContainerGroupsClient) Update(ctx context.Context, resourceGroupName string, containerGroupName string, resource Resource, options *ContainerGroupsUpdateOptions) (ContainerGroupsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, containerGroupName, resource, options) + if err != nil { + return ContainerGroupsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainerGroupsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainerGroupsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ContainerGroupsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, resource Resource, options *ContainerGroupsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, resource) +} + +// updateHandleResponse handles the Update response. +func (client *ContainerGroupsClient) updateHandleResponse(resp *http.Response) (ContainerGroupsUpdateResponse, error) { + result := ContainerGroupsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroup); err != nil { + return ContainerGroupsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ContainerGroupsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/containerinstance/armcontainerinstance/zz_generated_containers_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_containers_client.go new file mode 100644 index 000000000000..01d4e8e67f30 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_containers_client.go @@ -0,0 +1,257 @@ +//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 armcontainerinstance + +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" + "strconv" + "strings" +) + +// ContainersClient contains the methods for the Containers group. +// Don't use this type directly, use NewContainersClient() instead. +type ContainersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewContainersClient creates a new instance of ContainersClient with the specified values. +func NewContainersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ContainersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ContainersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Attach - Attach to the output stream of a specific container instance in a specified resource group and container group. +// If the operation fails it returns the *CloudError error type. +func (client *ContainersClient) Attach(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, options *ContainersAttachOptions) (ContainersAttachResponse, error) { + req, err := client.attachCreateRequest(ctx, resourceGroupName, containerGroupName, containerName, options) + if err != nil { + return ContainersAttachResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainersAttachResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainersAttachResponse{}, client.attachHandleError(resp) + } + return client.attachHandleResponse(resp) +} + +// attachCreateRequest creates the Attach request. +func (client *ContainersClient) attachCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, options *ContainersAttachOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/attach" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + if containerName == "" { + return nil, errors.New("parameter containerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// attachHandleResponse handles the Attach response. +func (client *ContainersClient) attachHandleResponse(resp *http.Response) (ContainersAttachResponse, error) { + result := ContainersAttachResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerAttachResponse); err != nil { + return ContainersAttachResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// attachHandleError handles the Attach error response. +func (client *ContainersClient) attachHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ExecuteCommand - Executes a command for a specific container instance in a specified resource group and container group. +// If the operation fails it returns the *CloudError error type. +func (client *ContainersClient) ExecuteCommand(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest, options *ContainersExecuteCommandOptions) (ContainersExecuteCommandResponse, error) { + req, err := client.executeCommandCreateRequest(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest, options) + if err != nil { + return ContainersExecuteCommandResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainersExecuteCommandResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainersExecuteCommandResponse{}, client.executeCommandHandleError(resp) + } + return client.executeCommandHandleResponse(resp) +} + +// executeCommandCreateRequest creates the ExecuteCommand request. +func (client *ContainersClient) executeCommandCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest, options *ContainersExecuteCommandOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + if containerName == "" { + return nil, errors.New("parameter containerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, containerExecRequest) +} + +// executeCommandHandleResponse handles the ExecuteCommand response. +func (client *ContainersClient) executeCommandHandleResponse(resp *http.Response) (ContainersExecuteCommandResponse, error) { + result := ContainersExecuteCommandResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerExecResponse); err != nil { + return ContainersExecuteCommandResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// executeCommandHandleError handles the ExecuteCommand error response. +func (client *ContainersClient) executeCommandHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListLogs - Get the logs for a specified container instance in a specified resource group and container group. +// If the operation fails it returns the *CloudError error type. +func (client *ContainersClient) ListLogs(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, options *ContainersListLogsOptions) (ContainersListLogsResponse, error) { + req, err := client.listLogsCreateRequest(ctx, resourceGroupName, containerGroupName, containerName, options) + if err != nil { + return ContainersListLogsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ContainersListLogsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ContainersListLogsResponse{}, client.listLogsHandleError(resp) + } + return client.listLogsHandleResponse(resp) +} + +// listLogsCreateRequest creates the ListLogs request. +func (client *ContainersClient) listLogsCreateRequest(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, options *ContainersListLogsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs" + 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 containerGroupName == "" { + return nil, errors.New("parameter containerGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupName}", url.PathEscape(containerGroupName)) + if containerName == "" { + return nil, errors.New("parameter containerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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", "2021-09-01") + if options != nil && options.Tail != nil { + reqQP.Set("tail", strconv.FormatInt(int64(*options.Tail), 10)) + } + if options != nil && options.Timestamps != nil { + reqQP.Set("timestamps", strconv.FormatBool(*options.Timestamps)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listLogsHandleResponse handles the ListLogs response. +func (client *ContainersClient) listLogsHandleResponse(resp *http.Response) (ContainersListLogsResponse, error) { + result := ContainersListLogsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Logs); err != nil { + return ContainersListLogsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listLogsHandleError handles the ListLogs error response. +func (client *ContainersClient) listLogsHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/containerinstance/armcontainerinstance/zz_generated_location_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_location_client.go new file mode 100644 index 000000000000..11241cc5d8a9 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_location_client.go @@ -0,0 +1,220 @@ +//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 armcontainerinstance + +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" +) + +// LocationClient contains the methods for the Location group. +// Don't use this type directly, use NewLocationClient() instead. +type LocationClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewLocationClient creates a new instance of LocationClient with the specified values. +func NewLocationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LocationClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &LocationClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// ListCachedImages - Get the list of cached images on specific OS type for a subscription in a region. +// If the operation fails it returns the *CloudError error type. +func (client *LocationClient) ListCachedImages(location string, options *LocationListCachedImagesOptions) *LocationListCachedImagesPager { + return &LocationListCachedImagesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCachedImagesCreateRequest(ctx, location, options) + }, + advancer: func(ctx context.Context, resp LocationListCachedImagesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CachedImagesListResult.NextLink) + }, + } +} + +// listCachedImagesCreateRequest creates the ListCachedImages request. +func (client *LocationClient) listCachedImagesCreateRequest(ctx context.Context, location string, options *LocationListCachedImagesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/cachedImages" + 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.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listCachedImagesHandleResponse handles the ListCachedImages response. +func (client *LocationClient) listCachedImagesHandleResponse(resp *http.Response) (LocationListCachedImagesResponse, error) { + result := LocationListCachedImagesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CachedImagesListResult); err != nil { + return LocationListCachedImagesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listCachedImagesHandleError handles the ListCachedImages error response. +func (client *LocationClient) listCachedImagesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListCapabilities - Get the list of CPU/memory/GPU capabilities of a region. +// If the operation fails it returns the *CloudError error type. +func (client *LocationClient) ListCapabilities(location string, options *LocationListCapabilitiesOptions) *LocationListCapabilitiesPager { + return &LocationListCapabilitiesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listCapabilitiesCreateRequest(ctx, location, options) + }, + advancer: func(ctx context.Context, resp LocationListCapabilitiesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CapabilitiesListResult.NextLink) + }, + } +} + +// listCapabilitiesCreateRequest creates the ListCapabilities request. +func (client *LocationClient) listCapabilitiesCreateRequest(ctx context.Context, location string, options *LocationListCapabilitiesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/capabilities" + 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.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listCapabilitiesHandleResponse handles the ListCapabilities response. +func (client *LocationClient) listCapabilitiesHandleResponse(resp *http.Response) (LocationListCapabilitiesResponse, error) { + result := LocationListCapabilitiesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CapabilitiesListResult); err != nil { + return LocationListCapabilitiesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listCapabilitiesHandleError handles the ListCapabilities error response. +func (client *LocationClient) listCapabilitiesHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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) +} + +// ListUsage - Get the usage for a subscription +// If the operation fails it returns the *CloudError error type. +func (client *LocationClient) ListUsage(ctx context.Context, location string, options *LocationListUsageOptions) (LocationListUsageResponse, error) { + req, err := client.listUsageCreateRequest(ctx, location, options) + if err != nil { + return LocationListUsageResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LocationListUsageResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LocationListUsageResponse{}, client.listUsageHandleError(resp) + } + return client.listUsageHandleResponse(resp) +} + +// listUsageCreateRequest creates the ListUsage request. +func (client *LocationClient) listUsageCreateRequest(ctx context.Context, location string, options *LocationListUsageOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/locations/{location}/usages" + 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.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listUsageHandleResponse handles the ListUsage response. +func (client *LocationClient) listUsageHandleResponse(resp *http.Response) (LocationListUsageResponse, error) { + result := LocationListUsageResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.UsageListResult); err != nil { + return LocationListUsageResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listUsageHandleError handles the ListUsage error response. +func (client *LocationClient) listUsageHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := CloudError{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/containerinstance/armcontainerinstance/zz_generated_models.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_models.go new file mode 100644 index 000000000000..21f8a911f8aa --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_models.go @@ -0,0 +1,1165 @@ +//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 armcontainerinstance + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// AzureFileVolume - The properties of the Azure File volume. Azure File shares are mounted as volumes. +type AzureFileVolume struct { + // REQUIRED; The name of the Azure File share to be mounted as a volume. + ShareName *string `json:"shareName,omitempty"` + + // REQUIRED; The name of the storage account that contains the Azure File share. + StorageAccountName *string `json:"storageAccountName,omitempty"` + + // The flag indicating whether the Azure File shared mounted as a volume is read-only. + ReadOnly *bool `json:"readOnly,omitempty"` + + // The storage account access key used to access the Azure File share. + StorageAccountKey *string `json:"storageAccountKey,omitempty"` +} + +// CachedImages - The cached image and OS type. +type CachedImages struct { + // REQUIRED; The cached image name. + Image *string `json:"image,omitempty"` + + // REQUIRED; The OS type of the cached image. + OSType *string `json:"osType,omitempty"` +} + +// CachedImagesListResult - The response containing cached images. +type CachedImagesListResult struct { + // The URI to fetch the next page of cached images. + NextLink *string `json:"nextLink,omitempty"` + + // The list of cached images. + Value []*CachedImages `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CachedImagesListResult. +func (c CachedImagesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// Capabilities - The regional capabilities. +type Capabilities struct { + // READ-ONLY; The supported capabilities. + Capabilities *CapabilitiesCapabilities `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY; The GPU sku that this capability describes. + Gpu *string `json:"gpu,omitempty" azure:"ro"` + + // READ-ONLY; The ip address type that this capability describes. + IPAddressType *string `json:"ipAddressType,omitempty" azure:"ro"` + + // READ-ONLY; The resource location. + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; The OS type that this capability describes. + OSType *string `json:"osType,omitempty" azure:"ro"` + + // READ-ONLY; The resource type that this capability describes. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` +} + +// CapabilitiesCapabilities - The supported capabilities. +type CapabilitiesCapabilities struct { + // READ-ONLY; The maximum allowed CPU request in cores. + MaxCPU *float32 `json:"maxCpu,omitempty" azure:"ro"` + + // READ-ONLY; The maximum allowed GPU count. + MaxGpuCount *float32 `json:"maxGpuCount,omitempty" azure:"ro"` + + // READ-ONLY; The maximum allowed memory request in GB. + MaxMemoryInGB *float32 `json:"maxMemoryInGB,omitempty" azure:"ro"` +} + +// CapabilitiesListResult - The response containing list of capabilities. +type CapabilitiesListResult struct { + // The URI to fetch the next page of capabilities. + NextLink *string `json:"nextLink,omitempty"` + + // The list of capabilities. + Value []*Capabilities `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CapabilitiesListResult. +func (c CapabilitiesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CloudError - An error response from the Container Instance service. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudError struct { + raw string + // An error response from the Container Instance service. + InnerError *CloudErrorBody `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. +func (e CloudError) Error() string { + return e.raw +} + +// CloudErrorBody - An error response from the Container Instance service. +type CloudErrorBody struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +type Components10Wh5UdSchemasContainergroupidentityPropertiesUserassignedidentitiesAdditionalproperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// Container - A container instance. +type Container struct { + // REQUIRED; The user-provided name of the container instance. + Name *string `json:"name,omitempty"` + + // REQUIRED; The properties of the container instance. + Properties *ContainerProperties `json:"properties,omitempty"` +} + +// ContainerAttachResponse - The information for the output stream from container attach. +type ContainerAttachResponse struct { + // The password to the output stream from the attach. Send as an Authorization header value when connecting to the websocketUri. + Password *string `json:"password,omitempty"` + + // The uri for the output stream from the attach. + WebSocketURI *string `json:"webSocketUri,omitempty"` +} + +// ContainerExec - The container execution command, for liveness or readiness probe +type ContainerExec struct { + // The commands to execute within the container. + Command []*string `json:"command,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerExec. +func (c ContainerExec) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "command", c.Command) + return json.Marshal(objectMap) +} + +// ContainerExecRequest - The container exec request. +type ContainerExecRequest struct { + // The command to be executed. + Command *string `json:"command,omitempty"` + + // The size of the terminal. + TerminalSize *ContainerExecRequestTerminalSize `json:"terminalSize,omitempty"` +} + +// ContainerExecRequestTerminalSize - The size of the terminal. +type ContainerExecRequestTerminalSize struct { + // The column size of the terminal + Cols *int32 `json:"cols,omitempty"` + + // The row size of the terminal + Rows *int32 `json:"rows,omitempty"` +} + +// ContainerExecResponse - The information for the container exec command. +type ContainerExecResponse struct { + // The password to start the exec command. + Password *string `json:"password,omitempty"` + + // The uri for the exec websocket. + WebSocketURI *string `json:"webSocketUri,omitempty"` +} + +// ContainerGroup - A container group. +type ContainerGroup struct { + Resource + // REQUIRED; The container group properties + Properties *ContainerGroupProperties `json:"properties,omitempty"` + + // The identity of the container group, if configured. + Identity *ContainerGroupIdentity `json:"identity,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroup. +func (c ContainerGroup) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.Resource.marshalInternal(objectMap) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ContainerGroupDiagnostics - Container group diagnostic information. +type ContainerGroupDiagnostics struct { + // Container group log analytics information. + LogAnalytics *LogAnalytics `json:"logAnalytics,omitempty"` +} + +// ContainerGroupIdentity - Identity for the container group. +type ContainerGroupIdentity struct { + // The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of + // user assigned identities. The type 'None' will + // remove any identities from the container group. + Type *ResourceIdentityType `json:"type,omitempty"` + + // The list of user identities associated with the container group. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*Components10Wh5UdSchemasContainergroupidentityPropertiesUserassignedidentitiesAdditionalproperties `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal id of the container group identity. This property will only be provided for a system assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant id associated with the container group. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupIdentity. +func (c ContainerGroupIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", c.PrincipalID) + populate(objectMap, "tenantId", c.TenantID) + populate(objectMap, "type", c.Type) + populate(objectMap, "userAssignedIdentities", c.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// ContainerGroupListResult - The container group list response that contains the container group properties. +type ContainerGroupListResult struct { + // The URI to fetch the next page of container groups. + NextLink *string `json:"nextLink,omitempty"` + + // The list of container groups. + Value []*ContainerGroup `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupListResult. +func (c ContainerGroupListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ContainerGroupProperties - The container group properties +type ContainerGroupProperties struct { + // REQUIRED; The containers within the container group. + Containers []*Container `json:"containers,omitempty"` + + // REQUIRED; The operating system type required by the containers in the container group. + OSType *OperatingSystemTypes `json:"osType,omitempty"` + + // The DNS config information for a container group. + DNSConfig *DNSConfiguration `json:"dnsConfig,omitempty"` + + // The diagnostic information for a container group. + Diagnostics *ContainerGroupDiagnostics `json:"diagnostics,omitempty"` + + // The encryption properties for a container group. + EncryptionProperties *EncryptionProperties `json:"encryptionProperties,omitempty"` + + // The IP address type of the container group. + IPAddress *IPAddress `json:"ipAddress,omitempty"` + + // The image registry credentials by which the container group is created from. + ImageRegistryCredentials []*ImageRegistryCredential `json:"imageRegistryCredentials,omitempty"` + + // The init containers for a container group. + InitContainers []*InitContainerDefinition `json:"initContainers,omitempty"` + + // Restart policy for all containers within the container group. + // * Always Always restart + // * OnFailure Restart on failure + // * Never Never restart + RestartPolicy *ContainerGroupRestartPolicy `json:"restartPolicy,omitempty"` + + // The SKU for a container group. + SKU *ContainerGroupSKU `json:"sku,omitempty"` + + // The subnet resource IDs for a container group. + SubnetIDs []*ContainerGroupSubnetID `json:"subnetIds,omitempty"` + + // The list of volumes that can be mounted by containers in this container group. + Volumes []*Volume `json:"volumes,omitempty"` + + // READ-ONLY; The instance view of the container group. Only valid in response. + InstanceView *ContainerGroupPropertiesInstanceView `json:"instanceView,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the container group. This only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProperties. +func (c ContainerGroupProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "containers", c.Containers) + populate(objectMap, "dnsConfig", c.DNSConfig) + populate(objectMap, "diagnostics", c.Diagnostics) + populate(objectMap, "encryptionProperties", c.EncryptionProperties) + populate(objectMap, "ipAddress", c.IPAddress) + populate(objectMap, "imageRegistryCredentials", c.ImageRegistryCredentials) + populate(objectMap, "initContainers", c.InitContainers) + populate(objectMap, "instanceView", c.InstanceView) + populate(objectMap, "osType", c.OSType) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "restartPolicy", c.RestartPolicy) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "subnetIds", c.SubnetIDs) + populate(objectMap, "volumes", c.Volumes) + return json.Marshal(objectMap) +} + +// ContainerGroupPropertiesInstanceView - The instance view of the container group. Only valid in response. +type ContainerGroupPropertiesInstanceView struct { + // READ-ONLY; The events of this container group. + Events []*Event `json:"events,omitempty" azure:"ro"` + + // READ-ONLY; The state of the container group. Only valid in response. + State *string `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupPropertiesInstanceView. +func (c ContainerGroupPropertiesInstanceView) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "events", c.Events) + populate(objectMap, "state", c.State) + return json.Marshal(objectMap) +} + +// ContainerGroupSubnetID - Container group subnet information. +type ContainerGroupSubnetID struct { + // REQUIRED; Resource ID of virtual network and subnet. + ID *string `json:"id,omitempty"` + + // Friendly name for the subnet. + Name *string `json:"name,omitempty"` +} + +// ContainerGroupsBeginCreateOrUpdateOptions contains the optional parameters for the ContainerGroups.BeginCreateOrUpdate method. +type ContainerGroupsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsBeginDeleteOptions contains the optional parameters for the ContainerGroups.BeginDelete method. +type ContainerGroupsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsBeginRestartOptions contains the optional parameters for the ContainerGroups.BeginRestart method. +type ContainerGroupsBeginRestartOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsBeginStartOptions contains the optional parameters for the ContainerGroups.BeginStart method. +type ContainerGroupsBeginStartOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsGetOptions contains the optional parameters for the ContainerGroups.Get method. +type ContainerGroupsGetOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsGetOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the ContainerGroups.GetOutboundNetworkDependenciesEndpoints +// method. +type ContainerGroupsGetOutboundNetworkDependenciesEndpointsOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsListByResourceGroupOptions contains the optional parameters for the ContainerGroups.ListByResourceGroup method. +type ContainerGroupsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsListOptions contains the optional parameters for the ContainerGroups.List method. +type ContainerGroupsListOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsStopOptions contains the optional parameters for the ContainerGroups.Stop method. +type ContainerGroupsStopOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupsUpdateOptions contains the optional parameters for the ContainerGroups.Update method. +type ContainerGroupsUpdateOptions struct { + // placeholder for future optional parameters +} + +// ContainerHTTPGet - The container Http Get settings, for liveness or readiness probe +type ContainerHTTPGet struct { + // REQUIRED; The port number to probe. + Port *int32 `json:"port,omitempty"` + + // The HTTP headers. + HTTPHeaders []*HTTPHeader `json:"httpHeaders,omitempty"` + + // The path to probe. + Path *string `json:"path,omitempty"` + + // The scheme. + Scheme *Scheme `json:"scheme,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerHTTPGet. +func (c ContainerHTTPGet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "httpHeaders", c.HTTPHeaders) + populate(objectMap, "path", c.Path) + populate(objectMap, "port", c.Port) + populate(objectMap, "scheme", c.Scheme) + return json.Marshal(objectMap) +} + +// ContainerPort - The port exposed on the container instance. +type ContainerPort struct { + // REQUIRED; The port number exposed within the container group. + Port *int32 `json:"port,omitempty"` + + // The protocol associated with the port. + Protocol *ContainerNetworkProtocol `json:"protocol,omitempty"` +} + +// ContainerProbe - The container probe, for liveness or readiness +type ContainerProbe struct { + // The execution command to probe + Exec *ContainerExec `json:"exec,omitempty"` + + // The failure threshold. + FailureThreshold *int32 `json:"failureThreshold,omitempty"` + + // The Http Get settings to probe + HTTPGet *ContainerHTTPGet `json:"httpGet,omitempty"` + + // The initial delay seconds. + InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"` + + // The period seconds. + PeriodSeconds *int32 `json:"periodSeconds,omitempty"` + + // The success threshold. + SuccessThreshold *int32 `json:"successThreshold,omitempty"` + + // The timeout seconds. + TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` +} + +// ContainerProperties - The container instance properties. +type ContainerProperties struct { + // REQUIRED; The name of the image used to create the container instance. + Image *string `json:"image,omitempty"` + + // REQUIRED; The resource requirements of the container instance. + Resources *ResourceRequirements `json:"resources,omitempty"` + + // The commands to execute within the container instance in exec form. + Command []*string `json:"command,omitempty"` + + // The environment variables to set in the container instance. + EnvironmentVariables []*EnvironmentVariable `json:"environmentVariables,omitempty"` + + // The liveness probe. + LivenessProbe *ContainerProbe `json:"livenessProbe,omitempty"` + + // The exposed ports on the container instance. + Ports []*ContainerPort `json:"ports,omitempty"` + + // The readiness probe. + ReadinessProbe *ContainerProbe `json:"readinessProbe,omitempty"` + + // The volume mounts available to the container instance. + VolumeMounts []*VolumeMount `json:"volumeMounts,omitempty"` + + // READ-ONLY; The instance view of the container instance. Only valid in response. + InstanceView *ContainerPropertiesInstanceView `json:"instanceView,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerProperties. +func (c ContainerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "command", c.Command) + populate(objectMap, "environmentVariables", c.EnvironmentVariables) + populate(objectMap, "image", c.Image) + populate(objectMap, "instanceView", c.InstanceView) + populate(objectMap, "livenessProbe", c.LivenessProbe) + populate(objectMap, "ports", c.Ports) + populate(objectMap, "readinessProbe", c.ReadinessProbe) + populate(objectMap, "resources", c.Resources) + populate(objectMap, "volumeMounts", c.VolumeMounts) + return json.Marshal(objectMap) +} + +// ContainerPropertiesInstanceView - The instance view of the container instance. Only valid in response. +type ContainerPropertiesInstanceView struct { + // READ-ONLY; Current container instance state. + CurrentState *ContainerState `json:"currentState,omitempty" azure:"ro"` + + // READ-ONLY; The events of the container instance. + Events []*Event `json:"events,omitempty" azure:"ro"` + + // READ-ONLY; Previous container instance state. + PreviousState *ContainerState `json:"previousState,omitempty" azure:"ro"` + + // READ-ONLY; The number of times that the container instance has been restarted. + RestartCount *int32 `json:"restartCount,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerPropertiesInstanceView. +func (c ContainerPropertiesInstanceView) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentState", c.CurrentState) + populate(objectMap, "events", c.Events) + populate(objectMap, "previousState", c.PreviousState) + populate(objectMap, "restartCount", c.RestartCount) + return json.Marshal(objectMap) +} + +// ContainerState - The container instance state. +type ContainerState struct { + // READ-ONLY; The human-readable status of the container instance state. + DetailStatus *string `json:"detailStatus,omitempty" azure:"ro"` + + // READ-ONLY; The container instance exit codes correspond to those from the docker run command. + ExitCode *int32 `json:"exitCode,omitempty" azure:"ro"` + + // READ-ONLY; The date-time when the container instance state finished. + FinishTime *time.Time `json:"finishTime,omitempty" azure:"ro"` + + // READ-ONLY; The date-time when the container instance state started. + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` + + // READ-ONLY; The state of the container instance. + State *string `json:"state,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerState. +func (c ContainerState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "detailStatus", c.DetailStatus) + populate(objectMap, "exitCode", c.ExitCode) + populateTimeRFC3339(objectMap, "finishTime", c.FinishTime) + populateTimeRFC3339(objectMap, "startTime", c.StartTime) + populate(objectMap, "state", c.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerState. +func (c *ContainerState) 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 "detailStatus": + err = unpopulate(val, &c.DetailStatus) + delete(rawMsg, key) + case "exitCode": + err = unpopulate(val, &c.ExitCode) + delete(rawMsg, key) + case "finishTime": + err = unpopulateTimeRFC3339(val, &c.FinishTime) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, &c.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &c.State) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ContainersAttachOptions contains the optional parameters for the Containers.Attach method. +type ContainersAttachOptions struct { + // placeholder for future optional parameters +} + +// ContainersExecuteCommandOptions contains the optional parameters for the Containers.ExecuteCommand method. +type ContainersExecuteCommandOptions struct { + // placeholder for future optional parameters +} + +// ContainersListLogsOptions contains the optional parameters for the Containers.ListLogs method. +type ContainersListLogsOptions struct { + // The number of lines to show from the tail of the container instance log. If not provided, all available logs are shown up to 4mb. + Tail *int32 + // If true, adds a timestamp at the beginning of every line of log output. If not provided, defaults to false. + Timestamps *bool +} + +// DNSConfiguration - DNS configuration for the container group. +type DNSConfiguration struct { + // REQUIRED; The DNS servers for the container group. + NameServers []*string `json:"nameServers,omitempty"` + + // The DNS options for the container group. + Options *string `json:"options,omitempty"` + + // The DNS search domains for hostname lookup in the container group. + SearchDomains *string `json:"searchDomains,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DNSConfiguration. +func (d DNSConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nameServers", d.NameServers) + populate(objectMap, "options", d.Options) + populate(objectMap, "searchDomains", d.SearchDomains) + return json.Marshal(objectMap) +} + +// EncryptionProperties - The container group encryption properties. +type EncryptionProperties struct { + // REQUIRED; The encryption key name. + KeyName *string `json:"keyName,omitempty"` + + // REQUIRED; The encryption key version. + KeyVersion *string `json:"keyVersion,omitempty"` + + // REQUIRED; The keyvault base url. + VaultBaseURL *string `json:"vaultBaseUrl,omitempty"` +} + +// EnvironmentVariable - The environment variable to set within the container instance. +type EnvironmentVariable struct { + // REQUIRED; The name of the environment variable. + Name *string `json:"name,omitempty"` + + // The value of the secure environment variable. + SecureValue *string `json:"secureValue,omitempty"` + + // The value of the environment variable. + Value *string `json:"value,omitempty"` +} + +// Event - A container group or container instance event. +type Event struct { + // READ-ONLY; The count of the event. + Count *int32 `json:"count,omitempty" azure:"ro"` + + // READ-ONLY; The date-time of the earliest logged event. + FirstTimestamp *time.Time `json:"firstTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; The date-time of the latest logged event. + LastTimestamp *time.Time `json:"lastTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; The event message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The event name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The event type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Event. +func (e Event) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", e.Count) + populateTimeRFC3339(objectMap, "firstTimestamp", e.FirstTimestamp) + populateTimeRFC3339(objectMap, "lastTimestamp", e.LastTimestamp) + populate(objectMap, "message", e.Message) + populate(objectMap, "name", e.Name) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Event. +func (e *Event) 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 "count": + err = unpopulate(val, &e.Count) + delete(rawMsg, key) + case "firstTimestamp": + err = unpopulateTimeRFC3339(val, &e.FirstTimestamp) + delete(rawMsg, key) + case "lastTimestamp": + err = unpopulateTimeRFC3339(val, &e.LastTimestamp) + delete(rawMsg, key) + case "message": + err = unpopulate(val, &e.Message) + 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 +} + +// GitRepoVolume - Represents a volume that is populated with the contents of a git repository +type GitRepoVolume struct { + // REQUIRED; Repository URL + Repository *string `json:"repository,omitempty"` + + // Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, + // the volume will contain the git repository in + // the subdirectory with the given name. + Directory *string `json:"directory,omitempty"` + + // Commit hash for the specified revision. + Revision *string `json:"revision,omitempty"` +} + +// GpuResource - The GPU resource. +type GpuResource struct { + // REQUIRED; The count of the GPU resource. + Count *int32 `json:"count,omitempty"` + + // REQUIRED; The SKU of the GPU resource. + SKU *GpuSKU `json:"sku,omitempty"` +} + +// HTTPHeader - The HTTP header. +type HTTPHeader struct { + // The header name. + Name *string `json:"name,omitempty"` + + // The header value. + Value *string `json:"value,omitempty"` +} + +// IPAddress - IP address for the container group. +type IPAddress struct { + // REQUIRED; The list of ports exposed on the container group. + Ports []*Port `json:"ports,omitempty"` + + // REQUIRED; Specifies if the IP is exposed to the public internet or private VNET. + Type *ContainerGroupIPAddressType `json:"type,omitempty"` + + // The Dns name label for the IP. + DNSNameLabel *string `json:"dnsNameLabel,omitempty"` + + // The IP exposed to the public internet. + IP *string `json:"ip,omitempty"` + + // READ-ONLY; The FQDN for the IP. + Fqdn *string `json:"fqdn,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type IPAddress. +func (i IPAddress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsNameLabel", i.DNSNameLabel) + populate(objectMap, "fqdn", i.Fqdn) + populate(objectMap, "ip", i.IP) + populate(objectMap, "ports", i.Ports) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// ImageRegistryCredential - Image registry credential. +type ImageRegistryCredential struct { + // REQUIRED; The Docker image registry server without a protocol such as "http" and "https". + Server *string `json:"server,omitempty"` + + // REQUIRED; The username for the private registry. + Username *string `json:"username,omitempty"` + + // The identity for the private registry. + Identity *string `json:"identity,omitempty"` + + // The identity URL for the private registry. + IdentityURL *string `json:"identityUrl,omitempty"` + + // The password for the private registry. + Password *string `json:"password,omitempty"` +} + +// InitContainerDefinition - The init container definition. +type InitContainerDefinition struct { + // REQUIRED; The name for the init container. + Name *string `json:"name,omitempty"` + + // REQUIRED; The properties for the init container. + Properties *InitContainerPropertiesDefinition `json:"properties,omitempty"` +} + +// InitContainerPropertiesDefinition - The init container definition properties. +type InitContainerPropertiesDefinition struct { + // The command to execute within the init container in exec form. + Command []*string `json:"command,omitempty"` + + // The environment variables to set in the init container. + EnvironmentVariables []*EnvironmentVariable `json:"environmentVariables,omitempty"` + + // The image of the init container. + Image *string `json:"image,omitempty"` + + // The volume mounts available to the init container. + VolumeMounts []*VolumeMount `json:"volumeMounts,omitempty"` + + // READ-ONLY; The instance view of the init container. Only valid in response. + InstanceView *InitContainerPropertiesDefinitionInstanceView `json:"instanceView,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type InitContainerPropertiesDefinition. +func (i InitContainerPropertiesDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "command", i.Command) + populate(objectMap, "environmentVariables", i.EnvironmentVariables) + populate(objectMap, "image", i.Image) + populate(objectMap, "instanceView", i.InstanceView) + populate(objectMap, "volumeMounts", i.VolumeMounts) + return json.Marshal(objectMap) +} + +// InitContainerPropertiesDefinitionInstanceView - The instance view of the init container. Only valid in response. +type InitContainerPropertiesDefinitionInstanceView struct { + // READ-ONLY; The current state of the init container. + CurrentState *ContainerState `json:"currentState,omitempty" azure:"ro"` + + // READ-ONLY; The events of the init container. + Events []*Event `json:"events,omitempty" azure:"ro"` + + // READ-ONLY; The previous state of the init container. + PreviousState *ContainerState `json:"previousState,omitempty" azure:"ro"` + + // READ-ONLY; The number of times that the init container has been restarted. + RestartCount *int32 `json:"restartCount,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type InitContainerPropertiesDefinitionInstanceView. +func (i InitContainerPropertiesDefinitionInstanceView) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentState", i.CurrentState) + populate(objectMap, "events", i.Events) + populate(objectMap, "previousState", i.PreviousState) + populate(objectMap, "restartCount", i.RestartCount) + return json.Marshal(objectMap) +} + +// LocationListCachedImagesOptions contains the optional parameters for the Location.ListCachedImages method. +type LocationListCachedImagesOptions struct { + // placeholder for future optional parameters +} + +// LocationListCapabilitiesOptions contains the optional parameters for the Location.ListCapabilities method. +type LocationListCapabilitiesOptions struct { + // placeholder for future optional parameters +} + +// LocationListUsageOptions contains the optional parameters for the Location.ListUsage method. +type LocationListUsageOptions struct { + // placeholder for future optional parameters +} + +// LogAnalytics - Container group log analytics information. +type LogAnalytics struct { + // REQUIRED; The workspace id for log analytics + WorkspaceID *string `json:"workspaceId,omitempty"` + + // REQUIRED; The workspace key for log analytics + WorkspaceKey *string `json:"workspaceKey,omitempty"` + + // The log type to be used. + LogType *LogAnalyticsLogType `json:"logType,omitempty"` + + // Metadata for log analytics. + Metadata map[string]*string `json:"metadata,omitempty"` + + // The workspace resource id for log analytics + WorkspaceResourceID *string `json:"workspaceResourceId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LogAnalytics. +func (l LogAnalytics) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logType", l.LogType) + populate(objectMap, "metadata", l.Metadata) + populate(objectMap, "workspaceId", l.WorkspaceID) + populate(objectMap, "workspaceKey", l.WorkspaceKey) + populate(objectMap, "workspaceResourceId", l.WorkspaceResourceID) + return json.Marshal(objectMap) +} + +// Logs - The logs. +type Logs struct { + // The content of the log. + Content *string `json:"content,omitempty"` +} + +// Operation - An operation for Azure Container Instance service. +type Operation struct { + // REQUIRED; The display information of the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // REQUIRED; The name of the operation. + Name *string `json:"name,omitempty"` + + // The intended executor of the operation. + Origin *ContainerInstanceOperationsOrigin `json:"origin,omitempty"` + + // The additional properties. + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// OperationDisplay - The display information of the operation. +type OperationDisplay struct { + // The description of the operation. + Description *string `json:"description,omitempty"` + + // The friendly name of the operation. + Operation *string `json:"operation,omitempty"` + + // The name of the provider of the operation. + Provider *string `json:"provider,omitempty"` + + // The name of the resource type of the operation. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - The operation list response that contains all operations for Azure Container Instance service. +type OperationListResult struct { + // The URI to fetch the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of operations. + Value []*Operation `json:"value,omitempty"` +} + +// 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 +} + +// Port - The port exposed on the container group. +type Port struct { + // REQUIRED; The port number. + Port *int32 `json:"port,omitempty"` + + // The protocol associated with the port. + Protocol *ContainerGroupNetworkProtocol `json:"protocol,omitempty"` +} + +// Resource - The Resource model definition. +type Resource struct { + // The resource location. + Location *string `json:"location,omitempty"` + + // The resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // The zones for the container group. + Zones []*string `json:"zones,omitempty"` + + // READ-ONLY; The resource id. + 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + populate(objectMap, "zones", r.Zones) +} + +// ResourceLimits - The resource limits. +type ResourceLimits struct { + // The CPU limit of this container instance. + CPU *float64 `json:"cpu,omitempty"` + + // The GPU limit of this container instance. + Gpu *GpuResource `json:"gpu,omitempty"` + + // The memory limit in GB of this container instance. + MemoryInGB *float64 `json:"memoryInGB,omitempty"` +} + +// ResourceRequests - The resource requests. +type ResourceRequests struct { + // REQUIRED; The CPU request of this container instance. + CPU *float64 `json:"cpu,omitempty"` + + // REQUIRED; The memory request in GB of this container instance. + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + + // The GPU request of this container instance. + Gpu *GpuResource `json:"gpu,omitempty"` +} + +// ResourceRequirements - The resource requirements. +type ResourceRequirements struct { + // REQUIRED; The resource requests of this container instance. + Requests *ResourceRequests `json:"requests,omitempty"` + + // The resource limits of this container instance. + Limits *ResourceLimits `json:"limits,omitempty"` +} + +// Usage - A single usage result +type Usage struct { + // READ-ONLY; The current usage of the resource + CurrentValue *int32 `json:"currentValue,omitempty" azure:"ro"` + + // READ-ONLY; The maximum permitted usage of the resource. + Limit *int32 `json:"limit,omitempty" azure:"ro"` + + // READ-ONLY; The name object of the resource + Name *UsageName `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Unit of the usage result + Unit *string `json:"unit,omitempty" azure:"ro"` +} + +// UsageListResult - The response containing the usage data +type UsageListResult struct { + // READ-ONLY; The usage data. + Value []*Usage `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type UsageListResult. +func (u UsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UsageName - The name object of the resource +type UsageName struct { + // READ-ONLY; The localized name of the resource + LocalizedValue *string `json:"localizedValue,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Value *string `json:"value,omitempty" azure:"ro"` +} + +// Volume - The properties of the volume. +type Volume struct { + // REQUIRED; The name of the volume. + Name *string `json:"name,omitempty"` + + // The Azure File volume. + AzureFile *AzureFileVolume `json:"azureFile,omitempty"` + + // The empty directory volume. + EmptyDir map[string]interface{} `json:"emptyDir,omitempty"` + + // The git repo volume. + GitRepo *GitRepoVolume `json:"gitRepo,omitempty"` + + // The secret volume. + Secret map[string]*string `json:"secret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Volume. +func (v Volume) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "azureFile", v.AzureFile) + populate(objectMap, "emptyDir", v.EmptyDir) + populate(objectMap, "gitRepo", v.GitRepo) + populate(objectMap, "name", v.Name) + populate(objectMap, "secret", v.Secret) + return json.Marshal(objectMap) +} + +// VolumeMount - The properties of the volume mount. +type VolumeMount struct { + // REQUIRED; The path within the container where the volume should be mounted. Must not contain colon (:). + MountPath *string `json:"mountPath,omitempty"` + + // REQUIRED; The name of the volume mount. + Name *string `json:"name,omitempty"` + + // The flag indicating whether the volume mount is read-only. + ReadOnly *bool `json:"readOnly,omitempty"` +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_operations_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_operations_client.go new file mode 100644 index 000000000000..21a2be981138 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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 armcontainerinstance + +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 - List the operations for Azure Container Instance service. +// If the operation fails it returns the *CloudError 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.ContainerInstance/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", "2021-09-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 := CloudError{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/containerinstance/armcontainerinstance/zz_generated_pagers.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_pagers.go new file mode 100644 index 000000000000..b8af57ca412d --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_pagers.go @@ -0,0 +1,287 @@ +//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 armcontainerinstance + +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" +) + +// ContainerGroupsListByResourceGroupPager provides operations for iterating over paged responses. +type ContainerGroupsListByResourceGroupPager struct { + client *ContainerGroupsClient + current ContainerGroupsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ContainerGroupsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ContainerGroupsListByResourceGroupPager) 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 *ContainerGroupsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ContainerGroupListResult.NextLink == nil || len(*p.current.ContainerGroupListResult.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 ContainerGroupsListByResourceGroupResponse page. +func (p *ContainerGroupsListByResourceGroupPager) PageResponse() ContainerGroupsListByResourceGroupResponse { + return p.current +} + +// ContainerGroupsListPager provides operations for iterating over paged responses. +type ContainerGroupsListPager struct { + client *ContainerGroupsClient + current ContainerGroupsListResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ContainerGroupsListResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ContainerGroupsListPager) 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 *ContainerGroupsListPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ContainerGroupListResult.NextLink == nil || len(*p.current.ContainerGroupListResult.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 ContainerGroupsListResponse page. +func (p *ContainerGroupsListPager) PageResponse() ContainerGroupsListResponse { + return p.current +} + +// LocationListCachedImagesPager provides operations for iterating over paged responses. +type LocationListCachedImagesPager struct { + client *LocationClient + current LocationListCachedImagesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LocationListCachedImagesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LocationListCachedImagesPager) 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 *LocationListCachedImagesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CachedImagesListResult.NextLink == nil || len(*p.current.CachedImagesListResult.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.listCachedImagesHandleError(resp) + return false + } + result, err := p.client.listCachedImagesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LocationListCachedImagesResponse page. +func (p *LocationListCachedImagesPager) PageResponse() LocationListCachedImagesResponse { + return p.current +} + +// LocationListCapabilitiesPager provides operations for iterating over paged responses. +type LocationListCapabilitiesPager struct { + client *LocationClient + current LocationListCapabilitiesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, LocationListCapabilitiesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *LocationListCapabilitiesPager) 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 *LocationListCapabilitiesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CapabilitiesListResult.NextLink == nil || len(*p.current.CapabilitiesListResult.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.listCapabilitiesHandleError(resp) + return false + } + result, err := p.client.listCapabilitiesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current LocationListCapabilitiesResponse page. +func (p *LocationListCapabilitiesPager) PageResponse() LocationListCapabilitiesResponse { + 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/containerinstance/armcontainerinstance/zz_generated_pollers.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_pollers.go new file mode 100644 index 000000000000..63f017938bcd --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_pollers.go @@ -0,0 +1,187 @@ +//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 armcontainerinstance + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// ContainerGroupsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ContainerGroupsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContainerGroupsCreateOrUpdatePoller) 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 *ContainerGroupsCreateOrUpdatePoller) 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 ContainerGroupsCreateOrUpdateResponse will be returned. +func (p *ContainerGroupsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (ContainerGroupsCreateOrUpdateResponse, error) { + respType := ContainerGroupsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ContainerGroup) + if err != nil { + return ContainerGroupsCreateOrUpdateResponse{}, 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 *ContainerGroupsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContainerGroupsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ContainerGroupsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContainerGroupsDeletePoller) 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 *ContainerGroupsDeletePoller) 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 ContainerGroupsDeleteResponse will be returned. +func (p *ContainerGroupsDeletePoller) FinalResponse(ctx context.Context) (ContainerGroupsDeleteResponse, error) { + respType := ContainerGroupsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.ContainerGroup) + if err != nil { + return ContainerGroupsDeleteResponse{}, 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 *ContainerGroupsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContainerGroupsRestartPoller provides polling facilities until the operation reaches a terminal state. +type ContainerGroupsRestartPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContainerGroupsRestartPoller) 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 *ContainerGroupsRestartPoller) 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 ContainerGroupsRestartResponse will be returned. +func (p *ContainerGroupsRestartPoller) FinalResponse(ctx context.Context) (ContainerGroupsRestartResponse, error) { + respType := ContainerGroupsRestartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ContainerGroupsRestartResponse{}, 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 *ContainerGroupsRestartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ContainerGroupsStartPoller provides polling facilities until the operation reaches a terminal state. +type ContainerGroupsStartPoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ContainerGroupsStartPoller) 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 *ContainerGroupsStartPoller) 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 ContainerGroupsStartResponse will be returned. +func (p *ContainerGroupsStartPoller) FinalResponse(ctx context.Context) (ContainerGroupsStartResponse, error) { + respType := ContainerGroupsStartResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ContainerGroupsStartResponse{}, 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 *ContainerGroupsStartPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_response_types.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_response_types.go new file mode 100644 index 000000000000..b612c739d8b0 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_response_types.go @@ -0,0 +1,363 @@ +//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 armcontainerinstance + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// ContainerGroupsCreateOrUpdatePollerResponse contains the response from method ContainerGroups.CreateOrUpdate. +type ContainerGroupsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContainerGroupsCreateOrUpdatePoller + + // 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 ContainerGroupsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContainerGroupsCreateOrUpdateResponse, error) { + respType := ContainerGroupsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ContainerGroup) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContainerGroupsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *ContainerGroupsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *ContainerGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContainerGroupsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &ContainerGroupsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContainerGroupsCreateOrUpdateResponse contains the response from method ContainerGroups.CreateOrUpdate. +type ContainerGroupsCreateOrUpdateResponse struct { + ContainerGroupsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsCreateOrUpdateResult contains the result from method ContainerGroups.CreateOrUpdate. +type ContainerGroupsCreateOrUpdateResult struct { + ContainerGroup +} + +// ContainerGroupsDeletePollerResponse contains the response from method ContainerGroups.Delete. +type ContainerGroupsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ContainerGroupsDeletePoller + + // 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 ContainerGroupsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContainerGroupsDeleteResponse, error) { + respType := ContainerGroupsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ContainerGroup) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContainerGroupsDeletePollerResponse from the provided client and resume token. +func (l *ContainerGroupsDeletePollerResponse) Resume(ctx context.Context, client *ContainerGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContainerGroupsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ContainerGroupsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContainerGroupsDeleteResponse contains the response from method ContainerGroups.Delete. +type ContainerGroupsDeleteResponse struct { + ContainerGroupsDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsDeleteResult contains the result from method ContainerGroups.Delete. +type ContainerGroupsDeleteResult struct { + ContainerGroup +} + +// ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse contains the response from method ContainerGroups.GetOutboundNetworkDependenciesEndpoints. +type ContainerGroupsGetOutboundNetworkDependenciesEndpointsResponse struct { + ContainerGroupsGetOutboundNetworkDependenciesEndpointsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsGetOutboundNetworkDependenciesEndpointsResult contains the result from method ContainerGroups.GetOutboundNetworkDependenciesEndpoints. +type ContainerGroupsGetOutboundNetworkDependenciesEndpointsResult struct { + // Response for network dependencies, always empty list. + StringArray []*string +} + +// ContainerGroupsGetResponse contains the response from method ContainerGroups.Get. +type ContainerGroupsGetResponse struct { + ContainerGroupsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsGetResult contains the result from method ContainerGroups.Get. +type ContainerGroupsGetResult struct { + ContainerGroup +} + +// ContainerGroupsListByResourceGroupResponse contains the response from method ContainerGroups.ListByResourceGroup. +type ContainerGroupsListByResourceGroupResponse struct { + ContainerGroupsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsListByResourceGroupResult contains the result from method ContainerGroups.ListByResourceGroup. +type ContainerGroupsListByResourceGroupResult struct { + ContainerGroupListResult +} + +// ContainerGroupsListResponse contains the response from method ContainerGroups.List. +type ContainerGroupsListResponse struct { + ContainerGroupsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsListResult contains the result from method ContainerGroups.List. +type ContainerGroupsListResult struct { + ContainerGroupListResult +} + +// ContainerGroupsRestartPollerResponse contains the response from method ContainerGroups.Restart. +type ContainerGroupsRestartPollerResponse struct { + // Poller contains an initialized poller. + Poller *ContainerGroupsRestartPoller + + // 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 ContainerGroupsRestartPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContainerGroupsRestartResponse, error) { + respType := ContainerGroupsRestartResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContainerGroupsRestartPollerResponse from the provided client and resume token. +func (l *ContainerGroupsRestartPollerResponse) Resume(ctx context.Context, client *ContainerGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContainerGroupsClient.Restart", token, client.pl, client.restartHandleError) + if err != nil { + return err + } + poller := &ContainerGroupsRestartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContainerGroupsRestartResponse contains the response from method ContainerGroups.Restart. +type ContainerGroupsRestartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsStartPollerResponse contains the response from method ContainerGroups.Start. +type ContainerGroupsStartPollerResponse struct { + // Poller contains an initialized poller. + Poller *ContainerGroupsStartPoller + + // 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 ContainerGroupsStartPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ContainerGroupsStartResponse, error) { + respType := ContainerGroupsStartResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ContainerGroupsStartPollerResponse from the provided client and resume token. +func (l *ContainerGroupsStartPollerResponse) Resume(ctx context.Context, client *ContainerGroupsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ContainerGroupsClient.Start", token, client.pl, client.startHandleError) + if err != nil { + return err + } + poller := &ContainerGroupsStartPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ContainerGroupsStartResponse contains the response from method ContainerGroups.Start. +type ContainerGroupsStartResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsStopResponse contains the response from method ContainerGroups.Stop. +type ContainerGroupsStopResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsUpdateResponse contains the response from method ContainerGroups.Update. +type ContainerGroupsUpdateResponse struct { + ContainerGroupsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainerGroupsUpdateResult contains the result from method ContainerGroups.Update. +type ContainerGroupsUpdateResult struct { + ContainerGroup +} + +// ContainersAttachResponse contains the response from method Containers.Attach. +type ContainersAttachResponse struct { + ContainersAttachResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainersAttachResult contains the result from method Containers.Attach. +type ContainersAttachResult struct { + ContainerAttachResponse +} + +// ContainersExecuteCommandResponse contains the response from method Containers.ExecuteCommand. +type ContainersExecuteCommandResponse struct { + ContainersExecuteCommandResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainersExecuteCommandResult contains the result from method Containers.ExecuteCommand. +type ContainersExecuteCommandResult struct { + ContainerExecResponse +} + +// ContainersListLogsResponse contains the response from method Containers.ListLogs. +type ContainersListLogsResponse struct { + ContainersListLogsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContainersListLogsResult contains the result from method Containers.ListLogs. +type ContainersListLogsResult struct { + Logs +} + +// LocationListCachedImagesResponse contains the response from method Location.ListCachedImages. +type LocationListCachedImagesResponse struct { + LocationListCachedImagesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationListCachedImagesResult contains the result from method Location.ListCachedImages. +type LocationListCachedImagesResult struct { + CachedImagesListResult +} + +// LocationListCapabilitiesResponse contains the response from method Location.ListCapabilities. +type LocationListCapabilitiesResponse struct { + LocationListCapabilitiesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationListCapabilitiesResult contains the result from method Location.ListCapabilities. +type LocationListCapabilitiesResult struct { + CapabilitiesListResult +} + +// LocationListUsageResponse contains the response from method Location.ListUsage. +type LocationListUsageResponse struct { + LocationListUsageResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LocationListUsageResult contains the result from method Location.ListUsage. +type LocationListUsageResult struct { + UsageListResult +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_time_rfc3339.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..52ac91b16386 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/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 armcontainerinstance + +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 +}