Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR: Regenerating the Go SDK (ec0083f539696d6b9a2b4f07210b8847aa4b73e2) #940

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions resource-manager/containerinstance/2023-05-01/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ package v2023_05_01
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

import (
"github.com/Azure/go-autorest/autorest"
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/containerinstance/2023-05-01/containerinstance"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
ContainerInstance *containerinstance.ContainerInstanceClient
}

func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client {

containerInstanceClient := containerinstance.NewContainerInstanceClientWithBaseURI(endpoint)
configureAuthFunc(&containerInstanceClient.Client)

return Client{
ContainerInstance: &containerInstanceClient,
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
containerInstanceClient, err := containerinstance.NewContainerInstanceClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building ContainerInstance client: %+v", err)
}
configureFunc(containerInstanceClient.Client)

return &Client{
ContainerInstance: containerInstanceClient,
}, nil
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package containerinstance

import "github.com/Azure/go-autorest/autorest"
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ContainerInstanceClient struct {
Client autorest.Client
baseUri string
Client *resourcemanager.Client
}

func NewContainerInstanceClientWithBaseURI(endpoint string) ContainerInstanceClient {
return ContainerInstanceClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
func NewContainerInstanceClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerInstanceClient, error) {
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerinstance", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating ContainerInstanceClient: %+v", err)
}

return &ContainerInstanceClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package containerinstance

import "strings"
import (
"encoding/json"
"fmt"
"strings"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
Expand All @@ -19,6 +23,19 @@ func PossibleValuesForContainerGroupIPAddressType() []string {
}
}

func (s *ContainerGroupIPAddressType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerGroupIPAddressType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerGroupIPAddressType(input string) (*ContainerGroupIPAddressType, error) {
vals := map[string]ContainerGroupIPAddressType{
"private": ContainerGroupIPAddressTypePrivate,
Expand Down Expand Up @@ -47,6 +64,19 @@ func PossibleValuesForContainerGroupNetworkProtocol() []string {
}
}

func (s *ContainerGroupNetworkProtocol) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerGroupNetworkProtocol(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerGroupNetworkProtocol(input string) (*ContainerGroupNetworkProtocol, error) {
vals := map[string]ContainerGroupNetworkProtocol{
"tcp": ContainerGroupNetworkProtocolTCP,
Expand Down Expand Up @@ -75,6 +105,19 @@ func PossibleValuesForContainerGroupPriority() []string {
}
}

func (s *ContainerGroupPriority) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerGroupPriority(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerGroupPriority(input string) (*ContainerGroupPriority, error) {
vals := map[string]ContainerGroupPriority{
"regular": ContainerGroupPriorityRegular,
Expand Down Expand Up @@ -105,6 +148,19 @@ func PossibleValuesForContainerGroupRestartPolicy() []string {
}
}

func (s *ContainerGroupRestartPolicy) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerGroupRestartPolicy(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerGroupRestartPolicy(input string) (*ContainerGroupRestartPolicy, error) {
vals := map[string]ContainerGroupRestartPolicy{
"always": ContainerGroupRestartPolicyAlways,
Expand Down Expand Up @@ -136,6 +192,19 @@ func PossibleValuesForContainerGroupSku() []string {
}
}

func (s *ContainerGroupSku) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerGroupSku(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerGroupSku(input string) (*ContainerGroupSku, error) {
vals := map[string]ContainerGroupSku{
"confidential": ContainerGroupSkuConfidential,
Expand Down Expand Up @@ -165,6 +234,19 @@ func PossibleValuesForContainerNetworkProtocol() []string {
}
}

func (s *ContainerNetworkProtocol) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseContainerNetworkProtocol(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseContainerNetworkProtocol(input string) (*ContainerNetworkProtocol, error) {
vals := map[string]ContainerNetworkProtocol{
"tcp": ContainerNetworkProtocolTCP,
Expand Down Expand Up @@ -199,6 +281,19 @@ func PossibleValuesForDnsNameLabelReusePolicy() []string {
}
}

func (s *DnsNameLabelReusePolicy) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseDnsNameLabelReusePolicy(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseDnsNameLabelReusePolicy(input string) (*DnsNameLabelReusePolicy, error) {
vals := map[string]DnsNameLabelReusePolicy{
"noreuse": DnsNameLabelReusePolicyNoreuse,
Expand Down Expand Up @@ -232,6 +327,19 @@ func PossibleValuesForGpuSku() []string {
}
}

func (s *GpuSku) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseGpuSku(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseGpuSku(input string) (*GpuSku, error) {
vals := map[string]GpuSku{
"k80": GpuSkuKEightZero,
Expand Down Expand Up @@ -261,6 +369,19 @@ func PossibleValuesForLogAnalyticsLogType() []string {
}
}

func (s *LogAnalyticsLogType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseLogAnalyticsLogType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseLogAnalyticsLogType(input string) (*LogAnalyticsLogType, error) {
vals := map[string]LogAnalyticsLogType{
"containerinsights": LogAnalyticsLogTypeContainerInsights,
Expand Down Expand Up @@ -289,6 +410,19 @@ func PossibleValuesForOperatingSystemTypes() []string {
}
}

func (s *OperatingSystemTypes) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseOperatingSystemTypes(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseOperatingSystemTypes(input string) (*OperatingSystemTypes, error) {
vals := map[string]OperatingSystemTypes{
"linux": OperatingSystemTypesLinux,
Expand Down Expand Up @@ -317,6 +451,19 @@ func PossibleValuesForScheme() []string {
}
}

func (s *Scheme) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseScheme(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseScheme(input string) (*Scheme, error) {
vals := map[string]Scheme{
"http": SchemeHTTP,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package containerinstance

import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ContainerGroupsCreateOrUpdateOperationResponse struct {
Poller pollers.Poller
HttpResponse *http.Response
OData *odata.OData
Model *ContainerGroup
}

// ContainerGroupsCreateOrUpdate ...
func (c ContainerInstanceClient) ContainerGroupsCreateOrUpdate(ctx context.Context, id ContainerGroupId, input ContainerGroup) (result ContainerGroupsCreateOrUpdateOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusCreated,
http.StatusOK,
},
HttpMethod: http.MethodPut,
Path: id.ID(),
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

if err = req.Marshal(input); err != nil {
return
}

var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client)
if err != nil {
return
}

return
}

// ContainerGroupsCreateOrUpdateThenPoll performs ContainerGroupsCreateOrUpdate then polls until it's completed
func (c ContainerInstanceClient) ContainerGroupsCreateOrUpdateThenPoll(ctx context.Context, id ContainerGroupId, input ContainerGroup) error {
result, err := c.ContainerGroupsCreateOrUpdate(ctx, id, input)
if err != nil {
return fmt.Errorf("performing ContainerGroupsCreateOrUpdate: %+v", err)
}

if err := result.Poller.PollUntilDone(ctx); err != nil {
return fmt.Errorf("polling after ContainerGroupsCreateOrUpdate: %+v", err)
}

return nil
}
Loading
Loading