From 6448f89e6b2097e7223ccca88bd37a8503d95479 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 4 Oct 2024 07:10:43 +0000 Subject: [PATCH] CodeGen from PR 30854 in Azure/azure-rest-api-specs Merge 9210d8f9352f151fc7d9888cf4513081f6c14fe6 into 75fdb87b5367a3ab306e85fb6daa7501d54f0553 --- .../armcontainerinstance/CHANGELOG.md | 27 + .../armcontainerinstance/README.md | 2 +- .../armcontainerinstance/autorest.md | 7 +- .../armcontainerinstance/client_factory.go | 57 +- .../armcontainerinstance/constants.go | 2 +- .../containergroupprofile_client.go | 184 ++ .../containergroupprofiles_client.go | 424 +++++ .../containergroups_client.go | 69 +- .../containergroups_client_example_test.go | 1476 ----------------- .../armcontainerinstance/containers_client.go | 21 +- .../containers_client_example_test.go | 98 -- .../fake/containergroupprofile_server.go | 156 ++ .../fake/containergroupprofiles_server.go | 314 ++++ .../fake/server_factory.go | 14 + .../armcontainerinstance/fake/time_rfc3339.go | 42 +- .../armcontainerinstance/go.mod | 12 +- .../armcontainerinstance/go.sum | 17 - .../armcontainerinstance/location_client.go | 21 +- .../location_client_example_test.go | 147 -- .../armcontainerinstance/models.go | 150 +- .../armcontainerinstance/models_serde.go | 322 +++- .../armcontainerinstance/operations_client.go | 4 +- .../operations_client_example_test.go | 56 - .../armcontainerinstance/options.go | 46 + .../{response_types.go => responses.go} | 47 + .../subnetserviceassociationlink_client.go | 11 +- ...viceassociationlink_client_example_test.go | 39 - .../armcontainerinstance/time_rfc3339.go | 42 +- 28 files changed, 1847 insertions(+), 1960 deletions(-) create mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofile_client.go create mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofiles_client.go delete mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client_example_test.go delete mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client_example_test.go create mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofile_server.go create mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofiles_server.go delete mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/location_client_example_test.go delete mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client_example_test.go rename sdk/resourcemanager/containerinstance/armcontainerinstance/{response_types.go => responses.go} (67%) delete mode 100644 sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client_example_test.go diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md index e886bc710b6c..f94de5e53eea 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md @@ -1,5 +1,32 @@ # Release History +## 2.5.0-beta.1 (2024-10-04) +### Features Added + +- New function `*ClientFactory.NewContainerGroupProfileClient() *ContainerGroupProfileClient` +- New function `*ClientFactory.NewContainerGroupProfilesClient() *ContainerGroupProfilesClient` +- New function `NewContainerGroupProfileClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ContainerGroupProfileClient, error)` +- New function `*ContainerGroupProfileClient.GetByRevisionNumber(context.Context, string, string, string, *ContainerGroupProfileClientGetByRevisionNumberOptions) (ContainerGroupProfileClientGetByRevisionNumberResponse, error)` +- New function `*ContainerGroupProfileClient.NewListAllRevisionsPager(string, string, *ContainerGroupProfileClientListAllRevisionsOptions) *runtime.Pager[ContainerGroupProfileClientListAllRevisionsResponse]` +- New function `NewContainerGroupProfilesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*ContainerGroupProfilesClient, error)` +- New function `*ContainerGroupProfilesClient.CreateOrUpdate(context.Context, string, string, ContainerGroupProfile, *ContainerGroupProfilesClientCreateOrUpdateOptions) (ContainerGroupProfilesClientCreateOrUpdateResponse, error)` +- New function `*ContainerGroupProfilesClient.Delete(context.Context, string, string, *ContainerGroupProfilesClientDeleteOptions) (ContainerGroupProfilesClientDeleteResponse, error)` +- New function `*ContainerGroupProfilesClient.Get(context.Context, string, string, *ContainerGroupProfilesClientGetOptions) (ContainerGroupProfilesClientGetResponse, error)` +- New function `*ContainerGroupProfilesClient.NewListByResourceGroupPager(string, *ContainerGroupProfilesClientListByResourceGroupOptions) *runtime.Pager[ContainerGroupProfilesClientListByResourceGroupResponse]` +- New function `*ContainerGroupProfilesClient.NewListPager(*ContainerGroupProfilesClientListOptions) *runtime.Pager[ContainerGroupProfilesClientListResponse]` +- New function `*ContainerGroupProfilesClient.Patch(context.Context, string, string, ContainerGroupProfilePatch, *ContainerGroupProfilesClientPatchOptions) (ContainerGroupProfilesClientPatchResponse, error)` +- New struct `ConfigMap` +- New struct `ContainerGroupProfile` +- New struct `ContainerGroupProfileListResult` +- New struct `ContainerGroupProfilePatch` +- New struct `ContainerGroupProfileProperties` +- New struct `ContainerGroupProfilePropertiesProperties` +- New struct `ContainerGroupProfileReferenceDefinition` +- New struct `StandbyPoolProfileDefinition` +- New field `ContainerGroupProfile`, `IsCreatedFromStandbyPool`, `StandbyPoolProfile` in struct `ContainerGroupPropertiesProperties` +- New field `ConfigMap` in struct `ContainerProperties` + + ## 2.4.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md index a94d69229ceb..63276275a276 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/README.md @@ -57,7 +57,7 @@ clientFactory, err := armcontainerinstance.NewClientFactory(, c A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewContainersClient() +client := clientFactory.NewContainerGroupProfileClient() ``` ## Fakes diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md index 936dffc5cb0f..80a1531d2e0b 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerinstance/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/containerinstance/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.4.0 -tag: package-2023-05 +module-version: 2.5.0-beta.1 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go index f470f27ecc5f..67b400c79b51 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go @@ -17,53 +17,76 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } +// NewContainerGroupProfileClient creates a new instance of ContainerGroupProfileClient. +func (c *ClientFactory) NewContainerGroupProfileClient() *ContainerGroupProfileClient { + return &ContainerGroupProfileClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewContainerGroupProfilesClient creates a new instance of ContainerGroupProfilesClient. +func (c *ClientFactory) NewContainerGroupProfilesClient() *ContainerGroupProfilesClient { + return &ContainerGroupProfilesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + // NewContainerGroupsClient creates a new instance of ContainerGroupsClient. func (c *ClientFactory) NewContainerGroupsClient() *ContainerGroupsClient { - subClient, _ := NewContainerGroupsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ContainerGroupsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewContainersClient creates a new instance of ContainersClient. func (c *ClientFactory) NewContainersClient() *ContainersClient { - subClient, _ := NewContainersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ContainersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewLocationClient creates a new instance of LocationClient. func (c *ClientFactory) NewLocationClient() *LocationClient { - subClient, _ := NewLocationClient(c.subscriptionID, c.credential, c.options) - return subClient + return &LocationClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewSubnetServiceAssociationLinkClient creates a new instance of SubnetServiceAssociationLinkClient. func (c *ClientFactory) NewSubnetServiceAssociationLinkClient() *SubnetServiceAssociationLinkClient { - subClient, _ := NewSubnetServiceAssociationLinkClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SubnetServiceAssociationLinkClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/constants.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/constants.go index 2b87ecc769d7..2ba614c5c7ea 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/constants.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/constants.go @@ -10,7 +10,7 @@ package armcontainerinstance const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance" - moduleVersion = "v2.4.0" + moduleVersion = "v2.5.0-beta.1" ) // ContainerGroupIPAddressType - Specifies if the IP is exposed to the public internet or private VNET. diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofile_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofile_client.go new file mode 100644 index 000000000000..19d406df78a2 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofile_client.go @@ -0,0 +1,184 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerinstance + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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" +) + +// ContainerGroupProfileClient contains the methods for the ContainerGroupProfile group. +// Don't use this type directly, use NewContainerGroupProfileClient() instead. +type ContainerGroupProfileClient struct { + internal *arm.Client + subscriptionID string +} + +// NewContainerGroupProfileClient creates a new instance of ContainerGroupProfileClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewContainerGroupProfileClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainerGroupProfileClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ContainerGroupProfileClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// GetByRevisionNumber - Gets the properties of the specified revision of the container group profile in the given subscription +// and resource group. The operation returns the properties of container group profile including +// containers, image registry credentials, restart policy, IP address type, OS type, volumes, current revision number, etc. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - revisionNumber - The revision number of the container group profile. +// - options - ContainerGroupProfileClientGetByRevisionNumberOptions contains the optional parameters for the ContainerGroupProfileClient.GetByRevisionNumber +// method. +func (client *ContainerGroupProfileClient) GetByRevisionNumber(ctx context.Context, resourceGroupName string, containerGroupProfileName string, revisionNumber string, options *ContainerGroupProfileClientGetByRevisionNumberOptions) (ContainerGroupProfileClientGetByRevisionNumberResponse, error) { + var err error + const operationName = "ContainerGroupProfileClient.GetByRevisionNumber" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByRevisionNumberCreateRequest(ctx, resourceGroupName, containerGroupProfileName, revisionNumber, options) + if err != nil { + return ContainerGroupProfileClientGetByRevisionNumberResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ContainerGroupProfileClientGetByRevisionNumberResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ContainerGroupProfileClientGetByRevisionNumberResponse{}, err + } + resp, err := client.getByRevisionNumberHandleResponse(httpResp) + return resp, err +} + +// getByRevisionNumberCreateRequest creates the GetByRevisionNumber request. +func (client *ContainerGroupProfileClient) getByRevisionNumberCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, revisionNumber string, options *ContainerGroupProfileClientGetByRevisionNumberOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}/revisions/{revisionNumber}" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + if revisionNumber == "" { + return nil, errors.New("parameter revisionNumber cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{revisionNumber}", url.PathEscape(revisionNumber)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByRevisionNumberHandleResponse handles the GetByRevisionNumber response. +func (client *ContainerGroupProfileClient) getByRevisionNumberHandleResponse(resp *http.Response) (ContainerGroupProfileClientGetByRevisionNumberResponse, error) { + result := ContainerGroupProfileClientGetByRevisionNumberResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfile); err != nil { + return ContainerGroupProfileClientGetByRevisionNumberResponse{}, err + } + return result, nil +} + +// NewListAllRevisionsPager - Get a list of all the revisions of the specified container group profile in the given subscription +// and resource group. This operation returns properties of each revision of the specified container +// group profile including containers, image registry credentials, restart policy, IP address type, OS type volumes, revision +// number, etc. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - options - ContainerGroupProfileClientListAllRevisionsOptions contains the optional parameters for the ContainerGroupProfileClient.NewListAllRevisionsPager +// method. +func (client *ContainerGroupProfileClient) NewListAllRevisionsPager(resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfileClientListAllRevisionsOptions) *runtime.Pager[ContainerGroupProfileClientListAllRevisionsResponse] { + return runtime.NewPager(runtime.PagingHandler[ContainerGroupProfileClientListAllRevisionsResponse]{ + More: func(page ContainerGroupProfileClientListAllRevisionsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ContainerGroupProfileClientListAllRevisionsResponse) (ContainerGroupProfileClientListAllRevisionsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ContainerGroupProfileClient.NewListAllRevisionsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listAllRevisionsCreateRequest(ctx, resourceGroupName, containerGroupProfileName, options) + }, nil) + if err != nil { + return ContainerGroupProfileClientListAllRevisionsResponse{}, err + } + return client.listAllRevisionsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listAllRevisionsCreateRequest creates the ListAllRevisions request. +func (client *ContainerGroupProfileClient) listAllRevisionsCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfileClientListAllRevisionsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}/revisions" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllRevisionsHandleResponse handles the ListAllRevisions response. +func (client *ContainerGroupProfileClient) listAllRevisionsHandleResponse(resp *http.Response) (ContainerGroupProfileClientListAllRevisionsResponse, error) { + result := ContainerGroupProfileClientListAllRevisionsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfileListResult); err != nil { + return ContainerGroupProfileClientListAllRevisionsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofiles_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofiles_client.go new file mode 100644 index 000000000000..3df4a8b678ab --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroupprofiles_client.go @@ -0,0 +1,424 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerinstance + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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" +) + +// ContainerGroupProfilesClient contains the methods for the ContainerGroupProfiles group. +// Don't use this type directly, use NewContainerGroupProfilesClient() instead. +type ContainerGroupProfilesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewContainerGroupProfilesClient creates a new instance of ContainerGroupProfilesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewContainerGroupProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainerGroupProfilesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ContainerGroupProfilesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or update container group profiles with specified configurations. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - containerGroupProfile - The properties of the container group profile to be created or updated. +// - options - ContainerGroupProfilesClientCreateOrUpdateOptions contains the optional parameters for the ContainerGroupProfilesClient.CreateOrUpdate +// method. +func (client *ContainerGroupProfilesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerGroupProfileName string, containerGroupProfile ContainerGroupProfile, options *ContainerGroupProfilesClientCreateOrUpdateOptions) (ContainerGroupProfilesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ContainerGroupProfilesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, containerGroupProfileName, containerGroupProfile, options) + if err != nil { + return ContainerGroupProfilesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ContainerGroupProfilesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ContainerGroupProfilesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ContainerGroupProfilesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, containerGroupProfile ContainerGroupProfile, options *ContainerGroupProfilesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, containerGroupProfile); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ContainerGroupProfilesClient) createOrUpdateHandleResponse(resp *http.Response) (ContainerGroupProfilesClientCreateOrUpdateResponse, error) { + result := ContainerGroupProfilesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfile); err != nil { + return ContainerGroupProfilesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete the specified container group profile 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 an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - options - ContainerGroupProfilesClientDeleteOptions contains the optional parameters for the ContainerGroupProfilesClient.Delete +// method. +func (client *ContainerGroupProfilesClient) Delete(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfilesClientDeleteOptions) (ContainerGroupProfilesClientDeleteResponse, error) { + var err error + const operationName = "ContainerGroupProfilesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, containerGroupProfileName, options) + if err != nil { + return ContainerGroupProfilesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ContainerGroupProfilesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ContainerGroupProfilesClientDeleteResponse{}, err + } + return ContainerGroupProfilesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContainerGroupProfilesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfilesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the properties of the specified container group profile in the specified subscription and resource group. The +// operation returns the properties of container group profile including containers, +// image registry credentials, restart policy, IP address type, OS type, volumes, current revision number, etc. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - options - ContainerGroupProfilesClientGetOptions contains the optional parameters for the ContainerGroupProfilesClient.Get +// method. +func (client *ContainerGroupProfilesClient) Get(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfilesClientGetOptions) (ContainerGroupProfilesClientGetResponse, error) { + var err error + const operationName = "ContainerGroupProfilesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, containerGroupProfileName, options) + if err != nil { + return ContainerGroupProfilesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ContainerGroupProfilesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ContainerGroupProfilesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ContainerGroupProfilesClient) getCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *ContainerGroupProfilesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContainerGroupProfilesClient) getHandleResponse(resp *http.Response) (ContainerGroupProfilesClientGetResponse, error) { + result := ContainerGroupProfilesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfile); err != nil { + return ContainerGroupProfilesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get a list of container group profiles in the specified subscription. This operation returns properties +// of each container group profile including containers, image registry credentials, restart +// policy, IP address type, OS type,volumes,current revision number, etc. +// +// Generated from API version 2024-05-01-preview +// - options - ContainerGroupProfilesClientListOptions contains the optional parameters for the ContainerGroupProfilesClient.NewListPager +// method. +func (client *ContainerGroupProfilesClient) NewListPager(options *ContainerGroupProfilesClientListOptions) *runtime.Pager[ContainerGroupProfilesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ContainerGroupProfilesClientListResponse]{ + More: func(page ContainerGroupProfilesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ContainerGroupProfilesClientListResponse) (ContainerGroupProfilesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ContainerGroupProfilesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return ContainerGroupProfilesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ContainerGroupProfilesClient) listCreateRequest(ctx context.Context, options *ContainerGroupProfilesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroupProfiles" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ContainerGroupProfilesClient) listHandleResponse(resp *http.Response) (ContainerGroupProfilesClientListResponse, error) { + result := ContainerGroupProfilesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfileListResult); err != nil { + return ContainerGroupProfilesClientListResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Get a list of container group profiles in a specified subscription and resource group. This +// operation returns properties of each container group profile including containers, image registry +// credentials, restart policy, IP address type, OS type volumes, current revision number, etc. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ContainerGroupProfilesClientListByResourceGroupOptions contains the optional parameters for the ContainerGroupProfilesClient.NewListByResourceGroupPager +// method. +func (client *ContainerGroupProfilesClient) NewListByResourceGroupPager(resourceGroupName string, options *ContainerGroupProfilesClientListByResourceGroupOptions) *runtime.Pager[ContainerGroupProfilesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ContainerGroupProfilesClientListByResourceGroupResponse]{ + More: func(page ContainerGroupProfilesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ContainerGroupProfilesClientListByResourceGroupResponse) (ContainerGroupProfilesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ContainerGroupProfilesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ContainerGroupProfilesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ContainerGroupProfilesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ContainerGroupProfilesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ContainerGroupProfilesClient) listByResourceGroupHandleResponse(resp *http.Response) (ContainerGroupProfilesClientListByResourceGroupResponse, error) { + result := ContainerGroupProfilesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfileListResult); err != nil { + return ContainerGroupProfilesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// Patch - Patches container group profile with specified properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - containerGroupProfileName - The name of the container group profile. +// - properties - The container group profile properties that need to be updated. +// - options - ContainerGroupProfilesClientPatchOptions contains the optional parameters for the ContainerGroupProfilesClient.Patch +// method. +func (client *ContainerGroupProfilesClient) Patch(ctx context.Context, resourceGroupName string, containerGroupProfileName string, properties ContainerGroupProfilePatch, options *ContainerGroupProfilesClientPatchOptions) (ContainerGroupProfilesClientPatchResponse, error) { + var err error + const operationName = "ContainerGroupProfilesClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, containerGroupProfileName, properties, options) + if err != nil { + return ContainerGroupProfilesClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ContainerGroupProfilesClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ContainerGroupProfilesClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *ContainerGroupProfilesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, containerGroupProfileName string, properties ContainerGroupProfilePatch, options *ContainerGroupProfilesClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}" + 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 containerGroupProfileName == "" { + return nil, errors.New("parameter containerGroupProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerGroupProfileName}", url.PathEscape(containerGroupProfileName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *ContainerGroupProfilesClient) patchHandleResponse(resp *http.Response) (ContainerGroupProfilesClientPatchResponse, error) { + result := ContainerGroupProfilesClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerGroupProfile); err != nil { + return ContainerGroupProfilesClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go index b1f380a00bcc..e575ddddf561 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go @@ -28,8 +28,7 @@ type ContainerGroupsClient struct { } // NewContainerGroupsClient creates a new instance of ContainerGroupsClient with the specified values. -// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewContainerGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainerGroupsClient, error) { @@ -47,8 +46,8 @@ func NewContainerGroupsClient(subscriptionID string, credential azcore.TokenCred // BeginCreateOrUpdate - Create or update container groups with specified configurations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - containerGroup - The properties of the container group to be created or updated. // - options - ContainerGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the ContainerGroupsClient.BeginCreateOrUpdate @@ -73,7 +72,7 @@ func (client *ContainerGroupsClient) BeginCreateOrUpdate(ctx context.Context, re // CreateOrUpdate - Create or update container groups with specified configurations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview func (client *ContainerGroupsClient) createOrUpdate(ctx context.Context, resourceGroupName string, containerGroupName string, containerGroup ContainerGroup, options *ContainerGroupsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ContainerGroupsClient.BeginCreateOrUpdate" @@ -115,7 +114,7 @@ func (client *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, containerGroup); err != nil { @@ -128,8 +127,8 @@ func (client *ContainerGroupsClient) createOrUpdateCreateRequest(ctx context.Con // not delete other resources provided by the user, such as volumes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginDeleteOptions contains the optional parameters for the ContainerGroupsClient.BeginDelete // method. @@ -154,7 +153,7 @@ func (client *ContainerGroupsClient) BeginDelete(ctx context.Context, resourceGr // delete other resources provided by the user, such as volumes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview func (client *ContainerGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ContainerGroupsClient.BeginDelete" @@ -196,7 +195,7 @@ func (client *ContainerGroupsClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -207,8 +206,8 @@ func (client *ContainerGroupsClient) deleteCreateRequest(ctx context.Context, re // credentials, restart policy, IP address type, OS type, state, and volumes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientGetOptions contains the optional parameters for the ContainerGroupsClient.Get method. func (client *ContainerGroupsClient) Get(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientGetOptions) (ContainerGroupsClientGetResponse, error) { @@ -253,7 +252,7 @@ func (client *ContainerGroupsClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -272,8 +271,8 @@ func (client *ContainerGroupsClient) getHandleResponse(resp *http.Response) (Con // control of network setting and configuration. For container groups, this will always be an empty list. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientGetOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the // ContainerGroupsClient.GetOutboundNetworkDependenciesEndpoints method. @@ -319,7 +318,7 @@ func (client *ContainerGroupsClient) getOutboundNetworkDependenciesEndpointsCrea return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +337,7 @@ func (client *ContainerGroupsClient) getOutboundNetworkDependenciesEndpointsHand // container group including containers, image registry credentials, restart policy, IP address // type, OS type, state, and volumes. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview // - options - ContainerGroupsClientListOptions contains the optional parameters for the ContainerGroupsClient.NewListPager // method. func (client *ContainerGroupsClient) NewListPager(options *ContainerGroupsClientListOptions) *runtime.Pager[ContainerGroupsClientListResponse] { @@ -376,7 +375,7 @@ func (client *ContainerGroupsClient) listCreateRequest(ctx context.Context, opti return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -395,8 +394,8 @@ func (client *ContainerGroupsClient) listHandleResponse(resp *http.Response) (Co // returns properties of each container group including containers, image registry credentials, restart // policy, IP address type, OS type, state, and volumes. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ContainerGroupsClientListByResourceGroupOptions contains the optional parameters for the ContainerGroupsClient.NewListByResourceGroupPager // method. func (client *ContainerGroupsClient) NewListByResourceGroupPager(resourceGroupName string, options *ContainerGroupsClientListByResourceGroupOptions) *runtime.Pager[ContainerGroupsClientListByResourceGroupResponse] { @@ -438,7 +437,7 @@ func (client *ContainerGroupsClient) listByResourceGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -457,8 +456,8 @@ func (client *ContainerGroupsClient) listByResourceGroupHandleResponse(resp *htt // downloaded. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginRestartOptions contains the optional parameters for the ContainerGroupsClient.BeginRestart // method. @@ -482,7 +481,7 @@ func (client *ContainerGroupsClient) BeginRestart(ctx context.Context, resourceG // 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 an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview func (client *ContainerGroupsClient) restart(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginRestartOptions) (*http.Response, error) { var err error const operationName = "ContainerGroupsClient.BeginRestart" @@ -524,7 +523,7 @@ func (client *ContainerGroupsClient) restartCreateRequest(ctx context.Context, r return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -533,8 +532,8 @@ func (client *ContainerGroupsClient) restartCreateRequest(ctx context.Context, r // BeginStart - Starts all containers in a container group. Compute resources will be allocated and billing will start. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginStartOptions contains the optional parameters for the ContainerGroupsClient.BeginStart // method. @@ -558,7 +557,7 @@ func (client *ContainerGroupsClient) BeginStart(ctx context.Context, resourceGro // Start - Starts all containers in a container group. Compute resources will be allocated and billing will start. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview func (client *ContainerGroupsClient) start(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientBeginStartOptions) (*http.Response, error) { var err error const operationName = "ContainerGroupsClient.BeginStart" @@ -600,7 +599,7 @@ func (client *ContainerGroupsClient) startCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -609,8 +608,8 @@ func (client *ContainerGroupsClient) startCreateRequest(ctx context.Context, res // Stop - Stops all containers in a container group. Compute resources will be deallocated and billing will stop. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientStopOptions contains the optional parameters for the ContainerGroupsClient.Stop method. func (client *ContainerGroupsClient) Stop(ctx context.Context, resourceGroupName string, containerGroupName string, options *ContainerGroupsClientStopOptions) (ContainerGroupsClientStopResponse, error) { @@ -654,7 +653,7 @@ func (client *ContainerGroupsClient) stopCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -663,8 +662,8 @@ func (client *ContainerGroupsClient) stopCreateRequest(ctx context.Context, reso // Update - Updates container group tags with specified values. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - resource - The container group resource with just the tags to be updated. // - options - ContainerGroupsClientUpdateOptions contains the optional parameters for the ContainerGroupsClient.Update method. @@ -710,7 +709,7 @@ func (client *ContainerGroupsClient) updateCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, resource); err != nil { diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client_example_test.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client_example_test.go deleted file mode 100644 index f9d9fd1559f1..000000000000 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client_example_test.go +++ /dev/null @@ -1,1476 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armcontainerinstance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsList.json -func ExampleContainerGroupsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewContainerGroupsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ContainerGroupListResult = armcontainerinstance.ContainerGroupListResult{ - // Value: []*armcontainerinstance.ContainerGroup{ - // { - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // InstanceView: &armcontainerinstance.ContainerPropertiesInstanceView{ - // CurrentState: &armcontainerinstance.ContainerState{ - // DetailStatus: to.Ptr(""), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-17T17:27:21.000Z"); return t}()), - // State: to.Ptr("Running"), - // }, - // Events: []*armcontainerinstance.Event{ - // }, - // RestartCount: to.Ptr[int32](0), - // }, - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // { - // Server: to.Ptr("azcloudconsoleregistry.azurecr.io"), - // Username: to.Ptr("azcloudconsoleregistry"), - // }}, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ReadOnly: to.Ptr(false), - // ShareName: to.Ptr("share1"), - // StorageAccountName: to.Ptr("storage1"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Zones: []*string{ - // to.Ptr("1")}, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsListByResourceGroup.json -func ExampleContainerGroupsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewContainerGroupsClient().NewListByResourceGroupPager("demo", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ContainerGroupListResult = armcontainerinstance.ContainerGroupListResult{ - // Value: []*armcontainerinstance.ContainerGroup{ - // { - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // { - // Server: to.Ptr("azcloudconsoleregistry.azurecr.io"), - // Username: to.Ptr("azcloudconsoleregistry"), - // }}, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ReadOnly: to.Ptr(false), - // ShareName: to.Ptr("share1"), - // StorageAccountName: to.Ptr("storage1"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Zones: []*string{ - // to.Ptr("1")}, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGetPriority.json -func ExampleContainerGroupsClient_Get_containerGroupsGetWithPriority() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainerGroupsClient().Get(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("test-container-001"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // to.Ptr("/bin/sh"), - // to.Ptr("-c"), - // to.Ptr("sleep 10")}, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("alpine:latest"), - // InstanceView: &armcontainerinstance.ContainerPropertiesInstanceView{ - // CurrentState: &armcontainerinstance.ContainerState{ - // DetailStatus: to.Ptr("Completed"), - // ExitCode: to.Ptr[int32](0), - // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:33:55.565Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:33:44.217Z"); return t}()), - // State: to.Ptr("Terminated"), - // }, - // Events: []*armcontainerinstance.Event{ - // { - // Name: to.Ptr("Pulling"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](2), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:28:22.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:32:09.000Z"); return t}()), - // Message: to.Ptr("pulling image \"alpine@sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870\""), - // }, - // { - // Name: to.Ptr("Pulled"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](2), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:32:08.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:32:38.000Z"); return t}()), - // Message: to.Ptr("Successfully pulled image \"alpine@sha256:1304f174557314a7ed9eddb4eab12fed12cb0cd9809e4c28f29af86979a3c870\""), - // }, - // { - // Name: to.Ptr("Started"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](1), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:33:44.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-11T19:33:44.000Z"); return t}()), - // Message: to.Ptr("Started container"), - // }}, - // RestartCount: to.Ptr[int32](0), - // }, - // Ports: []*armcontainerinstance.ContainerPort{ - // }, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1), - // }, - // }, - // }, - // }}, - // InitContainers: []*armcontainerinstance.InitContainerDefinition{ - // }, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // }, - // State: to.Ptr("Succeeded"), - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // Priority: to.Ptr(armcontainerinstance.ContainerGroupPrioritySpot), - // ProvisioningState: to.Ptr("Succeeded"), - // RestartPolicy: to.Ptr(armcontainerinstance.ContainerGroupRestartPolicyNever), - // SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard), - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subId/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("eastus"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGet_Failed.json -func ExampleContainerGroupsClient_Get_containerGroupsGetFailed() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainerGroupsClient().Get(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // InstanceView: &armcontainerinstance.ContainerPropertiesInstanceView{ - // CurrentState: &armcontainerinstance.ContainerState{ - // DetailStatus: to.Ptr(""), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-08T00:09:10.000Z"); return t}()), - // State: to.Ptr("Waiting"), - // }, - // Events: []*armcontainerinstance.Event{ - // { - // Name: to.Ptr("Pulling"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](1), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-08T00:09:01.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-08T00:09:01.000Z"); return t}()), - // Message: to.Ptr("pulling image \"nginx\""), - // }, - // { - // Name: to.Ptr("Pulled"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](1), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-08T00:09:10.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-08T00:09:10.000Z"); return t}()), - // Message: to.Ptr("Successfully pulled image \"nginx\""), - // }}, - // RestartCount: to.Ptr[int32](0), - // }, - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // { - // Server: to.Ptr("azcloudconsoleregistry.azurecr.io"), - // Username: to.Ptr("azcloudconsoleregistry"), - // }}, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // { - // Name: to.Ptr("FailedMount"), - // Type: to.Ptr("Normal"), - // Count: to.Ptr[int32](1), - // FirstTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-08T00:19:10.000Z"); return t}()), - // LastTimestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-08T00:19:10.000Z"); return t}()), - // Message: to.Ptr("Output: mount error(2): Permission denied"), - // }}, - // State: to.Ptr("Pending"), - // }, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ReadOnly: to.Ptr(false), - // ShareName: to.Ptr("share1"), - // StorageAccountName: to.Ptr("storage1"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsGet_Succeeded.json -func ExampleContainerGroupsClient_Get_containerGroupsGetSucceeded() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainerGroupsClient().Get(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // { - // Server: to.Ptr("azcloudconsoleregistry.azurecr.io"), - // Username: to.Ptr("azcloudconsoleregistry"), - // }}, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ReadOnly: to.Ptr(false), - // ShareName: to.Ptr("share1"), - // StorageAccountName: to.Ptr("storage1"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Zones: []*string{ - // to.Ptr("1")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupCreateConfidential.json -func ExampleContainerGroupsClient_BeginCreateOrUpdate_confidentialContainerGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{ - Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - ConfidentialComputeProperties: &armcontainerinstance.ConfidentialComputeProperties{ - CcePolicy: to.Ptr("eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"), - }, - Containers: []*armcontainerinstance.Container{ - { - Name: to.Ptr("accdemo"), - Properties: &armcontainerinstance.ContainerProperties{ - Command: []*string{}, - EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{}, - Image: to.Ptr("confiimage"), - Ports: []*armcontainerinstance.ContainerPort{ - { - Port: to.Ptr[int32](8000), - }}, - Resources: &armcontainerinstance.ResourceRequirements{ - Requests: &armcontainerinstance.ResourceRequests{ - CPU: to.Ptr[float64](1), - MemoryInGB: to.Ptr[float64](1.5), - }, - }, - SecurityContext: &armcontainerinstance.SecurityContextDefinition{ - Capabilities: &armcontainerinstance.SecurityContextCapabilitiesDefinition{ - Add: []*string{ - to.Ptr("CAP_NET_ADMIN")}, - }, - Privileged: to.Ptr(false), - }, - }, - }}, - ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{}, - IPAddress: &armcontainerinstance.IPAddress{ - Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - Ports: []*armcontainerinstance.Port{ - { - Port: to.Ptr[int32](8000), - Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - }}, - }, - OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUConfidential), - }, - Location: to.Ptr("westeurope"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // ConfidentialComputeProperties: &armcontainerinstance.ConfidentialComputeProperties{ - // CcePolicy: to.Ptr("eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"), - // }, - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("accdemo"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("confiimage"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](8000), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // SecurityContext: &armcontainerinstance.SecurityContextDefinition{ - // Capabilities: &armcontainerinstance.SecurityContextCapabilitiesDefinition{ - // Add: []*string{ - // to.Ptr("CAP_NET_ADMIN")}, - // }, - // Privileged: to.Ptr(false), - // }, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // }, - // InitContainers: []*armcontainerinstance.InitContainerDefinition{ - // }, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // }, - // State: to.Ptr("Running"), - // }, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](8000), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUConfidential), - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("westeurope"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupExtensions.json -func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupCreateWithExtensions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{ - Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - Containers: []*armcontainerinstance.Container{ - { - Name: to.Ptr("demo1"), - Properties: &armcontainerinstance.ContainerProperties{ - Command: []*string{}, - EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{}, - Image: to.Ptr("nginx"), - Ports: []*armcontainerinstance.ContainerPort{ - { - Port: to.Ptr[int32](80), - }}, - Resources: &armcontainerinstance.ResourceRequirements{ - Requests: &armcontainerinstance.ResourceRequests{ - CPU: to.Ptr[float64](1), - MemoryInGB: to.Ptr[float64](1.5), - }, - }, - }, - }}, - ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{}, - IPAddress: &armcontainerinstance.IPAddress{ - Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePrivate), - Ports: []*armcontainerinstance.Port{ - { - Port: to.Ptr[int32](80), - Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - }}, - }, - OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{ - { - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet"), - }}, - Extensions: []*armcontainerinstance.DeploymentExtensionSpec{ - { - Name: to.Ptr("kube-proxy"), - Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{ - ExtensionType: to.Ptr("kube-proxy"), - ProtectedSettings: map[string]any{ - "kubeConfig": "", - }, - Settings: map[string]any{ - "clusterCidr": "10.240.0.0/16", - "kubeVersion": "v1.9.10", - }, - Version: to.Ptr("1.0"), - }, - }, - { - Name: to.Ptr("vk-realtime-metrics"), - Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{ - ExtensionType: to.Ptr("realtime-metrics"), - Version: to.Ptr("1.0"), - }, - }}, - }, - Location: to.Ptr("eastus2"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // }, - // InitContainers: []*armcontainerinstance.InitContainerDefinition{ - // }, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // }, - // State: to.Ptr("Pending"), - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard), - // SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet"), - // }}, - // Extensions: []*armcontainerinstance.DeploymentExtensionSpec{ - // { - // Name: to.Ptr("kube-proxy"), - // Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{ - // ExtensionType: to.Ptr("kube-proxy"), - // Settings: map[string]any{ - // "clusterCidr": "10.240.0.0/16", - // "kubeVersion": "v1.9.10", - // }, - // Version: to.Ptr("1.0"), - // }, - // }, - // { - // Name: to.Ptr("vk-realtime-metrics"), - // Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{ - // ExtensionType: to.Ptr("realtime-metrics"), - // Version: to.Ptr("1.0"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("eastus2"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupEncryptionProperties.json -func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupWithEncryptionProperties() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{ - Identity: &armcontainerinstance.ContainerGroupIdentity{ - Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {}, - }, - }, - Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - Containers: []*armcontainerinstance.Container{ - { - Name: to.Ptr("demo1"), - Properties: &armcontainerinstance.ContainerProperties{ - Command: []*string{}, - EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{}, - Image: to.Ptr("nginx"), - Ports: []*armcontainerinstance.ContainerPort{ - { - Port: to.Ptr[int32](80), - }}, - Resources: &armcontainerinstance.ResourceRequirements{ - Requests: &armcontainerinstance.ResourceRequests{ - CPU: to.Ptr[float64](1), - MemoryInGB: to.Ptr[float64](1.5), - }, - }, - }, - }}, - EncryptionProperties: &armcontainerinstance.EncryptionProperties{ - Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity"), - KeyName: to.Ptr("test-key"), - KeyVersion: to.Ptr(""), - VaultBaseURL: to.Ptr("https://testkeyvault.vault.azure.net"), - }, - ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{}, - IPAddress: &armcontainerinstance.IPAddress{ - Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - Ports: []*armcontainerinstance.Port{ - { - Port: to.Ptr[int32](80), - Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - }}, - }, - OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - }, - Location: to.Ptr("eastus2"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Identity: &armcontainerinstance.ContainerGroupIdentity{ - // Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned), - // TenantID: to.Ptr(""), - // UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": &armcontainerinstance.UserAssignedIdentities{ - // ClientID: to.Ptr(""), - // PrincipalID: to.Ptr(""), - // }, - // }, - // }, - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // }, - // }}, - // EncryptionProperties: &armcontainerinstance.EncryptionProperties{ - // Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity"), - // KeyName: to.Ptr("test-key"), - // KeyVersion: to.Ptr(""), - // VaultBaseURL: to.Ptr("https://testkeyvault.vault.azure.net/"), - // }, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // }, - // InitContainers: []*armcontainerinstance.InitContainerDefinition{ - // }, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // }, - // State: to.Ptr("Pending"), - // }, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard), - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("eastus2"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsCreateOrUpdate.json -func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{ - Identity: &armcontainerinstance.ContainerGroupIdentity{ - Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}, - }, - }, - Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - Containers: []*armcontainerinstance.Container{ - { - Name: to.Ptr("demo1"), - Properties: &armcontainerinstance.ContainerProperties{ - Command: []*string{}, - EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{}, - Image: to.Ptr("nginx"), - Ports: []*armcontainerinstance.ContainerPort{ - { - Port: to.Ptr[int32](80), - }}, - Resources: &armcontainerinstance.ResourceRequirements{ - Requests: &armcontainerinstance.ResourceRequests{ - CPU: to.Ptr[float64](1), - Gpu: &armcontainerinstance.GpuResource{ - Count: to.Ptr[int32](1), - SKU: to.Ptr(armcontainerinstance.GpuSKUK80), - }, - MemoryInGB: to.Ptr[float64](1.5), - }, - }, - VolumeMounts: []*armcontainerinstance.VolumeMount{ - { - Name: to.Ptr("volume1"), - MountPath: to.Ptr("/mnt/volume1"), - ReadOnly: to.Ptr(false), - }, - { - Name: to.Ptr("volume2"), - MountPath: to.Ptr("/mnt/volume2"), - ReadOnly: to.Ptr(false), - }, - { - Name: to.Ptr("volume3"), - MountPath: to.Ptr("/mnt/volume3"), - ReadOnly: to.Ptr(true), - }}, - }, - }}, - Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{ - LogAnalytics: &armcontainerinstance.LogAnalytics{ - LogType: to.Ptr(armcontainerinstance.LogAnalyticsLogTypeContainerInsights), - Metadata: map[string]*string{ - "test-key": to.Ptr("test-metadata-value"), - }, - WorkspaceID: to.Ptr("workspaceid"), - WorkspaceKey: to.Ptr("workspaceKey"), - WorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"), - }, - }, - DNSConfig: &armcontainerinstance.DNSConfiguration{ - NameServers: []*string{ - to.Ptr("1.1.1.1")}, - Options: to.Ptr("ndots:2"), - SearchDomains: to.Ptr("cluster.local svc.cluster.local"), - }, - ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{}, - IPAddress: &armcontainerinstance.IPAddress{ - Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure), - DNSNameLabel: to.Ptr("dnsnamelabel1"), - Ports: []*armcontainerinstance.Port{ - { - Port: to.Ptr[int32](80), - Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - }}, - }, - OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{ - { - ID: to.Ptr("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"), - }}, - Volumes: []*armcontainerinstance.Volume{ - { - Name: to.Ptr("volume1"), - AzureFile: &armcontainerinstance.AzureFileVolume{ - ShareName: to.Ptr("shareName"), - StorageAccountKey: to.Ptr("accountKey"), - StorageAccountName: to.Ptr("accountName"), - }, - }, - { - Name: to.Ptr("volume2"), - EmptyDir: map[string]any{}, - }, - { - Name: to.Ptr("volume3"), - Secret: map[string]*string{ - "secretKey1": to.Ptr("SecretValue1InBase64"), - "secretKey2": to.Ptr("SecretValue2InBase64"), - }, - }}, - }, - Location: to.Ptr("west us"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // Gpu: &armcontainerinstance.GpuResource{ - // Count: to.Ptr[int32](1), - // SKU: to.Ptr(armcontainerinstance.GpuSKUK80), - // }, - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }, - // { - // Name: to.Ptr("volume2"), - // MountPath: to.Ptr("/mnt/volume2"), - // ReadOnly: to.Ptr(false), - // }, - // { - // Name: to.Ptr("volume3"), - // MountPath: to.Ptr("/mnt/volume3"), - // ReadOnly: to.Ptr(true), - // }}, - // }, - // }}, - // Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{ - // LogAnalytics: &armcontainerinstance.LogAnalytics{ - // WorkspaceID: to.Ptr("workspaceid"), - // }, - // }, - // DNSConfig: &armcontainerinstance.DNSConfiguration{ - // NameServers: []*string{ - // to.Ptr("1.1.1.1")}, - // Options: to.Ptr("ndots:2"), - // SearchDomains: to.Ptr("cluster.local svc.cluster.local"), - // }, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // }, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure), - // DNSNameLabel: to.Ptr("dnsnamelabel1"), - // Fqdn: to.Ptr("dnsnamelabel1.azure-container.io"), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ShareName: to.Ptr("shareName"), - // StorageAccountName: to.Ptr("accountName"), - // }, - // }, - // { - // Name: to.Ptr("volume2"), - // EmptyDir: map[string]any{ - // }, - // }, - // { - // Name: to.Ptr("volume3"), - // Secret: map[string]*string{ - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Zones: []*string{ - // to.Ptr("1")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsCreatePriority.json -func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateWithPriority() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{ - Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - Containers: []*armcontainerinstance.Container{ - { - Name: to.Ptr("test-container-001"), - Properties: &armcontainerinstance.ContainerProperties{ - Command: []*string{ - to.Ptr("/bin/sh"), - to.Ptr("-c"), - to.Ptr("sleep 10")}, - Image: to.Ptr("alpine:latest"), - Resources: &armcontainerinstance.ResourceRequirements{ - Requests: &armcontainerinstance.ResourceRequests{ - CPU: to.Ptr[float64](1), - MemoryInGB: to.Ptr[float64](1), - }, - }, - }, - }}, - OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - Priority: to.Ptr(armcontainerinstance.ContainerGroupPrioritySpot), - RestartPolicy: to.Ptr(armcontainerinstance.ContainerGroupRestartPolicyNever), - SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard), - }, - Location: to.Ptr("eastus"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("test-container-001"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // to.Ptr("/bin/sh"), - // to.Ptr("-c"), - // to.Ptr("sleep 10")}, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("alpine:latest"), - // Ports: []*armcontainerinstance.ContainerPort{ - // }, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1), - // }, - // }, - // }, - // }}, - // InitContainers: []*armcontainerinstance.InitContainerDefinition{ - // }, - // InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{ - // Events: []*armcontainerinstance.Event{ - // }, - // State: to.Ptr("Succeeded"), - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // Priority: to.Ptr(armcontainerinstance.ContainerGroupPrioritySpot), - // ProvisioningState: to.Ptr("Succeeded"), - // RestartPolicy: to.Ptr(armcontainerinstance.ContainerGroupRestartPolicyNever), - // SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard), - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subId/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("eastus"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsUpdate.json -func ExampleContainerGroupsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainerGroupsClient().Update(ctx, "demoResource", "demo1", armcontainerinstance.Resource{ - Tags: map[string]*string{ - "tag1key": to.Ptr("tag1Value"), - "tag2key": to.Ptr("tag2Value"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }, - // { - // Name: to.Ptr("volume2"), - // MountPath: to.Ptr("/mnt/volume2"), - // ReadOnly: to.Ptr(false), - // }, - // { - // Name: to.Ptr("volume3"), - // MountPath: to.Ptr("/mnt/volume3"), - // ReadOnly: to.Ptr(true), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // }, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // DNSNameLabel: to.Ptr("dnsnamelabel1"), - // Fqdn: to.Ptr("dnsnamelabel1.azure-container.io"), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ShareName: to.Ptr("shareName"), - // StorageAccountName: to.Ptr("accountName"), - // }, - // }, - // { - // Name: to.Ptr("volume2"), - // EmptyDir: map[string]any{ - // }, - // }, - // { - // Name: to.Ptr("volume3"), - // Secret: map[string]*string{ - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demoResource/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Tags: map[string]*string{ - // "tag1key": to.Ptr("tag1Value"), - // "tag2key": to.Ptr("tag2Value"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsDelete.json -func ExampleContainerGroupsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginDelete(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerGroup = armcontainerinstance.ContainerGroup{ - // Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{ - // Containers: []*armcontainerinstance.Container{ - // { - // Name: to.Ptr("demo1"), - // Properties: &armcontainerinstance.ContainerProperties{ - // Command: []*string{ - // }, - // EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{ - // }, - // Image: to.Ptr("nginx"), - // Ports: []*armcontainerinstance.ContainerPort{ - // { - // Port: to.Ptr[int32](80), - // }}, - // Resources: &armcontainerinstance.ResourceRequirements{ - // Requests: &armcontainerinstance.ResourceRequests{ - // CPU: to.Ptr[float64](1), - // MemoryInGB: to.Ptr[float64](1.5), - // }, - // }, - // VolumeMounts: []*armcontainerinstance.VolumeMount{ - // { - // Name: to.Ptr("volume1"), - // MountPath: to.Ptr("/mnt/volume1"), - // ReadOnly: to.Ptr(false), - // }}, - // }, - // }}, - // ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{ - // { - // Server: to.Ptr("azcloudconsoleregistry.azurecr.io"), - // Username: to.Ptr("azcloudconsoleregistry"), - // }}, - // IPAddress: &armcontainerinstance.IPAddress{ - // Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic), - // IP: to.Ptr("10.0.0.1"), - // Ports: []*armcontainerinstance.Port{ - // { - // Port: to.Ptr[int32](80), - // Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP), - // }}, - // }, - // OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux), - // ProvisioningState: to.Ptr("Succeeded"), - // Volumes: []*armcontainerinstance.Volume{ - // { - // Name: to.Ptr("volume1"), - // AzureFile: &armcontainerinstance.AzureFileVolume{ - // ReadOnly: to.Ptr(false), - // ShareName: to.Ptr("share1"), - // StorageAccountName: to.Ptr("storage1"), - // }, - // }}, - // }, - // Name: to.Ptr("demo1"), - // Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"), - // Location: to.Ptr("WestUs"), - // Zones: []*string{ - // to.Ptr("1")}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsRestart.json -func ExampleContainerGroupsClient_BeginRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginRestart(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsStop.json -func ExampleContainerGroupsClient_Stop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewContainerGroupsClient().Stop(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupsStart.json -func ExampleContainerGroupsClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewContainerGroupsClient().BeginStart(ctx, "demo", "demo1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go index a9563967f5cb..36957b47fbee 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go @@ -29,8 +29,7 @@ type ContainersClient struct { } // NewContainersClient creates a new instance of ContainersClient with the specified values. -// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewContainersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainersClient, error) { @@ -48,8 +47,8 @@ func NewContainersClient(subscriptionID string, credential azcore.TokenCredentia // 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 an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. // - options - ContainersClientAttachOptions contains the optional parameters for the ContainersClient.Attach method. @@ -99,7 +98,7 @@ func (client *ContainersClient) attachCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -117,8 +116,8 @@ func (client *ContainersClient) attachHandleResponse(resp *http.Response) (Conta // ExecuteCommand - Executes a command for a specific container instance in a specified resource group and container group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. // - containerExecRequest - The request for the exec command. @@ -170,7 +169,7 @@ func (client *ContainersClient) executeCommandCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, containerExecRequest); err != nil { @@ -191,8 +190,8 @@ func (client *ContainersClient) executeCommandHandleResponse(resp *http.Response // ListLogs - Get the logs for a specified container instance in a specified resource group and container group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. // - options - ContainersClientListLogsOptions contains the optional parameters for the ContainersClient.ListLogs method. @@ -242,7 +241,7 @@ func (client *ContainersClient) listLogsCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") if options != nil && options.Tail != nil { reqQP.Set("tail", strconv.FormatInt(int64(*options.Tail), 10)) } diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client_example_test.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client_example_test.go deleted file mode 100644 index 3f7131c9ec37..000000000000 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client_example_test.go +++ /dev/null @@ -1,98 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armcontainerinstance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerListLogs.json -func ExampleContainersClient_ListLogs() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainersClient().ListLogs(ctx, "demo", "demo1", "container1", &armcontainerinstance.ContainersClientListLogsOptions{Tail: to.Ptr[int32](10), - Timestamps: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Logs = armcontainerinstance.Logs{ - // Content: to.Ptr("log content"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerExec.json -func ExampleContainersClient_ExecuteCommand() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainersClient().ExecuteCommand(ctx, "demo", "demo1", "container1", armcontainerinstance.ContainerExecRequest{ - Command: to.Ptr("/bin/bash"), - TerminalSize: &armcontainerinstance.ContainerExecRequestTerminalSize{ - Cols: to.Ptr[int32](12), - Rows: to.Ptr[int32](12), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerExecResponse = armcontainerinstance.ContainerExecResponse{ - // Password: to.Ptr("password"), - // WebSocketURI: to.Ptr("wss://web-socket-uri"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerAttach.json -func ExampleContainersClient_Attach() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewContainersClient().Attach(ctx, "demo", "demo1", "container1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ContainerAttachResponse = armcontainerinstance.ContainerAttachResponse{ - // Password: to.Ptr("password"), - // WebSocketURI: to.Ptr("wss://web-socket-uri"), - // } -} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofile_server.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofile_server.go new file mode 100644 index 000000000000..f91e2c33316c --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofile_server.go @@ -0,0 +1,156 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" + "net/http" + "net/url" + "regexp" +) + +// ContainerGroupProfileServer is a fake server for instances of the armcontainerinstance.ContainerGroupProfileClient type. +type ContainerGroupProfileServer struct { + // GetByRevisionNumber is the fake for method ContainerGroupProfileClient.GetByRevisionNumber + // HTTP status codes to indicate success: http.StatusOK + GetByRevisionNumber func(ctx context.Context, resourceGroupName string, containerGroupProfileName string, revisionNumber string, options *armcontainerinstance.ContainerGroupProfileClientGetByRevisionNumberOptions) (resp azfake.Responder[armcontainerinstance.ContainerGroupProfileClientGetByRevisionNumberResponse], errResp azfake.ErrorResponder) + + // NewListAllRevisionsPager is the fake for method ContainerGroupProfileClient.NewListAllRevisionsPager + // HTTP status codes to indicate success: http.StatusOK + NewListAllRevisionsPager func(resourceGroupName string, containerGroupProfileName string, options *armcontainerinstance.ContainerGroupProfileClientListAllRevisionsOptions) (resp azfake.PagerResponder[armcontainerinstance.ContainerGroupProfileClientListAllRevisionsResponse]) +} + +// NewContainerGroupProfileServerTransport creates a new instance of ContainerGroupProfileServerTransport with the provided implementation. +// The returned ContainerGroupProfileServerTransport instance is connected to an instance of armcontainerinstance.ContainerGroupProfileClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewContainerGroupProfileServerTransport(srv *ContainerGroupProfileServer) *ContainerGroupProfileServerTransport { + return &ContainerGroupProfileServerTransport{ + srv: srv, + newListAllRevisionsPager: newTracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfileClientListAllRevisionsResponse]](), + } +} + +// ContainerGroupProfileServerTransport connects instances of armcontainerinstance.ContainerGroupProfileClient to instances of ContainerGroupProfileServer. +// Don't use this type directly, use NewContainerGroupProfileServerTransport instead. +type ContainerGroupProfileServerTransport struct { + srv *ContainerGroupProfileServer + newListAllRevisionsPager *tracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfileClientListAllRevisionsResponse]] +} + +// Do implements the policy.Transporter interface for ContainerGroupProfileServerTransport. +func (c *ContainerGroupProfileServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ContainerGroupProfileClient.GetByRevisionNumber": + resp, err = c.dispatchGetByRevisionNumber(req) + case "ContainerGroupProfileClient.NewListAllRevisionsPager": + resp, err = c.dispatchNewListAllRevisionsPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ContainerGroupProfileServerTransport) dispatchGetByRevisionNumber(req *http.Request) (*http.Response, error) { + if c.srv.GetByRevisionNumber == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByRevisionNumber not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revisions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + revisionNumberParam, err := url.PathUnescape(matches[regex.SubexpIndex("revisionNumber")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.GetByRevisionNumber(req.Context(), resourceGroupNameParam, containerGroupProfileNameParam, revisionNumberParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ContainerGroupProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ContainerGroupProfileServerTransport) dispatchNewListAllRevisionsPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListAllRevisionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListAllRevisionsPager not implemented")} + } + newListAllRevisionsPager := c.newListAllRevisionsPager.get(req) + if newListAllRevisionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revisions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListAllRevisionsPager(resourceGroupNameParam, containerGroupProfileNameParam, nil) + newListAllRevisionsPager = &resp + c.newListAllRevisionsPager.add(req, newListAllRevisionsPager) + server.PagerResponderInjectNextLinks(newListAllRevisionsPager, req, func(page *armcontainerinstance.ContainerGroupProfileClientListAllRevisionsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListAllRevisionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListAllRevisionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListAllRevisionsPager) { + c.newListAllRevisionsPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofiles_server.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofiles_server.go new file mode 100644 index 000000000000..871d95dfd860 --- /dev/null +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/containergroupprofiles_server.go @@ -0,0 +1,314 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" + "net/http" + "net/url" + "regexp" +) + +// ContainerGroupProfilesServer is a fake server for instances of the armcontainerinstance.ContainerGroupProfilesClient type. +type ContainerGroupProfilesServer struct { + // CreateOrUpdate is the fake for method ContainerGroupProfilesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, containerGroupProfileName string, containerGroupProfile armcontainerinstance.ContainerGroupProfile, options *armcontainerinstance.ContainerGroupProfilesClientCreateOrUpdateOptions) (resp azfake.Responder[armcontainerinstance.ContainerGroupProfilesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ContainerGroupProfilesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *armcontainerinstance.ContainerGroupProfilesClientDeleteOptions) (resp azfake.Responder[armcontainerinstance.ContainerGroupProfilesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ContainerGroupProfilesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, containerGroupProfileName string, options *armcontainerinstance.ContainerGroupProfilesClientGetOptions) (resp azfake.Responder[armcontainerinstance.ContainerGroupProfilesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ContainerGroupProfilesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armcontainerinstance.ContainerGroupProfilesClientListOptions) (resp azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListResponse]) + + // NewListByResourceGroupPager is the fake for method ContainerGroupProfilesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armcontainerinstance.ContainerGroupProfilesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListByResourceGroupResponse]) + + // Patch is the fake for method ContainerGroupProfilesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, containerGroupProfileName string, properties armcontainerinstance.ContainerGroupProfilePatch, options *armcontainerinstance.ContainerGroupProfilesClientPatchOptions) (resp azfake.Responder[armcontainerinstance.ContainerGroupProfilesClientPatchResponse], errResp azfake.ErrorResponder) +} + +// NewContainerGroupProfilesServerTransport creates a new instance of ContainerGroupProfilesServerTransport with the provided implementation. +// The returned ContainerGroupProfilesServerTransport instance is connected to an instance of armcontainerinstance.ContainerGroupProfilesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewContainerGroupProfilesServerTransport(srv *ContainerGroupProfilesServer) *ContainerGroupProfilesServerTransport { + return &ContainerGroupProfilesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListByResourceGroupResponse]](), + } +} + +// ContainerGroupProfilesServerTransport connects instances of armcontainerinstance.ContainerGroupProfilesClient to instances of ContainerGroupProfilesServer. +// Don't use this type directly, use NewContainerGroupProfilesServerTransport instead. +type ContainerGroupProfilesServerTransport struct { + srv *ContainerGroupProfilesServer + newListPager *tracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armcontainerinstance.ContainerGroupProfilesClientListByResourceGroupResponse]] +} + +// Do implements the policy.Transporter interface for ContainerGroupProfilesServerTransport. +func (c *ContainerGroupProfilesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ContainerGroupProfilesClient.CreateOrUpdate": + resp, err = c.dispatchCreateOrUpdate(req) + case "ContainerGroupProfilesClient.Delete": + resp, err = c.dispatchDelete(req) + case "ContainerGroupProfilesClient.Get": + resp, err = c.dispatchGet(req) + case "ContainerGroupProfilesClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "ContainerGroupProfilesClient.NewListByResourceGroupPager": + resp, err = c.dispatchNewListByResourceGroupPager(req) + case "ContainerGroupProfilesClient.Patch": + resp, err = c.dispatchPatch(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerinstance.ContainerGroupProfile](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, containerGroupProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ContainerGroupProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if c.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, containerGroupProfileNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, containerGroupProfileNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ContainerGroupProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListPager(nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerinstance.ContainerGroupProfilesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armcontainerinstance.ContainerGroupProfilesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *ContainerGroupProfilesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if c.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerInstance/containerGroupProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerinstance.ContainerGroupProfilePatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + containerGroupProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("containerGroupProfileName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Patch(req.Context(), resourceGroupNameParam, containerGroupProfileNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ContainerGroupProfile, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/server_factory.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/server_factory.go index 6fd7a42d7c13..d5c86f50643d 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/server_factory.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/server_factory.go @@ -19,6 +19,8 @@ import ( // ServerFactory is a fake server for instances of the armcontainerinstance.ClientFactory type. type ServerFactory struct { + ContainerGroupProfileServer ContainerGroupProfileServer + ContainerGroupProfilesServer ContainerGroupProfilesServer ContainerGroupsServer ContainerGroupsServer ContainersServer ContainersServer LocationServer LocationServer @@ -40,6 +42,8 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { type ServerFactoryTransport struct { srv *ServerFactory trMu sync.Mutex + trContainerGroupProfileServer *ContainerGroupProfileServerTransport + trContainerGroupProfilesServer *ContainerGroupProfilesServerTransport trContainerGroupsServer *ContainerGroupsServerTransport trContainersServer *ContainersServerTransport trLocationServer *LocationServerTransport @@ -60,6 +64,16 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "ContainerGroupProfileClient": + initServer(s, &s.trContainerGroupProfileServer, func() *ContainerGroupProfileServerTransport { + return NewContainerGroupProfileServerTransport(&s.srv.ContainerGroupProfileServer) + }) + resp, err = s.trContainerGroupProfileServer.Do(req) + case "ContainerGroupProfilesClient": + initServer(s, &s.trContainerGroupProfilesServer, func() *ContainerGroupProfilesServerTransport { + return NewContainerGroupProfilesServerTransport(&s.srv.ContainerGroupProfilesServer) + }) + resp, err = s.trContainerGroupProfilesServer.Do(req) case "ContainerGroupsClient": initServer(s, &s.trContainerGroupsServer, func() *ContainerGroupsServerTransport { return NewContainerGroupsServerTransport(&s.srv.ContainerGroupsServer) diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/time_rfc3339.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/time_rfc3339.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod index 68ac261b2e39..9fddaa0c2de1 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/a go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go index 875cf995e60d..26a649ea85b2 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go @@ -28,8 +28,7 @@ type LocationClient struct { } // NewLocationClient creates a new instance of LocationClient with the specified values. -// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLocationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationClient, error) { @@ -46,8 +45,8 @@ func NewLocationClient(subscriptionID string, credential azcore.TokenCredential, // NewListCachedImagesPager - Get the list of cached images on specific OS type for a subscription in a region. // -// Generated from API version 2023-05-01 -// - location - The identifier for the physical azure location. +// Generated from API version 2024-05-01-preview +// - location - The name of the Azure region. // - options - LocationClientListCachedImagesOptions contains the optional parameters for the LocationClient.NewListCachedImagesPager // method. func (client *LocationClient) NewListCachedImagesPager(location string, options *LocationClientListCachedImagesOptions) *runtime.Pager[LocationClientListCachedImagesResponse] { @@ -89,7 +88,7 @@ func (client *LocationClient) listCachedImagesCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,8 +105,8 @@ func (client *LocationClient) listCachedImagesHandleResponse(resp *http.Response // NewListCapabilitiesPager - Get the list of CPU/memory/GPU capabilities of a region. // -// Generated from API version 2023-05-01 -// - location - The identifier for the physical azure location. +// Generated from API version 2024-05-01-preview +// - location - The name of the Azure region. // - options - LocationClientListCapabilitiesOptions contains the optional parameters for the LocationClient.NewListCapabilitiesPager // method. func (client *LocationClient) NewListCapabilitiesPager(location string, options *LocationClientListCapabilitiesOptions) *runtime.Pager[LocationClientListCapabilitiesResponse] { @@ -149,7 +148,7 @@ func (client *LocationClient) listCapabilitiesCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -166,8 +165,8 @@ func (client *LocationClient) listCapabilitiesHandleResponse(resp *http.Response // NewListUsagePager - Get the usage for a subscription // -// Generated from API version 2023-05-01 -// - location - The identifier for the physical azure location. +// Generated from API version 2024-05-01-preview +// - location - The name of the Azure region. // - options - LocationClientListUsageOptions contains the optional parameters for the LocationClient.NewListUsagePager method. func (client *LocationClient) NewListUsagePager(location string, options *LocationClientListUsageOptions) *runtime.Pager[LocationClientListUsageResponse] { return runtime.NewPager(runtime.PagingHandler[LocationClientListUsageResponse]{ @@ -209,7 +208,7 @@ func (client *LocationClient) listUsageCreateRequest(ctx context.Context, locati return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client_example_test.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client_example_test.go deleted file mode 100644 index 4eacde585c09..000000000000 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client_example_test.go +++ /dev/null @@ -1,147 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armcontainerinstance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/ContainerGroupUsage.json -func ExampleLocationClient_NewListUsagePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLocationClient().NewListUsagePager("westcentralus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageListResult = armcontainerinstance.UsageListResult{ - // Value: []*armcontainerinstance.Usage{ - // { - // Name: &armcontainerinstance.UsageName{ - // LocalizedValue: to.Ptr("Container Groups"), - // Value: to.Ptr("ContainerGroups"), - // }, - // CurrentValue: to.Ptr[int32](1), - // Limit: to.Ptr[int32](2000), - // Unit: to.Ptr("Count"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/CachedImagesList.json -func ExampleLocationClient_NewListCachedImagesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLocationClient().NewListCachedImagesPager("westcentralus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CachedImagesListResult = armcontainerinstance.CachedImagesListResult{ - // Value: []*armcontainerinstance.CachedImages{ - // { - // Image: to.Ptr("ubuntu:16.04"), - // OSType: to.Ptr("Linux"), - // }, - // { - // Image: to.Ptr("alpine:3.6"), - // OSType: to.Ptr("Linux"), - // }, - // { - // Image: to.Ptr("microsoft/nanoserver:10.0.14393.2485"), - // OSType: to.Ptr("Windows"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/CapabilitiesList.json -func ExampleLocationClient_NewListCapabilitiesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLocationClient().NewListCapabilitiesPager("westus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CapabilitiesListResult = armcontainerinstance.CapabilitiesListResult{ - // Value: []*armcontainerinstance.Capabilities{ - // { - // Capabilities: &armcontainerinstance.CapabilitiesCapabilities{ - // MaxCPU: to.Ptr[float32](4), - // MaxGpuCount: to.Ptr[float32](4), - // MaxMemoryInGB: to.Ptr[float32](14), - // }, - // Gpu: to.Ptr("K80"), - // IPAddressType: to.Ptr("Public"), - // Location: to.Ptr("West US"), - // OSType: to.Ptr("Linux"), - // ResourceType: to.Ptr("containerGroups"), - // }, - // { - // Capabilities: &armcontainerinstance.CapabilitiesCapabilities{ - // MaxCPU: to.Ptr[float32](4), - // MaxGpuCount: to.Ptr[float32](0), - // MaxMemoryInGB: to.Ptr[float32](14), - // }, - // Gpu: to.Ptr("None"), - // IPAddressType: to.Ptr("Public"), - // Location: to.Ptr("West US"), - // OSType: to.Ptr("Windows"), - // ResourceType: to.Ptr("containerGroups"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/models.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/models.go index 16f45d2e8eb0..f3c06c7e56ab 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/models.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/models.go @@ -91,6 +91,12 @@ type ConfidentialComputeProperties struct { CcePolicy *string } +// ConfigMap - The container config map. +type ConfigMap struct { + // The key value pairs dictionary in the config map. + KeyValuePairs map[string]*string +} + // Container - A container instance. type Container struct { // REQUIRED; The user-provided name of the container instance. @@ -203,6 +209,109 @@ type ContainerGroupListResult struct { Value []*ContainerGroup } +// ContainerGroupProfile - A container group profile. +type ContainerGroupProfile struct { + // REQUIRED; The container group profile properties + Properties *ContainerGroupProfilePropertiesProperties + + // The resource location. + Location *string + + // The resource tags. + Tags map[string]*string + + // The zones for the container group. + Zones []*string + + // READ-ONLY; The resource id. + ID *string + + // READ-ONLY; The resource name. + Name *string + + // READ-ONLY; The resource type. + Type *string +} + +// ContainerGroupProfileListResult - The container group profile list response that contains the container group profile properties. +type ContainerGroupProfileListResult struct { + // The URI to fetch the next page of container group profiles. + NextLink *string + + // The list of container group profiles. + Value []*ContainerGroupProfile +} + +// ContainerGroupProfilePatch - Properties of container group profile that need to be patched +type ContainerGroupProfilePatch struct { + // Resource tags. + Tags map[string]*string +} + +// ContainerGroupProfileProperties - The container group profile properties +type ContainerGroupProfileProperties struct { + // REQUIRED; The container group profile properties + Properties *ContainerGroupProfilePropertiesProperties +} + +// ContainerGroupProfilePropertiesProperties - The container group profile properties +type ContainerGroupProfilePropertiesProperties struct { + // REQUIRED; The containers within the container group. + Containers []*Container + + // REQUIRED; The operating system type required by the containers in the container group. + OSType *OperatingSystemTypes + + // The properties for confidential container group + ConfidentialComputeProperties *ConfidentialComputeProperties + + // The diagnostic information for a container group. + Diagnostics *ContainerGroupDiagnostics + + // The encryption properties for a container group. + EncryptionProperties *EncryptionProperties + + // extensions used by virtual kubelet + Extensions []*DeploymentExtensionSpec + + // The IP address type of the container group. + IPAddress *IPAddress + + // The image registry credentials by which the container group is created from. + ImageRegistryCredentials []*ImageRegistryCredential + + // The init containers for a container group. + InitContainers []*InitContainerDefinition + + // The priority of the container group. + Priority *ContainerGroupPriority + + // Restart policy for all containers within the container group. + // * Always Always restart + // * OnFailure Restart on failure + // * Never Never restart + RestartPolicy *ContainerGroupRestartPolicy + + // The SKU for a container group. + SKU *ContainerGroupSKU + + // The list of volumes that can be mounted by containers in this container group. + Volumes []*Volume + + // READ-ONLY; The container group profile current revision number. This only appears in the response. + Revision *int32 +} + +// ContainerGroupProfileReferenceDefinition - The container group profile reference. +type ContainerGroupProfileReferenceDefinition struct { + // The container group profile reference id.This will be an ARM resource id in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}'. + ID *string + + // The container group profile reference revision. + Revision *int32 +} + // ContainerGroupProperties - The container group properties type ContainerGroupProperties struct { // REQUIRED; The container group properties @@ -226,12 +335,12 @@ type ContainerGroupPropertiesProperties struct { // REQUIRED; The containers within the container group. Containers []*Container - // REQUIRED; The operating system type required by the containers in the container group. - OSType *OperatingSystemTypes - // The properties for confidential container group ConfidentialComputeProperties *ConfidentialComputeProperties + // The reference container group profile properties. + ContainerGroupProfile *ContainerGroupProfileReferenceDefinition + // The DNS config information for a container group. DNSConfig *DNSConfiguration @@ -253,6 +362,9 @@ type ContainerGroupPropertiesProperties struct { // The init containers for a container group. InitContainers []*InitContainerDefinition + // The operating system type required by the containers in the container group. + OSType *OperatingSystemTypes + // The priority of the container group. Priority *ContainerGroupPriority @@ -265,6 +377,9 @@ type ContainerGroupPropertiesProperties struct { // The SKU for a container group. SKU *ContainerGroupSKU + // The reference standby pool profile properties. + StandbyPoolProfile *StandbyPoolProfileDefinition + // The subnet resource IDs for a container group. SubnetIDs []*ContainerGroupSubnetID @@ -274,6 +389,9 @@ type ContainerGroupPropertiesProperties struct { // READ-ONLY; The instance view of the container group. Only valid in response. InstanceView *ContainerGroupPropertiesInstanceView + // READ-ONLY; The flag indicating whether the container group is created by standby pool. + IsCreatedFromStandbyPool *bool + // READ-ONLY; The provisioning state of the container group. This only appears in the response. ProvisioningState *string } @@ -337,18 +455,18 @@ type ContainerProbe struct { // ContainerProperties - The container instance properties. type ContainerProperties struct { - // REQUIRED; The name of the image used to create the container instance. - Image *string - - // REQUIRED; The resource requirements of the container instance. - Resources *ResourceRequirements - // The commands to execute within the container instance in exec form. Command []*string + // The config map. + ConfigMap *ConfigMap + // The environment variables to set in the container instance. EnvironmentVariables []*EnvironmentVariable + // The name of the image used to create the container instance. + Image *string + // The liveness probe. LivenessProbe *ContainerProbe @@ -358,6 +476,9 @@ type ContainerProperties struct { // The readiness probe. ReadinessProbe *ContainerProbe + // The resource requirements of the container instance. + Resources *ResourceRequirements + // The container security properties. SecurityContext *SecurityContextDefinition @@ -763,6 +884,17 @@ type SecurityContextDefinition struct { SeccompProfile *string } +// StandbyPoolProfileDefinition - The standby pool profile reference. +type StandbyPoolProfileDefinition struct { + // The flag to determine whether ACI should fail the create request if the container group can not be obtained from standby + // pool. + FailContainerGroupCreateOnReuseFailure *bool + + // The standby pool profile reference id.This will be an ARM resource id in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StandbyPool/standbyContainerGroupPools/{standbyPoolName}'. + ID *string +} + // Usage - A single usage result type Usage struct { // READ-ONLY; The current usage of the resource diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/models_serde.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/models_serde.go index 0888362f277e..6c25e1bf1ff9 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/models_serde.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/models_serde.go @@ -256,6 +256,33 @@ func (c *ConfidentialComputeProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ConfigMap. +func (c ConfigMap) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyValuePairs", c.KeyValuePairs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigMap. +func (c *ConfigMap) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyValuePairs": + err = unpopulate(val, "KeyValuePairs", &c.KeyValuePairs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Container. func (c Container) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -590,6 +617,252 @@ func (c *ContainerGroupListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfile. +func (c ContainerGroupProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + populate(objectMap, "zones", c.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfile. +func (c *ContainerGroupProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &c.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfileListResult. +func (c ContainerGroupProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfileListResult. +func (c *ContainerGroupProfileListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfilePatch. +func (c ContainerGroupProfilePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfilePatch. +func (c *ContainerGroupProfilePatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfileProperties. +func (c ContainerGroupProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfileProperties. +func (c *ContainerGroupProfileProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfilePropertiesProperties. +func (c ContainerGroupProfilePropertiesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "confidentialComputeProperties", c.ConfidentialComputeProperties) + populate(objectMap, "containers", c.Containers) + populate(objectMap, "diagnostics", c.Diagnostics) + populate(objectMap, "encryptionProperties", c.EncryptionProperties) + populate(objectMap, "extensions", c.Extensions) + populate(objectMap, "ipAddress", c.IPAddress) + populate(objectMap, "imageRegistryCredentials", c.ImageRegistryCredentials) + populate(objectMap, "initContainers", c.InitContainers) + populate(objectMap, "osType", c.OSType) + populate(objectMap, "priority", c.Priority) + populate(objectMap, "restartPolicy", c.RestartPolicy) + populate(objectMap, "revision", c.Revision) + populate(objectMap, "sku", c.SKU) + populate(objectMap, "volumes", c.Volumes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfilePropertiesProperties. +func (c *ContainerGroupProfilePropertiesProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "confidentialComputeProperties": + err = unpopulate(val, "ConfidentialComputeProperties", &c.ConfidentialComputeProperties) + delete(rawMsg, key) + case "containers": + err = unpopulate(val, "Containers", &c.Containers) + delete(rawMsg, key) + case "diagnostics": + err = unpopulate(val, "Diagnostics", &c.Diagnostics) + delete(rawMsg, key) + case "encryptionProperties": + err = unpopulate(val, "EncryptionProperties", &c.EncryptionProperties) + delete(rawMsg, key) + case "extensions": + err = unpopulate(val, "Extensions", &c.Extensions) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, "IPAddress", &c.IPAddress) + delete(rawMsg, key) + case "imageRegistryCredentials": + err = unpopulate(val, "ImageRegistryCredentials", &c.ImageRegistryCredentials) + delete(rawMsg, key) + case "initContainers": + err = unpopulate(val, "InitContainers", &c.InitContainers) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &c.OSType) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &c.Priority) + delete(rawMsg, key) + case "restartPolicy": + err = unpopulate(val, "RestartPolicy", &c.RestartPolicy) + delete(rawMsg, key) + case "revision": + err = unpopulate(val, "Revision", &c.Revision) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &c.SKU) + delete(rawMsg, key) + case "volumes": + err = unpopulate(val, "Volumes", &c.Volumes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerGroupProfileReferenceDefinition. +func (c ContainerGroupProfileReferenceDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "revision", c.Revision) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupProfileReferenceDefinition. +func (c *ContainerGroupProfileReferenceDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "revision": + err = unpopulate(val, "Revision", &c.Revision) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ContainerGroupProperties. func (c ContainerGroupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -656,6 +929,7 @@ func (c *ContainerGroupPropertiesInstanceView) UnmarshalJSON(data []byte) error func (c ContainerGroupPropertiesProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "confidentialComputeProperties", c.ConfidentialComputeProperties) + populate(objectMap, "containerGroupProfile", c.ContainerGroupProfile) populate(objectMap, "containers", c.Containers) populate(objectMap, "dnsConfig", c.DNSConfig) populate(objectMap, "diagnostics", c.Diagnostics) @@ -665,11 +939,13 @@ func (c ContainerGroupPropertiesProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "imageRegistryCredentials", c.ImageRegistryCredentials) populate(objectMap, "initContainers", c.InitContainers) populate(objectMap, "instanceView", c.InstanceView) + populate(objectMap, "isCreatedFromStandbyPool", c.IsCreatedFromStandbyPool) populate(objectMap, "osType", c.OSType) populate(objectMap, "priority", c.Priority) populate(objectMap, "provisioningState", c.ProvisioningState) populate(objectMap, "restartPolicy", c.RestartPolicy) populate(objectMap, "sku", c.SKU) + populate(objectMap, "standbyPoolProfile", c.StandbyPoolProfile) populate(objectMap, "subnetIds", c.SubnetIDs) populate(objectMap, "volumes", c.Volumes) return json.Marshal(objectMap) @@ -687,6 +963,9 @@ func (c *ContainerGroupPropertiesProperties) UnmarshalJSON(data []byte) error { case "confidentialComputeProperties": err = unpopulate(val, "ConfidentialComputeProperties", &c.ConfidentialComputeProperties) delete(rawMsg, key) + case "containerGroupProfile": + err = unpopulate(val, "ContainerGroupProfile", &c.ContainerGroupProfile) + delete(rawMsg, key) case "containers": err = unpopulate(val, "Containers", &c.Containers) delete(rawMsg, key) @@ -714,6 +993,9 @@ func (c *ContainerGroupPropertiesProperties) UnmarshalJSON(data []byte) error { case "instanceView": err = unpopulate(val, "InstanceView", &c.InstanceView) delete(rawMsg, key) + case "isCreatedFromStandbyPool": + err = unpopulate(val, "IsCreatedFromStandbyPool", &c.IsCreatedFromStandbyPool) + delete(rawMsg, key) case "osType": err = unpopulate(val, "OSType", &c.OSType) delete(rawMsg, key) @@ -729,6 +1011,9 @@ func (c *ContainerGroupPropertiesProperties) UnmarshalJSON(data []byte) error { case "sku": err = unpopulate(val, "SKU", &c.SKU) delete(rawMsg, key) + case "standbyPoolProfile": + err = unpopulate(val, "StandbyPoolProfile", &c.StandbyPoolProfile) + delete(rawMsg, key) case "subnetIds": err = unpopulate(val, "SubnetIDs", &c.SubnetIDs) delete(rawMsg, key) @@ -899,6 +1184,7 @@ func (c *ContainerProbe) UnmarshalJSON(data []byte) error { func (c ContainerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "command", c.Command) + populate(objectMap, "configMap", c.ConfigMap) populate(objectMap, "environmentVariables", c.EnvironmentVariables) populate(objectMap, "image", c.Image) populate(objectMap, "instanceView", c.InstanceView) @@ -923,6 +1209,9 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { case "command": err = unpopulate(val, "Command", &c.Command) delete(rawMsg, key) + case "configMap": + err = unpopulate(val, "ConfigMap", &c.ConfigMap) + delete(rawMsg, key) case "environmentVariables": err = unpopulate(val, "EnvironmentVariables", &c.EnvironmentVariables) delete(rawMsg, key) @@ -2006,6 +2295,37 @@ func (s *SecurityContextDefinition) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type StandbyPoolProfileDefinition. +func (s StandbyPoolProfileDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "failContainerGroupCreateOnReuseFailure", s.FailContainerGroupCreateOnReuseFailure) + populate(objectMap, "id", s.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StandbyPoolProfileDefinition. +func (s *StandbyPoolProfileDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "failContainerGroupCreateOnReuseFailure": + err = unpopulate(val, "FailContainerGroupCreateOnReuseFailure", &s.FailContainerGroupCreateOnReuseFailure) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Usage. func (u Usage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2237,7 +2557,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client.go index 1a5040055849..f861e15cc616 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - List the operations for Azure Container Instance service. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client_example_test.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client_example_test.go deleted file mode 100644 index e40f68cfb0af..000000000000 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/operations_client_example_test.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armcontainerinstance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armcontainerinstance.OperationListResult{ - // Value: []*armcontainerinstance.Operation{ - // { - // Name: to.Ptr("Microsoft.ContainerInstance/containerGroups/read"), - // Display: &armcontainerinstance.OperationDisplay{ - // Description: to.Ptr("Get all container goups."), - // Operation: to.Ptr("Get Container Groups"), - // Provider: to.Ptr("Microsoft Container Instance"), - // Resource: to.Ptr("Container Group"), - // }, - // Origin: to.Ptr(armcontainerinstance.ContainerInstanceOperationsOriginUser), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/options.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/options.go index 9929ef45987a..ea02a2d3dd5e 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/options.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/options.go @@ -8,6 +8,52 @@ package armcontainerinstance +// ContainerGroupProfileClientGetByRevisionNumberOptions contains the optional parameters for the ContainerGroupProfileClient.GetByRevisionNumber +// method. +type ContainerGroupProfileClientGetByRevisionNumberOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfileClientListAllRevisionsOptions contains the optional parameters for the ContainerGroupProfileClient.NewListAllRevisionsPager +// method. +type ContainerGroupProfileClientListAllRevisionsOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientCreateOrUpdateOptions contains the optional parameters for the ContainerGroupProfilesClient.CreateOrUpdate +// method. +type ContainerGroupProfilesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientDeleteOptions contains the optional parameters for the ContainerGroupProfilesClient.Delete +// method. +type ContainerGroupProfilesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientGetOptions contains the optional parameters for the ContainerGroupProfilesClient.Get method. +type ContainerGroupProfilesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientListByResourceGroupOptions contains the optional parameters for the ContainerGroupProfilesClient.NewListByResourceGroupPager +// method. +type ContainerGroupProfilesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientListOptions contains the optional parameters for the ContainerGroupProfilesClient.NewListPager +// method. +type ContainerGroupProfilesClientListOptions struct { + // placeholder for future optional parameters +} + +// ContainerGroupProfilesClientPatchOptions contains the optional parameters for the ContainerGroupProfilesClient.Patch method. +type ContainerGroupProfilesClientPatchOptions struct { + // placeholder for future optional parameters +} + // ContainerGroupsClientBeginCreateOrUpdateOptions contains the optional parameters for the ContainerGroupsClient.BeginCreateOrUpdate // method. type ContainerGroupsClientBeginCreateOrUpdateOptions struct { diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/response_types.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/responses.go similarity index 67% rename from sdk/resourcemanager/containerinstance/armcontainerinstance/response_types.go rename to sdk/resourcemanager/containerinstance/armcontainerinstance/responses.go index 906a11648d80..d92fcb82790a 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/response_types.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/responses.go @@ -8,6 +8,53 @@ package armcontainerinstance +// ContainerGroupProfileClientGetByRevisionNumberResponse contains the response from method ContainerGroupProfileClient.GetByRevisionNumber. +type ContainerGroupProfileClientGetByRevisionNumberResponse struct { + // A container group profile. + ContainerGroupProfile +} + +// ContainerGroupProfileClientListAllRevisionsResponse contains the response from method ContainerGroupProfileClient.NewListAllRevisionsPager. +type ContainerGroupProfileClientListAllRevisionsResponse struct { + // The container group profile list response that contains the container group profile properties. + ContainerGroupProfileListResult +} + +// ContainerGroupProfilesClientCreateOrUpdateResponse contains the response from method ContainerGroupProfilesClient.CreateOrUpdate. +type ContainerGroupProfilesClientCreateOrUpdateResponse struct { + // A container group profile. + ContainerGroupProfile +} + +// ContainerGroupProfilesClientDeleteResponse contains the response from method ContainerGroupProfilesClient.Delete. +type ContainerGroupProfilesClientDeleteResponse struct { + // placeholder for future response values +} + +// ContainerGroupProfilesClientGetResponse contains the response from method ContainerGroupProfilesClient.Get. +type ContainerGroupProfilesClientGetResponse struct { + // A container group profile. + ContainerGroupProfile +} + +// ContainerGroupProfilesClientListByResourceGroupResponse contains the response from method ContainerGroupProfilesClient.NewListByResourceGroupPager. +type ContainerGroupProfilesClientListByResourceGroupResponse struct { + // The container group profile list response that contains the container group profile properties. + ContainerGroupProfileListResult +} + +// ContainerGroupProfilesClientListResponse contains the response from method ContainerGroupProfilesClient.NewListPager. +type ContainerGroupProfilesClientListResponse struct { + // The container group profile list response that contains the container group profile properties. + ContainerGroupProfileListResult +} + +// ContainerGroupProfilesClientPatchResponse contains the response from method ContainerGroupProfilesClient.Patch. +type ContainerGroupProfilesClientPatchResponse struct { + // A container group profile. + ContainerGroupProfile +} + // ContainerGroupsClientCreateOrUpdateResponse contains the response from method ContainerGroupsClient.BeginCreateOrUpdate. type ContainerGroupsClientCreateOrUpdateResponse struct { // A container group. diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go index ae8498fd1b16..549fbc483fc7 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go @@ -28,8 +28,7 @@ type SubnetServiceAssociationLinkClient struct { } // NewSubnetServiceAssociationLinkClient creates a new instance of SubnetServiceAssociationLinkClient with the specified values. -// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms -// part of the URI for every service call. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSubnetServiceAssociationLinkClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubnetServiceAssociationLinkClient, error) { @@ -48,8 +47,8 @@ func NewSubnetServiceAssociationLinkClient(subscriptionID string, credential azc // by the user. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 -// - resourceGroupName - The name of the resource group. +// Generated from API version 2024-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - virtualNetworkName - The name of the virtual network. // - subnetName - The name of the subnet. // - options - SubnetServiceAssociationLinkClientBeginDeleteOptions contains the optional parameters for the SubnetServiceAssociationLinkClient.BeginDelete @@ -75,7 +74,7 @@ func (client *SubnetServiceAssociationLinkClient) BeginDelete(ctx context.Contex // by the user. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview func (client *SubnetServiceAssociationLinkClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualNetworkName string, subnetName string, options *SubnetServiceAssociationLinkClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "SubnetServiceAssociationLinkClient.BeginDelete" @@ -121,7 +120,7 @@ func (client *SubnetServiceAssociationLinkClient) deleteCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2024-05-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client_example_test.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client_example_test.go deleted file mode 100644 index 577447e45d68..000000000000 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client_example_test.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// 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. -// DO NOT EDIT. - -package armcontainerinstance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e60df62e9e0d88462e6abba81a76d94eab000f0d/specification/containerinstance/resource-manager/Microsoft.ContainerInstance/stable/2023-05-01/examples/SubnetServiceAssociationLinkDelete.json -func ExampleSubnetServiceAssociationLinkClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcontainerinstance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewSubnetServiceAssociationLinkClient().BeginDelete(ctx, "demo", "demo2", "demo3", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/time_rfc3339.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/time_rfc3339.go index 967bf5db1a53..40515196a138 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/time_rfc3339.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // 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+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339