diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md index e886bc710b6c..90f5458d3966 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 2.5.0-beta.1 (2024-06-26) +### Features Added + +- New struct `ConfigMap` +- 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..a265c9f7ad7d 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.NewContainerGroupsClient() ``` ## 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..0dcc9b43552c 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/client_factory.go @@ -17,8 +17,7 @@ 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. @@ -28,42 +27,51 @@ type ClientFactory struct { // - 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 } // 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/containergroups_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go index b1f380a00bcc..43fcd76ddc7f 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containergroups_client.go @@ -47,7 +47,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - containerGroup - The properties of the container group to be created or updated. @@ -73,7 +73,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 +115,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,7 +128,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginDeleteOptions contains the optional parameters for the ContainerGroupsClient.BeginDelete @@ -154,7 +154,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 +196,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,7 +207,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientGetOptions contains the optional parameters for the ContainerGroupsClient.Get method. @@ -253,7 +253,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,7 +272,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientGetOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the @@ -319,7 +319,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 +338,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 +376,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,7 +395,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - options - ContainerGroupsClientListByResourceGroupOptions contains the optional parameters for the ContainerGroupsClient.NewListByResourceGroupPager // method. @@ -438,7 +438,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,7 +457,7 @@ func (client *ContainerGroupsClient) listByResourceGroupHandleResponse(resp *htt // 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 // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginRestartOptions contains the optional parameters for the ContainerGroupsClient.BeginRestart @@ -482,7 +482,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 +524,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,7 +533,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientBeginStartOptions contains the optional parameters for the ContainerGroupsClient.BeginStart @@ -558,7 +558,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 +600,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,7 +609,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - options - ContainerGroupsClientStopOptions contains the optional parameters for the ContainerGroupsClient.Stop method. @@ -654,7 +654,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,7 +663,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - resource - The container group resource with just the tags to be updated. @@ -710,7 +710,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..6e2e9fc23c87 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/containers_client.go @@ -48,7 +48,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. @@ -99,7 +99,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,7 +117,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. @@ -170,7 +170,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,7 +191,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - containerGroupName - The name of the container group. // - containerName - The name of the container instance. @@ -242,7 +242,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/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 9e7f46c1d94f..113a45f43ec9 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.12.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.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.24.0 // indirect golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.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 e8d8068ae2d8..6b8c4a4ad083 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.12.0 h1:1nGuui+4POelzDwI7RG56yfQJHCnKvwfMoU7VsEp+Zg= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0/go.mod h1:99EvauvlcJ1U06amZiksfYz/3aFGyIhWGHVyiZXtBAI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0 h1:U2rTu3Ef+7w9FHKIAXM6ZyqF3UOWJZ12zIm8zECAFfg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.6.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 h1:H+U3Gk9zY56G3u872L82bk4thcsy2Gghb9ExT4Zvm1o= github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0/go.mod h1:mgrmMSgaLp9hmax62XQTd0N4aAqSE5E0DulSpVYK7vc= -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.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.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..52dbdef643f3 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/location_client.go @@ -46,7 +46,7 @@ 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 +// Generated from API version 2024-05-01-preview // - location - The identifier for the physical azure location. // - options - LocationClientListCachedImagesOptions contains the optional parameters for the LocationClient.NewListCachedImagesPager // method. @@ -89,7 +89,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,7 +106,7 @@ 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 +// Generated from API version 2024-05-01-preview // - location - The identifier for the physical azure location. // - options - LocationClientListCapabilitiesOptions contains the optional parameters for the LocationClient.NewListCapabilitiesPager // method. @@ -149,7 +149,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,7 +166,7 @@ func (client *LocationClient) listCapabilitiesHandleResponse(resp *http.Response // NewListUsagePager - Get the usage for a subscription // -// Generated from API version 2023-05-01 +// Generated from API version 2024-05-01-preview // - location - The identifier for the physical azure location. // - options - LocationClientListUsageOptions contains the optional parameters for the LocationClient.NewListUsagePager method. func (client *LocationClient) NewListUsagePager(location string, options *LocationClientListUsageOptions) *runtime.Pager[LocationClientListUsageResponse] { @@ -209,7 +209,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..e166ce9634c2 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,16 @@ type ContainerGroupListResult struct { Value []*ContainerGroup } +// 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 +242,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 +269,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 +284,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 +296,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 +362,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 +383,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 +791,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..fca63d1402d6 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,37 @@ func (c *ContainerGroupListResult) UnmarshalJSON(data []byte) error { 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 +714,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 +724,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 +748,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 +778,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 +796,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 +969,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 +994,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 +2080,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 +2342,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/response_types.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/responses.go similarity index 100% rename from sdk/resourcemanager/containerinstance/armcontainerinstance/response_types.go rename to sdk/resourcemanager/containerinstance/armcontainerinstance/responses.go diff --git a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go b/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go index ae8498fd1b16..b84e5eb4ac0b 100644 --- a/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go +++ b/sdk/resourcemanager/containerinstance/armcontainerinstance/subnetserviceassociationlink_client.go @@ -48,7 +48,7 @@ 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 +// Generated from API version 2024-05-01-preview // - resourceGroupName - The name of the resource group. // - virtualNetworkName - The name of the virtual network. // - subnetName - The name of the subnet. @@ -75,7 +75,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 +121,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