From 261a6ebc23d8d95f918348f75a43c00dbbf68b5d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 2 May 2024 00:11:38 +0000 Subject: [PATCH] CodeGen from PR 28788 in Azure/azure-rest-api-specs Merge 6ae8b3a1a6b3bab083825f4e0d1dbce36502ec61 into bc174a7c518905c30ab708ade70b3030b49dba7b --- .../resources/armchanges/CHANGELOG.md | 4 + .../resources/armchanges/autorest.md | 6 +- .../resources/armchanges/client.go | 8 +- .../armchanges/client_example_test.go | 149 -- .../resources/armchanges/client_factory.go | 15 +- .../resources/armchanges/constants.go | 2 +- .../resources/armchanges/go.mod | 12 +- .../resources/armchanges/go.sum | 19 - .../resources/armchanges/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../armdeploymentscripts/CHANGELOG.md | 7 + .../armdeploymentscripts/autorest.md | 6 +- .../resources/armdeploymentscripts/client.go | 34 +- .../client_example_test.go | 764 --------- .../armdeploymentscripts/client_factory.go | 15 +- .../armdeploymentscripts/constants.go | 2 +- .../fake/polymorphic_helpers.go | 2 +- .../armdeploymentscripts/fake/time_rfc3339.go | 42 +- .../resources/armdeploymentscripts/go.mod | 2 +- .../resources/armdeploymentscripts/models.go | 12 + .../armdeploymentscripts/models_serde.go | 37 +- .../polymorphic_helpers.go | 4 +- .../{response_types.go => responses.go} | 0 .../armdeploymentscripts/time_rfc3339.go | 42 +- .../armdeploymentstacks/CHANGELOG.md | 4 + .../resources/armdeploymentstacks/autorest.md | 6 +- .../resources/armdeploymentstacks/client.go | 26 +- .../client_example_test.go | 1088 ------------- .../armdeploymentstacks/client_factory.go | 15 +- .../armdeploymentstacks/constants.go | 2 +- .../armdeploymentstacks/fake/time_rfc3339.go | 42 +- .../resources/armdeploymentstacks/go.mod | 12 +- .../resources/armdeploymentstacks/go.sum | 19 - .../armdeploymentstacks/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../armdeploymentstacks/time_rfc3339.go | 42 +- .../resources/armfeatures/CHANGELOG.md | 4 + .../resources/armfeatures/autorest.md | 6 +- .../armfeatures/client_example_test.go | 190 --- .../resources/armfeatures/client_factory.go | 26 +- .../resources/armfeatures/constants.go | 2 +- .../armfeatures/fake/time_rfc3339.go | 42 +- .../feature_client_example_test.go | 62 - .../resources/armfeatures/go.mod | 2 +- .../resources/armfeatures/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 ...eatureregistrations_client_example_test.go | 198 --- .../resources/armfeatures/time_rfc3339.go | 42 +- .../resources/armlinks/CHANGELOG.md | 4 + .../resources/armlinks/autorest.md | 6 +- .../resources/armlinks/client_factory.go | 20 +- .../resources/armlinks/constants.go | 2 +- .../resources/armlinks/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../resources/armlocks/CHANGELOG.md | 4 + ...orizationoperations_client_example_test.go | 54 - .../resources/armlocks/autorest.md | 6 +- .../resources/armlocks/client_factory.go | 20 +- .../resources/armlocks/constants.go | 2 +- .../resources/armlocks/fake/time_rfc3339.go | 42 +- sdk/resourcemanager/resources/armlocks/go.mod | 12 +- sdk/resourcemanager/resources/armlocks/go.sum | 19 - .../managementlocks_client_example_test.go | 471 ------ .../resources/armlocks/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../resources/armlocks/time_rfc3339.go | 42 +- .../armmanagedapplications/CHANGELOG.md | 4 + .../armmanagedapplications/README.md | 2 +- .../application_client_example_test.go | 62 - ...licationdefinitions_client_example_test.go | 237 --- .../applications_client_example_test.go | 381 ----- .../armmanagedapplications/autorest.md | 6 +- .../armmanagedapplications/client_factory.go | 26 +- .../armmanagedapplications/constants.go | 2 +- .../resources/armmanagedapplications/go.mod | 12 +- .../resources/armmanagedapplications/go.sum | 19 - .../armmanagedapplications/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../resources/armpolicy/CHANGELOG.md | 44 + .../resources/armpolicy/README.md | 2 +- .../resources/armpolicy/assignments_client.go | 66 +- .../assignments_client_example_test.go | 1365 ----------------- .../resources/armpolicy/autorest.md | 7 +- .../resources/armpolicy/client_factory.go | 106 +- .../resources/armpolicy/constants.go | 2 +- ...datapolicymanifests_client_example_test.go | 278 ---- .../resources/armpolicy/definitions_client.go | 114 +- .../definitions_client_example_test.go | 806 ---------- .../armpolicy/definitionversions_client.go | 829 ++++++++++ .../resources/armpolicy/exemptions_client.go | 2 +- .../exemptions_client_example_test.go | 639 -------- .../armpolicy/fake/definitions_server.go | 24 +- .../fake/definitionversions_server.go | 583 +++++++ .../armpolicy/fake/server_factory.go | 46 +- .../armpolicy/fake/setdefinitions_server.go | 24 +- .../fake/setdefinitionversions_server.go | 583 +++++++ .../resources/armpolicy/fake/time_rfc3339.go | 42 +- .../resources/armpolicy/go.mod | 2 +- .../resources/armpolicy/models.go | 127 +- .../resources/armpolicy/models_serde.go | 280 +++- .../resources/armpolicy/options.go | 156 ++ .../{response_types.go => responses.go} | 152 ++ .../armpolicy/setdefinitions_client.go | 114 +- .../setdefinitions_client_example_test.go | 1028 ------------- .../armpolicy/setdefinitionversions_client.go | 832 ++++++++++ .../resources/armpolicy/time_rfc3339.go | 42 +- .../resources/armpolicy/variables_client.go | 2 +- .../variables_client_example_test.go | 355 ----- .../armpolicy/variablevalues_client.go | 2 +- .../variablevalues_client_example_test.go | 395 ----- .../resources/armresources/CHANGELOG.md | 19 + .../resources/armresources/README.md | 4 +- .../resources/armresources/autorest.md | 6 +- .../resources/armresources/client.go | 68 +- .../resources/armresources/client_factory.go | 56 +- .../resources/armresources/constants.go | 18 +- .../deploymentoperations_client.go | 40 +- .../armresources/deployments_client.go | 218 +-- .../deployments_client_example_test.go | 1044 ------------- .../deployments_client_live_test.go | 2 +- .../fake/deploymentoperations_server.go | 2 +- .../armresources/fake/deployments_server.go | 2 +- .../armresources/fake/operations_server.go | 2 +- .../fake/providerresourcetypes_server.go | 2 +- .../armresources/fake/providers_server.go | 2 +- .../fake/resourcegroups_server.go | 2 +- .../resources/armresources/fake/server.go | 2 +- .../armresources/fake/tags_server.go | 209 ++- .../armresources/fake/time_rfc3339.go | 42 +- .../resources/armresources/go.mod | 4 +- .../resources/armresources/models.go | 39 +- .../resources/armresources/models_serde.go | 107 +- .../armresources/operations_client.go | 4 +- .../resources/armresources/options.go | 32 +- .../providerresourcetypes_client.go | 4 +- ...oviderresourcetypes_client_example_test.go | 67 - .../armresources/providers_client.go | 36 +- .../providers_client_example_test.go | 532 ------- .../armresources/resourcegroups_client.go | 32 +- .../resourcegroups_client_example_test.go | 220 --- .../resourcegroups_client_live_test.go | 2 +- .../resources_client_live_test.go | 2 +- .../{response_types.go => responses.go} | 6 +- .../resources/armresources/tags_client.go | 186 ++- .../armresources/tags_client_example_test.go | 145 -- .../armresources/tags_client_live_test.go | 2 +- .../resources/armresources/time_rfc3339.go | 42 +- .../resources/armsubscriptions/CHANGELOG.md | 4 + .../resources/armsubscriptions/autorest.md | 7 +- .../armsubscriptions/client_example_test.go | 408 ----- .../armsubscriptions/client_factory.go | 28 +- .../resources/armsubscriptions/constants.go | 2 +- .../resources/armsubscriptions/go.mod | 2 +- .../armsubscriptions/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../subscription_client_example_test.go | 43 - .../tenants_client_example_test.go | 82 - .../resources/armtemplatespecs/CHANGELOG.md | 4 + .../resources/armtemplatespecs/autorest.md | 6 +- .../armtemplatespecs/client_example_test.go | 371 ----- .../armtemplatespecs/client_factory.go | 21 +- .../resources/armtemplatespecs/constants.go | 2 +- .../armtemplatespecs/fake/time_rfc3339.go | 42 +- .../resources/armtemplatespecs/go.mod | 2 +- .../armtemplatespecs/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 ...emplatespecversions_client_example_test.go | 339 ---- .../armtemplatespecs/time_rfc3339.go | 42 +- 168 files changed, 5314 insertions(+), 12827 deletions(-) delete mode 100644 sdk/resourcemanager/resources/armchanges/client_example_test.go rename sdk/resourcemanager/resources/armchanges/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armdeploymentscripts/client_example_test.go rename sdk/resourcemanager/resources/armdeploymentscripts/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armdeploymentstacks/client_example_test.go rename sdk/resourcemanager/resources/armdeploymentstacks/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armfeatures/client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armfeatures/feature_client_example_test.go rename sdk/resourcemanager/resources/armfeatures/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go rename sdk/resourcemanager/resources/armlinks/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go rename sdk/resourcemanager/resources/armlocks/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go rename sdk/resourcemanager/resources/armmanagedapplications/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/definitionversions_client.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go create mode 100644 sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go rename sdk/resourcemanager/resources/armpolicy/{response_types.go => responses.go} (65%) delete mode 100644 sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go create mode 100644 sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armresources/deployments_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armresources/providers_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go rename sdk/resourcemanager/resources/armresources/{response_types.go => responses.go} (99%) delete mode 100644 sdk/resourcemanager/resources/armresources/tags_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/client_example_test.go rename sdk/resourcemanager/resources/armsubscriptions/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armtemplatespecs/client_example_test.go rename sdk/resourcemanager/resources/armtemplatespecs/{response_types.go => responses.go} (100%) delete mode 100644 sdk/resourcemanager/resources/armtemplatespecs/templatespecversions_client_example_test.go diff --git a/sdk/resourcemanager/resources/armchanges/CHANGELOG.md b/sdk/resourcemanager/resources/armchanges/CHANGELOG.md index 7e46a86ac2b8..881d4ae5621b 100644 --- a/sdk/resourcemanager/resources/armchanges/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armchanges/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armchanges/autorest.md b/sdk/resourcemanager/resources/armchanges/autorest.md index 88dfde006675..786b757dccff 100644 --- a/sdk/resourcemanager/resources/armchanges/autorest.md +++ b/sdk/resourcemanager/resources/armchanges/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-changes: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armchanges/client.go b/sdk/resourcemanager/resources/armchanges/client.go index 1bd5ada6743b..713639c464bd 100644 --- a/sdk/resourcemanager/resources/armchanges/client.go +++ b/sdk/resourcemanager/resources/armchanges/client.go @@ -182,13 +182,13 @@ func (client *Client) listCreateRequest(ctx context.Context, resourceGroupName s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-05-01") - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) - } if options != nil && options.SkipToken != nil { reqQP.Set("$skipToken", *options.SkipToken) } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(*options.Top, 10)) + } + reqQP.Set("api-version", "2022-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armchanges/client_example_test.go b/sdk/resourcemanager/resources/armchanges/client_example_test.go deleted file mode 100644 index ff4e4df3f929..000000000000 --- a/sdk/resourcemanager/resources/armchanges/client_example_test.go +++ /dev/null @@ -1,149 +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 armchanges_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchanges" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-05-01/examples/ListChanges.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchanges.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListPager("resourceGroup1", "resourceProvider1", "resourceType1", "resourceName1", &armchanges.ClientListOptions{Top: nil, - SkipToken: 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.ChangeResourceListResult = armchanges.ChangeResourceListResult{ - // Value: []*armchanges.ChangeResourceResult{ - // { - // Name: to.Ptr("a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](2), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("6eac9d0f-63b4-4e7f-97a5-740c73757efb"), - // PreviousResourceSnapshotID: to.Ptr("ed90e35a-1661-42cc-a44c-e27f508005be"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeUpdate), - // Changes: map[string]*armchanges.ChangeBase{ - // "properties.provisioningState": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategorySystem), - // NewValue: to.Ptr("Succeeded"), - // PreviousValue: to.Ptr("Updating"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeUpdate), - // }, - // "tags.key1": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategoryUser), - // NewValue: to.Ptr("someValue"), - // PreviousValue: to.Ptr("null"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeInsert), - // }, - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // }, - // { - // Name: to.Ptr("a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/a9f34285-13a2-e79c-f468-cfb71c7bd227"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](0), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("4db20fc0-de17-4cdd-92d8-fd6bf94b9fd9"), - // PreviousResourceSnapshotID: to.Ptr("b09f5e52-0b46-4d13-84a9-08653d39fed6"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeCreate), - // Changes: map[string]*armchanges.ChangeBase{ - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-05-01/examples/GetChange.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armchanges.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "resourceGroup1", "resourceProvider1", "resourceType1", "resourceName1", "1d58d72f-0719-4a48-9228-b7ea682885bf", 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.ChangeResourceResult = armchanges.ChangeResourceResult{ - // Name: to.Ptr("1d58d72f-0719-4a48-9228-b7ea682885bf"), - // Type: to.Ptr("Microsoft.Resources/changes"), - // ID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1/Microsoft.Resources/changes/1d58d72f-0719-4a48-9228-b7ea682885bf"), - // Properties: &armchanges.ChangeProperties{ - // ChangeAttributes: &armchanges.ChangeAttributes{ - // ChangesCount: to.Ptr[int64](2), - // CorrelationID: to.Ptr("88420d5d-8d0e-471f-9115-10d34750c617"), - // NewResourceSnapshotID: to.Ptr("6eac9d0f-63b4-4e7f-97a5-740c73757efb"), - // PreviousResourceSnapshotID: to.Ptr("ed90e35a-1661-42cc-a44c-e27f508005be"), - // Timestamp: to.Ptr("2021-11-19T14:29:09.9210000Z"), - // }, - // ChangeType: to.Ptr(armchanges.ChangeTypeUpdate), - // Changes: map[string]*armchanges.ChangeBase{ - // "properties.provisioningState": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategorySystem), - // NewValue: to.Ptr("Succeeded"), - // PreviousValue: to.Ptr("Updating"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeUpdate), - // }, - // "tags.key1": &armchanges.ChangeBase{ - // ChangeCategory: to.Ptr(armchanges.ChangeCategoryUser), - // NewValue: to.Ptr("someValue"), - // PreviousValue: to.Ptr("null"), - // PropertyChangeType: to.Ptr(armchanges.PropertyChangeTypeInsert), - // }, - // }, - // TargetResourceID: to.Ptr("/subscriptions/subscriptionId1/resourceGroups/resourceGroup1/providers/resourceProvider1/resourceType1/resourceName1"), - // TargetResourceType: to.Ptr("resourceProvider1/resourceType1"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armchanges/client_factory.go b/sdk/resourcemanager/resources/armchanges/client_factory.go index b1eb0676c4bd..ad8b92844387 100644 --- a/sdk/resourcemanager/resources/armchanges/client_factory.go +++ b/sdk/resourcemanager/resources/armchanges/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. @@ -27,18 +26,20 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armchanges/constants.go b/sdk/resourcemanager/resources/armchanges/constants.go index 127888bd0061..ce9f19a79bde 100644 --- a/sdk/resourcemanager/resources/armchanges/constants.go +++ b/sdk/resourcemanager/resources/armchanges/constants.go @@ -10,7 +10,7 @@ package armchanges const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchanges" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // ChangeCategory - The entity that made the change diff --git a/sdk/resourcemanager/resources/armchanges/go.mod b/sdk/resourcemanager/resources/armchanges/go.mod index dbe1d83a1029..6c86b786fb25 100644 --- a/sdk/resourcemanager/resources/armchanges/go.mod +++ b/sdk/resourcemanager/resources/armchanges/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armchange go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armchanges/go.sum b/sdk/resourcemanager/resources/armchanges/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/resources/armchanges/go.sum +++ b/sdk/resourcemanager/resources/armchanges/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/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-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armchanges/models_serde.go b/sdk/resourcemanager/resources/armchanges/models_serde.go index af114ae11505..772ba04b6f9d 100644 --- a/sdk/resourcemanager/resources/armchanges/models_serde.go +++ b/sdk/resourcemanager/resources/armchanges/models_serde.go @@ -367,7 +367,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/resources/armchanges/response_types.go b/sdk/resourcemanager/resources/armchanges/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armchanges/response_types.go rename to sdk/resourcemanager/resources/armchanges/responses.go diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/CHANGELOG.md b/sdk/resourcemanager/resources/armdeploymentscripts/CHANGELOG.md index 35bae96c4a63..b52d0305e9cb 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armdeploymentscripts/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 2.2.0 (2024-05-02) +### Features Added + +- New struct `ContainerGroupSubnetID` +- New field `SubnetIDs` in struct `ContainerConfiguration` + + ## 2.1.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/autorest.md b/sdk/resourcemanager/resources/armdeploymentscripts/autorest.md index 0f813d9df8f7..69e66ddb17bc 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/autorest.md +++ b/sdk/resourcemanager/resources/armdeploymentscripts/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 +module-version: 2.2.0 package-deploymentscripts: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/client.go b/sdk/resourcemanager/resources/armdeploymentscripts/client.go index b9365062bfc1..6df33dc64e0a 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/client.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/client.go @@ -47,7 +47,7 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // BeginCreate - Creates a deployment script. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - deploymentScript - Deployment script supplied to the operation. @@ -72,7 +72,7 @@ func (client *Client) BeginCreate(ctx context.Context, resourceGroupName string, // Create - Creates a deployment script. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 func (client *Client) create(ctx context.Context, resourceGroupName string, scriptName string, deploymentScript DeploymentScriptClassification, options *ClientBeginCreateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreate" @@ -114,7 +114,7 @@ func (client *Client) createCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, deploymentScript); err != nil { @@ -126,7 +126,7 @@ func (client *Client) createCreateRequest(ctx context.Context, resourceGroupName // Delete - Deletes a deployment script. When operation completes, status code 200 returned without content. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - options - ClientDeleteOptions contains the optional parameters for the Client.Delete method. @@ -171,7 +171,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -180,7 +180,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // Get - Gets a deployment script with a given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - options - ClientGetOptions contains the optional parameters for the Client.Get method. @@ -226,7 +226,7 @@ func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName st return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -244,7 +244,7 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // GetLogs - Gets deployment script logs for a given deployment script name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - options - ClientGetLogsOptions contains the optional parameters for the Client.GetLogs method. @@ -290,7 +290,7 @@ func (client *Client) getLogsCreateRequest(ctx context.Context, resourceGroupNam return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -308,7 +308,7 @@ func (client *Client) getLogsHandleResponse(resp *http.Response) (ClientGetLogsR // GetLogsDefault - Gets deployment script logs for a given deployment script name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - options - ClientGetLogsDefaultOptions contains the optional parameters for the Client.GetLogsDefault method. @@ -354,7 +354,7 @@ func (client *Client) getLogsDefaultCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Tail != nil { reqQP.Set("tail", strconv.FormatInt(int64(*options.Tail), 10)) } @@ -374,7 +374,7 @@ func (client *Client) getLogsDefaultHandleResponse(resp *http.Response) (ClientG // NewListByResourceGroupPager - Lists deployments scripts. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager // method. @@ -417,7 +417,7 @@ func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -434,7 +434,7 @@ func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (Cl // NewListBySubscriptionPager - Lists all deployment scripts for a given subscription. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - options - ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ @@ -471,7 +471,7 @@ func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -489,7 +489,7 @@ func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (Cli // Update - Updates deployment script tags with specified values. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2020-10-01 +// Generated from API version 2023-08-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - scriptName - Name of the deployment script. // - options - ClientUpdateOptions contains the optional parameters for the Client.Update method. @@ -535,7 +535,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2020-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.DeploymentScript != nil { diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/client_example_test.go b/sdk/resourcemanager/resources/armdeploymentscripts/client_example_test.go deleted file mode 100644 index 75d13041bcef..000000000000 --- a/sdk/resourcemanager/resources/armdeploymentscripts/client_example_test.go +++ /dev/null @@ -1,764 +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 armdeploymentscripts_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/resources/armdeploymentscripts/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create.json -func ExampleClient_BeginCreate_deploymentScriptsCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{ - Identity: &armdeploymentscripts.ManagedServiceIdentity{ - Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}, - }, - }, - Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - Location: to.Ptr("westus"), - Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - RetentionInterval: to.Ptr("PT7D"), - ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - SupportingScriptUris: []*string{ - to.Ptr("https://uri1.to.supporting.script"), - to.Ptr("https://uri2.to.supporting.script")}, - Timeout: to.Ptr("PT1H"), - AzPowerShellVersion: to.Ptr("1.7.0"), - }, - }, 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 = armdeploymentscripts.ClientCreateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_No_UserManagedIdentity.json -func ExampleClient_BeginCreate_deploymentScriptsCreateNoUserManagedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{ - Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - Location: to.Ptr("westus"), - Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - RetentionInterval: to.Ptr("PT7D"), - ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - SupportingScriptUris: []*string{ - to.Ptr("https://uri1.to.supporting.script"), - to.Ptr("https://uri2.to.supporting.script")}, - Timeout: to.Ptr("PT1H"), - AzPowerShellVersion: to.Ptr("1.7.0"), - }, - }, 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 = armdeploymentscripts.ClientCreateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Min_Create.json -func ExampleClient_BeginCreate_deploymentScriptsCreateMinCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{ - Identity: &armdeploymentscripts.ManagedServiceIdentity{ - Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}, - }, - }, - Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - Location: to.Ptr("westus"), - Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - RetentionInterval: to.Ptr("P7D"), - ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - AzPowerShellVersion: to.Ptr("1.7.0"), - }, - }, 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 = armdeploymentscripts.ClientCreateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Custom_Aci_Name.json -func ExampleClient_BeginCreate_deploymentScriptsCreateUsingCustomAciName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{ - Identity: &armdeploymentscripts.ManagedServiceIdentity{ - Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}, - }, - }, - Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - Location: to.Ptr("westus"), - Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - ContainerSettings: &armdeploymentscripts.ContainerConfiguration{ - ContainerGroupName: to.Ptr("contoso-aci"), - }, - Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - RetentionInterval: to.Ptr("PT7D"), - ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - SupportingScriptUris: []*string{ - to.Ptr("https://uri1.to.supporting.script"), - to.Ptr("https://uri2.to.supporting.script")}, - Timeout: to.Ptr("PT1H"), - AzPowerShellVersion: to.Ptr("1.7.0"), - }, - }, 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 = armdeploymentscripts.ClientCreateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // ContainerSettings: &armdeploymentscripts.ContainerConfiguration{ - // ContainerGroupName: to.Ptr("contoso-aci"), - // }, - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Create_Using_Existing_StorageAccount.json -func ExampleClient_BeginCreate_deploymentScriptsCreateUsingExistingStorageAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreate(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.AzurePowerShellScript{ - Identity: &armdeploymentscripts.ManagedServiceIdentity{ - Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": {}, - }, - }, - Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - Location: to.Ptr("westus"), - Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - StorageAccountSettings: &armdeploymentscripts.StorageAccountConfiguration{ - StorageAccountKey: to.Ptr("contosostoragekey"), - StorageAccountName: to.Ptr("contosostorage"), - }, - Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - RetentionInterval: to.Ptr("PT7D"), - ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - SupportingScriptUris: []*string{ - to.Ptr("https://uri1.to.supporting.script"), - to.Ptr("https://uri2.to.supporting.script")}, - Timeout: to.Ptr("PT1H"), - AzPowerShellVersion: to.Ptr("1.7.0"), - }, - }, 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 = armdeploymentscripts.ClientCreateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // StorageAccountSettings: &armdeploymentscripts.StorageAccountConfiguration{ - // StorageAccountName: to.Ptr("contosostorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Update.json -func ExampleClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Update(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.ClientUpdateOptions{DeploymentScript: &armdeploymentscripts.DeploymentScriptUpdateParameter{ - Tags: map[string]*string{}, - }, - }) - 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 = armdeploymentscripts.ClientUpdateResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // SystemData: &armdeploymentscripts.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // }, - // Tags: map[string]*string{ - // }, - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Get.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "script-rg", "MyDeploymentScript", 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 = armdeploymentscripts.ClientGetResponse{ - // DeploymentScriptClassification: &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // SystemData: &armdeploymentscripts.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // }, - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("PT7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Delete.json -func ExampleClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewClient().Delete(ctx, "script-rg", "MyDeploymentScript", 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/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListBySubscription.json -func ExampleClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListBySubscriptionPager(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.DeploymentScriptListResult = armdeploymentscripts.DeploymentScriptListResult{ - // Value: []armdeploymentscripts.DeploymentScriptClassification{ - // &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // SystemData: &armdeploymentscripts.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // }, - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("PT7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_GetLogs.json -func ExampleClient_GetLogs() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetLogs(ctx, "script-rg", "MyDeploymentScript", 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.ScriptLogsList = armdeploymentscripts.ScriptLogsList{ - // Value: []*armdeploymentscripts.ScriptLog{ - // { - // Properties: &armdeploymentscripts.LogProperties{ - // Log: to.Ptr("script execution stdout/stderr logs"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_GetLogsDefault.json -func ExampleClient_GetLogsDefault_deploymentScriptsGetLogs() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetLogsDefault(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.ClientGetLogsDefaultOptions{Tail: 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.ScriptLog = armdeploymentscripts.ScriptLog{ - // Properties: &armdeploymentscripts.LogProperties{ - // Log: to.Ptr("script execution stdout/stderr logs"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_GetLogsDefaultWithTail.json -func ExampleClient_GetLogsDefault_deploymentScriptsGetLogsWithTail() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetLogsDefault(ctx, "script-rg", "MyDeploymentScript", &armdeploymentscripts.ClientGetLogsDefaultOptions{Tail: to.Ptr[int32](5)}) - 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.ScriptLog = armdeploymentscripts.ScriptLog{ - // Properties: &armdeploymentscripts.LogProperties{ - // Log: to.Ptr("script execution stdout/stderr logs"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListByResourceGroup.json -func ExampleClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentscripts.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListByResourceGroupPager("script-rg", 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.DeploymentScriptListResult = armdeploymentscripts.DeploymentScriptListResult{ - // Value: []armdeploymentscripts.DeploymentScriptClassification{ - // &armdeploymentscripts.AzurePowerShellScript{ - // Identity: &armdeploymentscripts.ManagedServiceIdentity{ - // Type: to.Ptr(armdeploymentscripts.ManagedServiceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armdeploymentscripts.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai": &armdeploymentscripts.UserAssignedIdentity{ - // }, - // }, - // }, - // Kind: to.Ptr(armdeploymentscripts.ScriptTypeAzurePowerShell), - // Location: to.Ptr("westus"), - // SystemData: &armdeploymentscripts.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentscripts.CreatedByTypeApplication), - // }, - // Properties: &armdeploymentscripts.AzurePowerShellScriptProperties{ - // CleanupPreference: to.Ptr(armdeploymentscripts.CleanupOptionsAlways), - // Outputs: map[string]any{ - // "output1": "value1", - // }, - // ProvisioningState: to.Ptr(armdeploymentscripts.ScriptProvisioningStateSucceeded), - // Status: &armdeploymentscripts.ScriptStatus{ - // ContainerInstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ContainerInstance/containerGroups/scriptContainer"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-11-13T23:19:45.000Z"); return t}()), - // StorageAccountID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.Storage/storageAccounts/scriptStorage"), - // }, - // Arguments: to.Ptr("-Location 'westus' -Name \"*rg2\""), - // RetentionInterval: to.Ptr("P7D"), - // ScriptContent: to.Ptr("Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name"), - // SupportingScriptUris: []*string{ - // to.Ptr("https://uri1.to.supporting.script"), - // to.Ptr("https://uri2.to.supporting.script")}, - // Timeout: to.Ptr("PT1H"), - // AzPowerShellVersion: to.Ptr("1.7.0"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/client_factory.go b/sdk/resourcemanager/resources/armdeploymentscripts/client_factory.go index 893af5932ce8..63489c8cb75e 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/client_factory.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/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. @@ -27,18 +26,20 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/constants.go b/sdk/resourcemanager/resources/armdeploymentscripts/constants.go index 17c2820265ca..4a33c9e0c491 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/constants.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/constants.go @@ -10,7 +10,7 @@ package armdeploymentscripts const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentscripts" - moduleVersion = "v2.1.0" + moduleVersion = "v2.2.0" ) // CleanupOptions - The clean up preference when the script execution gets in a terminal state. Default setting is 'Always'. diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/fake/polymorphic_helpers.go b/sdk/resourcemanager/resources/armdeploymentscripts/fake/polymorphic_helpers.go index 7a3434cc17f1..1dbec4b82472 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/fake/polymorphic_helpers.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/fake/polymorphic_helpers.go @@ -14,7 +14,7 @@ import ( ) func unmarshalDeploymentScriptClassification(rawMsg json.RawMessage) (armdeploymentscripts.DeploymentScriptClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armdeploymentscripts/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/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/resources/armdeploymentscripts/go.mod b/sdk/resourcemanager/resources/armdeploymentscripts/go.mod index f0397b1b41d9..f534fbe8fa6f 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/go.mod +++ b/sdk/resourcemanager/resources/armdeploymentscripts/go.mod @@ -4,7 +4,6 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v0.6.0 @@ -13,6 +12,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/models.go b/sdk/resourcemanager/resources/armdeploymentscripts/models.go index 8722a4717a31..8111c1ba787f 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/models.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/models.go @@ -224,6 +224,18 @@ type ContainerConfiguration struct { // } }. If you do not want to specify a 'containerGroupName' then do not // add 'containerSettings' property. ContainerGroupName *string + + // The subnet resource IDs for a container group. + SubnetIDs []*ContainerGroupSubnetID +} + +// ContainerGroupSubnetID - Container group subnet information. +type ContainerGroupSubnetID struct { + // REQUIRED; Resource ID of subnet. + ID *string + + // Friendly name for the subnet. + Name *string } // DeploymentScript - Deployment script object. diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/models_serde.go b/sdk/resourcemanager/resources/armdeploymentscripts/models_serde.go index a4b8dc462d2a..971be35980dc 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/models_serde.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/models_serde.go @@ -338,6 +338,7 @@ func (a *AzureResourceBase) UnmarshalJSON(data []byte) error { func (c ContainerConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "containerGroupName", c.ContainerGroupName) + populate(objectMap, "subnetIds", c.SubnetIDs) return json.Marshal(objectMap) } @@ -353,6 +354,40 @@ func (c *ContainerConfiguration) UnmarshalJSON(data []byte) error { case "containerGroupName": err = unpopulate(val, "ContainerGroupName", &c.ContainerGroupName) delete(rawMsg, key) + case "subnetIds": + err = unpopulate(val, "SubnetIDs", &c.SubnetIDs) + 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 ContainerGroupSubnetID. +func (c ContainerGroupSubnetID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerGroupSubnetID. +func (c *ContainerGroupSubnetID) 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 "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -927,7 +962,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/resources/armdeploymentscripts/polymorphic_helpers.go b/sdk/resourcemanager/resources/armdeploymentscripts/polymorphic_helpers.go index ab6bf154a2d5..22488df3680c 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/polymorphic_helpers.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/polymorphic_helpers.go @@ -11,7 +11,7 @@ package armdeploymentscripts import "encoding/json" func unmarshalDeploymentScriptClassification(rawMsg json.RawMessage) (DeploymentScriptClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -34,7 +34,7 @@ func unmarshalDeploymentScriptClassification(rawMsg json.RawMessage) (Deployment } func unmarshalDeploymentScriptClassificationArray(rawMsg json.RawMessage) ([]DeploymentScriptClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/response_types.go b/sdk/resourcemanager/resources/armdeploymentscripts/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armdeploymentscripts/response_types.go rename to sdk/resourcemanager/resources/armdeploymentscripts/responses.go diff --git a/sdk/resourcemanager/resources/armdeploymentscripts/time_rfc3339.go b/sdk/resourcemanager/resources/armdeploymentscripts/time_rfc3339.go index b1f88d20041a..692c6870b774 100644 --- a/sdk/resourcemanager/resources/armdeploymentscripts/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armdeploymentscripts/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/resources/armdeploymentstacks/CHANGELOG.md b/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md index cfc50ca01af0..b30b2cd715e1 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.2.1 (2024-05-02) +### Other Changes + + ## 0.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md index 119d23bdf762..52799647abe9 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md +++ b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.0 +module-version: 0.2.1 package-deploymentstacks: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/client.go b/sdk/resourcemanager/resources/armdeploymentstacks/client.go index e8766dabf590..a4706b08a546 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/client.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/client.go @@ -346,16 +346,16 @@ func (client *Client) deleteAtManagementGroupCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.UnmanageActionResources != nil { - reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.UnmanageActionManagementGroups != nil { + reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) } if options != nil && options.UnmanageActionResourceGroups != nil { reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) } - if options != nil && options.UnmanageActionManagementGroups != nil { - reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) } - reqQP.Set("api-version", "2022-08-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -434,13 +434,13 @@ func (client *Client) deleteAtResourceGroupCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.UnmanageActionResources != nil { - reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) - } + reqQP.Set("api-version", "2022-08-01-preview") if options != nil && options.UnmanageActionResourceGroups != nil { reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) } - reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -513,13 +513,13 @@ func (client *Client) deleteAtSubscriptionCreateRequest(ctx context.Context, dep return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.UnmanageActionResources != nil { - reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) - } + reqQP.Set("api-version", "2022-08-01-preview") if options != nil && options.UnmanageActionResourceGroups != nil { reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) } - reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/client_example_test.go b/sdk/resourcemanager/resources/armdeploymentstacks/client_example_test.go deleted file mode 100644 index e742cef73e28..000000000000 --- a/sdk/resourcemanager/resources/armdeploymentstacks/client_example_test.go +++ /dev/null @@ -1,1088 +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 armdeploymentstacks_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/resources/armdeploymentstacks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackResourceGroupList.json -func ExampleClient_NewListAtResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListAtResourceGroupPager("deploymentStacksRG", 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.DeploymentStackListResult = armdeploymentstacks.DeploymentStackListResult{ - // Value: []*armdeploymentstacks.DeploymentStack{ - // { - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }, - // { - // Name: to.Ptr("simpleDeploymentStack2"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack2"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deployments/simpleDeploymentStack2-20210301-3f41c"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-2222-2222-2222-000000000000/resourceGroups/templateSpecsRG/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackSubscriptionList.json -func ExampleClient_NewListAtSubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListAtSubscriptionPager(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.DeploymentStackListResult = armdeploymentstacks.DeploymentStackListResult{ - // Value: []*armdeploymentstacks.DeploymentStack{ - // { - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }, - // { - // Name: to.Ptr("simpleDeploymentStack2"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack2"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deployments/simpleDeploymentStack2-20210301-3f41c"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-2222-2222-2222-000000000000/resourceGroups/templateSpecsRG/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackManagementGroupList.json -func ExampleClient_NewListAtManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListAtManagementGroupPager("myMg", 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.DeploymentStackListResult = armdeploymentstacks.DeploymentStackListResult{ - // Value: []*armdeploymentstacks.DeploymentStack{ - // { - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }, - // { - // Name: to.Ptr("simpleDeploymentStack2"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack2"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deployments/simpleDeploymentStack2-20210301-3f41c"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackResourceGroupCreate.json -func ExampleClient_BeginCreateOrUpdateAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreateOrUpdateAtResourceGroup(ctx, "deploymentStacksRG", "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Location: to.Ptr("eastus"), - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - }, - DenySettings: &armdeploymentstacks.DenySettings{ - ApplyToChildScopes: to.Ptr(false), - ExcludedActions: []*string{ - to.Ptr("action")}, - ExcludedPrincipals: []*string{ - to.Ptr("principal")}, - Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - }, - Parameters: map[string]any{ - "parameter1": map[string]any{ - "value": "a string", - }, - }, - }, - Tags: map[string]*string{ - "tagkey": to.Ptr("tagVal"), - }, - }, 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackResourceGroupGet.json -func ExampleClient_GetAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetAtResourceGroup(ctx, "deploymentStacksRG", "simpleDeploymentStack", 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deployments/simpleDeploymentStack-20210301-3f41c"), - // DeploymentScope: to.Ptr("/subscriptions/00000000-1111-1111-1111-000000000000"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-2222-2222-2222-000000000000/resourceGroups/templateSpecsRG/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackResourceGroupDelete.json -func ExampleClient_BeginDeleteAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginDeleteAtResourceGroup(ctx, "deploymentStacksRG", "simpleDeploymentStack", &armdeploymentstacks.ClientBeginDeleteAtResourceGroupOptions{UnmanageActionResources: nil, - UnmanageActionResourceGroups: 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/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackSubscriptionCreate.json -func ExampleClient_BeginCreateOrUpdateAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreateOrUpdateAtSubscription(ctx, "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Location: to.Ptr("eastus"), - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - }, - DenySettings: &armdeploymentstacks.DenySettings{ - ApplyToChildScopes: to.Ptr(false), - ExcludedActions: []*string{ - to.Ptr("action")}, - ExcludedPrincipals: []*string{ - to.Ptr("principal")}, - Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - }, - Parameters: map[string]any{ - "parameter1": map[string]any{ - "value": "a string", - }, - }, - }, - Tags: map[string]*string{ - "tagkey": to.Ptr("tagVal"), - }, - }, 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackSubscriptionGet.json -func ExampleClient_GetAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetAtSubscription(ctx, "simpleDeploymentStack", 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/deployments/simpleDeploymentStack-20210301-3f41c"), - // DeploymentScope: to.Ptr("/subscriptions/00000000-1111-1111-1111-000000000000"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-2222-2222-2222-000000000000/resourceGroups/templateSpecsRG/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackSubscriptionDelete.json -func ExampleClient_BeginDeleteAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginDeleteAtSubscription(ctx, "simpleDeploymentStack", &armdeploymentstacks.ClientBeginDeleteAtSubscriptionOptions{UnmanageActionResources: nil, - UnmanageActionResourceGroups: 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/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackManagementGroupCreate.json -func ExampleClient_BeginCreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginCreateOrUpdateAtManagementGroup(ctx, "myMg", "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Location: to.Ptr("eastus"), - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - }, - DenySettings: &armdeploymentstacks.DenySettings{ - ApplyToChildScopes: to.Ptr(false), - ExcludedActions: []*string{ - to.Ptr("action")}, - ExcludedPrincipals: []*string{ - to.Ptr("principal")}, - Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - }, - Parameters: map[string]any{ - "parameter1": map[string]any{ - "value": "a string", - }, - }, - }, - Tags: map[string]*string{ - "tagkey": to.Ptr("tagVal"), - }, - }, 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackManagementGroupGet.json -func ExampleClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetAtManagementGroup(ctx, "myMg", "simpleDeploymentStack", 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.DeploymentStack = armdeploymentstacks.DeploymentStack{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // SystemData: &armdeploymentstacks.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armdeploymentstacks.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armdeploymentstacks.DeploymentStackProperties{ - // Description: to.Ptr("my Description"), - // ActionOnUnmanage: &armdeploymentstacks.DeploymentStackPropertiesActionOnUnmanage{ - // ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - // ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - // }, - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deployments/simpleDeploymentStack-20210301-3f41c"), - // DeploymentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg"), - // Duration: to.Ptr("PT1D12H"), - // Outputs: map[string]any{ - // "myOut": "myVal", - // }, - // Parameters: map[string]any{ - // "parameter1":map[string]any{ - // "value": "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningStateSucceeded), - // Resources: []*armdeploymentstacks.ManagedResourceReference{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }, - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), - // DenyStatus: to.Ptr(armdeploymentstacks.DenyStatusModeDenyDelete), - // Status: to.Ptr(armdeploymentstacks.ResourceStatusModeManaged), - // }}, - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackManagementGroupDelete.json -func ExampleClient_BeginDeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewClient().BeginDeleteAtManagementGroup(ctx, "myMg", "simpleDeploymentStack", &armdeploymentstacks.ClientBeginDeleteAtManagementGroupOptions{UnmanageActionResources: nil, - UnmanageActionResourceGroups: nil, - UnmanageActionManagementGroups: 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/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackExportTemplate.json -func ExampleClient_ExportTemplateAtResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().ExportTemplateAtResourceGroup(ctx, "deploymentStacksRG", "simpleDeploymentStack", 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.DeploymentStackTemplateDefinition = armdeploymentstacks.DeploymentStackTemplateDefinition{ - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "functions":[]any{ - // }, - // "metadata":map[string]any{ - // "_generator":map[string]any{ - // "name": "bicep", - // "templateHash": "1201162276450656794", - // "version": "0.4.1008.15138", - // }, - // }, - // "outputs":map[string]any{ - // "myOut":map[string]any{ - // "type": "int", - // "value": float64(1), - // }, - // }, - // "resources":[]any{ - // }, - // }, - // TemplateLink: &armdeploymentstacks.TemplateLink{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackSubscriptionExportTemplate.json -func ExampleClient_ExportTemplateAtSubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().ExportTemplateAtSubscription(ctx, "simpleDeploymentStack", 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.DeploymentStackTemplateDefinition = armdeploymentstacks.DeploymentStackTemplateDefinition{ - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "functions":[]any{ - // }, - // "metadata":map[string]any{ - // "_generator":map[string]any{ - // "name": "bicep", - // "templateHash": "1201162276450656794", - // "version": "0.4.1008.15138", - // }, - // }, - // "outputs":map[string]any{ - // "myOut":map[string]any{ - // "type": "int", - // "value": float64(1), - // }, - // }, - // "resources":[]any{ - // }, - // }, - // TemplateLink: &armdeploymentstacks.TemplateLink{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ca162308f1010bfb85b9c85021e863e7bd397a1f/specification/resources/resource-manager/Microsoft.Resources/preview/2022-08-01-preview/examples/DeploymentStackManagementGroupExportTemplate.json -func ExampleClient_ExportTemplateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdeploymentstacks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().ExportTemplateAtManagementGroup(ctx, "myMg", "simpleDeploymentStack", 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.DeploymentStackTemplateDefinition = armdeploymentstacks.DeploymentStackTemplateDefinition{ - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "functions":[]any{ - // }, - // "metadata":map[string]any{ - // "_generator":map[string]any{ - // "name": "bicep", - // "templateHash": "1201162276450656794", - // "version": "0.4.1008.15138", - // }, - // }, - // "outputs":map[string]any{ - // "myOut":map[string]any{ - // "type": "int", - // "value": float64(1), - // }, - // }, - // "resources":[]any{ - // }, - // }, - // TemplateLink: &armdeploymentstacks.TemplateLink{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/templateSpecs/templateSpec/versions/1.0"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go b/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go index 02c56e2557af..ebb2df01fa1e 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/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. @@ -27,18 +26,20 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/constants.go b/sdk/resourcemanager/resources/armdeploymentstacks/constants.go index 2c5fa661de4c..d9d10d9287e0 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/constants.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/constants.go @@ -10,7 +10,7 @@ package armdeploymentstacks const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks" - moduleVersion = "v0.2.0" + moduleVersion = "v0.2.1" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armdeploymentstacks/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/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/resources/armdeploymentstacks/go.mod b/sdk/resourcemanager/resources/armdeploymentstacks/go.mod index e9c285b26ef5..3c6fe4d7998c 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/go.mod +++ b/sdk/resourcemanager/resources/armdeploymentstacks/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploy go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/go.sum b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/go.sum +++ b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/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-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go b/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go index 843a40310164..8242ba301e23 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go @@ -660,7 +660,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/resources/armdeploymentstacks/response_types.go b/sdk/resourcemanager/resources/armdeploymentstacks/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armdeploymentstacks/response_types.go rename to sdk/resourcemanager/resources/armdeploymentstacks/responses.go diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go b/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go index bdfc0231875a..a6355f151f6d 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armdeploymentstacks/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/resources/armfeatures/CHANGELOG.md b/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md index d653480c8669..e2c99fac5b39 100644 --- a/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armfeatures/autorest.md b/sdk/resourcemanager/resources/armfeatures/autorest.md index 1a48abbc75ad..859da4552bad 100644 --- a/sdk/resourcemanager/resources/armfeatures/autorest.md +++ b/sdk/resourcemanager/resources/armfeatures/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-features: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armfeatures/client_example_test.go b/sdk/resourcemanager/resources/armfeatures/client_example_test.go deleted file mode 100644 index 3a2e23b144cb..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/client_example_test.go +++ /dev/null @@ -1,190 +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 armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json -func ExampleClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListAllPager(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.FeatureOperationsListResult = armfeatures.FeatureOperationsListResult{ - // Value: []*armfeatures.FeatureResult{ - // { - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // }, - // { - // Name: to.Ptr("Feature2"), - // Type: to.Ptr("type2"), - // ID: to.Ptr("feature_id2"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListPager("Resource Provider Namespace", 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.FeatureOperationsListResult = armfeatures.FeatureOperationsListResult{ - // Value: []*armfeatures.FeatureResult{ - // { - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // }, - // { - // Name: to.Ptr("Feature2"), - // Type: to.Ptr("type2"), - // ID: to.Ptr("feature_id2"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json -func ExampleClient_Register() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Register(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("type1"), - // ID: to.Ptr("feature_id1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("registered"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json -func ExampleClient_Unregister() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Unregister(ctx, "Resource Provider Namespace", "feature", 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.FeatureResult = armfeatures.FeatureResult{ - // Name: to.Ptr("Feature1"), - // Type: to.Ptr("Microsoft.Features/providers/features"), - // ID: to.Ptr("/subscriptions/ff23096b-f5a2-46ea-bd62-59c3e93fef9a/providers/Microsoft.Features/providers/Microsoft.Test/features/Feature1"), - // Properties: &armfeatures.FeatureProperties{ - // State: to.Ptr("unregistered"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armfeatures/client_factory.go b/sdk/resourcemanager/resources/armfeatures/client_factory.go index 9b131cfb4178..1f3d5c2a6270 100644 --- a/sdk/resourcemanager/resources/armfeatures/client_factory.go +++ b/sdk/resourcemanager/resources/armfeatures/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. @@ -27,30 +26,35 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewFeatureClient creates a new instance of FeatureClient. func (c *ClientFactory) NewFeatureClient() *FeatureClient { - subClient, _ := NewFeatureClient(c.credential, c.options) - return subClient + return &FeatureClient{ + internal: c.internal, + } } // NewSubscriptionFeatureRegistrationsClient creates a new instance of SubscriptionFeatureRegistrationsClient. func (c *ClientFactory) NewSubscriptionFeatureRegistrationsClient() *SubscriptionFeatureRegistrationsClient { - subClient, _ := NewSubscriptionFeatureRegistrationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SubscriptionFeatureRegistrationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armfeatures/constants.go b/sdk/resourcemanager/resources/armfeatures/constants.go index eb6e8a88741a..3f4956a88ea1 100644 --- a/sdk/resourcemanager/resources/armfeatures/constants.go +++ b/sdk/resourcemanager/resources/armfeatures/constants.go @@ -10,7 +10,7 @@ package armfeatures const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // SubscriptionFeatureRegistrationApprovalType - The feature approval type. diff --git a/sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armfeatures/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armfeatures/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/resources/armfeatures/feature_client_example_test.go b/sdk/resourcemanager/resources/armfeatures/feature_client_example_test.go deleted file mode 100644 index bd2c269e9cdb..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/feature_client_example_test.go +++ /dev/null @@ -1,62 +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 armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json -func ExampleFeatureClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFeatureClient().NewListOperationsPager(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 = armfeatures.OperationListResult{ - // Value: []*armfeatures.Operation{ - // { - // Name: to.Ptr("FeaturesOpeartion1"), - // Display: &armfeatures.OperationDisplay{ - // Operation: to.Ptr("Read"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource1"), - // }, - // }, - // { - // Name: to.Ptr("FeaturesOpeartion2"), - // Display: &armfeatures.OperationDisplay{ - // Operation: to.Ptr("Write"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource2"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armfeatures/go.mod b/sdk/resourcemanager/resources/armfeatures/go.mod index a89bc2938d1a..c588adf67e98 100644 --- a/sdk/resourcemanager/resources/armfeatures/go.mod +++ b/sdk/resourcemanager/resources/armfeatures/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armfeatures/models_serde.go b/sdk/resourcemanager/resources/armfeatures/models_serde.go index ca4a215d3bab..39aef09c7bd3 100644 --- a/sdk/resourcemanager/resources/armfeatures/models_serde.go +++ b/sdk/resourcemanager/resources/armfeatures/models_serde.go @@ -509,7 +509,7 @@ func populate(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/resources/armfeatures/response_types.go b/sdk/resourcemanager/resources/armfeatures/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armfeatures/response_types.go rename to sdk/resourcemanager/resources/armfeatures/responses.go diff --git a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go b/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go deleted file mode 100644 index ec2ff1c617b1..000000000000 --- a/sdk/resourcemanager/resources/armfeatures/subscriptionfeatureregistrations_client_example_test.go +++ /dev/null @@ -1,198 +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 armfeatures_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armfeatures" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json -func ExampleSubscriptionFeatureRegistrationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionFeatureRegistrationsClient().Get(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", 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.SubscriptionFeatureRegistration = armfeatures.SubscriptionFeatureRegistration{ - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json -func ExampleSubscriptionFeatureRegistrationsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionFeatureRegistrationsClient().CreateOrUpdate(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", &armfeatures.SubscriptionFeatureRegistrationsClientCreateOrUpdateOptions{SubscriptionFeatureRegistrationType: &armfeatures.SubscriptionFeatureRegistration{ - Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{}, - }, - }) - 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.SubscriptionFeatureRegistration = armfeatures.SubscriptionFeatureRegistration{ - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json -func ExampleSubscriptionFeatureRegistrationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSubscriptionFeatureRegistrationsClient().Delete(ctx, "subscriptionFeatureRegistrationGroupTestRG", "testFeature", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json -func ExampleSubscriptionFeatureRegistrationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionFeatureRegistrationsClient().NewListBySubscriptionPager("subscriptionFeatureRegistrationGroupTestRG", 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.SubscriptionFeatureRegistrationList = armfeatures.SubscriptionFeatureRegistrationList{ - // Value: []*armfeatures.SubscriptionFeatureRegistration{ - // { - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json -func ExampleSubscriptionFeatureRegistrationsClient_NewListAllBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armfeatures.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSubscriptionFeatureRegistrationsClient().NewListAllBySubscriptionPager(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.SubscriptionFeatureRegistrationList = armfeatures.SubscriptionFeatureRegistrationList{ - // Value: []*armfeatures.SubscriptionFeatureRegistration{ - // { - // Name: to.Ptr("testFeature"), - // Type: to.Ptr("Microsoft.Features/featureProviders/subscriptionFeatureRegistrations"), - // ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Features/featureProviders/Microsoft.TestRP/subscriptionFeatureRegistrations/testFeature"), - // Properties: &armfeatures.SubscriptionFeatureRegistrationProperties{ - // ApprovalType: to.Ptr(armfeatures.SubscriptionFeatureRegistrationApprovalTypeApprovalRequired), - // AuthorizationProfile: &armfeatures.AuthorizationProfile{ - // }, - // FeatureName: to.Ptr("testFeature"), - // ProviderNamespace: to.Ptr("Microsoft.TestRP"), - // RegistrationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-26T01:57:51.734Z"); return t}()), - // ReleaseDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-05T00:34:53.124Z"); return t}()), - // State: to.Ptr(armfeatures.SubscriptionFeatureRegistrationStatePending), - // SubscriptionID: to.Ptr("00000000-1111-2222-3333-444444444444"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go b/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go index 19d49fb2bc17..d78c654ff21d 100644 --- a/sdk/resourcemanager/resources/armfeatures/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armfeatures/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/resources/armlinks/CHANGELOG.md b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md index 29bb7be8f7bd..d3d7e3cc6bee 100644 --- a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armlinks/autorest.md b/sdk/resourcemanager/resources/armlinks/autorest.md index cd3b42a8b2b7..87be6eb06de5 100644 --- a/sdk/resourcemanager/resources/armlinks/autorest.md +++ b/sdk/resourcemanager/resources/armlinks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-links: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlinks/client_factory.go b/sdk/resourcemanager/resources/armlinks/client_factory.go index d2403f979d20..ac068cfdf468 100644 --- a/sdk/resourcemanager/resources/armlinks/client_factory.go +++ b/sdk/resourcemanager/resources/armlinks/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. @@ -27,24 +26,27 @@ 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 } // 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, + } } // NewResourceLinksClient creates a new instance of ResourceLinksClient. func (c *ClientFactory) NewResourceLinksClient() *ResourceLinksClient { - subClient, _ := NewResourceLinksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ResourceLinksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armlinks/constants.go b/sdk/resourcemanager/resources/armlinks/constants.go index 754be60ee9b1..b35cffe28cee 100644 --- a/sdk/resourcemanager/resources/armlinks/constants.go +++ b/sdk/resourcemanager/resources/armlinks/constants.go @@ -10,5 +10,5 @@ package armlinks const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) diff --git a/sdk/resourcemanager/resources/armlinks/models_serde.go b/sdk/resourcemanager/resources/armlinks/models_serde.go index acdd748cf488..613540984cd3 100644 --- a/sdk/resourcemanager/resources/armlinks/models_serde.go +++ b/sdk/resourcemanager/resources/armlinks/models_serde.go @@ -269,7 +269,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/resources/armlinks/response_types.go b/sdk/resourcemanager/resources/armlinks/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armlinks/response_types.go rename to sdk/resourcemanager/resources/armlinks/responses.go diff --git a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md index f642f9e83509..e25d1aea3b28 100644 --- a/sdk/resourcemanager/resources/armlocks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlocks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go b/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go deleted file mode 100644 index 8113cd1323bc..000000000000 --- a/sdk/resourcemanager/resources/armlocks/authorizationoperations_client_example_test.go +++ /dev/null @@ -1,54 +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 armlocks_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json -func ExampleAuthorizationOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAuthorizationOperationsClient().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 = armlocks.OperationListResult{ - // Value: []*armlocks.Operation{ - // { - // Name: to.Ptr("Microsoft.Authorization/locks/read"), - // Display: &armlocks.OperationDisplay{ - // Operation: to.Ptr("read"), - // Provider: to.Ptr("Microsoft.Authorization"), - // Resource: to.Ptr("locks"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/autorest.md b/sdk/resourcemanager/resources/armlocks/autorest.md index 7217053d37ca..b09e7157848e 100644 --- a/sdk/resourcemanager/resources/armlocks/autorest.md +++ b/sdk/resourcemanager/resources/armlocks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-locks: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlocks/client_factory.go b/sdk/resourcemanager/resources/armlocks/client_factory.go index ede49372b654..a9669d32d49f 100644 --- a/sdk/resourcemanager/resources/armlocks/client_factory.go +++ b/sdk/resourcemanager/resources/armlocks/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. @@ -27,24 +26,27 @@ 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 } // NewAuthorizationOperationsClient creates a new instance of AuthorizationOperationsClient. func (c *ClientFactory) NewAuthorizationOperationsClient() *AuthorizationOperationsClient { - subClient, _ := NewAuthorizationOperationsClient(c.credential, c.options) - return subClient + return &AuthorizationOperationsClient{ + internal: c.internal, + } } // NewManagementLocksClient creates a new instance of ManagementLocksClient. func (c *ClientFactory) NewManagementLocksClient() *ManagementLocksClient { - subClient, _ := NewManagementLocksClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ManagementLocksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armlocks/constants.go b/sdk/resourcemanager/resources/armlocks/constants.go index f54d3758f0cd..4717988aae91 100644 --- a/sdk/resourcemanager/resources/armlocks/constants.go +++ b/sdk/resourcemanager/resources/armlocks/constants.go @@ -10,7 +10,7 @@ package armlocks const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armlocks/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armlocks/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/resources/armlocks/go.mod b/sdk/resourcemanager/resources/armlocks/go.mod index b4fb2dd8c5ee..2e0445672cde 100644 --- a/sdk/resourcemanager/resources/armlocks/go.mod +++ b/sdk/resourcemanager/resources/armlocks/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlocks go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armlocks/go.sum b/sdk/resourcemanager/resources/armlocks/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/resources/armlocks/go.sum +++ b/sdk/resourcemanager/resources/armlocks/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/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-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go b/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go deleted file mode 100644 index 1458096d49a9..000000000000 --- a/sdk/resourcemanager/resources/armlocks/managementlocks_client_example_test.go +++ /dev/null @@ -1,471 +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 armlocks_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/resources/armlocks" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json -func ExampleManagementLocksClient_DeleteAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json -func ExampleManagementLocksClient_GetAtResourceGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtResourceGroupLevel(ctx, "resourcegroupname", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json -func ExampleManagementLocksClient_CreateOrUpdateByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateByScope(ctx, "subscriptions/subscriptionId", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json -func ExampleManagementLocksClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteByScope(ctx, "subscriptions/subscriptionId", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json -func ExampleManagementLocksClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetByScope(ctx, "subscriptions/subscriptionId", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json -func ExampleManagementLocksClient_DeleteAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json -func ExampleManagementLocksClient_GetAtResourceLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtResourceLevel(ctx, "resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json -func ExampleManagementLocksClient_CreateOrUpdateAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().CreateOrUpdateAtSubscriptionLevel(ctx, "testlock", armlocks.ManagementLockObject{ - Properties: &armlocks.ManagementLockProperties{ - Level: to.Ptr(armlocks.LockLevelReadOnly), - }, - }, 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json -func ExampleManagementLocksClient_DeleteAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewManagementLocksClient().DeleteAtSubscriptionLevel(ctx, "testlock", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json -func ExampleManagementLocksClient_GetAtSubscriptionLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewManagementLocksClient().GetAtSubscriptionLevel(ctx, "testlock", 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.ManagementLockObject = armlocks.ManagementLockObject{ - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json -func ExampleManagementLocksClient_NewListAtResourceGroupLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtResourceGroupLevelPager("resourcegroupname", &armlocks.ManagementLocksClientListAtResourceGroupLevelOptions{Filter: 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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json -func ExampleManagementLocksClient_NewListAtResourceLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtResourceLevelPager("resourcegroupname", "Microsoft.Storage", "parentResourcePath", "storageAccounts", "teststorageaccount", &armlocks.ManagementLocksClientListAtResourceLevelOptions{Filter: 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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json -func ExampleManagementLocksClient_NewListAtSubscriptionLevelPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListAtSubscriptionLevelPager(&armlocks.ManagementLocksClientListAtSubscriptionLevelOptions{Filter: 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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json -func ExampleManagementLocksClient_NewListByScopePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armlocks.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewManagementLocksClient().NewListByScopePager("subscriptions/subscriptionId", &armlocks.ManagementLocksClientListByScopeOptions{Filter: 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.ManagementLockListResult = armlocks.ManagementLockListResult{ - // Value: []*armlocks.ManagementLockObject{ - // { - // Name: to.Ptr("testlock"), - // Type: to.Ptr("Microsoft.Authorization/locks"), - // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock"), - // Properties: &armlocks.ManagementLockProperties{ - // Level: to.Ptr(armlocks.LockLevelReadOnly), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armlocks/models_serde.go b/sdk/resourcemanager/resources/armlocks/models_serde.go index 238ddc6ac501..4c642c3b8597 100644 --- a/sdk/resourcemanager/resources/armlocks/models_serde.go +++ b/sdk/resourcemanager/resources/armlocks/models_serde.go @@ -417,7 +417,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/resources/armlocks/response_types.go b/sdk/resourcemanager/resources/armlocks/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armlocks/response_types.go rename to sdk/resourcemanager/resources/armlocks/responses.go diff --git a/sdk/resourcemanager/resources/armlocks/time_rfc3339.go b/sdk/resourcemanager/resources/armlocks/time_rfc3339.go index 043a6952fc7a..aaaadf1f4634 100644 --- a/sdk/resourcemanager/resources/armlocks/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armlocks/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/resources/armmanagedapplications/CHANGELOG.md b/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md index 2bb309ae12ac..6f272c9b5a50 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armmanagedapplications/README.md b/sdk/resourcemanager/resources/armmanagedapplications/README.md index 1812126f3657..2b628c014d9b 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/README.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/README.md @@ -57,7 +57,7 @@ clientFactory, err := armmanagedapplications.NewClientFactory(, 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.NewApplicationClient() +client := clientFactory.NewApplicationDefinitionsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go deleted file mode 100644 index a65aa4faf1de..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/application_client_example_test.go +++ /dev/null @@ -1,62 +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 armmanagedapplications_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json -func ExampleApplicationClient_NewListOperationsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationClient().NewListOperationsPager(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 = armmanagedapplications.OperationListResult{ - // Value: []*armmanagedapplications.Operation{ - // { - // Name: to.Ptr("SolutionsOpeartion1"), - // Display: &armmanagedapplications.OperationDisplay{ - // Operation: to.Ptr("Read"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource1"), - // }, - // }, - // { - // Name: to.Ptr("SolutionssOpeartion2"), - // Display: &armmanagedapplications.OperationDisplay{ - // Operation: to.Ptr("Write"), - // Provider: to.Ptr("Microsoft.ResourceProvider"), - // Resource: to.Ptr("Resource2"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go deleted file mode 100644 index 2cc2e38b19b3..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/applicationdefinitions_client_example_test.go +++ /dev/null @@ -1,237 +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 armmanagedapplications_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/resources/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json -func ExampleApplicationDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationDefinitionsClient().Get(ctx, "rg", "myManagedApplicationDef", 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.ApplicationDefinition = armmanagedapplications.ApplicationDefinition{ - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationDefinitionsClient().BeginDelete(ctx, "rg", "myManagedApplicationDef", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json -func ExampleApplicationDefinitionsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationDefinitionsClient().BeginCreateOrUpdate(ctx, "rg", "myManagedApplicationDef", armmanagedapplications.ApplicationDefinition{ - Location: to.Ptr("East US 2"), - Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - Description: to.Ptr("myManagedApplicationDef description"), - Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - { - PrincipalID: to.Ptr("validprincipalguid"), - RoleDefinitionID: to.Ptr("validroleguid"), - }}, - DisplayName: to.Ptr("myManagedApplicationDef"), - LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - }, - }, 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.ApplicationDefinition = armmanagedapplications.ApplicationDefinition{ - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json -func ExampleApplicationDefinitionsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationDefinitionsClient().NewListByResourceGroupPager("rg", 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.ApplicationDefinitionListResult = armmanagedapplications.ApplicationDefinitionListResult{ - // Value: []*armmanagedapplications.ApplicationDefinition{ - // { - // Name: to.Ptr("myManagedApplicationDef"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef"), - // Location: to.Ptr("East US 2"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplicationDef2"), - // Type: to.Ptr("Microsoft.Solutions/applicationDefinitions"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myManagedApplicationDef2"), - // Location: to.Ptr("West US"), - // Properties: &armmanagedapplications.ApplicationDefinitionProperties{ - // Description: to.Ptr("myManagedApplicationDef2 description"), - // Artifacts: []*armmanagedapplications.ApplicationArtifact{ - // { - // Name: to.Ptr("CreateUiDefinition"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeCustom), - // URI: to.Ptr("https://path/to/managedApplicationCreateUiDefinition.json"), - // }, - // { - // Name: to.Ptr("ManagedApplicationResourceTemplate"), - // Type: to.Ptr(armmanagedapplications.ApplicationArtifactTypeTemplate), - // URI: to.Ptr("https://path/to/mainTemplate.json"), - // }}, - // Authorizations: []*armmanagedapplications.ApplicationProviderAuthorization{ - // { - // PrincipalID: to.Ptr("validprincipalguid"), - // RoleDefinitionID: to.Ptr("validroleguid"), - // }}, - // DisplayName: to.Ptr("myManagedApplicationDef2"), - // LockLevel: to.Ptr(armmanagedapplications.ApplicationLockLevelNone), - // PackageFileURI: to.Ptr("https://path/to/packagezipfile"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go b/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go deleted file mode 100644 index 63b8f7224a2c..000000000000 --- a/sdk/resourcemanager/resources/armmanagedapplications/applications_client_example_test.go +++ /dev/null @@ -1,381 +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 armmanagedapplications_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/resources/armmanagedapplications" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json -func ExampleApplicationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().Get(ctx, "rg", "myManagedApplication", 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json -func ExampleApplicationsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginDelete(ctx, "rg", "myManagedApplication", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json -func ExampleApplicationsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginCreateOrUpdate(ctx, "rg", "myManagedApplication", armmanagedapplications.Application{ - Location: to.Ptr("East US 2"), - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json -func ExampleApplicationsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().Update(ctx, "rg", "myManagedApplication", &armmanagedapplications.ApplicationsClientUpdateOptions{Parameters: &armmanagedapplications.ApplicationPatchable{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationPropertiesPatchable{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - }) - 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json -func ExampleApplicationsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationsClient().NewListByResourceGroupPager("rg", 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.ApplicationListResult = armmanagedapplications.ApplicationListResult{ - // Value: []*armmanagedapplications.Application{ - // { - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplication2"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication2"), - // Location: to.Ptr("West US"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json -func ExampleApplicationsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplicationsClient().NewListBySubscriptionPager(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.ApplicationListResult = armmanagedapplications.ApplicationListResult{ - // Value: []*armmanagedapplications.Application{ - // { - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("myManagedApplication2"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication2"), - // Location: to.Ptr("West US"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json -func ExampleApplicationsClient_GetByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().GetByID(ctx, "myApplicationId", 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json -func ExampleApplicationsClient_BeginDeleteByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginDeleteByID(ctx, "myApplicationId", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json -func ExampleApplicationsClient_BeginCreateOrUpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewApplicationsClient().BeginCreateOrUpdateByID(ctx, "myApplicationId", armmanagedapplications.Application{ - Location: to.Ptr("East US 2"), - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Location: to.Ptr("East US 2"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json -func ExampleApplicationsClient_UpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagedapplications.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplicationsClient().UpdateByID(ctx, "myApplicationId", &armmanagedapplications.ApplicationsClientUpdateByIDOptions{Parameters: &armmanagedapplications.Application{ - Kind: to.Ptr("ServiceCatalog"), - Properties: &armmanagedapplications.ApplicationProperties{ - ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - }, - }, - }) - 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.Application = armmanagedapplications.Application{ - // Name: to.Ptr("myManagedApplication"), - // Type: to.Ptr("Microsoft.Solutions/applications"), - // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applications/myManagedApplication"), - // Kind: to.Ptr("ServiceCatalog"), - // Properties: &armmanagedapplications.ApplicationProperties{ - // ApplicationDefinitionID: to.Ptr("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - // ManagedResourceGroupID: to.Ptr("/subscriptions/subid/resourceGroups/myManagedRG"), - // ProvisioningState: to.Ptr(armmanagedapplications.ProvisioningStateSucceeded), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armmanagedapplications/autorest.md b/sdk/resourcemanager/resources/armmanagedapplications/autorest.md index 24d811660b16..18eb6db063f2 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/autorest.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-managedapplications: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go b/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go index 7dd85ca82e2b..63af14109285 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/client_factory.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/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. @@ -27,30 +26,35 @@ 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 } // NewApplicationClient creates a new instance of ApplicationClient. func (c *ClientFactory) NewApplicationClient() *ApplicationClient { - subClient, _ := NewApplicationClient(c.credential, c.options) - return subClient + return &ApplicationClient{ + internal: c.internal, + } } // NewApplicationDefinitionsClient creates a new instance of ApplicationDefinitionsClient. func (c *ClientFactory) NewApplicationDefinitionsClient() *ApplicationDefinitionsClient { - subClient, _ := NewApplicationDefinitionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ApplicationDefinitionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewApplicationsClient creates a new instance of ApplicationsClient. func (c *ClientFactory) NewApplicationsClient() *ApplicationsClient { - subClient, _ := NewApplicationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ApplicationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armmanagedapplications/constants.go b/sdk/resourcemanager/resources/armmanagedapplications/constants.go index 0af828198ae9..c559dadcf3ec 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/constants.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/constants.go @@ -10,7 +10,7 @@ package armmanagedapplications const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanagedapplications" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // ApplicationArtifactType - The managed application artifact type. diff --git a/sdk/resourcemanager/resources/armmanagedapplications/go.mod b/sdk/resourcemanager/resources/armmanagedapplications/go.mod index 0591beae37be..bd6e187105d0 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/go.mod +++ b/sdk/resourcemanager/resources/armmanagedapplications/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armmanage go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armmanagedapplications/go.sum b/sdk/resourcemanager/resources/armmanagedapplications/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/go.sum +++ b/sdk/resourcemanager/resources/armmanagedapplications/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/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-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= 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.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go b/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go index bf63041d30f9..45ee34f655d9 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go +++ b/sdk/resourcemanager/resources/armmanagedapplications/models_serde.go @@ -900,7 +900,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/resources/armmanagedapplications/response_types.go b/sdk/resourcemanager/resources/armmanagedapplications/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armmanagedapplications/response_types.go rename to sdk/resourcemanager/resources/armmanagedapplications/responses.go diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index 8f90d906063f..af4238e39538 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,49 @@ # Release History +## 0.10.0 (2024-05-02) +### Features Added + +- New function `*ClientFactory.NewDefinitionVersionsClient() *DefinitionVersionsClient` +- New function `*ClientFactory.NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient` +- New function `NewDefinitionVersionsClient(string, string, string, azcore.TokenCredential, *arm.ClientOptions) (*DefinitionVersionsClient, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdate(context.Context, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Delete(context.Context, *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error)` +- New function `*DefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Get(context.Context, *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error)` +- New function `*DefinitionVersionsClient.GetAtManagementGroup(context.Context, string, *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.GetBuiltIn(context.Context, *DefinitionVersionsClientGetBuiltInOptions) (DefinitionVersionsClientGetBuiltInResponse, error)` +- New function `*DefinitionVersionsClient.ListAll(context.Context, *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error)` +- New function `*DefinitionVersionsClient.ListAllAtManagementGroup(context.Context, string, *DefinitionVersionsClientListAllAtManagementGroupOptions) (DefinitionVersionsClientListAllAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.ListAllBuiltins(context.Context, *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error)` +- New function `*DefinitionVersionsClient.NewListBuiltInPager(*DefinitionVersionsClientListBuiltInOptions) *runtime.Pager[DefinitionVersionsClientListBuiltInResponse]` +- New function `*DefinitionVersionsClient.NewListByManagementGroupPager(string, *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse]` +- New function `*DefinitionVersionsClient.NewListPager(*DefinitionVersionsClientListOptions) *runtime.Pager[DefinitionVersionsClientListResponse]` +- New function `NewSetDefinitionVersionsClient(string, string, string, azcore.TokenCredential, *arm.ClientOptions) (*SetDefinitionVersionsClient, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdate(context.Context, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Delete(context.Context, *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error)` +- New function `*SetDefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Get(context.Context, *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error)` +- New function `*SetDefinitionVersionsClient.GetAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.GetBuiltIn(context.Context, *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAll(context.Context, *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAllAtManagementGroup(context.Context, string, *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.ListAllBuiltins(context.Context, *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error)` +- New function `*SetDefinitionVersionsClient.NewListBuiltInPager(*SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse]` +- New function `*SetDefinitionVersionsClient.NewListByManagementGroupPager(string, *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse]` +- New function `*SetDefinitionVersionsClient.NewListPager(*SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse]` +- New struct `DefinitionVersion` +- New struct `DefinitionVersionListResult` +- New struct `DefinitionVersionProperties` +- New struct `SetDefinitionVersion` +- New struct `SetDefinitionVersionListResult` +- New struct `SetDefinitionVersionProperties` +- New field `Version`, `Versions` in struct `DefinitionProperties` +- New field `Schema` in struct `ParameterDefinitionsValue` +- New field `Version`, `Versions` in struct `SetDefinitionProperties` + + ## 0.9.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armpolicy/README.md b/sdk/resourcemanager/resources/armpolicy/README.md index 0a39dd6a4699..8bc87ec748fc 100644 --- a/sdk/resourcemanager/resources/armpolicy/README.md +++ b/sdk/resourcemanager/resources/armpolicy/README.md @@ -57,7 +57,7 @@ clientFactory, err := armpolicy.NewClientFactory(, cred, &optio 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.NewDefinitionsClient() +client := clientFactory.NewAssignmentsClient() ``` ## Fakes diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client.go b/sdk/resourcemanager/resources/armpolicy/assignments_client.go index 1346bdc15c8a..5d95048e43d1 100644 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client.go +++ b/sdk/resourcemanager/resources/armpolicy/assignments_client.go @@ -29,7 +29,7 @@ type AssignmentsClient struct { } // NewAssignmentsClient creates a new instance of AssignmentsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error) { @@ -49,7 +49,7 @@ func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredenti // resource group scope, that policy applies to all resources in the group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -93,7 +93,7 @@ func (client *AssignmentsClient) createCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -121,7 +121,7 @@ func (client *AssignmentsClient) createHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - policyAssignmentID - The ID of the policy assignment to create. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - parameters - Parameters for policy assignment. // - options - AssignmentsClientCreateByIDOptions contains the optional parameters for the AssignmentsClient.CreateByID method. @@ -156,7 +156,7 @@ func (client *AssignmentsClient) createByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -179,7 +179,7 @@ func (client *AssignmentsClient) createByIDHandleResponse(resp *http.Response) ( // '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -222,7 +222,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +246,7 @@ func (client *AssignmentsClient) deleteHandleResponse(resp *http.Response) (Assi // (resource). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - policyAssignmentID - The ID of the policy assignment to delete. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - options - AssignmentsClientDeleteByIDOptions contains the optional parameters for the AssignmentsClient.DeleteByID method. func (client *AssignmentsClient) DeleteByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientDeleteByIDOptions) (AssignmentsClientDeleteByIDResponse, error) { @@ -280,7 +280,7 @@ func (client *AssignmentsClient) deleteByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -298,7 +298,7 @@ func (client *AssignmentsClient) deleteByIDHandleResponse(resp *http.Response) ( // Get - This operation retrieves a single policy assignment, given its name and the scope it was created at. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -341,7 +341,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -364,7 +364,7 @@ func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (Assignm // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - policyAssignmentID - The ID of the policy assignment to get. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - options - AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. func (client *AssignmentsClient) GetByID(ctx context.Context, policyAssignmentID string, options *AssignmentsClientGetByIDOptions) (AssignmentsClientGetByIDResponse, error) { @@ -398,7 +398,7 @@ func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, polic return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -425,7 +425,7 @@ func (client *AssignmentsClient) getByIDHandleResponse(resp *http.Response) (Ass // is provided, the returned list includes all policy assignments of the policy // definition whose id is {value}. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. func (client *AssignmentsClient) NewListPager(options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientListResponse]{ @@ -465,7 +465,7 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -493,7 +493,7 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign // If $filter=policyDefinitionId eq '{value}' is provided, the returned list // includes all policy assignments of the policy definition whose id is {value} that apply to the management group. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager // method. @@ -535,7 +535,7 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -577,7 +577,7 @@ func (client *AssignmentsClient) listForManagementGroupHandleResponse(resp *http // format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, // {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - resourceGroupName - The name of the resource group containing the resource. // - resourceProviderNamespace - The namespace of the resource provider. For example, the namespace of a virtual machine is // Microsoft.Compute (from Microsoft.Compute/virtualMachines) @@ -612,6 +612,10 @@ func (client *AssignmentsClient) NewListForResourcePager(resourceGroupName strin // listForResourceCreateRequest creates the ListForResource request. func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *AssignmentsClientListForResourceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") } @@ -626,10 +630,6 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err @@ -638,7 +638,7 @@ func (client *AssignmentsClient) listForResourceCreateRequest(ctx context.Contex if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -670,7 +670,7 @@ func (client *AssignmentsClient) listForResourceHandleResponse(resp *http.Respon // is provided, the returned list includes all policy assignments of the // policy definition whose id is {value} that apply to the resource group. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - resourceGroupName - The name of the resource group that contains policy assignments. // - options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager // method. @@ -700,14 +700,14 @@ func (client *AssignmentsClient) NewListForResourceGroupPager(resourceGroupName // listForResourceGroupCreateRequest creates the ListForResourceGroup request. func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AssignmentsClientListForResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err @@ -716,7 +716,7 @@ func (client *AssignmentsClient) listForResourceGroupCreateRequest(ctx context.C if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -741,7 +741,7 @@ func (client *AssignmentsClient) listForResourceGroupHandleResponse(resp *http.R // group scope, that policy applies to all resources in the group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - scope - The scope of the policy assignment. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), // subscription (format: // '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', @@ -785,7 +785,7 @@ func (client *AssignmentsClient) updateCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -813,7 +813,7 @@ func (client *AssignmentsClient) updateHandleResponse(resp *http.Response) (Assi // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-06-01 +// Generated from API version 2023-04-01 // - policyAssignmentID - The ID of the policy assignment to update. Use the format '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. // - parameters - Parameters for policy assignment patch request. // - options - AssignmentsClientUpdateByIDOptions contains the optional parameters for the AssignmentsClient.UpdateByID method. @@ -848,7 +848,7 @@ func (client *AssignmentsClient) updateByIDCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go deleted file mode 100644 index 3bbfb5e9ae70..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/assignments_client_example_test.go +++ /dev/null @@ -1,1365 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/deletePolicyAssignment.json -func ExampleAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignment.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - }}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Foo Bar", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentNonComplianceMessages.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - DisplayName: to.Ptr("Enforce security policies"), - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr("Resources must comply with all internal security policies. See for more info."), - }, - { - Message: to.Ptr("Resource names must start with 'DeptA' and end with '-LC'."), - PolicyDefinitionReferenceID: to.Ptr("10420126870854049575"), - }, - { - Message: to.Ptr("Storage accounts must have firewall rules configured."), - PolicyDefinitionReferenceID: to.Ptr("8572513655450389710"), - }}, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Limit the resource location and resource SKU"), - DisplayName: to.Ptr("Limit the resource location and resource SKU"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - Overrides: []*armpolicy.Override{ - { - Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("Limit_Skus"), - to.Ptr("Limit_Locations")}, - Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - }}, - Value: to.Ptr("Audit"), - }}, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Limit the resource location and resource SKU"), - DisplayName: to.Ptr("Limit the resource location and resource SKU"), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithoutEnforcement.json -func ExampleAssignmentsClient_Create_createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().Create(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - DisplayName: to.Ptr("Enforce resource naming rules"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDoNotEnforce), - Metadata: map[string]any{ - "assignedBy": "Special Someone", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Overrides: []*armpolicy.Override{ - // { - // Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("Limit_Skus"), - // to.Ptr("Limit_Locations")}, - // Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - // }}, - // Value: to.Ptr("Audit"), - // }}, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Get_retrieveAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithASystemAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithAUserAssignedIdentity() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": {}, - }, - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("EnforceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/EnforceNaming"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned), - // UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{ - // "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": &armpolicy.UserAssignedIdentitiesValue{ - // ClientID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // }, - // }, - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Force resource names to begin with given DeptA and end with -LC"), - // DisplayName: to.Ptr("Enforce resource naming rules"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithOverrides.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithOverrides() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{ - Properties: &armpolicy.AssignmentUpdateProperties{ - Overrides: []*armpolicy.Override{ - { - Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("Limit_Skus"), - to.Ptr("Limit_Locations")}, - Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - }}, - Value: to.Ptr("Audit"), - }}, - }, - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // Overrides: []*armpolicy.Override{ - // { - // Kind: to.Ptr(armpolicy.OverrideKindPolicyEffect), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("Limit_Skus"), - // to.Ptr("Limit_Locations")}, - // Kind: to.Ptr(armpolicy.SelectorKindPolicyDefinitionReferenceID), - // }}, - // Value: to.Ptr("Audit"), - // }}, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithResourceSelectors.json -func ExampleAssignmentsClient_Update_updateAPolicyAssignmentWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", armpolicy.AssignmentUpdate{ - Properties: &armpolicy.AssignmentUpdateProperties{ - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Limit the resource location and resource SKU"), - // DisplayName: to.Ptr("Limit the resource location and resource SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Special Someone", - // }, - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResourceGroup.json -func ExampleAssignmentsClient_NewListForResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DisplayName: to.Ptr("Storage Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResource.json -func ExampleAssignmentsClient_NewListForResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DisplayName: to.Ptr("VM Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/vmSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForManagementGroup.json -func ExampleAssignmentsClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListForManagementGroupPager("TestManagementGroup", &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("TestCostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestCostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DisplayName: to.Ptr("Storage Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), - // }, - // }, - // { - // Name: to.Ptr("TestTagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyAssignments/TestTagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/providers/Microsoft.Management/managementGroups/TestManagementGroup"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignments.json -func ExampleAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAssignmentsClient().NewListPager(&armpolicy.AssignmentsClientListOptions{Filter: to.Ptr("atScope()"), - Top: 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.AssignmentListResult = armpolicy.AssignmentListResult{ - // Value: []*armpolicy.Assignment{ - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Minimize the risk of accidental cost overruns"), - // DisplayName: to.Ptr("Storage Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "allowedSkus": &armpolicy.ParameterValuesValue{ - // Value: "Standard_A1", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/storageSkus"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // }, - // { - // Name: to.Ptr("TagEnforcement"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/TagEnforcement"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Ensure a given tag key and value are present on all resources"), - // DisplayName: to.Ptr("Enforces a tag key and value"), - // NotScopes: []*string{ - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/TagKeyValue"), - // Scope: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/deletePolicyAssignmentById.json -func ExampleAssignmentsClient_DeleteByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().DeleteByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/createPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_CreateByID_createOrUpdatePolicyAssignmentWithAManagedIdentityById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewAssignmentsClient().CreateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.Assignment{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - DisplayName: to.Ptr("Enforce storage account SKU"), - EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - Metadata: map[string]any{ - "assignedBy": "Cheapskate Boss", - }, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_GetByID_retrieveAPolicyAssignmentWithAManagedIdentityById() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().GetByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("westus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/updatePolicyAssignmentWithIdentityById.json -func ExampleAssignmentsClient_UpdateByID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAssignmentsClient().UpdateByID(ctx, "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr("eastus"), - }, 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.Assignment = armpolicy.Assignment{ - // Name: to.Ptr("LowCostStorage"), - // Type: to.Ptr("Microsoft.Authorization/policyAssignments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"), - // Identity: &armpolicy.Identity{ - // Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - // PrincipalID: to.Ptr("e6d23f8d-af97-4fbc-bda6-00604e4e3d0a"), - // TenantID: to.Ptr("4bee2b8a-1bee-47c2-90e9-404241551135"), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armpolicy.AssignmentProperties{ - // Description: to.Ptr("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created"), - // DisplayName: to.Ptr("Enforce storage account SKU"), - // EnforcementMode: to.Ptr(armpolicy.EnforcementModeDefault), - // Metadata: map[string]any{ - // "assignedBy": "Cheapskate Boss", - // }, - // NotScopes: []*string{ - // }, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md index f8b50d429714..f2db1b48e973 100644 --- a/sdk/resourcemanager/resources/armpolicy/autorest.md +++ b/sdk/resourcemanager/resources/armpolicy/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.9.0 +module-version: 0.10.0 package-policy: true -tag: package-policy-2022-06 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/client_factory.go b/sdk/resourcemanager/resources/armpolicy/client_factory.go index 16ca41746025..711cdc4eb7ee 100644 --- a/sdk/resourcemanager/resources/armpolicy/client_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/client_factory.go @@ -16,65 +16,127 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + subscriptionID string + policyDefinitionName string + policyDefinitionVersion string + policySetDefinitionName string + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - policyDefinitionName - The name of the policy definition. +// - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is +// the minor version number, and z is the patch number +// - policySetDefinitionName - The name of the policy set definition. // - 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) +func NewClientFactory(subscriptionID string, policyDefinitionName string, policyDefinitionVersion string, policySetDefinitionName string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + 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, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + policySetDefinitionName: policySetDefinitionName, + internal: internal, }, nil } // NewAssignmentsClient creates a new instance of AssignmentsClient. func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { - subClient, _ := NewAssignmentsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &AssignmentsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient. func (c *ClientFactory) NewDataPolicyManifestsClient() *DataPolicyManifestsClient { - subClient, _ := NewDataPolicyManifestsClient(c.credential, c.options) - return subClient + return &DataPolicyManifestsClient{ + internal: c.internal, + } +} + +// NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient. +func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient { + return &DefinitionVersionsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewDefinitionsClient creates a new instance of DefinitionsClient. func (c *ClientFactory) NewDefinitionsClient() *DefinitionsClient { - subClient, _ := NewDefinitionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DefinitionsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewExemptionsClient creates a new instance of ExemptionsClient. func (c *ClientFactory) NewExemptionsClient() *ExemptionsClient { - subClient, _ := NewExemptionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ExemptionsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } +} + +// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient. +func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient { + return &SetDefinitionVersionsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewSetDefinitionsClient creates a new instance of SetDefinitionsClient. func (c *ClientFactory) NewSetDefinitionsClient() *SetDefinitionsClient { - subClient, _ := NewSetDefinitionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SetDefinitionsClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewVariableValuesClient creates a new instance of VariableValuesClient. func (c *ClientFactory) NewVariableValuesClient() *VariableValuesClient { - subClient, _ := NewVariableValuesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &VariableValuesClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } // NewVariablesClient creates a new instance of VariablesClient. func (c *ClientFactory) NewVariablesClient() *VariablesClient { - subClient, _ := NewVariablesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &VariablesClient{ + subscriptionID: c.subscriptionID, + policyDefinitionName: c.policyDefinitionName, + policyDefinitionVersion: c.policyDefinitionVersion, + policySetDefinitionName: c.policySetDefinitionName, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armpolicy/constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go index 341a352cfd93..cac3bbbdbb31 100644 --- a/sdk/resourcemanager/resources/armpolicy/constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -10,7 +10,7 @@ package armpolicy const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - moduleVersion = "v0.9.0" + moduleVersion = "v0.10.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go deleted file mode 100644 index 1ede4c2b1d49..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client_example_test.go +++ /dev/null @@ -1,278 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json -func ExampleDataPolicyManifestsClient_GetByPolicyMode() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDataPolicyManifestsClient().GetByPolicyMode(ctx, "Microsoft.KeyVault.Data", 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.DataPolicyManifest = armpolicy.DataPolicyManifest{ - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("Audit"), - // }, - // { - // Name: to.Ptr("Deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifests() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: 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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Kubernetes.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.Kubernetes.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // DetailsSchema: map[string]any{ - // "type": "object", - // "additionalProperties": false, - // "properties":map[string]any{ - // "constraint":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "constraintTemplate":map[string]any{ - // "type": "string", - // "pattern": "^(?i)(https:\\/\\/raw\\.githubusercontent\\.com\\/){1}(.+)(\\.){1}(yaml|yml){1}$", - // }, - // "values":map[string]any{ - // "type": "object", - // "additionalProperties":map[string]any{ - // }, - // "maxProperties": float64(10), - // }, - // }, - // "required":[]any{ - // "constraintTemplate", - // }, - // }, - // }}, - // IsBuiltInOnly: to.Ptr(false), - // Namespaces: []*string{ - // to.Ptr("Microsoft.Kubernetes"), - // to.Ptr("Microsoft.ContainerService")}, - // PolicyMode: to.Ptr("Microsoft.Kubernetes.Data"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json -func ExampleDataPolicyManifestsClient_NewListPager_listDataPolicyManifestsWithNamespaceFilter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDataPolicyManifestsClient().NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: to.Ptr("namespace eq 'Microsoft.KeyVault'")}) - 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.DataPolicyManifestListResult = armpolicy.DataPolicyManifestListResult{ - // Value: []*armpolicy.DataPolicyManifest{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data"), - // Type: to.Ptr("Microsoft.Authorization/dataPolicyManifests"), - // ID: to.Ptr("/providers/Microsoft.Authorization/dataPolicyManifests/Microsoft.KeyVault.Data"), - // Properties: &armpolicy.DataPolicyManifestProperties{ - // Effects: []*armpolicy.DataEffect{ - // { - // Name: to.Ptr("audit"), - // }, - // { - // Name: to.Ptr("deny"), - // }}, - // FieldValues: []*string{ - // to.Ptr("type")}, - // IsBuiltInOnly: to.Ptr(true), - // Namespaces: []*string{ - // to.Ptr("Microsoft.KeyVault")}, - // PolicyMode: to.Ptr("Microsoft.KeyVault.Data"), - // ResourceFunctions: &armpolicy.DataManifestResourceFunctionsDefinition{ - // Custom: []*armpolicy.DataManifestCustomResourceFunctionDefinition{ - // { - // Name: to.Ptr("vault"), - // AllowCustomProperties: to.Ptr(false), - // DefaultProperties: []*string{ - // to.Ptr("location"), - // to.Ptr("tags")}, - // FullyQualifiedResourceType: to.Ptr("Microsoft.KeyVault/vaults"), - // }}, - // Standard: []*string{ - // to.Ptr("subscription"), - // to.Ptr("resourceGroup")}, - // }, - // ResourceTypeAliases: []*armpolicy.ResourceTypeAliases{ - // { - // Aliases: []*armpolicy.Alias{ - // { - // Name: to.Ptr("Microsoft.KeyVault.Data/vaults/certificates/keyProperties.keyType"), - // Paths: []*armpolicy.AliasPath{ - // { - // Path: to.Ptr("keyProperties.keyType"), - // APIVersions: []*string{ - // to.Ptr("2019-01-01")}, - // }}, - // }}, - // ResourceType: to.Ptr("vaults/certificates"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client.go b/sdk/resourcemanager/resources/armpolicy/definitions_client.go index 02fdc7258b28..f151f47d7510 100644 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/definitions_client.go @@ -29,7 +29,7 @@ type DefinitionsClient struct { } // NewDefinitionsClient creates a new instance of DefinitionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionsClient, error) { @@ -47,7 +47,7 @@ func NewDefinitionsClient(subscriptionID string, credential azcore.TokenCredenti // CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. // - options - DefinitionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdate @@ -77,20 +77,20 @@ func (client *DefinitionsClient) CreateOrUpdate(ctx context.Context, policyDefin // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *DefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -112,19 +112,19 @@ func (client *DefinitionsClient) createOrUpdateHandleResponse(resp *http.Respons // the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policyDefinitionName - The name of the policy definition to create. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to create. // - parameters - The policy definition properties. // - options - DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup // method. -func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { +func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { var err error const operationName = "DefinitionsClient.CreateOrUpdateAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, parameters, options) + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, parameters, options) if err != nil { return DefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } @@ -141,22 +141,22 @@ func (client *DefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Con } // createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters Definition, options *DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -177,7 +177,7 @@ func (client *DefinitionsClient) createOrUpdateAtManagementGroupHandleResponse(r // Delete - This operation deletes the policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the policy definition to delete. // - options - DefinitionsClientDeleteOptions contains the optional parameters for the DefinitionsClient.Delete method. func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (DefinitionsClientDeleteResponse, error) { @@ -204,20 +204,20 @@ func (client *DefinitionsClient) Delete(ctx context.Context, policyDefinitionNam // deleteCreateRequest creates the Delete request. func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policyDefinitionName string, options *DefinitionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -226,18 +226,18 @@ func (client *DefinitionsClient) deleteCreateRequest(ctx context.Context, policy // DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policyDefinitionName - The name of the policy definition to delete. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to delete. // - options - DefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.DeleteAtManagementGroup // method. -func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error) { +func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (DefinitionsClientDeleteAtManagementGroupResponse, error) { var err error const operationName = "DefinitionsClient.DeleteAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, options) + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, options) if err != nil { return DefinitionsClientDeleteAtManagementGroupResponse{}, err } @@ -253,22 +253,22 @@ func (client *DefinitionsClient) DeleteAtManagementGroup(ctx context.Context, po } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -277,7 +277,7 @@ func (client *DefinitionsClient) deleteAtManagementGroupCreateRequest(ctx contex // Get - This operation retrieves the policy definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientGetOptions contains the optional parameters for the DefinitionsClient.Get method. func (client *DefinitionsClient) Get(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (DefinitionsClientGetResponse, error) { @@ -305,20 +305,20 @@ func (client *DefinitionsClient) Get(ctx context.Context, policyDefinitionName s // getCreateRequest creates the Get request. func (client *DefinitionsClient) getCreateRequest(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -336,18 +336,18 @@ func (client *DefinitionsClient) getHandleResponse(resp *http.Response) (Definit // GetAtManagementGroup - This operation retrieves the policy definition in the given management group with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policyDefinitionName - The name of the policy definition to get. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policyDefinitionName - The name of the policy definition to get. // - options - DefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.GetAtManagementGroup // method. -func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientGetAtManagementGroupOptions) (DefinitionsClientGetAtManagementGroupResponse, error) { +func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientGetAtManagementGroupOptions) (DefinitionsClientGetAtManagementGroupResponse, error) { var err error const operationName = "DefinitionsClient.GetAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, policyDefinitionName, managementGroupID, options) + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, policyDefinitionName, options) if err != nil { return DefinitionsClientGetAtManagementGroupResponse{}, err } @@ -364,22 +364,22 @@ func (client *DefinitionsClient) GetAtManagementGroup(ctx context.Context, polic } // getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policyDefinitionName string, managementGroupID string, options *DefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { +func (client *DefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policyDefinitionName string, options *DefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}" - if policyDefinitionName == "" { - return nil, errors.New("parameter policyDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -397,7 +397,7 @@ func (client *DefinitionsClient) getAtManagementGroupHandleResponse(resp *http.R // GetBuiltIn - This operation retrieves the built-in policy definition with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policyDefinitionName - The name of the built-in policy definition to get. // - options - DefinitionsClientGetBuiltInOptions contains the optional parameters for the DefinitionsClient.GetBuiltIn method. func (client *DefinitionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, options *DefinitionsClientGetBuiltInOptions) (DefinitionsClientGetBuiltInResponse, error) { @@ -434,7 +434,7 @@ func (client *DefinitionsClient) getBuiltInCreateRequest(ctx context.Context, po return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -459,7 +459,7 @@ func (client *DefinitionsClient) getBuiltInHandleResponse(resp *http.Response) ( // are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq // {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - options - DefinitionsClientListOptions contains the optional parameters for the DefinitionsClient.NewListPager method. func (client *DefinitionsClient) NewListPager(options *DefinitionsClientListOptions) *runtime.Pager[DefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DefinitionsClientListResponse]{ @@ -496,10 +496,10 @@ func (client *DefinitionsClient) listCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -525,7 +525,7 @@ func (client *DefinitionsClient) listHandleResponse(resp *http.Response) (Defini // and Static. If $filter='category -eq {value}' is provided, the returned list // only includes all built-in policy definitions whose category match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - options - DefinitionsClientListBuiltInOptions contains the optional parameters for the DefinitionsClient.NewListBuiltInPager // method. func (client *DefinitionsClient) NewListBuiltInPager(options *DefinitionsClientListBuiltInOptions) *runtime.Pager[DefinitionsClientListBuiltInResponse] { @@ -559,10 +559,10 @@ func (client *DefinitionsClient) listBuiltInCreateRequest(ctx context.Context, o return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -593,7 +593,7 @@ func (client *DefinitionsClient) listBuiltInHandleResponse(resp *http.Response) // Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category // match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - DefinitionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionsClient.NewListByManagementGroupPager // method. @@ -632,10 +632,10 @@ func (client *DefinitionsClient) listByManagementGroupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go deleted file mode 100644 index 81dcfa2ae4d5..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/definitions_client_example_test.go +++ /dev/null @@ -1,806 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json -func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "ResourceNaming", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json -func ExampleDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicyDefinitionWithAdvancedParameters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdate(ctx, "EventHubDiagnosticLogs", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised"), - DisplayName: to.Ptr("Event Hubs should have diagnostic logging enabled"), - Metadata: map[string]any{ - "category": "Event Hub", - }, - Mode: to.Ptr("Indexed"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "requiredRetentionDays": { - Type: to.Ptr(armpolicy.ParameterTypeInteger), - AllowedValues: []any{ - float64(0), - float64(30), - float64(90), - float64(180), - float64(365)}, - DefaultValue: float64(365), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("The required diagnostic logs retention in days"), - DisplayName: to.Ptr("Required retention (days)"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "equals": "Microsoft.EventHub/namespaces", - "field": "type", - }, - "then": map[string]any{ - "effect": "AuditIfNotExists", - "details": map[string]any{ - "type": "Microsoft.Insights/diagnosticSettings", - "existenceCondition": map[string]any{ - "allOf": []any{ - map[string]any{ - "equals": "true", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", - }, - map[string]any{ - "equals": "[parameters('requiredRetentionDays')]", - "field": "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", - }, - }, - }, - }, - }, - }, - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json -func ExampleDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().Delete(ctx, "ResourceNaming", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json -func ExampleDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().Get(ctx, "ResourceNaming", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json -func ExampleDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().GetBuiltIn(ctx, "7433c107-6db4-4ad1-b57a-a76dce0154a1", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "ResourceNaming", "MyManagementGroup", armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr("Force resource names to begin with given 'prefix' and/or end with given 'suffix'"), - DisplayName: to.Ptr("Enforce resource naming convention"), - Metadata: map[string]any{ - "category": "Naming", - }, - Mode: to.Ptr("All"), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name prefix"), - DisplayName: to.Ptr("Prefix"), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr("Resource name suffix"), - DisplayName: to.Ptr("Suffix"), - }, - }, - }, - PolicyRule: map[string]any{ - "if": map[string]any{ - "not": map[string]any{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]any{ - "effect": "deny", - }, - }, - }, - }, 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDefinitionsClient().DeleteAtManagementGroup(ctx, "ResourceNaming", "MyManagementGroup", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json -func ExampleDefinitionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDefinitionsClient().GetAtManagementGroup(ctx, "ResourceNaming", "MyManagementGroup", 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.Definition = armpolicy.Definition{ - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json -func ExampleDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListPager(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // }, - // { - // Name: to.Ptr("AuditSoonToExpireCerts"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/AuditSoonToExpireCerts"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."), - // DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"), - // Metadata: map[string]any{ - // "category": "KeyVault DataPlane", - // }, - // Mode: to.Ptr("Microsoft.KeyVault.Data"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "daysToExpire": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeInteger), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The number of days for a certificate to expire."), - // DisplayName: to.Ptr("Days to expire"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", - // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", - // }, - // "then":map[string]any{ - // "effect": "audit", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json -func ExampleDefinitionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("06a78e20-9358-41c9-923c-fb736d382a12"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a12"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit DB level audit setting for SQL databases"), - // DisplayName: to.Ptr("Audit SQL DB Level Audit Setting"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "setting": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // AllowedValues: []any{ - // "enabled", - // "disabled"}, - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Audit Setting"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "equals": "Microsoft.Sql/servers/databases", - // "field": "type", - // }, - // "then":map[string]any{ - // "effect": "AuditIfNotExists", - // "details":map[string]any{ - // "name": "default", - // "type": "Microsoft.Sql/servers/databases/auditingSettings", - // "existenceCondition":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "[parameters('setting')]", - // "field": "Microsoft.Sql/auditingSettings.state", - // }, - // }, - // }, - // }, - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeStatic), - // }, - // }, - // { - // Name: to.Ptr("abeed54a-73c5-441d-8a8c-6b5e7a0c299e"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/abeed54a-73c5-441d-8a8c-6b5e7a0c299e"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Audit certificates that are stored in Azure Key Vault, that expire within 'X' number of days."), - // DisplayName: to.Ptr("Audit KeyVault certificates that expire within specified number of days"), - // Metadata: map[string]any{ - // "category": "KeyVault DataPlane", - // }, - // Mode: to.Ptr("Microsoft.KeyVault.Data"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "daysToExpire": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeInteger), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The number of days for a certificate to expire."), - // DisplayName: to.Ptr("Days to expire"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "field": "Microsoft.KeyVault.Data/vaults/certificates/attributes/expiresOn", - // "lessOrEquals": "[addDays(utcNow(), parameters('daysToExpire'))]", - // }, - // "then":map[string]any{ - // "effect": "audit", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json -func ExampleDefinitionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: 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.DefinitionListResult = armpolicy.DefinitionListResult{ - // Value: []*armpolicy.Definition{ - // { - // Name: to.Ptr("7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("This policy enables you to specify a set of storage account SKUs that your organization can deploy."), - // DisplayName: to.Ptr("Allowed storage account SKUs"), - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeArray), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("The list of SKUs that can be specified for storage accounts."), - // DisplayName: to.Ptr("Allowed SKUs"), - // StrongType: to.Ptr("StorageSKUs"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "allOf":[]any{ - // map[string]any{ - // "equals": "Microsoft.Storage/storageAccounts", - // "field": "type", - // }, - // map[string]any{ - // "not":map[string]any{ - // "field": "Microsoft.Storage/storageAccounts/sku.name", - // "in": "[parameters('listOfAllowedSKUs')]", - // }, - // }, - // }, - // }, - // "then":map[string]any{ - // "effect": "Deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("ResourceNaming"), - // Type: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // Properties: &armpolicy.DefinitionProperties{ - // Description: to.Ptr("Force resource names to begin with 'prefix' and end with 'suffix'"), - // DisplayName: to.Ptr("Naming Convention"), - // Metadata: map[string]any{ - // "category": "Naming", - // }, - // Mode: to.Ptr("All"), - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "prefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name prefix"), - // DisplayName: to.Ptr("Prefix"), - // }, - // }, - // "suffix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // Description: to.Ptr("Resource name suffix"), - // DisplayName: to.Ptr("Suffix"), - // }, - // }, - // }, - // PolicyRule: map[string]any{ - // "if":map[string]any{ - // "not":map[string]any{ - // "field": "name", - // "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - // }, - // }, - // "then":map[string]any{ - // "effect": "deny", - // }, - // }, - // PolicyType: to.Ptr(armpolicy.PolicyTypeCustom), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go new file mode 100644 index 000000000000..c0609d45d3f4 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go @@ -0,0 +1,829 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpolicy + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DefinitionVersionsClient contains the methods for the PolicyDefinitionVersions group. +// Don't use this type directly, use NewDefinitionVersionsClient() instead. +type DefinitionVersionsClient struct { + internal *arm.Client + subscriptionID string + policyDefinitionName string + policyDefinitionVersion string +} + +// NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - policyDefinitionName - The name of the policy definition. +// - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is +// the minor version number, and z is the patch number +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDefinitionVersionsClient(subscriptionID string, policyDefinitionName string, policyDefinitionVersion string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefinitionVersionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DefinitionVersionsClient{ + subscriptionID: subscriptionID, + policyDefinitionName: policyDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - This operation creates or updates a policy definition in the given subscription with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - parameters - The policy definition properties. +// - options - DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate +// method. +func (client *DefinitionVersionsClient) CreateOrUpdate(ctx context.Context, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, parameters, options) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DefinitionVersionsClient) createOrUpdateCreateRequest(ctx context.Context, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DefinitionVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (DefinitionVersionsClientCreateOrUpdateResponse, error) { + result := DefinitionVersionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateAtManagementGroup - This operation creates or updates a policy definition version in the given management +// group with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - parameters - The policy definition properties. +// - options - DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +func (client *DefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.CreateOrUpdateAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupName, parameters, options) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, parameters DefinitionVersion, options *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. +func (client *DefinitionVersionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + result := DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + return result, nil +} + +// Delete - This operation deletes the policy definition version in the given subscription with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete +// method. +func (client *DefinitionVersionsClient) Delete(ctx context.Context, options *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientDeleteResponse{}, err + } + return DefinitionVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DefinitionVersionsClient) deleteCreateRequest(ctx context.Context, options *DefinitionVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteAtManagementGroup - This operation deletes the policy definition in the given management group with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *DefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.DeleteAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + return DefinitionVersionsClientDeleteAtManagementGroupResponse{}, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *DefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - This operation retrieves the policy definition version in the given subscription with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method. +func (client *DefinitionVersionsClient) Get(ctx context.Context, options *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DefinitionVersionsClient) getCreateRequest(ctx context.Context, options *DefinitionVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DefinitionVersionsClient) getHandleResponse(resp *http.Response) (DefinitionVersionsClientGetResponse, error) { + result := DefinitionVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - This operation retrieves the policy definition version in the given management group with the given +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *DefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.GetAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *DefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *DefinitionVersionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientGetAtManagementGroupResponse, error) { + result := DefinitionVersionsClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// GetBuiltIn - This operation retrieves the built-in policy definition version with the given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn +// method. +func (client *DefinitionVersionsClient) GetBuiltIn(ctx context.Context, options *DefinitionVersionsClientGetBuiltInOptions) (DefinitionVersionsClientGetBuiltInResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.GetBuiltIn" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBuiltInCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *DefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Context, options *DefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *DefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Response) (DefinitionVersionsClientGetBuiltInResponse, error) { + result := DefinitionVersionsClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersion); err != nil { + return DefinitionVersionsClientGetBuiltInResponse{}, err + } + return result, nil +} + +// NewListPager - This operation retrieves a list of all the policy definition versions for the given policy definition. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager +// method. +func (client *DefinitionVersionsClient) NewListPager(options *DefinitionVersionsClientListOptions) *runtime.Pager[DefinitionVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListResponse]{ + More: func(page DefinitionVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListResponse) (DefinitionVersionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DefinitionVersionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return DefinitionVersionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *DefinitionVersionsClient) listCreateRequest(ctx context.Context, options *DefinitionVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DefinitionVersionsClient) listHandleResponse(resp *http.Response) (DefinitionVersionsClientListResponse, error) { + result := DefinitionVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListResponse{}, err + } + return result, nil +} + +// ListAll - This operation lists all the policy definition versions for all policy definitions within a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll +// method. +func (client *DefinitionVersionsClient) ListAll(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (DefinitionVersionsClientListAllResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.ListAll" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllResponse{}, err + } + resp, err := client.listAllHandleResponse(httpResp) + return resp, err +} + +// listAllCreateRequest creates the ListAll request. +func (client *DefinitionVersionsClient) listAllCreateRequest(ctx context.Context, options *DefinitionVersionsClientListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *DefinitionVersionsClient) listAllHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllResponse, error) { + result := DefinitionVersionsClientListAllResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllResponse{}, err + } + return result, nil +} + +// ListAllAtManagementGroup - This operation lists all the policy definition versions for all policy definitions at the management +// group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup +// method. +func (client *DefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListAllAtManagementGroupOptions) (DefinitionVersionsClientListAllAtManagementGroupResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.ListAllAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + resp, err := client.listAllAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// listAllAtManagementGroupCreateRequest creates the ListAllAtManagementGroup request. +func (client *DefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListAllAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllAtManagementGroupHandleResponse handles the ListAllAtManagementGroup response. +func (client *DefinitionVersionsClient) listAllAtManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllAtManagementGroupResponse, error) { + result := DefinitionVersionsClientListAllAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + return result, nil +} + +// ListAllBuiltins - This operation lists all the built-in policy definition versions for all built-in policy definitions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins +// method. +func (client *DefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (DefinitionVersionsClientListAllBuiltinsResponse, error) { + var err error + const operationName = "DefinitionVersionsClient.ListAllBuiltins" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllBuiltinsCreateRequest(ctx, options) + if err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + resp, err := client.listAllBuiltinsHandleResponse(httpResp) + return resp, err +} + +// listAllBuiltinsCreateRequest creates the ListAllBuiltins request. +func (client *DefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context.Context, options *DefinitionVersionsClientListAllBuiltinsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/listPolicyDefinitionVersions" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllBuiltinsHandleResponse handles the ListAllBuiltins response. +func (client *DefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http.Response) (DefinitionVersionsClientListAllBuiltinsResponse, error) { + result := DefinitionVersionsClientListAllBuiltinsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListAllBuiltinsResponse{}, err + } + return result, nil +} + +// NewListBuiltInPager - This operation retrieves a list of all the built-in policy definition versions for the given policy +// definition. +// +// Generated from API version 2023-04-01 +// - options - DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *DefinitionVersionsClient) NewListBuiltInPager(options *DefinitionVersionsClientListBuiltInOptions) *runtime.Pager[DefinitionVersionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListBuiltInResponse]{ + More: func(page DefinitionVersionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListBuiltInResponse) (DefinitionVersionsClientListBuiltInResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DefinitionVersionsClient.NewListBuiltInPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBuiltInCreateRequest(ctx, options) + }, nil) + if err != nil { + return DefinitionVersionsClientListBuiltInResponse{}, err + } + return client.listBuiltInHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBuiltInCreateRequest creates the ListBuiltIn request. +func (client *DefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Context, options *DefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBuiltInHandleResponse handles the ListBuiltIn response. +func (client *DefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Response) (DefinitionVersionsClientListBuiltInResponse, error) { + result := DefinitionVersionsClientListBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListBuiltInResponse{}, err + } + return result, nil +} + +// NewListByManagementGroupPager - This operation retrieves a list of all the policy definition versions for the given policy +// definition in the given management group. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *DefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, options *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DefinitionVersionsClientListByManagementGroupResponse]{ + More: func(page DefinitionVersionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DefinitionVersionsClientListByManagementGroupResponse) (DefinitionVersionsClientListByManagementGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DefinitionVersionsClient.NewListByManagementGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByManagementGroupCreateRequest(ctx, managementGroupName, options) + }, nil) + if err != nil { + return DefinitionVersionsClientListByManagementGroupResponse{}, err + } + return client.listByManagementGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByManagementGroupCreateRequest creates the ListByManagementGroup request. +func (client *DefinitionVersionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *DefinitionVersionsClientListByManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policyDefinitionName == "" { + return nil, errors.New("parameter client.policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(client.policyDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByManagementGroupHandleResponse handles the ListByManagementGroup response. +func (client *DefinitionVersionsClient) listByManagementGroupHandleResponse(resp *http.Response) (DefinitionVersionsClientListByManagementGroupResponse, error) { + result := DefinitionVersionsClientListByManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DefinitionVersionListResult); err != nil { + return DefinitionVersionsClientListByManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go index b0dead1ca36a..3c4564fefe22 100644 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/exemptions_client.go @@ -28,7 +28,7 @@ type ExemptionsClient struct { } // NewExemptionsClient creates a new instance of ExemptionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExemptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExemptionsClient, error) { diff --git a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go deleted file mode 100644 index b73b15acc056..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go +++ /dev/null @@ -1,639 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/deletePolicyExemption.json -func ExampleExemptionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExemptionsClient().Delete(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemption.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/createOrUpdatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_CreateOrUpdate_createOrUpdateAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().CreateOrUpdate(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr("Exempt demo cluster from limit sku"), - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - DisplayName: to.Ptr("Exempt demo cluster"), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]any{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemption.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemption() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/getPolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Get_retrieveAPolicyExemptionWithResourceSelectors() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Get(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/updatePolicyExemptionWithResourceSelectors.json -func ExampleExemptionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExemptionsClient().Update(ctx, "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", "DemoExpensiveVM", armpolicy.ExemptionUpdate{ - Properties: &armpolicy.ExemptionUpdateProperties{ - AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - ResourceSelectors: []*armpolicy.ResourceSelector{ - { - Name: to.Ptr("SDPRegions"), - Selectors: []*armpolicy.Selector{ - { - In: []*string{ - to.Ptr("eastus2euap"), - to.Ptr("centraluseuap")}, - Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - }}, - }}, - }, - }, 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.Exemption = armpolicy.Exemption{ - // Name: to.Ptr("DemoExpensiveVM"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVM"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // AssignmentScopeValidation: to.Ptr(armpolicy.AssignmentScopeValidationDefault), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // ResourceSelectors: []*armpolicy.ResourceSelector{ - // { - // Name: to.Ptr("SDPRegions"), - // Selectors: []*armpolicy.Selector{ - // { - // In: []*string{ - // to.Ptr("eastus2euap"), - // to.Ptr("centraluseuap")}, - // Kind: to.Ptr(armpolicy.SelectorKindResourceLocation), - // }}, - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForSubscription.json -func ExampleExemptionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListPager(&armpolicy.ExemptionsClientListOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVNetSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json -func ExampleExemptionsClient_NewListForResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourceGroupPager("TestResourceGroup", &armpolicy.ExemptionsClientListForResourceGroupOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("TestVMSub"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyExemptions/TestVMSub"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("TestVNetRG"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/TestVNetRG"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForResource.json -func ExampleExemptionsClient_NewListForResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForResourcePager("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", "MyTestComputer.cloudapp.net", &armpolicy.ExemptionsClientListForResourceOptions{Filter: 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("DemoExpensiveVMGroup"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Authorization/policyExemptions/DemoExpensiveVMGroup"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("jumpBoxExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/TestResourceGroup/providers/Microsoft.Compute/virtualMachines/MyTestVm/providers/Microsoft.Authorization/policyExemptions/jumpBoxExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json -func ExampleExemptionsClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExemptionsClient().NewListForManagementGroupPager("DevOrg", &armpolicy.ExemptionsClientListForManagementGroupOptions{Filter: to.Ptr("atScope()")}) - 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.ExemptionListResult = armpolicy.ExemptionListResult{ - // Value: []*armpolicy.Exemption{ - // { - // Name: to.Ptr("ResearchBudgetExemption"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/ResearchBudgetExemption"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt demo cluster from limit sku"), - // DisplayName: to.Ptr("Exempt demo cluster"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - // Metadata: map[string]any{ - // "reason": "Temporary exemption for a expensive VM demo", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/CostManagement"), - // PolicyDefinitionReferenceIDs: []*string{ - // to.Ptr("Limit_Skus")}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("VNetIsMonitored"), - // Type: to.Ptr("Microsoft.Authorization/policyExemptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/policyExemptions/VNetIsMonitored"), - // Properties: &armpolicy.ExemptionProperties{ - // Description: to.Ptr("Exempt jump box open ports from limit ports policy"), - // DisplayName: to.Ptr("Exempt jump box open ports"), - // ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryMitigated), - // Metadata: map[string]any{ - // "reason": "Need to open RDP port to corp net", - // }, - // PolicyAssignmentID: to.Ptr("/providers/Microsoft.Management/managementGroups/HardwareDivision/providers/Microsoft.Authorization/policyAssignments/LimitPorts"), - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go index 5b01c5054a6a..dbd59af6c35d 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/definitions_server.go @@ -31,7 +31,7 @@ type DefinitionsServer struct { // CreateOrUpdateAtManagementGroup is the fake for method DefinitionsClient.CreateOrUpdateAtManagementGroup // HTTP status codes to indicate success: http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, policyDefinitionName string, managementGroupID string, parameters armpolicy.Definition, options *armpolicy.DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) + CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, policyDefinitionName string, parameters armpolicy.Definition, options *armpolicy.DefinitionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) // Delete is the fake for method DefinitionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -39,7 +39,7 @@ type DefinitionsServer struct { // DeleteAtManagementGroup is the fake for method DefinitionsClient.DeleteAtManagementGroup // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, policyDefinitionName string, managementGroupID string, options *armpolicy.DefinitionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) + DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, policyDefinitionName string, options *armpolicy.DefinitionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) // Get is the fake for method DefinitionsClient.Get // HTTP status codes to indicate success: http.StatusOK @@ -47,7 +47,7 @@ type DefinitionsServer struct { // GetAtManagementGroup is the fake for method DefinitionsClient.GetAtManagementGroup // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, policyDefinitionName string, managementGroupID string, options *armpolicy.DefinitionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) + GetAtManagementGroup func(ctx context.Context, managementGroupID string, policyDefinitionName string, options *armpolicy.DefinitionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) // GetBuiltIn is the fake for method DefinitionsClient.GetBuiltIn // HTTP status codes to indicate success: http.StatusOK @@ -177,15 +177,15 @@ func (d *DefinitionsServerTransport) dispatchCreateOrUpdateAtManagementGroup(req if err != nil { return nil, err } - policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := d.srv.CreateOrUpdateAtManagementGroup(req.Context(), policyDefinitionNameParam, managementGroupIDParam, body, nil) + respr, errRespr := d.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, policyDefinitionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -239,15 +239,15 @@ func (d *DefinitionsServerTransport) dispatchDeleteAtManagementGroup(req *http.R if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := d.srv.DeleteAtManagementGroup(req.Context(), policyDefinitionNameParam, managementGroupIDParam, nil) + respr, errRespr := d.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, policyDefinitionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -301,15 +301,15 @@ func (d *DefinitionsServerTransport) dispatchGetAtManagementGroup(req *http.Requ if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := d.srv.GetAtManagementGroup(req.Context(), policyDefinitionNameParam, managementGroupIDParam, nil) + respr, errRespr := d.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, policyDefinitionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go new file mode 100644 index 000000000000..05ae762ac322 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go @@ -0,0 +1,583 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// DefinitionVersionsServer is a fake server for instances of the armpolicy.DefinitionVersionsClient type. +type DefinitionVersionsServer struct { + // CreateOrUpdate is the fake for method DefinitionVersionsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, parameters armpolicy.DefinitionVersion, options *armpolicy.DefinitionVersionsClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdateAtManagementGroup is the fake for method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupName string, parameters armpolicy.DefinitionVersion, options *armpolicy.DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method DefinitionVersionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, options *armpolicy.DefinitionVersionsClientDeleteOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DeleteAtManagementGroup is the fake for method DefinitionVersionsClient.DeleteAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.DefinitionVersionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DefinitionVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, options *armpolicy.DefinitionVersionsClientGetOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // GetAtManagementGroup is the fake for method DefinitionVersionsClient.GetAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + GetAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.DefinitionVersionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // GetBuiltIn is the fake for method DefinitionVersionsClient.GetBuiltIn + // HTTP status codes to indicate success: http.StatusOK + GetBuiltIn func(ctx context.Context, options *armpolicy.DefinitionVersionsClientGetBuiltInOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientGetBuiltInResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DefinitionVersionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armpolicy.DefinitionVersionsClientListOptions) (resp azfake.PagerResponder[armpolicy.DefinitionVersionsClientListResponse]) + + // ListAll is the fake for method DefinitionVersionsClient.ListAll + // HTTP status codes to indicate success: http.StatusOK + ListAll func(ctx context.Context, options *armpolicy.DefinitionVersionsClientListAllOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientListAllResponse], errResp azfake.ErrorResponder) + + // ListAllAtManagementGroup is the fake for method DefinitionVersionsClient.ListAllAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + ListAllAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.DefinitionVersionsClientListAllAtManagementGroupOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientListAllAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // ListAllBuiltins is the fake for method DefinitionVersionsClient.ListAllBuiltins + // HTTP status codes to indicate success: http.StatusOK + ListAllBuiltins func(ctx context.Context, options *armpolicy.DefinitionVersionsClientListAllBuiltinsOptions) (resp azfake.Responder[armpolicy.DefinitionVersionsClientListAllBuiltinsResponse], errResp azfake.ErrorResponder) + + // NewListBuiltInPager is the fake for method DefinitionVersionsClient.NewListBuiltInPager + // HTTP status codes to indicate success: http.StatusOK + NewListBuiltInPager func(options *armpolicy.DefinitionVersionsClientListBuiltInOptions) (resp azfake.PagerResponder[armpolicy.DefinitionVersionsClientListBuiltInResponse]) + + // NewListByManagementGroupPager is the fake for method DefinitionVersionsClient.NewListByManagementGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByManagementGroupPager func(managementGroupName string, options *armpolicy.DefinitionVersionsClientListByManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.DefinitionVersionsClientListByManagementGroupResponse]) +} + +// NewDefinitionVersionsServerTransport creates a new instance of DefinitionVersionsServerTransport with the provided implementation. +// The returned DefinitionVersionsServerTransport instance is connected to an instance of armpolicy.DefinitionVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDefinitionVersionsServerTransport(srv *DefinitionVersionsServer) *DefinitionVersionsServerTransport { + return &DefinitionVersionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListResponse]](), + newListBuiltInPager: newTracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListBuiltInResponse]](), + newListByManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListByManagementGroupResponse]](), + } +} + +// DefinitionVersionsServerTransport connects instances of armpolicy.DefinitionVersionsClient to instances of DefinitionVersionsServer. +// Don't use this type directly, use NewDefinitionVersionsServerTransport instead. +type DefinitionVersionsServerTransport struct { + srv *DefinitionVersionsServer + newListPager *tracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListResponse]] + newListBuiltInPager *tracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListBuiltInResponse]] + newListByManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.DefinitionVersionsClientListByManagementGroupResponse]] +} + +// Do implements the policy.Transporter interface for DefinitionVersionsServerTransport. +func (d *DefinitionVersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DefinitionVersionsClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DefinitionVersionsClient.CreateOrUpdateAtManagementGroup": + resp, err = d.dispatchCreateOrUpdateAtManagementGroup(req) + case "DefinitionVersionsClient.Delete": + resp, err = d.dispatchDelete(req) + case "DefinitionVersionsClient.DeleteAtManagementGroup": + resp, err = d.dispatchDeleteAtManagementGroup(req) + case "DefinitionVersionsClient.Get": + resp, err = d.dispatchGet(req) + case "DefinitionVersionsClient.GetAtManagementGroup": + resp, err = d.dispatchGetAtManagementGroup(req) + case "DefinitionVersionsClient.GetBuiltIn": + resp, err = d.dispatchGetBuiltIn(req) + case "DefinitionVersionsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + case "DefinitionVersionsClient.ListAll": + resp, err = d.dispatchListAll(req) + case "DefinitionVersionsClient.ListAllAtManagementGroup": + resp, err = d.dispatchListAllAtManagementGroup(req) + case "DefinitionVersionsClient.ListAllBuiltins": + resp, err = d.dispatchListAllBuiltins(req) + case "DefinitionVersionsClient.NewListBuiltInPager": + resp, err = d.dispatchNewListBuiltInPager(req) + case "DefinitionVersionsClient.NewListByManagementGroupPager": + resp, err = d.dispatchNewListByManagementGroupPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.DefinitionVersion](req) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdateAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.DefinitionVersion](req) + if err != nil { + return nil, err + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := d.srv.Delete(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { + if d.srv.DeleteAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.DeleteAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := d.srv.Get(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { + if d.srv.GetAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.GetAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchGetBuiltIn(req *http.Request) (*http.Response, error) { + if d.srv.GetBuiltIn == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBuiltIn not implemented")} + } + const regexStr = `/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := d.srv.GetBuiltIn(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.DefinitionVersionsClientListOptions + if topParam != nil { + options = &armpolicy.DefinitionVersionsClientListOptions{ + Top: topParam, + } + } + resp := d.srv.NewListPager(options) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.DefinitionVersionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchListAll(req *http.Request) (*http.Response, error) { + if d.srv.ListAll == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAll not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicyDefinitionVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := d.srv.ListAll(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchListAllAtManagementGroup(req *http.Request) (*http.Response, error) { + if d.srv.ListAllAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAllAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicyDefinitionVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.ListAllAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchListAllBuiltins(req *http.Request) (*http.Response, error) { + if d.srv.ListAllBuiltins == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAllBuiltins not implemented")} + } + respr, errRespr := d.srv.ListAllBuiltins(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchNewListBuiltInPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListBuiltInPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBuiltInPager not implemented")} + } + newListBuiltInPager := d.newListBuiltInPager.get(req) + if newListBuiltInPager == nil { + const regexStr = `/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.DefinitionVersionsClientListBuiltInOptions + if topParam != nil { + options = &armpolicy.DefinitionVersionsClientListBuiltInOptions{ + Top: topParam, + } + } + resp := d.srv.NewListBuiltInPager(options) + newListBuiltInPager = &resp + d.newListBuiltInPager.add(req, newListBuiltInPager) + server.PagerResponderInjectNextLinks(newListBuiltInPager, req, func(page *armpolicy.DefinitionVersionsClientListBuiltInResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBuiltInPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListBuiltInPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBuiltInPager) { + d.newListBuiltInPager.remove(req) + } + return resp, nil +} + +func (d *DefinitionVersionsServerTransport) dispatchNewListByManagementGroupPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByManagementGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByManagementGroupPager not implemented")} + } + newListByManagementGroupPager := d.newListByManagementGroupPager.get(req) + if newListByManagementGroupPager == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.DefinitionVersionsClientListByManagementGroupOptions + if topParam != nil { + options = &armpolicy.DefinitionVersionsClientListByManagementGroupOptions{ + Top: topParam, + } + } + resp := d.srv.NewListByManagementGroupPager(managementGroupNameParam, options) + newListByManagementGroupPager = &resp + d.newListByManagementGroupPager.add(req, newListByManagementGroupPager) + server.PagerResponderInjectNextLinks(newListByManagementGroupPager, req, func(page *armpolicy.DefinitionVersionsClientListByManagementGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByManagementGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByManagementGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByManagementGroupPager) { + d.newListByManagementGroupPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go index 243f08d91d25..37eec4cb2e1e 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go @@ -19,13 +19,15 @@ import ( // ServerFactory is a fake server for instances of the armpolicy.ClientFactory type. type ServerFactory struct { - AssignmentsServer AssignmentsServer - DataPolicyManifestsServer DataPolicyManifestsServer - DefinitionsServer DefinitionsServer - ExemptionsServer ExemptionsServer - SetDefinitionsServer SetDefinitionsServer - VariableValuesServer VariableValuesServer - VariablesServer VariablesServer + AssignmentsServer AssignmentsServer + DataPolicyManifestsServer DataPolicyManifestsServer + DefinitionVersionsServer DefinitionVersionsServer + DefinitionsServer DefinitionsServer + ExemptionsServer ExemptionsServer + SetDefinitionVersionsServer SetDefinitionVersionsServer + SetDefinitionsServer SetDefinitionsServer + VariableValuesServer VariableValuesServer + VariablesServer VariablesServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,15 +42,17 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armpolicy.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trAssignmentsServer *AssignmentsServerTransport - trDataPolicyManifestsServer *DataPolicyManifestsServerTransport - trDefinitionsServer *DefinitionsServerTransport - trExemptionsServer *ExemptionsServerTransport - trSetDefinitionsServer *SetDefinitionsServerTransport - trVariableValuesServer *VariableValuesServerTransport - trVariablesServer *VariablesServerTransport + srv *ServerFactory + trMu sync.Mutex + trAssignmentsServer *AssignmentsServerTransport + trDataPolicyManifestsServer *DataPolicyManifestsServerTransport + trDefinitionVersionsServer *DefinitionVersionsServerTransport + trDefinitionsServer *DefinitionsServerTransport + trExemptionsServer *ExemptionsServerTransport + trSetDefinitionVersionsServer *SetDefinitionVersionsServerTransport + trSetDefinitionsServer *SetDefinitionsServerTransport + trVariableValuesServer *VariableValuesServerTransport + trVariablesServer *VariablesServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -72,12 +76,22 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewDataPolicyManifestsServerTransport(&s.srv.DataPolicyManifestsServer) }) resp, err = s.trDataPolicyManifestsServer.Do(req) + case "DefinitionVersionsClient": + initServer(s, &s.trDefinitionVersionsServer, func() *DefinitionVersionsServerTransport { + return NewDefinitionVersionsServerTransport(&s.srv.DefinitionVersionsServer) + }) + resp, err = s.trDefinitionVersionsServer.Do(req) case "DefinitionsClient": initServer(s, &s.trDefinitionsServer, func() *DefinitionsServerTransport { return NewDefinitionsServerTransport(&s.srv.DefinitionsServer) }) resp, err = s.trDefinitionsServer.Do(req) case "ExemptionsClient": initServer(s, &s.trExemptionsServer, func() *ExemptionsServerTransport { return NewExemptionsServerTransport(&s.srv.ExemptionsServer) }) resp, err = s.trExemptionsServer.Do(req) + case "SetDefinitionVersionsClient": + initServer(s, &s.trSetDefinitionVersionsServer, func() *SetDefinitionVersionsServerTransport { + return NewSetDefinitionVersionsServerTransport(&s.srv.SetDefinitionVersionsServer) + }) + resp, err = s.trSetDefinitionVersionsServer.Do(req) case "SetDefinitionsClient": initServer(s, &s.trSetDefinitionsServer, func() *SetDefinitionsServerTransport { return NewSetDefinitionsServerTransport(&s.srv.SetDefinitionsServer) diff --git a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go index fc89147e3008..e3d09cdf7d11 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go @@ -31,7 +31,7 @@ type SetDefinitionsServer struct { // CreateOrUpdateAtManagementGroup is the fake for method SetDefinitionsClient.CreateOrUpdateAtManagementGroup // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, policySetDefinitionName string, managementGroupID string, parameters armpolicy.SetDefinition, options *armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) + CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters armpolicy.SetDefinition, options *armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) // Delete is the fake for method SetDefinitionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -39,7 +39,7 @@ type SetDefinitionsServer struct { // DeleteAtManagementGroup is the fake for method SetDefinitionsClient.DeleteAtManagementGroup // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *armpolicy.SetDefinitionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) + DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *armpolicy.SetDefinitionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) // Get is the fake for method SetDefinitionsClient.Get // HTTP status codes to indicate success: http.StatusOK @@ -47,7 +47,7 @@ type SetDefinitionsServer struct { // GetAtManagementGroup is the fake for method SetDefinitionsClient.GetAtManagementGroup // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *armpolicy.SetDefinitionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) + GetAtManagementGroup func(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *armpolicy.SetDefinitionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) // GetBuiltIn is the fake for method SetDefinitionsClient.GetBuiltIn // HTTP status codes to indicate success: http.StatusOK @@ -177,15 +177,15 @@ func (s *SetDefinitionsServerTransport) dispatchCreateOrUpdateAtManagementGroup( if err != nil { return nil, err } - policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.CreateOrUpdateAtManagementGroup(req.Context(), policySetDefinitionNameParam, managementGroupIDParam, body, nil) + respr, errRespr := s.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, policySetDefinitionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -239,15 +239,15 @@ func (s *SetDefinitionsServerTransport) dispatchDeleteAtManagementGroup(req *htt if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.DeleteAtManagementGroup(req.Context(), policySetDefinitionNameParam, managementGroupIDParam, nil) + respr, errRespr := s.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, policySetDefinitionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -301,15 +301,15 @@ func (s *SetDefinitionsServerTransport) dispatchGetAtManagementGroup(req *http.R if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), policySetDefinitionNameParam, managementGroupIDParam, nil) + respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, policySetDefinitionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go new file mode 100644 index 000000000000..c5a0feec14de --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go @@ -0,0 +1,583 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// SetDefinitionVersionsServer is a fake server for instances of the armpolicy.SetDefinitionVersionsClient type. +type SetDefinitionVersionsServer struct { + // CreateOrUpdate is the fake for method SetDefinitionVersionsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, parameters armpolicy.SetDefinitionVersion, options *armpolicy.SetDefinitionVersionsClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdateAtManagementGroup is the fake for method SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupName string, parameters armpolicy.SetDefinitionVersion, options *armpolicy.SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SetDefinitionVersionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, options *armpolicy.SetDefinitionVersionsClientDeleteOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DeleteAtManagementGroup is the fake for method SetDefinitionVersionsClient.DeleteAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SetDefinitionVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, options *armpolicy.SetDefinitionVersionsClientGetOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // GetAtManagementGroup is the fake for method SetDefinitionVersionsClient.GetAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + GetAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.SetDefinitionVersionsClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // GetBuiltIn is the fake for method SetDefinitionVersionsClient.GetBuiltIn + // HTTP status codes to indicate success: http.StatusOK + GetBuiltIn func(ctx context.Context, options *armpolicy.SetDefinitionVersionsClientGetBuiltInOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientGetBuiltInResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SetDefinitionVersionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armpolicy.SetDefinitionVersionsClientListOptions) (resp azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListResponse]) + + // ListAll is the fake for method SetDefinitionVersionsClient.ListAll + // HTTP status codes to indicate success: http.StatusOK + ListAll func(ctx context.Context, options *armpolicy.SetDefinitionVersionsClientListAllOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientListAllResponse], errResp azfake.ErrorResponder) + + // ListAllAtManagementGroup is the fake for method SetDefinitionVersionsClient.ListAllAtManagementGroup + // HTTP status codes to indicate success: http.StatusOK + ListAllAtManagementGroup func(ctx context.Context, managementGroupName string, options *armpolicy.SetDefinitionVersionsClientListAllAtManagementGroupOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientListAllAtManagementGroupResponse], errResp azfake.ErrorResponder) + + // ListAllBuiltins is the fake for method SetDefinitionVersionsClient.ListAllBuiltins + // HTTP status codes to indicate success: http.StatusOK + ListAllBuiltins func(ctx context.Context, options *armpolicy.SetDefinitionVersionsClientListAllBuiltinsOptions) (resp azfake.Responder[armpolicy.SetDefinitionVersionsClientListAllBuiltinsResponse], errResp azfake.ErrorResponder) + + // NewListBuiltInPager is the fake for method SetDefinitionVersionsClient.NewListBuiltInPager + // HTTP status codes to indicate success: http.StatusOK + NewListBuiltInPager func(options *armpolicy.SetDefinitionVersionsClientListBuiltInOptions) (resp azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListBuiltInResponse]) + + // NewListByManagementGroupPager is the fake for method SetDefinitionVersionsClient.NewListByManagementGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByManagementGroupPager func(managementGroupName string, options *armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListByManagementGroupResponse]) +} + +// NewSetDefinitionVersionsServerTransport creates a new instance of SetDefinitionVersionsServerTransport with the provided implementation. +// The returned SetDefinitionVersionsServerTransport instance is connected to an instance of armpolicy.SetDefinitionVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSetDefinitionVersionsServerTransport(srv *SetDefinitionVersionsServer) *SetDefinitionVersionsServerTransport { + return &SetDefinitionVersionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListResponse]](), + newListBuiltInPager: newTracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListBuiltInResponse]](), + newListByManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListByManagementGroupResponse]](), + } +} + +// SetDefinitionVersionsServerTransport connects instances of armpolicy.SetDefinitionVersionsClient to instances of SetDefinitionVersionsServer. +// Don't use this type directly, use NewSetDefinitionVersionsServerTransport instead. +type SetDefinitionVersionsServerTransport struct { + srv *SetDefinitionVersionsServer + newListPager *tracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListResponse]] + newListBuiltInPager *tracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListBuiltInResponse]] + newListByManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.SetDefinitionVersionsClientListByManagementGroupResponse]] +} + +// Do implements the policy.Transporter interface for SetDefinitionVersionsServerTransport. +func (s *SetDefinitionVersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SetDefinitionVersionsClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup": + resp, err = s.dispatchCreateOrUpdateAtManagementGroup(req) + case "SetDefinitionVersionsClient.Delete": + resp, err = s.dispatchDelete(req) + case "SetDefinitionVersionsClient.DeleteAtManagementGroup": + resp, err = s.dispatchDeleteAtManagementGroup(req) + case "SetDefinitionVersionsClient.Get": + resp, err = s.dispatchGet(req) + case "SetDefinitionVersionsClient.GetAtManagementGroup": + resp, err = s.dispatchGetAtManagementGroup(req) + case "SetDefinitionVersionsClient.GetBuiltIn": + resp, err = s.dispatchGetBuiltIn(req) + case "SetDefinitionVersionsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + case "SetDefinitionVersionsClient.ListAll": + resp, err = s.dispatchListAll(req) + case "SetDefinitionVersionsClient.ListAllAtManagementGroup": + resp, err = s.dispatchListAllAtManagementGroup(req) + case "SetDefinitionVersionsClient.ListAllBuiltins": + resp, err = s.dispatchListAllBuiltins(req) + case "SetDefinitionVersionsClient.NewListBuiltInPager": + resp, err = s.dispatchNewListBuiltInPager(req) + case "SetDefinitionVersionsClient.NewListByManagementGroupPager": + resp, err = s.dispatchNewListByManagementGroupPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinitionVersion](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdateAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armpolicy.SetDefinitionVersion](req) + if err != nil { + return nil, err + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.Delete(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.DeleteAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.DeleteAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.Get(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.GetAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method GetAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchGetBuiltIn(req *http.Request) (*http.Response, error) { + if s.srv.GetBuiltIn == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBuiltIn not implemented")} + } + const regexStr = `/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.GetBuiltIn(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.SetDefinitionVersionsClientListOptions + if topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListOptions{ + Top: topParam, + } + } + resp := s.srv.NewListPager(options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.SetDefinitionVersionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchListAll(req *http.Request) (*http.Response, error) { + if s.srv.ListAll == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAll not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicySetDefinitionVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := s.srv.ListAll(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchListAllAtManagementGroup(req *http.Request) (*http.Response, error) { + if s.srv.ListAllAtManagementGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAllAtManagementGroup not implemented")} + } + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/listPolicySetDefinitionVersions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ListAllAtManagementGroup(req.Context(), managementGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchListAllBuiltins(req *http.Request) (*http.Response, error) { + if s.srv.ListAllBuiltins == nil { + return nil, &nonRetriableError{errors.New("fake for method ListAllBuiltins not implemented")} + } + respr, errRespr := s.srv.ListAllBuiltins(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SetDefinitionVersionListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchNewListBuiltInPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBuiltInPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBuiltInPager not implemented")} + } + newListBuiltInPager := s.newListBuiltInPager.get(req) + if newListBuiltInPager == nil { + const regexStr = `/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.SetDefinitionVersionsClientListBuiltInOptions + if topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListBuiltInOptions{ + Top: topParam, + } + } + resp := s.srv.NewListBuiltInPager(options) + newListBuiltInPager = &resp + s.newListBuiltInPager.add(req, newListBuiltInPager) + server.PagerResponderInjectNextLinks(newListBuiltInPager, req, func(page *armpolicy.SetDefinitionVersionsClientListBuiltInResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBuiltInPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBuiltInPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBuiltInPager) { + s.newListBuiltInPager.remove(req) + } + return resp, nil +} + +func (s *SetDefinitionVersionsServerTransport) dispatchNewListByManagementGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByManagementGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByManagementGroupPager not implemented")} + } + newListByManagementGroupPager := s.newListByManagementGroupPager.get(req) + if newListByManagementGroupPager == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policySetDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions + if topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions{ + Top: topParam, + } + } + resp := s.srv.NewListByManagementGroupPager(managementGroupNameParam, options) + newListByManagementGroupPager = &resp + s.newListByManagementGroupPager.add(req, newListByManagementGroupPager) + server.PagerResponderInjectNextLinks(newListByManagementGroupPager, req, func(page *armpolicy.SetDefinitionVersionsClientListByManagementGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByManagementGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByManagementGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByManagementGroupPager) { + s.newListByManagementGroupPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armpolicy/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/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 0dbaadaccdea..1768a6276b13 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armpolicy/models.go b/sdk/resourcemanager/resources/armpolicy/models.go index 1fcbf47ced9f..bc1d8578b86c 100644 --- a/sdk/resourcemanager/resources/armpolicy/models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -306,6 +306,12 @@ type DefinitionProperties struct { // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. PolicyType *PolicyType + + // The policy definition version in #.#.# format. + Version *string + + // A list of available versions for this policy definition. + Versions []*string } // DefinitionReference - The policy definition reference. @@ -323,6 +329,60 @@ type DefinitionReference struct { PolicyDefinitionReferenceID *string } +// DefinitionVersion - The ID of the policy definition version. +type DefinitionVersion struct { + // The policy definition version properties. + Properties *DefinitionVersionProperties + + // READ-ONLY; The ID of the policy definition version. + ID *string + + // READ-ONLY; The name of the policy definition version. + Name *string + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions/versions). + Type *string +} + +// DefinitionVersionListResult - List of policy definition versions. +type DefinitionVersionListResult struct { + // The URL to use for getting the next set of results. + NextLink *string + + // An array of policy definitions versions. + Value []*DefinitionVersion +} + +// DefinitionVersionProperties - The policy definition properties. +type DefinitionVersionProperties struct { + // The policy definition description. + Description *string + + // The display name of the policy definition. + DisplayName *string + + // The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. + Metadata any + + // The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. + Mode *string + + // The parameter definitions for parameters used in the policy rule. The keys are the parameter names. + Parameters map[string]*ParameterDefinitionsValue + + // The policy rule. + PolicyRule any + + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType + + // The policy definition version in #.#.# format. + Version *string +} + // Exemption - The policy exemption. type Exemption struct { // REQUIRED; Properties for the policy exemption. @@ -449,6 +509,11 @@ type ParameterDefinitionsValue struct { // General metadata for the parameter. Metadata *ParameterDefinitionsValueMetadata + // Provides validation of parameter inputs during assignment using a self-defined JSON schema. This property is only supported + // for object-type parameters and follows the Json.NET Schema 2019-09 + // implementation. You can learn more about using schemas at https://json-schema.org/ and test draft schemas at https://www.jsonschemavalidator.net/. + Schema any + // The data type of the parameter. Type *ParameterType } @@ -512,7 +577,7 @@ type Selector struct { // SetDefinition - The policy set definition. type SetDefinition struct { - // The policy definition properties. + // The policy set definition properties. Properties *SetDefinitionProperties // READ-ONLY; The ID of the policy set definition. @@ -557,8 +622,68 @@ type SetDefinitionProperties struct { // The metadata describing groups of policy definition references within the policy set definition. PolicyDefinitionGroups []*DefinitionGroup + // The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType + + // The policy set definition version in #.#.# format. + Version *string + + // A list of available versions for this policy set definition. + Versions []*string +} + +// SetDefinitionVersion - The policy set definition version. +type SetDefinitionVersion struct { + // The policy set definition version properties. + Properties *SetDefinitionVersionProperties + + // READ-ONLY; The ID of the policy set definition version. + ID *string + + // READ-ONLY; The name of the policy set definition version. + Name *string + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). + Type *string +} + +// SetDefinitionVersionListResult - List of policy set definition versions. +type SetDefinitionVersionListResult struct { + // The URL to use for getting the next set of results. + NextLink *string + + // An array of policy set definition versions. + Value []*SetDefinitionVersion +} + +// SetDefinitionVersionProperties - The policy set definition properties. +type SetDefinitionVersionProperties struct { + // REQUIRED; An array of policy definition references. + PolicyDefinitions []*DefinitionReference + + // The policy set definition description. + Description *string + + // The display name of the policy set definition. + DisplayName *string + + // The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. + Metadata any + + // The policy set definition parameters that can be used in policy definition references. + Parameters map[string]*ParameterDefinitionsValue + + // The metadata describing groups of policy definition references within the policy set definition. + PolicyDefinitionGroups []*DefinitionGroup + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. PolicyType *PolicyType + + // The policy set definition version in #.#.# format. + Version *string } // SystemData - Metadata pertaining to creation and last modification of the resource. diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go index 74cb09e1e08b..b55f9614ec41 100644 --- a/sdk/resourcemanager/resources/armpolicy/models_serde.go +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -731,6 +731,8 @@ func (d DefinitionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "parameters", d.Parameters) populateAny(objectMap, "policyRule", d.PolicyRule) populate(objectMap, "policyType", d.PolicyType) + populate(objectMap, "version", d.Version) + populate(objectMap, "versions", d.Versions) return json.Marshal(objectMap) } @@ -764,6 +766,12 @@ func (d *DefinitionProperties) UnmarshalJSON(data []byte) error { case "policyType": err = unpopulate(val, "PolicyType", &d.PolicyType) delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + case "versions": + err = unpopulate(val, "Versions", &d.Versions) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -811,6 +819,135 @@ func (d *DefinitionReference) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersion. +func (d DefinitionVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersion. +func (d *DefinitionVersion) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersionListResult. +func (d DefinitionVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionListResult. +func (d *DefinitionVersionListResult) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersionProperties. +func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", d.Description) + populate(objectMap, "displayName", d.DisplayName) + populateAny(objectMap, "metadata", d.Metadata) + populate(objectMap, "mode", d.Mode) + populate(objectMap, "parameters", d.Parameters) + populateAny(objectMap, "policyRule", d.PolicyRule) + populate(objectMap, "policyType", d.PolicyType) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefinitionVersionProperties. +func (d *DefinitionVersionProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &d.Metadata) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "policyRule": + err = unpopulate(val, "PolicyRule", &d.PolicyRule) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &d.PolicyType) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Exemption. func (e Exemption) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1113,6 +1250,7 @@ func (p ParameterDefinitionsValue) MarshalJSON() ([]byte, error) { populate(objectMap, "allowedValues", p.AllowedValues) populateAny(objectMap, "defaultValue", p.DefaultValue) populate(objectMap, "metadata", p.Metadata) + populateAny(objectMap, "schema", p.Schema) populate(objectMap, "type", p.Type) return json.Marshal(objectMap) } @@ -1135,6 +1273,9 @@ func (p *ParameterDefinitionsValue) UnmarshalJSON(data []byte) error { case "metadata": err = unpopulate(val, "Metadata", &p.Metadata) delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &p.Schema) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &p.Type) delete(rawMsg, key) @@ -1408,6 +1549,8 @@ func (s SetDefinitionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) populate(objectMap, "policyDefinitions", s.PolicyDefinitions) populate(objectMap, "policyType", s.PolicyType) + populate(objectMap, "version", s.Version) + populate(objectMap, "versions", s.Versions) return json.Marshal(objectMap) } @@ -1441,6 +1584,141 @@ func (s *SetDefinitionProperties) UnmarshalJSON(data []byte) error { case "policyType": err = unpopulate(val, "PolicyType", &s.PolicyType) delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) + case "versions": + err = unpopulate(val, "Versions", &s.Versions) + 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 SetDefinitionVersion. +func (s SetDefinitionVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersion. +func (s *SetDefinitionVersion) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 SetDefinitionVersionListResult. +func (s SetDefinitionVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionListResult. +func (s *SetDefinitionVersionListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + 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 SetDefinitionVersionProperties. +func (s SetDefinitionVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populate(objectMap, "displayName", s.DisplayName) + populateAny(objectMap, "metadata", s.Metadata) + populate(objectMap, "parameters", s.Parameters) + populate(objectMap, "policyDefinitionGroups", s.PolicyDefinitionGroups) + populate(objectMap, "policyDefinitions", s.PolicyDefinitions) + populate(objectMap, "policyType", s.PolicyType) + populate(objectMap, "version", s.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDefinitionVersionProperties. +func (s *SetDefinitionVersionProperties) 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 "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "metadata": + err = unpopulate(val, "Metadata", &s.Metadata) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &s.Parameters) + delete(rawMsg, key) + case "policyDefinitionGroups": + err = unpopulate(val, "PolicyDefinitionGroups", &s.PolicyDefinitionGroups) + delete(rawMsg, key) + case "policyDefinitions": + err = unpopulate(val, "PolicyDefinitions", &s.PolicyDefinitions) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &s.PolicyType) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1808,7 +2086,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/resources/armpolicy/options.go b/sdk/resourcemanager/resources/armpolicy/options.go index bb228a94716a..8ebd82190ccf 100644 --- a/sdk/resourcemanager/resources/armpolicy/options.go +++ b/sdk/resourcemanager/resources/armpolicy/options.go @@ -125,6 +125,83 @@ type DataPolicyManifestsClientListOptions struct { Filter *string } +// DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate +// method. +type DefinitionVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup +// method. +type DefinitionVersionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete method. +type DefinitionVersionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup +// method. +type DefinitionVersionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn +// method. +type DefinitionVersionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method. +type DefinitionVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.ListAllAtManagementGroup +// method. +type DefinitionVersionsClientListAllAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the DefinitionVersionsClient.ListAllBuiltins +// method. +type DefinitionVersionsClientListAllBuiltinsOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListAllOptions contains the optional parameters for the DefinitionVersionsClient.ListAll method. +type DefinitionVersionsClientListAllOptions struct { + // placeholder for future optional parameters +} + +// DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager +// method. +type DefinitionVersionsClientListBuiltInOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager +// method. +type DefinitionVersionsClientListByManagementGroupOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager method. +type DefinitionVersionsClientListOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + // DefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionsClient.CreateOrUpdateAtManagementGroup // method. type DefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { @@ -296,6 +373,85 @@ type ExemptionsClientUpdateOptions struct { // placeholder for future optional parameters } +// SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate +// method. +type SetDefinitionVersionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup +// method. +type SetDefinitionVersionsClientDeleteAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete method. +type SetDefinitionVersionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup +// method. +type SetDefinitionVersionsClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn +// method. +type SetDefinitionVersionsClientGetBuiltInOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get method. +type SetDefinitionVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup +// method. +type SetDefinitionVersionsClientListAllAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins +// method. +type SetDefinitionVersionsClientListAllBuiltinsOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll +// method. +type SetDefinitionVersionsClientListAllOptions struct { + // placeholder for future optional parameters +} + +// SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager +// method. +type SetDefinitionVersionsClientListBuiltInOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager +// method. +type SetDefinitionVersionsClientListByManagementGroupOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + +// SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager +// method. +type SetDefinitionVersionsClientListOptions struct { + // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. + Top *int32 +} + // SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup // method. type SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions struct { diff --git a/sdk/resourcemanager/resources/armpolicy/response_types.go b/sdk/resourcemanager/resources/armpolicy/responses.go similarity index 65% rename from sdk/resourcemanager/resources/armpolicy/response_types.go rename to sdk/resourcemanager/resources/armpolicy/responses.go index f77339d18272..6c5262aabdcc 100644 --- a/sdk/resourcemanager/resources/armpolicy/response_types.go +++ b/sdk/resourcemanager/resources/armpolicy/responses.go @@ -92,6 +92,82 @@ type DataPolicyManifestsClientListResponse struct { DataPolicyManifestListResult } +// DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup. +type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientCreateOrUpdateResponse contains the response from method DefinitionVersionsClient.CreateOrUpdate. +type DefinitionVersionsClientCreateOrUpdateResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method DefinitionVersionsClient.DeleteAtManagementGroup. +type DefinitionVersionsClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// DefinitionVersionsClientDeleteResponse contains the response from method DefinitionVersionsClient.Delete. +type DefinitionVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// DefinitionVersionsClientGetAtManagementGroupResponse contains the response from method DefinitionVersionsClient.GetAtManagementGroup. +type DefinitionVersionsClientGetAtManagementGroupResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientGetBuiltInResponse contains the response from method DefinitionVersionsClient.GetBuiltIn. +type DefinitionVersionsClientGetBuiltInResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientGetResponse contains the response from method DefinitionVersionsClient.Get. +type DefinitionVersionsClientGetResponse struct { + // The ID of the policy definition version. + DefinitionVersion +} + +// DefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method DefinitionVersionsClient.ListAllAtManagementGroup. +type DefinitionVersionsClientListAllAtManagementGroupResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListAllBuiltinsResponse contains the response from method DefinitionVersionsClient.ListAllBuiltins. +type DefinitionVersionsClientListAllBuiltinsResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListAllResponse contains the response from method DefinitionVersionsClient.ListAll. +type DefinitionVersionsClientListAllResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListBuiltInResponse contains the response from method DefinitionVersionsClient.NewListBuiltInPager. +type DefinitionVersionsClientListBuiltInResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListByManagementGroupResponse contains the response from method DefinitionVersionsClient.NewListByManagementGroupPager. +type DefinitionVersionsClientListByManagementGroupResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + +// DefinitionVersionsClientListResponse contains the response from method DefinitionVersionsClient.NewListPager. +type DefinitionVersionsClientListResponse struct { + // List of policy definition versions. + DefinitionVersionListResult +} + // DefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionsClient.CreateOrUpdateAtManagementGroup. type DefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { // The policy definition. @@ -197,6 +273,82 @@ type ExemptionsClientUpdateResponse struct { Exemption } +// SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup. +type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientCreateOrUpdateResponse contains the response from method SetDefinitionVersionsClient.CreateOrUpdate. +type SetDefinitionVersionsClientCreateOrUpdateResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientDeleteAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.DeleteAtManagementGroup. +type SetDefinitionVersionsClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// SetDefinitionVersionsClientDeleteResponse contains the response from method SetDefinitionVersionsClient.Delete. +type SetDefinitionVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// SetDefinitionVersionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.GetAtManagementGroup. +type SetDefinitionVersionsClientGetAtManagementGroupResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientGetBuiltInResponse contains the response from method SetDefinitionVersionsClient.GetBuiltIn. +type SetDefinitionVersionsClientGetBuiltInResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientGetResponse contains the response from method SetDefinitionVersionsClient.Get. +type SetDefinitionVersionsClientGetResponse struct { + // The policy set definition version. + SetDefinitionVersion +} + +// SetDefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.ListAllAtManagementGroup. +type SetDefinitionVersionsClientListAllAtManagementGroupResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListAllBuiltinsResponse contains the response from method SetDefinitionVersionsClient.ListAllBuiltins. +type SetDefinitionVersionsClientListAllBuiltinsResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListAllResponse contains the response from method SetDefinitionVersionsClient.ListAll. +type SetDefinitionVersionsClientListAllResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListBuiltInResponse contains the response from method SetDefinitionVersionsClient.NewListBuiltInPager. +type SetDefinitionVersionsClientListBuiltInResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListByManagementGroupResponse contains the response from method SetDefinitionVersionsClient.NewListByManagementGroupPager. +type SetDefinitionVersionsClientListByManagementGroupResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + +// SetDefinitionVersionsClientListResponse contains the response from method SetDefinitionVersionsClient.NewListPager. +type SetDefinitionVersionsClientListResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult +} + // SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method SetDefinitionsClient.CreateOrUpdateAtManagementGroup. type SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse struct { // The policy set definition. diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index 457a89d51f08..501b71fcc24c 100644 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go @@ -29,7 +29,7 @@ type SetDefinitionsClient struct { } // NewSetDefinitionsClient creates a new instance of SetDefinitionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionsClient, error) { @@ -47,7 +47,7 @@ func NewSetDefinitionsClient(subscriptionID string, credential azcore.TokenCrede // CreateOrUpdate - This operation creates or updates a policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. // - options - SetDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdate @@ -77,20 +77,20 @@ func (client *SetDefinitionsClient) CreateOrUpdate(ctx context.Context, policySe // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *SetDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -112,19 +112,19 @@ func (client *SetDefinitionsClient) createOrUpdateHandleResponse(resp *http.Resp // with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to create. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to create. // - parameters - The policy set definition properties. // - options - SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.CreateOrUpdateAtManagementGroup // method. -func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { +func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse, error) { var err error const operationName = "SetDefinitionsClient.CreateOrUpdateAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, parameters, options) + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, parameters, options) if err != nil { return SetDefinitionsClientCreateOrUpdateAtManagementGroupResponse{}, err } @@ -141,22 +141,22 @@ func (client *SetDefinitionsClient) CreateOrUpdateAtManagementGroup(ctx context. } // createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, parameters SetDefinition, options *SetDefinitionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -177,7 +177,7 @@ func (client *SetDefinitionsClient) createOrUpdateAtManagementGroupHandleRespons // Delete - This operation deletes the policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to delete. // - options - SetDefinitionsClientDeleteOptions contains the optional parameters for the SetDefinitionsClient.Delete method. func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientDeleteOptions) (SetDefinitionsClientDeleteResponse, error) { @@ -204,20 +204,20 @@ func (client *SetDefinitionsClient) Delete(ctx context.Context, policySetDefinit // deleteCreateRequest creates the Delete request. func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -227,18 +227,18 @@ func (client *SetDefinitionsClient) deleteCreateRequest(ctx context.Context, pol // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to delete. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to delete. // - options - SetDefinitionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.DeleteAtManagementGroup // method. -func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error) { +func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (SetDefinitionsClientDeleteAtManagementGroupResponse, error) { var err error const operationName = "SetDefinitionsClient.DeleteAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, options) + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientDeleteAtManagementGroupResponse{}, err } @@ -254,22 +254,22 @@ func (client *SetDefinitionsClient) DeleteAtManagementGroup(ctx context.Context, } // deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,7 +278,7 @@ func (client *SetDefinitionsClient) deleteAtManagementGroupCreateRequest(ctx con // Get - This operation retrieves the policy set definition in the given subscription with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method. func (client *SetDefinitionsClient) Get(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetOptions) (SetDefinitionsClientGetResponse, error) { @@ -306,20 +306,20 @@ func (client *SetDefinitionsClient) Get(ctx context.Context, policySetDefinition // getCreateRequest creates the Get request. func (client *SetDefinitionsClient) getCreateRequest(ctx context.Context, policySetDefinitionName string, options *SetDefinitionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,18 +338,18 @@ func (client *SetDefinitionsClient) getHandleResponse(resp *http.Response) (SetD // name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 -// - policySetDefinitionName - The name of the policy set definition to get. +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. +// - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup // method. -func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientGetAtManagementGroupOptions) (SetDefinitionsClientGetAtManagementGroupResponse, error) { +func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientGetAtManagementGroupOptions) (SetDefinitionsClientGetAtManagementGroupResponse, error) { var err error const operationName = "SetDefinitionsClient.GetAtManagementGroup" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getAtManagementGroupCreateRequest(ctx, policySetDefinitionName, managementGroupID, options) + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, policySetDefinitionName, options) if err != nil { return SetDefinitionsClientGetAtManagementGroupResponse{}, err } @@ -366,22 +366,22 @@ func (client *SetDefinitionsClient) GetAtManagementGroup(ctx context.Context, po } // getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, policySetDefinitionName string, managementGroupID string, options *SetDefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { +func (client *SetDefinitionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, policySetDefinitionName string, options *SetDefinitionsClientGetAtManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}" - if policySetDefinitionName == "" { - return nil, errors.New("parameter policySetDefinitionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -399,7 +399,7 @@ func (client *SetDefinitionsClient) getAtManagementGroupHandleResponse(resp *htt // GetBuiltIn - This operation retrieves the built-in policy set definition with the given name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn // method. @@ -437,7 +437,7 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -463,7 +463,7 @@ func (client *SetDefinitionsClient) getBuiltInHandleResponse(resp *http.Response // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - options - SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. func (client *SetDefinitionsClient) NewListPager(options *SetDefinitionsClientListOptions) *runtime.Pager[SetDefinitionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SetDefinitionsClientListResponse]{ @@ -500,10 +500,10 @@ func (client *SetDefinitionsClient) listCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -527,7 +527,7 @@ func (client *SetDefinitionsClient) listHandleResponse(resp *http.Response) (Set // given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all // built-in policy set definitions whose category match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. func (client *SetDefinitionsClient) NewListBuiltInPager(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { @@ -561,10 +561,10 @@ func (client *SetDefinitionsClient) listBuiltInCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -595,7 +595,7 @@ func (client *SetDefinitionsClient) listBuiltInHandleResponse(resp *http.Respons // If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category // match the {value}. // -// Generated from API version 2021-06-01 +// Generated from API version 2023-04-01 // - managementGroupID - The ID of the management group. // - options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager // method. @@ -634,10 +634,10 @@ func (client *SetDefinitionsClient) listByManagementGroupCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go deleted file mode 100644 index 5b04c80e7aa7..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client_example_test.go +++ /dev/null @@ -1,1028 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json -func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinition() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - DefaultValue: "myPrefix", - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.Ptr("Prefix to enforce on resource names"), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "[parameters('namePrefix')]", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // "namePrefix": &armpolicy.ParameterDefinitionsValue{ - // Type: to.Ptr(armpolicy.ParameterTypeString), - // DefaultValue: "myPrefix", - // Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - // DisplayName: to.Ptr("Prefix to enforce on resource names"), - // }, - // }, - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "[parameters('namePrefix')]", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json -func ExampleSetDefinitionsClient_CreateOrUpdate_createOrUpdateAPolicySetDefinitionWithGroups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdate(ctx, "CostManagement", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json -func ExampleSetDefinitionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().Delete(ctx, "CostManagement", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json -func ExampleSetDefinitionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().Get(ctx, "CostManagement", 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json -func ExampleSetDefinitionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().GetBuiltIn(ctx, "1f3afdf9-d0c9-4c3d-847f-89da613e70a8", 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListPager(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json -func ExampleSetDefinitionsClient_NewListBuiltInPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListBuiltInPager(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup_createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().CreateOrUpdateAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr("Policies to enforce low cost storage SKUs"), - DisplayName: to.Ptr("Cost Management"), - Metadata: map[string]any{ - "category": "Cost Management", - }, - PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - { - Name: to.Ptr("CostSaving"), - Description: to.Ptr("Policies designed to control spend within a subscription."), - DisplayName: to.Ptr("Cost Management Policies"), - }, - { - Name: to.Ptr("Organizational"), - Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - DisplayName: to.Ptr("Organizational Policies"), - }}, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - GroupNames: []*string{ - to.Ptr("CostSaving")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []any{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - }, - { - GroupNames: []*string{ - to.Ptr("Organizational")}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - }}, - }, - }, 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitionGroups: []*armpolicy.DefinitionGroup{ - // { - // Name: to.Ptr("CostSaving"), - // Description: to.Ptr("Policies designed to control spend within a subscription."), - // DisplayName: to.Ptr("Cost Management Policies"), - // }, - // { - // Name: to.Ptr("Organizational"), - // Description: to.Ptr("Policies that help enforce resource organization standards within a subscription."), - // DisplayName: to.Ptr("Organizational Policies"), - // }}, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // GroupNames: []*string{ - // to.Ptr("CostSaving")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // GroupNames: []*string{ - // to.Ptr("Organizational")}, - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewSetDefinitionsClient().DeleteAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSetDefinitionsClient().GetAtManagementGroup(ctx, "CostManagement", "MyManagementGroup", 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.SetDefinition = armpolicy.SetDefinition{ - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json -func ExampleSetDefinitionsClient_NewListByManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewSetDefinitionsClient().NewListByManagementGroupPager("MyManagementGroup", &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: 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.SetDefinitionListResult = armpolicy.SetDefinitionListResult{ - // Value: []*armpolicy.SetDefinition{ - // { - // Name: to.Ptr("1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Authorization/policySetDefinitions/1f3afdf9-d0c9-4c3d-847f-89da613e70a8"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Monitor all the available security recommendations in Azure Security Center. This is the default policy for Azure Security Center."), - // DisplayName: to.Ptr("[Preview]: Enable Monitoring in Azure Security Center"), - // Metadata: map[string]any{ - // "category": "Security Center", - // }, - // Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/a8bef009-a5c9-4d0f-90d7-6018734e8a16"), - // PolicyDefinitionReferenceID: to.Ptr("RefId1"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af8051bf-258b-44e2-a2bf-165330459f9d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId2"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/86b3d65f-7626-441e-b690-81a8b71cff60"), - // PolicyDefinitionReferenceID: to.Ptr("RefId3"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/655cb504-bcee-4362-bd4c-402e6aa38759"), - // PolicyDefinitionReferenceID: to.Ptr("RefId4"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c"), - // PolicyDefinitionReferenceID: to.Ptr("RefId5"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/47a6b606-51aa-4496-8bb7-64b11cf66adc"), - // PolicyDefinitionReferenceID: to.Ptr("RefId6"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/44452482-524f-4bf4-b852-0bff7cc4a3ed"), - // PolicyDefinitionReferenceID: to.Ptr("RefId7"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/e1e5fd5d-3e4c-4ce1-8661-7d1873ae6b15"), - // PolicyDefinitionReferenceID: to.Ptr("RefId8"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/af6cd1bd-1635-48cb-bde7-5b15693900b9"), - // PolicyDefinitionReferenceID: to.Ptr("RefId9"), - // }, - // { - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/0961003e-5a0a-4549-abde-af6a37f2724d"), - // PolicyDefinitionReferenceID: to.Ptr("RefId10"), - // }}, - // PolicyType: to.Ptr(armpolicy.PolicyTypeBuiltIn), - // }, - // }, - // { - // Name: to.Ptr("CostManagement"), - // Type: to.Ptr("Microsoft.Authorization/policySetDefinitions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policySetDefinitions/CostManagement"), - // Properties: &armpolicy.SetDefinitionProperties{ - // Description: to.Ptr("Policies to enforce low cost storage SKUs"), - // DisplayName: to.Ptr("Cost Management"), - // Metadata: map[string]any{ - // "category": "Cost Management", - // }, - // PolicyDefinitions: []*armpolicy.DefinitionReference{ - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "listOfAllowedSKUs": &armpolicy.ParameterValuesValue{ - // Value: []any{ - // "Standard_GRS", - // "Standard_LRS", - // }, - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1"), - // PolicyDefinitionReferenceID: to.Ptr("Limit_Skus"), - // }, - // { - // Parameters: map[string]*armpolicy.ParameterValuesValue{ - // "prefix": &armpolicy.ParameterValuesValue{ - // Value: "DeptA", - // }, - // "suffix": &armpolicy.ParameterValuesValue{ - // Value: "-LC", - // }, - // }, - // PolicyDefinitionID: to.Ptr("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming"), - // PolicyDefinitionReferenceID: to.Ptr("Resource_Naming"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go new file mode 100644 index 000000000000..c12b42727dd3 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go @@ -0,0 +1,832 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armpolicy + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SetDefinitionVersionsClient contains the methods for the PolicySetDefinitionVersions group. +// Don't use this type directly, use NewSetDefinitionVersionsClient() instead. +type SetDefinitionVersionsClient struct { + internal *arm.Client + subscriptionID string + policySetDefinitionName string + policyDefinitionVersion string +} + +// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy definition version. The format is x.y.z where x is the major version number, y is +// the minor version number, and z is the patch number +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSetDefinitionVersionsClient(subscriptionID string, policySetDefinitionName string, policyDefinitionVersion string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SetDefinitionVersionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SetDefinitionVersionsClient{ + subscriptionID: subscriptionID, + policySetDefinitionName: policySetDefinitionName, + policyDefinitionVersion: policyDefinitionVersion, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - This operation creates or updates a policy set definition version in the given subscription with the given +// name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - parameters - The policy set definition properties. +// - options - SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate +// method. +func (client *SetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, parameters, options) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SetDefinitionVersionsClient) createOrUpdateCreateRequest(ctx context.Context, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SetDefinitionVersionsClient) createOrUpdateHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateResponse, error) { + result := SetDefinitionVersionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// CreateOrUpdateAtManagementGroup - This operation creates or updates a policy set definition version in the given management +// group with the given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - parameters - The policy set definition version properties. +// - options - SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupName string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupName, parameters, options) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, parameters SetDefinitionVersion, options *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateAtManagementGroupHandleResponse handles the CreateOrUpdateAtManagementGroup response. +func (client *SetDefinitionVersionsClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse{}, err + } + return result, nil +} + +// Delete - This operation deletes the policy set definition version in the given subscription with the given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete +// method. +func (client *SetDefinitionVersionsClient) Delete(ctx context.Context, options *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientDeleteResponse{}, err + } + return SetDefinitionVersionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SetDefinitionVersionsClient) deleteCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteAtManagementGroup - This operation deletes the policy set definition version in the given management group with the +// given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.DeleteAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, err + } + return SetDefinitionVersionsClientDeleteAtManagementGroupResponse{}, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *SetDefinitionVersionsClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - This operation retrieves the policy set definition version in the given subscription with the given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get +// method. +func (client *SetDefinitionVersionsClient) Get(ctx context.Context, options *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SetDefinitionVersionsClient) getCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SetDefinitionVersionsClient) getHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetResponse, error) { + result := SetDefinitionVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - This operation retrieves the policy set definition version in the given management group with the +// given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.GetAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *SetDefinitionVersionsClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *SetDefinitionVersionsClient) getAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// GetBuiltIn - This operation retrieves the built-in policy set definition version with the given name and version. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn +// method. +func (client *SetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, options *SetDefinitionVersionsClientGetBuiltInOptions) (SetDefinitionVersionsClientGetBuiltInResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.GetBuiltIn" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBuiltInCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + resp, err := client.getBuiltInHandleResponse(httpResp) + return resp, err +} + +// getBuiltInCreateRequest creates the GetBuiltIn request. +func (client *SetDefinitionVersionsClient) getBuiltInCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + if client.policyDefinitionVersion == "" { + return nil, errors.New("parameter client.policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(client.policyDefinitionVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBuiltInHandleResponse handles the GetBuiltIn response. +func (client *SetDefinitionVersionsClient) getBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientGetBuiltInResponse, error) { + result := SetDefinitionVersionsClientGetBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersion); err != nil { + return SetDefinitionVersionsClientGetBuiltInResponse{}, err + } + return result, nil +} + +// NewListPager - This operation retrieves a list of all the policy set definition versions for the given policy set definition. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager +// method. +func (client *SetDefinitionVersionsClient) NewListPager(options *SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListResponse]{ + More: func(page SetDefinitionVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListResponse) (SetDefinitionVersionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return SetDefinitionVersionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *SetDefinitionVersionsClient) listCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SetDefinitionVersionsClient) listHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListResponse, error) { + result := SetDefinitionVersionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListResponse{}, err + } + return result, nil +} + +// ListAll - This operation lists all the policy set definition versions for all policy set definitions within a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientListAllOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAll +// method. +func (client *SetDefinitionVersionsClient) ListAll(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (SetDefinitionVersionsClientListAllResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.ListAll" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllResponse{}, err + } + resp, err := client.listAllHandleResponse(httpResp) + return resp, err +} + +// listAllCreateRequest creates the ListAll request. +func (client *SetDefinitionVersionsClient) listAllCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListAllOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllHandleResponse handles the ListAll response. +func (client *SetDefinitionVersionsClient) listAllHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllResponse, error) { + result := SetDefinitionVersionsClientListAllResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllResponse{}, err + } + return result, nil +} + +// ListAllAtManagementGroup - This operation lists all the policy set definition versions for all policy set definitions at +// the management group scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) ListAllAtManagementGroup(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.ListAllAtManagementGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllAtManagementGroupCreateRequest(ctx, managementGroupName, options) + if err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + resp, err := client.listAllAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// listAllAtManagementGroupCreateRequest creates the ListAllAtManagementGroup request. +func (client *SetDefinitionVersionsClient) listAllAtManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListAllAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllAtManagementGroupHandleResponse handles the ListAllAtManagementGroup response. +func (client *SetDefinitionVersionsClient) listAllAtManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllAtManagementGroupResponse, error) { + result := SetDefinitionVersionsClientListAllAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllAtManagementGroupResponse{}, err + } + return result, nil +} + +// ListAllBuiltins - This operation lists all the built-in policy set definition versions for all built-in policy set definitions. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins +// method. +func (client *SetDefinitionVersionsClient) ListAllBuiltins(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { + var err error + const operationName = "SetDefinitionVersionsClient.ListAllBuiltins" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listAllBuiltinsCreateRequest(ctx, options) + if err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + resp, err := client.listAllBuiltinsHandleResponse(httpResp) + return resp, err +} + +// listAllBuiltinsCreateRequest creates the ListAllBuiltins request. +func (client *SetDefinitionVersionsClient) listAllBuiltinsCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListAllBuiltinsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/listPolicySetDefinitionVersions" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAllBuiltinsHandleResponse handles the ListAllBuiltins response. +func (client *SetDefinitionVersionsClient) listAllBuiltinsHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListAllBuiltinsResponse, error) { + result := SetDefinitionVersionsClientListAllBuiltinsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListAllBuiltinsResponse{}, err + } + return result, nil +} + +// NewListBuiltInPager - This operation retrieves a list of all the built-in policy set definition versions for the given +// built-in policy set definition. +// +// Generated from API version 2023-04-01 +// - options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *SetDefinitionVersionsClient) NewListBuiltInPager(options *SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListBuiltInResponse]{ + More: func(page SetDefinitionVersionsClientListBuiltInResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListBuiltInResponse) (SetDefinitionVersionsClientListBuiltInResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListBuiltInPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBuiltInCreateRequest(ctx, options) + }, nil) + if err != nil { + return SetDefinitionVersionsClientListBuiltInResponse{}, err + } + return client.listBuiltInHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBuiltInCreateRequest creates the ListBuiltIn request. +func (client *SetDefinitionVersionsClient) listBuiltInCreateRequest(ctx context.Context, options *SetDefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBuiltInHandleResponse handles the ListBuiltIn response. +func (client *SetDefinitionVersionsClient) listBuiltInHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListBuiltInResponse, error) { + result := SetDefinitionVersionsClientListBuiltInResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListBuiltInResponse{}, err + } + return result, nil +} + +// NewListByManagementGroupPager - This operation retrieves a list of all the policy set definition versions for the given +// policy set definition in a given management group. +// +// Generated from API version 2023-04-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *SetDefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[SetDefinitionVersionsClientListByManagementGroupResponse]{ + More: func(page SetDefinitionVersionsClientListByManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SetDefinitionVersionsClientListByManagementGroupResponse) (SetDefinitionVersionsClientListByManagementGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SetDefinitionVersionsClient.NewListByManagementGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByManagementGroupCreateRequest(ctx, managementGroupName, options) + }, nil) + if err != nil { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, err + } + return client.listByManagementGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByManagementGroupCreateRequest creates the ListByManagementGroup request. +func (client *SetDefinitionVersionsClient) listByManagementGroupCreateRequest(ctx context.Context, managementGroupName string, options *SetDefinitionVersionsClientListByManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupName}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + if managementGroupName == "" { + return nil, errors.New("parameter managementGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupName}", url.PathEscape(managementGroupName)) + if client.policySetDefinitionName == "" { + return nil, errors.New("parameter client.policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(client.policySetDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2023-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByManagementGroupHandleResponse handles the ListByManagementGroup response. +func (client *SetDefinitionVersionsClient) listByManagementGroupHandleResponse(resp *http.Response) (SetDefinitionVersionsClientListByManagementGroupResponse, error) { + result := SetDefinitionVersionsClientListByManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SetDefinitionVersionListResult); err != nil { + return SetDefinitionVersionsClientListByManagementGroupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go b/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go index b5e151c43800..9f953d92166d 100644 --- a/sdk/resourcemanager/resources/armpolicy/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armpolicy/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/resources/armpolicy/variables_client.go b/sdk/resourcemanager/resources/armpolicy/variables_client.go index 40efd8d8c4dc..200fd55640db 100644 --- a/sdk/resourcemanager/resources/armpolicy/variables_client.go +++ b/sdk/resourcemanager/resources/armpolicy/variables_client.go @@ -28,7 +28,7 @@ type VariablesClient struct { } // NewVariablesClient creates a new instance of VariablesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVariablesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariablesClient, error) { diff --git a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go deleted file mode 100644 index 39726b6d8ebb..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go +++ /dev/null @@ -1,355 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariable.json -func ExampleVariablesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().Delete(ctx, "DemoTestVariable", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariable.json -func ExampleVariablesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdate(ctx, "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariable.json -func ExampleVariablesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().Get(ctx, "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableAtManagementGroup.json -func ExampleVariablesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariablesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableAtManagementGroup.json -func ExampleVariablesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", armpolicy.Variable{ - Properties: &armpolicy.VariableProperties{ - Columns: []*armpolicy.VariableColumn{ - { - ColumnName: to.Ptr("TestColumn"), - }}, - }, - }, 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableAtManagementGroup.json -func ExampleVariablesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariablesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", 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.Variable = armpolicy.Variable{ - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForSubscription.json -func ExampleVariablesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariablesForManagementGroup.json -func ExampleVariablesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariablesClient().NewListForManagementGroupPager("DevOrg", 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.VariableListResult = armpolicy.VariableListResult{ - // Value: []*armpolicy.Variable{ - // { - // Name: to.Ptr("DemoTestVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("TestColumn"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NetworkingVariable"), - // Type: to.Ptr("Microsoft.Authorization/variables"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/NetworkingVariable"), - // Properties: &armpolicy.VariableProperties{ - // Columns: []*armpolicy.VariableColumn{ - // { - // ColumnName: to.Ptr("NetworkResourceName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go index 97ebe9c492d3..2c1b1cd3e026 100644 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go +++ b/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go @@ -28,7 +28,7 @@ type VariableValuesClient struct { } // NewVariableValuesClient creates a new instance of VariableValuesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVariableValuesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VariableValuesClient, error) { diff --git a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go b/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go deleted file mode 100644 index 4c4cf8803e69..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client_example_test.go +++ /dev/null @@ -1,395 +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 armpolicy_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/resources/armpolicy" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValue.json -func ExampleVariableValuesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().Delete(ctx, "DemoTestVariable", "TestValue", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValue.json -func ExampleVariableValuesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdate(ctx, "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValue.json -func ExampleVariableValuesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().Get(ctx, "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForSubscription.json -func ExampleVariableValuesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListPager("DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/listVariableValuesForManagementGroup.json -func ExampleVariableValuesClient_NewListForManagementGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewVariableValuesClient().NewListForManagementGroupPager("DevOrg", "DemoTestVariable", 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.VariableValueListResult = armpolicy.VariableValueListResult{ - // Value: []*armpolicy.VariableValue{ - // { - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }, - // { - // Name: to.Ptr("NullableTestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/NullableTestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("NullColumnName"), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/deleteVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_DeleteAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewVariableValuesClient().DeleteAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", 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/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/createOrUpdateVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().CreateOrUpdateAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", armpolicy.VariableValue{ - Properties: &armpolicy.VariableValueProperties{ - Values: []*armpolicy.VariableValueColumnValue{ - { - ColumnName: to.Ptr("StringColumn"), - ColumnValue: "SampleValue", - }, - { - ColumnName: to.Ptr("IntegerColumn"), - ColumnValue: float64(10), - }}, - }, - }, 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T02:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-08-01-preview/examples/getVariableValueAtManagementGroup.json -func ExampleVariableValuesClient_GetAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armpolicy.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewVariableValuesClient().GetAtManagementGroup(ctx, "DevOrg", "DemoTestVariable", "TestValue", 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.VariableValue = armpolicy.VariableValue{ - // Name: to.Ptr("TestValue"), - // Type: to.Ptr("Microsoft.Authorization/variables/values"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/DevOrg/providers/Microsoft.Authorization/variables/DemoTestVariable/values/TestValue"), - // Properties: &armpolicy.VariableValueProperties{ - // Values: []*armpolicy.VariableValueColumnValue{ - // { - // ColumnName: to.Ptr("StringColumn"), - // ColumnValue: "SampleValue", - // }, - // { - // ColumnName: to.Ptr("IntegerColumn"), - // ColumnValue: float64(10), - // }}, - // }, - // SystemData: &armpolicy.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armpolicy.CreatedByTypeUser), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/CHANGELOG.md b/sdk/resourcemanager/resources/armresources/CHANGELOG.md index 7186a65f14a3..e465da30fb64 100644 --- a/sdk/resourcemanager/resources/armresources/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armresources/CHANGELOG.md @@ -1,5 +1,24 @@ # Release History +## 2.0.0 (2024-05-02) +### Breaking Changes + +- Type of `DeploymentProperties.Parameters` has been changed from `any` to `map[string]*DeploymentParameter` +- Type of `DeploymentWhatIfProperties.Parameters` has been changed from `any` to `map[string]*DeploymentParameter` +- Operation `*TagsClient.CreateOrUpdateAtScope` has been changed to LRO, use `*TagsClient.BeginCreateOrUpdateAtScope` instead. +- Operation `*TagsClient.DeleteAtScope` has been changed to LRO, use `*TagsClient.BeginDeleteAtScope` instead. +- Operation `*TagsClient.UpdateAtScope` has been changed to LRO, use `*TagsClient.BeginUpdateAtScope` instead. + +### Features Added + +- New enum type `ExportTemplateOutputFormat` with values `ExportTemplateOutputFormatBicep`, `ExportTemplateOutputFormatJSON` +- New struct `DeploymentParameter` +- New struct `KeyVaultParameterReference` +- New struct `KeyVaultReference` +- New field `OutputFormat` in struct `ExportTemplateRequest` +- New field `Output` in struct `ResourceGroupExportResult` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armresources/README.md b/sdk/resourcemanager/resources/armresources/README.md index fbe11f6c642a..020ae24b3fc2 100644 --- a/sdk/resourcemanager/resources/armresources/README.md +++ b/sdk/resourcemanager/resources/armresources/README.md @@ -1,6 +1,6 @@ # Azure Resources Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2) The `armresources` module provides operations for working with Azure Resources. @@ -20,7 +20,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Resources module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2 ``` ## Authorization diff --git a/sdk/resourcemanager/resources/armresources/autorest.md b/sdk/resourcemanager/resources/armresources/autorest.md index 58dea419a422..7131f95f38e2 100644 --- a/sdk/resourcemanager/resources/armresources/autorest.md +++ b/sdk/resourcemanager/resources/armresources/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 2.0.0 package-resources: true ``` diff --git a/sdk/resourcemanager/resources/armresources/client.go b/sdk/resourcemanager/resources/armresources/client.go index 46fde2c78cb7..7cd61af885d3 100644 --- a/sdk/resourcemanager/resources/armresources/client.go +++ b/sdk/resourcemanager/resources/armresources/client.go @@ -46,7 +46,7 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // CheckExistence - Checks whether a resource exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group containing the resource to check. The name is case insensitive. // - resourceProviderNamespace - The resource provider of the resource to check. // - parentResourcePath - The parent resource identity. @@ -107,9 +107,11 @@ func (client *Client) checkExistenceCreateRequest(ctx context.Context, resourceG return req, nil } -// CheckExistenceByID - Checks by ID whether a resource exists. +// CheckExistenceByID - Checks by ID whether a resource exists. This API currently works only for a limited set of Resource +// providers. In the event that a Resource provider does not implement this API, ARM will respond with +// a 405. The alternative then is to use the GET API to check for the existence of the resource. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -153,7 +155,7 @@ func (client *Client) checkExistenceByIDCreateRequest(ctx context.Context, resou // BeginCreateOrUpdate - Creates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group for the resource. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -182,7 +184,7 @@ func (client *Client) BeginCreateOrUpdate(ctx context.Context, resourceGroupName // CreateOrUpdate - Creates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) createOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreateOrUpdate" @@ -242,7 +244,7 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, resourceG // BeginCreateOrUpdateByID - Create a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -269,7 +271,7 @@ func (client *Client) BeginCreateOrUpdateByID(ctx context.Context, resourceID st // CreateOrUpdateByID - Create a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) createOrUpdateByID(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginCreateOrUpdateByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreateOrUpdateByID" @@ -312,7 +314,7 @@ func (client *Client) createOrUpdateByIDCreateRequest(ctx context.Context, resou // BeginDelete - Deletes a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group that contains the resource to delete. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -340,7 +342,7 @@ func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, // Delete - Deletes a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, options *ClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "Client.BeginDelete" @@ -397,7 +399,7 @@ func (client *Client) deleteCreateRequest(ctx context.Context, resourceGroupName // BeginDeleteByID - Deletes a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -422,7 +424,7 @@ func (client *Client) BeginDeleteByID(ctx context.Context, resourceID string, ap // DeleteByID - Deletes a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) deleteByID(ctx context.Context, resourceID string, apiVersion string, options *ClientBeginDeleteByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginDeleteByID" @@ -462,7 +464,7 @@ func (client *Client) deleteByIDCreateRequest(ctx context.Context, resourceID st // Get - Gets a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group containing the resource to get. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -536,7 +538,7 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // GetByID - Gets a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -589,7 +591,7 @@ func (client *Client) getByIDHandleResponse(resp *http.Response) (ClientGetByIDR // NewListPager - Get all the resources in a subscription. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ @@ -626,16 +628,16 @@ func (client *Client) listCreateRequest(ctx context.Context, options *ClientList return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -652,7 +654,7 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons // NewListByResourceGroupPager - Get all the resources for a resource group. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The resource group with the resources to get. // - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager // method. @@ -695,16 +697,16 @@ func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -725,7 +727,7 @@ func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (Cl // on the groups until the move completes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - sourceResourceGroupName - The name of the resource group from the source subscription containing the resources to be moved. // - parameters - Parameters for moving resources. // - options - ClientBeginMoveResourcesOptions contains the optional parameters for the Client.BeginMoveResources method. @@ -752,7 +754,7 @@ func (client *Client) BeginMoveResources(ctx context.Context, sourceResourceGrou // on the groups until the move completes. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) moveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginMoveResourcesOptions) (*http.Response, error) { var err error const operationName = "Client.BeginMoveResources" @@ -790,7 +792,7 @@ func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceReso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -802,7 +804,7 @@ func (client *Client) moveResourcesCreateRequest(ctx context.Context, sourceReso // BeginUpdate - Updates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group for the resource. The name is case insensitive. // - resourceProviderNamespace - The namespace of the resource provider. // - parentResourcePath - The parent resource identity. @@ -831,7 +833,7 @@ func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, // Update - Updates a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginUpdate" @@ -891,7 +893,7 @@ func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName // BeginUpdateByID - Updates a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceID - The fully qualified ID of the resource, including the resource name and resource type. Use the format, // /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} // - apiVersion - The API version to use for the operation. @@ -917,7 +919,7 @@ func (client *Client) BeginUpdateByID(ctx context.Context, resourceID string, ap // UpdateByID - Updates a resource by ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) updateByID(ctx context.Context, resourceID string, apiVersion string, parameters GenericResource, options *ClientBeginUpdateByIDOptions) (*http.Response, error) { var err error const operationName = "Client.BeginUpdateByID" @@ -964,7 +966,7 @@ func (client *Client) updateByIDCreateRequest(ctx context.Context, resourceID st // error message. Retrieve the URL in the Location header value to check the result of the long-running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - sourceResourceGroupName - The name of the resource group from the source subscription containing the resources to be validated // for move. // - parameters - Parameters for moving resources. @@ -994,7 +996,7 @@ func (client *Client) BeginValidateMoveResources(ctx context.Context, sourceReso // error message. Retrieve the URL in the Location header value to check the result of the long-running operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *Client) validateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo, options *ClientBeginValidateMoveResourcesOptions) (*http.Response, error) { var err error const operationName = "Client.BeginValidateMoveResources" @@ -1032,7 +1034,7 @@ func (client *Client) validateMoveResourcesCreateRequest(ctx context.Context, so return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/client_factory.go b/sdk/resourcemanager/resources/armresources/client_factory.go index bcd6487d6961..8470b7bf6702 100644 --- a/sdk/resourcemanager/resources/armresources/client_factory.go +++ b/sdk/resourcemanager/resources/armresources/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. @@ -27,60 +26,75 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeploymentOperationsClient creates a new instance of DeploymentOperationsClient. func (c *ClientFactory) NewDeploymentOperationsClient() *DeploymentOperationsClient { - subClient, _ := NewDeploymentOperationsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeploymentOperationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewDeploymentsClient creates a new instance of DeploymentsClient. func (c *ClientFactory) NewDeploymentsClient() *DeploymentsClient { - subClient, _ := NewDeploymentsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &DeploymentsClient{ + 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, + } } // NewProviderResourceTypesClient creates a new instance of ProviderResourceTypesClient. func (c *ClientFactory) NewProviderResourceTypesClient() *ProviderResourceTypesClient { - subClient, _ := NewProviderResourceTypesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProviderResourceTypesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewProvidersClient creates a new instance of ProvidersClient. func (c *ClientFactory) NewProvidersClient() *ProvidersClient { - subClient, _ := NewProvidersClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ProvidersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewResourceGroupsClient creates a new instance of ResourceGroupsClient. func (c *ClientFactory) NewResourceGroupsClient() *ResourceGroupsClient { - subClient, _ := NewResourceGroupsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &ResourceGroupsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTagsClient creates a new instance of TagsClient. func (c *ClientFactory) NewTagsClient() *TagsClient { - subClient, _ := NewTagsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TagsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armresources/constants.go b/sdk/resourcemanager/resources/armresources/constants.go index 6cf0f0dc33cb..013db539c203 100644 --- a/sdk/resourcemanager/resources/armresources/constants.go +++ b/sdk/resourcemanager/resources/armresources/constants.go @@ -10,7 +10,7 @@ package armresources const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to. @@ -165,6 +165,22 @@ func PossibleDeploymentModeValues() []DeploymentMode { } } +// ExportTemplateOutputFormat - The output format for the exported resources. +type ExportTemplateOutputFormat string + +const ( + ExportTemplateOutputFormatBicep ExportTemplateOutputFormat = "Bicep" + ExportTemplateOutputFormatJSON ExportTemplateOutputFormat = "Json" +) + +// PossibleExportTemplateOutputFormatValues returns the possible values for the ExportTemplateOutputFormat const type. +func PossibleExportTemplateOutputFormatValues() []ExportTemplateOutputFormat { + return []ExportTemplateOutputFormat{ + ExportTemplateOutputFormatBicep, + ExportTemplateOutputFormatJSON, + } +} + // ExpressionEvaluationOptionsScopeType - The scope to be used for evaluation of parameters, variables and functions in a // nested template. type ExpressionEvaluationOptionsScopeType string diff --git a/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go b/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go index ec1e1ab800e4..313b28581ad9 100644 --- a/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go +++ b/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go @@ -47,7 +47,7 @@ func NewDeploymentOperationsClient(subscriptionID string, credential azcore.Toke // Get - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -99,7 +99,7 @@ func (client *DeploymentOperationsClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -117,7 +117,7 @@ func (client *DeploymentOperationsClient) getHandleResponse(resp *http.Response) // GetAtManagementGroupScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -165,7 +165,7 @@ func (client *DeploymentOperationsClient) getAtManagementGroupScopeCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -183,7 +183,7 @@ func (client *DeploymentOperationsClient) getAtManagementGroupScopeHandleRespons // GetAtScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. @@ -228,7 +228,7 @@ func (client *DeploymentOperationsClient) getAtScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -246,7 +246,7 @@ func (client *DeploymentOperationsClient) getAtScopeHandleResponse(resp *http.Re // GetAtSubscriptionScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. // - options - DeploymentOperationsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtSubscriptionScope @@ -293,7 +293,7 @@ func (client *DeploymentOperationsClient) getAtSubscriptionScopeCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -311,7 +311,7 @@ func (client *DeploymentOperationsClient) getAtSubscriptionScopeHandleResponse(r // GetAtTenantScope - Gets a deployments operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - operationID - The ID of the operation to get. // - options - DeploymentOperationsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.GetAtTenantScope @@ -354,7 +354,7 @@ func (client *DeploymentOperationsClient) getAtTenantScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +371,7 @@ func (client *DeploymentOperationsClient) getAtTenantScopeHandleResponse(resp *h // NewListPager - Gets all deployments operations for a deployment. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListOptions contains the optional parameters for the DeploymentOperationsClient.NewListPager @@ -422,7 +422,7 @@ func (client *DeploymentOperationsClient) listCreateRequest(ctx context.Context, if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -439,7 +439,7 @@ func (client *DeploymentOperationsClient) listHandleResponse(resp *http.Response // NewListAtManagementGroupScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtManagementGroupScopePager @@ -486,7 +486,7 @@ func (client *DeploymentOperationsClient) listAtManagementGroupScopeCreateReques if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -503,7 +503,7 @@ func (client *DeploymentOperationsClient) listAtManagementGroupScopeHandleRespon // NewListAtScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtScopePager @@ -547,7 +547,7 @@ func (client *DeploymentOperationsClient) listAtScopeCreateRequest(ctx context.C if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -564,7 +564,7 @@ func (client *DeploymentOperationsClient) listAtScopeHandleResponse(resp *http.R // NewListAtSubscriptionScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtSubscriptionScopePager // method. @@ -610,7 +610,7 @@ func (client *DeploymentOperationsClient) listAtSubscriptionScopeCreateRequest(c if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -627,7 +627,7 @@ func (client *DeploymentOperationsClient) listAtSubscriptionScopeHandleResponse( // NewListAtTenantScopePager - Gets all deployments operations for a deployment. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentOperationsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentOperationsClient.NewListAtTenantScopePager // method. @@ -669,7 +669,7 @@ func (client *DeploymentOperationsClient) listAtTenantScopeCreateRequest(ctx con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/deployments_client.go b/sdk/resourcemanager/resources/armresources/deployments_client.go index 2e9eff6b7792..bc13e1bc54b0 100644 --- a/sdk/resourcemanager/resources/armresources/deployments_client.go +++ b/sdk/resourcemanager/resources/armresources/deployments_client.go @@ -47,7 +47,7 @@ func NewDeploymentsClient(subscriptionID string, credential azcore.TokenCredenti // CalculateTemplateHash - Calculate the hash of the given template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - templateParam - The template provided to calculate hash. // - options - DeploymentsClientCalculateTemplateHashOptions contains the optional parameters for the DeploymentsClient.CalculateTemplateHash // method. @@ -81,7 +81,7 @@ func (client *DeploymentsClient) calculateTemplateHashCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, templateParam); err != nil { @@ -104,7 +104,7 @@ func (client *DeploymentsClient) calculateTemplateHashHandleResponse(resp *http. // currently running template deployment and leaves the resource group partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCancelOptions contains the optional parameters for the DeploymentsClient.Cancel method. @@ -149,7 +149,7 @@ func (client *DeploymentsClient) cancelCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -160,7 +160,7 @@ func (client *DeploymentsClient) cancelCreateRequest(ctx context.Context, resour // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCancelAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtManagementGroupScope @@ -202,7 +202,7 @@ func (client *DeploymentsClient) cancelAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -213,7 +213,7 @@ func (client *DeploymentsClient) cancelAtManagementGroupScopeCreateRequest(ctx c // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCancelAtScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtScope @@ -252,7 +252,7 @@ func (client *DeploymentsClient) cancelAtScopeCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -263,7 +263,7 @@ func (client *DeploymentsClient) cancelAtScopeCreateRequest(ctx context.Context, // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientCancelAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtSubscriptionScope // method. @@ -304,7 +304,7 @@ func (client *DeploymentsClient) cancelAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -315,7 +315,7 @@ func (client *DeploymentsClient) cancelAtSubscriptionScopeCreateRequest(ctx cont // currently running template deployment and leaves the resources partially deployed. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientCancelAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CancelAtTenantScope // method. @@ -352,7 +352,7 @@ func (client *DeploymentsClient) cancelAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -360,7 +360,7 @@ func (client *DeploymentsClient) cancelAtTenantScopeCreateRequest(ctx context.Co // CheckExistence - Checks whether the deployment exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group with the deployment to check. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCheckExistenceOptions contains the optional parameters for the DeploymentsClient.CheckExistence @@ -406,7 +406,7 @@ func (client *DeploymentsClient) checkExistenceCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -414,7 +414,7 @@ func (client *DeploymentsClient) checkExistenceCreateRequest(ctx context.Context // CheckExistenceAtManagementGroupScope - Checks whether the deployment exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCheckExistenceAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtManagementGroupScope @@ -456,7 +456,7 @@ func (client *DeploymentsClient) checkExistenceAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -464,7 +464,7 @@ func (client *DeploymentsClient) checkExistenceAtManagementGroupScopeCreateReque // CheckExistenceAtScope - Checks whether the deployment exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentsClientCheckExistenceAtScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtScope @@ -503,7 +503,7 @@ func (client *DeploymentsClient) checkExistenceAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -511,7 +511,7 @@ func (client *DeploymentsClient) checkExistenceAtScopeCreateRequest(ctx context. // CheckExistenceAtSubscriptionScope - Checks whether the deployment exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientCheckExistenceAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtSubscriptionScope // method. @@ -552,7 +552,7 @@ func (client *DeploymentsClient) checkExistenceAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -560,7 +560,7 @@ func (client *DeploymentsClient) checkExistenceAtSubscriptionScopeCreateRequest( // CheckExistenceAtTenantScope - Checks whether the deployment exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientCheckExistenceAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.CheckExistenceAtTenantScope // method. @@ -597,7 +597,7 @@ func (client *DeploymentsClient) checkExistenceAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -606,7 +606,7 @@ func (client *DeploymentsClient) checkExistenceAtTenantScopeCreateRequest(ctx co // BeginCreateOrUpdate - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to deploy the resources to. The name is case insensitive. The resource // group must already exist. // - deploymentName - The name of the deployment. @@ -633,7 +633,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdate(ctx context.Context, resour // CreateOrUpdate - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdate" @@ -675,7 +675,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -688,7 +688,7 @@ func (client *DeploymentsClient) createOrUpdateCreateRequest(ctx context.Context // to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. @@ -715,7 +715,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtManagementGroupScope(ctx c // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) createOrUpdateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtManagementGroupScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdateAtManagementGroupScope" @@ -753,7 +753,7 @@ func (client *DeploymentsClient) createOrUpdateAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -765,7 +765,7 @@ func (client *DeploymentsClient) createOrUpdateAtManagementGroupScopeCreateReque // BeginCreateOrUpdateAtScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. @@ -791,7 +791,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtScope(ctx context.Context, // CreateOrUpdateAtScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) createOrUpdateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdateAtScope" @@ -826,7 +826,7 @@ func (client *DeploymentsClient) createOrUpdateAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -839,7 +839,7 @@ func (client *DeploymentsClient) createOrUpdateAtScopeCreateRequest(ctx context. // JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. // - options - DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope @@ -865,7 +865,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtSubscriptionScope(ctx cont // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) createOrUpdateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginCreateOrUpdateAtSubscriptionScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdateAtSubscriptionScope" @@ -903,7 +903,7 @@ func (client *DeploymentsClient) createOrUpdateAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -916,7 +916,7 @@ func (client *DeploymentsClient) createOrUpdateAtSubscriptionScopeCreateRequest( // files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Additional parameters supplied to the operation. // - options - DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginCreateOrUpdateAtTenantScope @@ -941,7 +941,7 @@ func (client *DeploymentsClient) BeginCreateOrUpdateAtTenantScope(ctx context.Co // CreateOrUpdateAtTenantScope - You can provide the template and parameters directly in the request or link to JSON files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) createOrUpdateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginCreateOrUpdateAtTenantScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginCreateOrUpdateAtTenantScope" @@ -975,7 +975,7 @@ func (client *DeploymentsClient) createOrUpdateAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -994,7 +994,7 @@ func (client *DeploymentsClient) createOrUpdateAtTenantScopeCreateRequest(ctx co // code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group with the deployment to delete. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentsClientBeginDeleteOptions contains the optional parameters for the DeploymentsClient.BeginDelete method. @@ -1025,7 +1025,7 @@ func (client *DeploymentsClient) BeginDelete(ctx context.Context, resourceGroupN // code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) deleteOperation(ctx context.Context, resourceGroupName string, deploymentName string, options *DeploymentsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDelete" @@ -1067,7 +1067,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1082,7 +1082,7 @@ func (client *DeploymentsClient) deleteCreateRequest(ctx context.Context, resour // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentsClientBeginDeleteAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtManagementGroupScope @@ -1113,7 +1113,7 @@ func (client *DeploymentsClient) BeginDeleteAtManagementGroupScope(ctx context.C // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) deleteAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, options *DeploymentsClientBeginDeleteAtManagementGroupScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDeleteAtManagementGroupScope" @@ -1151,7 +1151,7 @@ func (client *DeploymentsClient) deleteAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1166,7 +1166,7 @@ func (client *DeploymentsClient) deleteAtManagementGroupScopeCreateRequest(ctx c // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentsClientBeginDeleteAtScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtScope @@ -1197,7 +1197,7 @@ func (client *DeploymentsClient) BeginDeleteAtScope(ctx context.Context, scope s // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) deleteAtScope(ctx context.Context, scope string, deploymentName string, options *DeploymentsClientBeginDeleteAtScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDeleteAtScope" @@ -1232,7 +1232,7 @@ func (client *DeploymentsClient) deleteAtScopeCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1247,7 +1247,7 @@ func (client *DeploymentsClient) deleteAtScopeCreateRequest(ctx context.Context, // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientBeginDeleteAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtSubscriptionScope // method. @@ -1277,7 +1277,7 @@ func (client *DeploymentsClient) BeginDeleteAtSubscriptionScope(ctx context.Cont // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) deleteAtSubscriptionScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtSubscriptionScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDeleteAtSubscriptionScope" @@ -1315,7 +1315,7 @@ func (client *DeploymentsClient) deleteAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1330,7 +1330,7 @@ func (client *DeploymentsClient) deleteAtSubscriptionScopeCreateRequest(ctx cont // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientBeginDeleteAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginDeleteAtTenantScope // method. @@ -1360,7 +1360,7 @@ func (client *DeploymentsClient) BeginDeleteAtTenantScope(ctx context.Context, d // Location header returns an error-level status code. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) deleteAtTenantScope(ctx context.Context, deploymentName string, options *DeploymentsClientBeginDeleteAtTenantScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginDeleteAtTenantScope" @@ -1394,7 +1394,7 @@ func (client *DeploymentsClient) deleteAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1403,7 +1403,7 @@ func (client *DeploymentsClient) deleteAtTenantScopeCreateRequest(ctx context.Co // ExportTemplate - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentsClientExportTemplateOptions contains the optional parameters for the DeploymentsClient.ExportTemplate @@ -1450,7 +1450,7 @@ func (client *DeploymentsClient) exportTemplateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1468,7 +1468,7 @@ func (client *DeploymentsClient) exportTemplateHandleResponse(resp *http.Respons // ExportTemplateAtManagementGroupScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentsClientExportTemplateAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtManagementGroupScope @@ -1511,7 +1511,7 @@ func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1529,7 +1529,7 @@ func (client *DeploymentsClient) exportTemplateAtManagementGroupScopeHandleRespo // ExportTemplateAtScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentsClientExportTemplateAtScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtScope @@ -1569,7 +1569,7 @@ func (client *DeploymentsClient) exportTemplateAtScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1587,7 +1587,7 @@ func (client *DeploymentsClient) exportTemplateAtScopeHandleResponse(resp *http. // ExportTemplateAtSubscriptionScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientExportTemplateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtSubscriptionScope // method. @@ -1629,7 +1629,7 @@ func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1647,7 +1647,7 @@ func (client *DeploymentsClient) exportTemplateAtSubscriptionScopeHandleResponse // ExportTemplateAtTenantScope - Exports the template used for specified deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientExportTemplateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.ExportTemplateAtTenantScope // method. @@ -1685,7 +1685,7 @@ func (client *DeploymentsClient) exportTemplateAtTenantScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1703,7 +1703,7 @@ func (client *DeploymentsClient) exportTemplateAtTenantScopeHandleResponse(resp // Get - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - deploymentName - The name of the deployment. // - options - DeploymentsClientGetOptions contains the optional parameters for the DeploymentsClient.Get method. @@ -1749,7 +1749,7 @@ func (client *DeploymentsClient) getCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1767,7 +1767,7 @@ func (client *DeploymentsClient) getHandleResponse(resp *http.Response) (Deploym // GetAtManagementGroupScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - options - DeploymentsClientGetAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.GetAtManagementGroupScope @@ -1810,7 +1810,7 @@ func (client *DeploymentsClient) getAtManagementGroupScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1828,7 +1828,7 @@ func (client *DeploymentsClient) getAtManagementGroupScopeHandleResponse(resp *h // GetAtScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - options - DeploymentsClientGetAtScopeOptions contains the optional parameters for the DeploymentsClient.GetAtScope method. @@ -1867,7 +1867,7 @@ func (client *DeploymentsClient) getAtScopeCreateRequest(ctx context.Context, sc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1885,7 +1885,7 @@ func (client *DeploymentsClient) getAtScopeHandleResponse(resp *http.Response) ( // GetAtSubscriptionScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientGetAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.GetAtSubscriptionScope // method. @@ -1927,7 +1927,7 @@ func (client *DeploymentsClient) getAtSubscriptionScopeCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1945,7 +1945,7 @@ func (client *DeploymentsClient) getAtSubscriptionScopeHandleResponse(resp *http // GetAtTenantScope - Gets a deployment. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - options - DeploymentsClientGetAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.GetAtTenantScope // method. @@ -1983,7 +1983,7 @@ func (client *DeploymentsClient) getAtTenantScopeCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2000,7 +2000,7 @@ func (client *DeploymentsClient) getAtTenantScopeHandleResponse(resp *http.Respo // NewListAtManagementGroupScopePager - Get all the deployments for a management group. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - options - DeploymentsClientListAtManagementGroupScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtManagementGroupScopePager // method. @@ -2045,7 +2045,7 @@ func (client *DeploymentsClient) listAtManagementGroupScopeCreateRequest(ctx con if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2062,7 +2062,7 @@ func (client *DeploymentsClient) listAtManagementGroupScopeHandleResponse(resp * // NewListAtScopePager - Get all the deployments at the given scope. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - options - DeploymentsClientListAtScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtScopePager // method. @@ -2104,7 +2104,7 @@ func (client *DeploymentsClient) listAtScopeCreateRequest(ctx context.Context, s if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2121,7 +2121,7 @@ func (client *DeploymentsClient) listAtScopeHandleResponse(resp *http.Response) // NewListAtSubscriptionScopePager - Get all the deployments for a subscription. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - DeploymentsClientListAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtSubscriptionScopePager // method. func (client *DeploymentsClient) NewListAtSubscriptionScopePager(options *DeploymentsClientListAtSubscriptionScopeOptions) *runtime.Pager[DeploymentsClientListAtSubscriptionScopeResponse] { @@ -2165,7 +2165,7 @@ func (client *DeploymentsClient) listAtSubscriptionScopeCreateRequest(ctx contex if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2182,7 +2182,7 @@ func (client *DeploymentsClient) listAtSubscriptionScopeHandleResponse(resp *htt // NewListAtTenantScopePager - Get all the deployments at the tenant scope. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - DeploymentsClientListAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.NewListAtTenantScopePager // method. func (client *DeploymentsClient) NewListAtTenantScopePager(options *DeploymentsClientListAtTenantScopeOptions) *runtime.Pager[DeploymentsClientListAtTenantScopeResponse] { @@ -2222,7 +2222,7 @@ func (client *DeploymentsClient) listAtTenantScopeCreateRequest(ctx context.Cont if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2239,7 +2239,7 @@ func (client *DeploymentsClient) listAtTenantScopeHandleResponse(resp *http.Resp // NewListByResourceGroupPager - Get all the deployments for a resource group. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group with the deployments to get. The name is case insensitive. // - options - DeploymentsClientListByResourceGroupOptions contains the optional parameters for the DeploymentsClient.NewListByResourceGroupPager // method. @@ -2288,7 +2288,7 @@ func (client *DeploymentsClient) listByResourceGroupCreateRequest(ctx context.Co if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -2307,7 +2307,7 @@ func (client *DeploymentsClient) listByResourceGroupHandleResponse(resp *http.Re // Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group the template will be deployed to. The name is case insensitive. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. @@ -2333,7 +2333,7 @@ func (client *DeploymentsClient) BeginValidate(ctx context.Context, resourceGrou // Validate - Validates whether the specified template is syntactically correct and will be accepted by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) validate(ctx context.Context, resourceGroupName string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginValidate" @@ -2375,7 +2375,7 @@ func (client *DeploymentsClient) validateCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2388,7 +2388,7 @@ func (client *DeploymentsClient) validateCreateRequest(ctx context.Context, reso // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. @@ -2415,7 +2415,7 @@ func (client *DeploymentsClient) BeginValidateAtManagementGroupScope(ctx context // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) validateAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtManagementGroupScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginValidateAtManagementGroupScope" @@ -2453,7 +2453,7 @@ func (client *DeploymentsClient) validateAtManagementGroupScopeCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2466,7 +2466,7 @@ func (client *DeploymentsClient) validateAtManagementGroupScopeCreateRequest(ctx // Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. @@ -2493,7 +2493,7 @@ func (client *DeploymentsClient) BeginValidateAtScope(ctx context.Context, scope // Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) validateAtScope(ctx context.Context, scope string, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginValidateAtScope" @@ -2528,7 +2528,7 @@ func (client *DeploymentsClient) validateAtScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2541,7 +2541,7 @@ func (client *DeploymentsClient) validateAtScopeCreateRequest(ctx context.Contex // by Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. // - options - DeploymentsClientBeginValidateAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtSubscriptionScope @@ -2567,7 +2567,7 @@ func (client *DeploymentsClient) BeginValidateAtSubscriptionScope(ctx context.Co // Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) validateAtSubscriptionScope(ctx context.Context, deploymentName string, parameters Deployment, options *DeploymentsClientBeginValidateAtSubscriptionScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginValidateAtSubscriptionScope" @@ -2605,7 +2605,7 @@ func (client *DeploymentsClient) validateAtSubscriptionScopeCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2618,7 +2618,7 @@ func (client *DeploymentsClient) validateAtSubscriptionScopeCreateRequest(ctx co // Azure Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. // - options - DeploymentsClientBeginValidateAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginValidateAtTenantScope @@ -2644,7 +2644,7 @@ func (client *DeploymentsClient) BeginValidateAtTenantScope(ctx context.Context, // Resource Manager.. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) validateAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeployment, options *DeploymentsClientBeginValidateAtTenantScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginValidateAtTenantScope" @@ -2678,7 +2678,7 @@ func (client *DeploymentsClient) validateAtTenantScopeCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2690,7 +2690,7 @@ func (client *DeploymentsClient) validateAtTenantScopeCreateRequest(ctx context. // BeginWhatIf - Returns changes that will be made by the deployment if executed at the scope of the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group the template will be deployed to. The name is case insensitive. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. @@ -2716,7 +2716,7 @@ func (client *DeploymentsClient) BeginWhatIf(ctx context.Context, resourceGroupN // WhatIf - Returns changes that will be made by the deployment if executed at the scope of the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) whatIf(ctx context.Context, resourceGroupName string, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginWhatIf" @@ -2758,7 +2758,7 @@ func (client *DeploymentsClient) whatIfCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2771,7 +2771,7 @@ func (client *DeploymentsClient) whatIfCreateRequest(ctx context.Context, resour // management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - groupID - The management group ID. // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. @@ -2799,7 +2799,7 @@ func (client *DeploymentsClient) BeginWhatIfAtManagementGroupScope(ctx context.C // group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) whatIfAtManagementGroupScope(ctx context.Context, groupID string, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtManagementGroupScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginWhatIfAtManagementGroupScope" @@ -2837,7 +2837,7 @@ func (client *DeploymentsClient) whatIfAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2849,7 +2849,7 @@ func (client *DeploymentsClient) whatIfAtManagementGroupScopeCreateRequest(ctx c // BeginWhatIfAtSubscriptionScope - Returns changes that will be made by the deployment if executed at the scope of the subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to What If. // - options - DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtSubscriptionScope @@ -2875,7 +2875,7 @@ func (client *DeploymentsClient) BeginWhatIfAtSubscriptionScope(ctx context.Cont // WhatIfAtSubscriptionScope - Returns changes that will be made by the deployment if executed at the scope of the subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) whatIfAtSubscriptionScope(ctx context.Context, deploymentName string, parameters DeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtSubscriptionScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginWhatIfAtSubscriptionScope" @@ -2913,7 +2913,7 @@ func (client *DeploymentsClient) whatIfAtSubscriptionScopeCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -2925,7 +2925,7 @@ func (client *DeploymentsClient) whatIfAtSubscriptionScopeCreateRequest(ctx cont // BeginWhatIfAtTenantScope - Returns changes that will be made by the deployment if executed at the scope of the tenant group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - deploymentName - The name of the deployment. // - parameters - Parameters to validate. // - options - DeploymentsClientBeginWhatIfAtTenantScopeOptions contains the optional parameters for the DeploymentsClient.BeginWhatIfAtTenantScope @@ -2951,7 +2951,7 @@ func (client *DeploymentsClient) BeginWhatIfAtTenantScope(ctx context.Context, d // WhatIfAtTenantScope - Returns changes that will be made by the deployment if executed at the scope of the tenant group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *DeploymentsClient) whatIfAtTenantScope(ctx context.Context, deploymentName string, parameters ScopedDeploymentWhatIf, options *DeploymentsClientBeginWhatIfAtTenantScopeOptions) (*http.Response, error) { var err error const operationName = "DeploymentsClient.BeginWhatIfAtTenantScope" @@ -2985,7 +2985,7 @@ func (client *DeploymentsClient) whatIfAtTenantScopeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go b/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go deleted file mode 100644 index 8b34318d619b..000000000000 --- a/sdk/resourcemanager/resources/armresources/deployments_client_example_test.go +++ /dev/null @@ -1,1044 +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 armresources_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/resources/armresources" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtScope(ctx, "providers/Microsoft.Management/managementGroups/my-management-group-id", "my-deployment", armresources.Deployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtTenantScope(ctx, "tenant-dep01", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("tenant-dep01"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Resources/deployments/tenant-dep01"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json -func ExampleDeploymentsClient_BeginWhatIfAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtTenantScope(ctx, "exampleDeploymentName", armresources.ScopedDeploymentWhatIf{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{}, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myManagementGroup", - // "type": "Microsoft.Management/managementGroups", - // "apiVersion": "2019-11-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtManagementGroupScope(ctx, "my-management-group-id", "my-deployment", armresources.ScopedDeployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyDefinitions/policy-definition-name"), - // ResourceName: to.Ptr("policy-definition-name"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyDefinitions"), - // }}, - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/my-management-group-id/providers/Microsoft.Authorization/policyAssignments/location-lock"), - // ResourceName: to.Ptr("location-lock"), - // ResourceType: to.Ptr("Microsoft.Authorization/policyAssignments"), - // }}, - // Duration: to.Ptr("PT1.2970875S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Authorization"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyDefinitions"), - // }, - // { - // Locations: []*string{ - // nil}, - // ResourceType: to.Ptr("policyAssignments"), - // }}, - // }, - // { - // Namespace: to.Ptr("Microsoft.Resources"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("deployments"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-24T22:52:38.789Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json -func ExampleDeploymentsClient_BeginWhatIfAtManagementGroupScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtManagementGroupScope(ctx, "myManagementGruop", "exampleDeploymentName", armresources.ScopedDeploymentWhatIf{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{}, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "before":map[string]any{ - // "name": "myPolicyAssignment", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "DoNotEnforce", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000001", - // }, - // }, - // "changeType": "Modify", - // "delta":[]any{ - // map[string]any{ - // "path": "properties.enforcementMode", - // "after": "DoNotEnforce", - // "before": "Default", - // "propertyChangeType": "Modify", - // }, - // }, - // "resourceId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // }, - // Before: map[string]any{ - // "name": "myPolicyAssignment", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "Default", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000001", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment"), - // }, - // { - // After: map[string]any{ - // "name": "myPolicyAssignment2", - // "type": "Microsoft.Authorization/policyAssignments", - // "apiVersion": "2019-06-01", - // "id": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2", - // "location": "westus2", - // "properties":map[string]any{ - // "enforcementMode": "Default", - // "policyDefinitionId": "/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyDefinition", - // "scope": "/subscriptions/00000000-0000-0000-0000-000000000002", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.Authorization/policyAssignments/myPolicyAssignment2"), - // }}, - // }, - // Status: to.Ptr("Succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json -func ExampleDeploymentsClient_BeginCreateOrUpdateAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdateAtSubscriptionScope(ctx, "my-deployment", armresources.Deployment{ - Location: to.Ptr("eastus"), - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/providers/Microsoft.Resources/deployments/my-deployment"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT1.2637681S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // }, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:51:58.628Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json -func ExampleDeploymentsClient_BeginWhatIfAtSubscriptionScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIfAtSubscriptionScope(ctx, "my-deployment", armresources.DeploymentWhatIf{ - Location: to.Ptr("westus"), - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{}, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // "tags":map[string]any{ - // "myNewTag": "my tag value", - // }, - // }, - // Before: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // Delta: []*armresources.WhatIfPropertyChange{ - // { - // Path: to.Ptr("tags.myNewTag"), - // After: "my tag value", - // PropertyChangeType: to.Ptr(armresources.PropertyChangeTypeCreate), - // }}, - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "myNewIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity", - // "location": "eastus", - // "tags":map[string]any{ - // "myOtherNewTag": "another new tag value", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "my-resource-group2", - // "type": "Microsoft.Resources/resourceGroups", - // "apiVersion": "2019-03-01", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group2", - // "location": "{location3}", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group2"), - // }}, - // }, - // Status: to.Ptr("succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillDeployATemplateWithAUriAndQueryString() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - QueryString: to.Ptr("sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d"), - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroupTemplateSpecsWithId.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // }, - // Duration: to.Ptr("PT22.8356799S"), - // Mode: to.Ptr(armresources.DeploymentModeIncremental), - // OutputResources: []*armresources.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/my-storage-account"), - // }}, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateHash: to.Ptr("0000000000000000000"), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T01:20:01.723Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeComplete), - OnErrorDeployment: &armresources.OnErrorDeployment{ - Type: to.Ptr(armresources.OnErrorDeploymentTypeSpecificDeployment), - DeploymentName: to.Ptr("name-of-deployment-to-use"), - }, - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }, - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }, - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet2"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // Duration: to.Ptr("PT0.8204881S"), - // Mode: to.Ptr(armresources.DeploymentModeComplete), - // OnErrorDeployment: &armresources.OnErrorDeploymentExtended{ - // Type: to.Ptr(armresources.OnErrorDeploymentTypeSpecificDeployment), - // DeploymentName: to.Ptr("name-of-deployment-to-use"), - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Network"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks"), - // }, - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks/subnets"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json -func ExampleDeploymentsClient_BeginCreateOrUpdate_createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginCreateOrUpdate(ctx, "my-resource-group", "my-deployment", armresources.Deployment{ - Properties: &armresources.DeploymentProperties{ - Mode: to.Ptr(armresources.DeploymentModeComplete), - OnErrorDeployment: &armresources.OnErrorDeployment{ - Type: to.Ptr(armresources.OnErrorDeploymentTypeLastSuccessful), - }, - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - }, 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.DeploymentExtended = armresources.DeploymentExtended{ - // Name: to.Ptr("my-deployment"), - // Type: to.Ptr("Microsoft.Resources/deployments"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/Microsoft.Resources/deployments/my-deployment"), - // Properties: &armresources.DeploymentPropertiesExtended{ - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Dependencies: []*armresources.Dependency{ - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }, - // { - // DependsOn: []*armresources.BasicDependency{ - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks"), - // }, - // { - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet1"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // ID: to.Ptr("{resourceid}"), - // ResourceName: to.Ptr("VNet1/Subnet2"), - // ResourceType: to.Ptr("Microsoft.Network/virtualNetworks/subnets"), - // }}, - // Duration: to.Ptr("PT0.8204881S"), - // Mode: to.Ptr(armresources.DeploymentModeComplete), - // OnErrorDeployment: &armresources.OnErrorDeploymentExtended{ - // Type: to.Ptr(armresources.OnErrorDeploymentTypeLastSuccessful), - // DeploymentName: to.Ptr("{nameOfLastSuccesfulDeployment}"), - // }, - // Parameters: map[string]any{ - // }, - // Providers: []*armresources.Provider{ - // { - // Namespace: to.Ptr("Microsoft.Network"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks"), - // }, - // { - // Locations: []*string{ - // to.Ptr("centralus")}, - // ResourceType: to.Ptr("virtualNetworks/subnets"), - // }}, - // }}, - // ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded), - // TemplateLink: &armresources.TemplateLink{ - // ContentVersion: to.Ptr("1.0.0.0"), - // URI: to.Ptr("https://example.com/exampleTemplate.json"), - // }, - // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json -func ExampleDeploymentsClient_BeginWhatIf() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeploymentsClient().BeginWhatIf(ctx, "my-resource-group", "my-deployment", armresources.DeploymentWhatIf{ - Properties: &armresources.DeploymentWhatIfProperties{ - Mode: to.Ptr(armresources.DeploymentModeIncremental), - Parameters: map[string]any{}, - TemplateLink: &armresources.TemplateLink{}, - }, - }, 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.WhatIfOperationResult = armresources.WhatIfOperationResult{ - // Properties: &armresources.WhatIfOperationProperties{ - // Changes: []*armresources.WhatIfChange{ - // { - // After: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // "tags":map[string]any{ - // "myNewTag": "my tag value", - // }, - // }, - // Before: map[string]any{ - // "name": "myExistingIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity", - // "location": "westus2", - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeModify), - // Delta: []*armresources.WhatIfPropertyChange{ - // { - // Path: to.Ptr("tags.myNewTag"), - // After: "my tag value", - // PropertyChangeType: to.Ptr(armresources.PropertyChangeTypeCreate), - // }}, - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myExistingIdentity"), - // }, - // { - // After: map[string]any{ - // "name": "myNewIdentity", - // "type": "Microsoft.ManagedIdentity/userAssignedIdentities", - // "apiVersion": "2018-11-30", - // "id": "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity", - // "location": "eastus", - // "tags":map[string]any{ - // "myOtherNewTag": "another new tag value", - // }, - // }, - // ChangeType: to.Ptr(armresources.ChangeTypeCreate), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myNewIdentity"), - // }}, - // }, - // Status: to.Ptr("succeeded"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json -func ExampleDeploymentsClient_CalculateTemplateHash() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeploymentsClient().CalculateTemplateHash(ctx, map[string]any{ - "$schema": "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", - "contentVersion": "1.0.0.0", - "outputs": map[string]any{ - "string": map[string]any{ - "type": "string", - "value": "myvalue", - }, - }, - "parameters": map[string]any{ - "string": map[string]any{ - "type": "string", - }, - }, - "resources": []any{}, - "variables": map[string]any{ - "array": []any{ - float64(1), - float64(2), - float64(3), - float64(4), - }, - "bool": true, - "int": float64(42), - "object": map[string]any{ - "object": map[string]any{ - "location": "West US", - "vmSize": "Large", - }, - }, - "string": "string", - }, - }, 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.TemplateHashResult = armresources.TemplateHashResult{ - // MinifiedTemplate: to.Ptr("{\"$SCHEMA\":\"HTTP://SCHEMAS.MANAGEMENT.AZURE.COM/DEPLOYMENTTEMPLATE?API-VERSION=2014-04-01-PREVIEW\",\"CONTENTVERSION\":\"1.0.0.0\",\"PARAMETERS\":{\"STRING\":{\"TYPE\":\"STRING\"}},\"VARIABLES\":{\"STRING\":\"STRING\",\"INT\":42,\"BOOL\":TRUE,\"ARRAY\":[1,2,3,4],\"OBJECT\":{\"OBJECT\":{\"VMSIZE\":\"LARGE\",\"LOCATION\":\"WEST US\"}}},\"RESOURCES\":[],\"OUTPUTS\":{\"STRING\":{\"TYPE\":\"STRING\",\"VALUE\":\"MYVALUE\"}}}"), - // TemplateHash: to.Ptr("695440707931307747"), - // } -} diff --git a/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go b/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go index 576784c22965..a466632a4e2a 100644 --- a/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/deployments_client_live_test.go @@ -18,7 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go b/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go index 64d1dbf2ec2b..0cc2e911e84f 100644 --- a/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/deploymentoperations_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/resources/armresources/fake/deployments_server.go b/sdk/resourcemanager/resources/armresources/fake/deployments_server.go index 4dbb81cdef51..1cf2f0a890ad 100644 --- a/sdk/resourcemanager/resources/armresources/fake/deployments_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/deployments_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/resources/armresources/fake/operations_server.go b/sdk/resourcemanager/resources/armresources/fake/operations_server.go index 9efc0cbd4a7e..5dc57b498004 100644 --- a/sdk/resourcemanager/resources/armresources/fake/operations_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/operations_server.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" ) diff --git a/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go b/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go index 67c2e7e91685..7b03ede2c258 100644 --- a/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/providerresourcetypes_server.go @@ -15,7 +15,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/resources/armresources/fake/providers_server.go b/sdk/resourcemanager/resources/armresources/fake/providers_server.go index 5681c862236d..896d5989fd68 100644 --- a/sdk/resourcemanager/resources/armresources/fake/providers_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/providers_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "reflect" diff --git a/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go b/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go index c44d076de850..bb13d0fcb29a 100644 --- a/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/resourcegroups_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/resources/armresources/fake/server.go b/sdk/resourcemanager/resources/armresources/fake/server.go index e0706267a031..d9785bc844c6 100644 --- a/sdk/resourcemanager/resources/armresources/fake/server.go +++ b/sdk/resourcemanager/resources/armresources/fake/server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/resources/armresources/fake/tags_server.go b/sdk/resourcemanager/resources/armresources/fake/tags_server.go index 91a1dfa51ce8..5c9395d85920 100644 --- a/sdk/resourcemanager/resources/armresources/fake/tags_server.go +++ b/sdk/resourcemanager/resources/armresources/fake/tags_server.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "net/http" "net/url" "regexp" @@ -28,9 +28,9 @@ type TagsServer struct { // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated CreateOrUpdate func(ctx context.Context, tagName string, options *armresources.TagsClientCreateOrUpdateOptions) (resp azfake.Responder[armresources.TagsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - // CreateOrUpdateAtScope is the fake for method TagsClient.CreateOrUpdateAtScope - // HTTP status codes to indicate success: http.StatusOK - CreateOrUpdateAtScope func(ctx context.Context, scope string, parameters armresources.TagsResource, options *armresources.TagsClientCreateOrUpdateAtScopeOptions) (resp azfake.Responder[armresources.TagsClientCreateOrUpdateAtScopeResponse], errResp azfake.ErrorResponder) + // BeginCreateOrUpdateAtScope is the fake for method TagsClient.BeginCreateOrUpdateAtScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdateAtScope func(ctx context.Context, scope string, parameters armresources.TagsResource, options *armresources.TagsClientBeginCreateOrUpdateAtScopeOptions) (resp azfake.PollerResponder[armresources.TagsClientCreateOrUpdateAtScopeResponse], errResp azfake.ErrorResponder) // CreateOrUpdateValue is the fake for method TagsClient.CreateOrUpdateValue // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated @@ -40,9 +40,9 @@ type TagsServer struct { // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent Delete func(ctx context.Context, tagName string, options *armresources.TagsClientDeleteOptions) (resp azfake.Responder[armresources.TagsClientDeleteResponse], errResp azfake.ErrorResponder) - // DeleteAtScope is the fake for method TagsClient.DeleteAtScope - // HTTP status codes to indicate success: http.StatusOK - DeleteAtScope func(ctx context.Context, scope string, options *armresources.TagsClientDeleteAtScopeOptions) (resp azfake.Responder[armresources.TagsClientDeleteAtScopeResponse], errResp azfake.ErrorResponder) + // BeginDeleteAtScope is the fake for method TagsClient.BeginDeleteAtScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDeleteAtScope func(ctx context.Context, scope string, options *armresources.TagsClientBeginDeleteAtScopeOptions) (resp azfake.PollerResponder[armresources.TagsClientDeleteAtScopeResponse], errResp azfake.ErrorResponder) // DeleteValue is the fake for method TagsClient.DeleteValue // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -56,9 +56,9 @@ type TagsServer struct { // HTTP status codes to indicate success: http.StatusOK NewListPager func(options *armresources.TagsClientListOptions) (resp azfake.PagerResponder[armresources.TagsClientListResponse]) - // UpdateAtScope is the fake for method TagsClient.UpdateAtScope - // HTTP status codes to indicate success: http.StatusOK - UpdateAtScope func(ctx context.Context, scope string, parameters armresources.TagsPatchResource, options *armresources.TagsClientUpdateAtScopeOptions) (resp azfake.Responder[armresources.TagsClientUpdateAtScopeResponse], errResp azfake.ErrorResponder) + // BeginUpdateAtScope is the fake for method TagsClient.BeginUpdateAtScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdateAtScope func(ctx context.Context, scope string, parameters armresources.TagsPatchResource, options *armresources.TagsClientBeginUpdateAtScopeOptions) (resp azfake.PollerResponder[armresources.TagsClientUpdateAtScopeResponse], errResp azfake.ErrorResponder) } // NewTagsServerTransport creates a new instance of TagsServerTransport with the provided implementation. @@ -66,16 +66,22 @@ type TagsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewTagsServerTransport(srv *TagsServer) *TagsServerTransport { return &TagsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armresources.TagsClientListResponse]](), + srv: srv, + beginCreateOrUpdateAtScope: newTracker[azfake.PollerResponder[armresources.TagsClientCreateOrUpdateAtScopeResponse]](), + beginDeleteAtScope: newTracker[azfake.PollerResponder[armresources.TagsClientDeleteAtScopeResponse]](), + newListPager: newTracker[azfake.PagerResponder[armresources.TagsClientListResponse]](), + beginUpdateAtScope: newTracker[azfake.PollerResponder[armresources.TagsClientUpdateAtScopeResponse]](), } } // TagsServerTransport connects instances of armresources.TagsClient to instances of TagsServer. // Don't use this type directly, use NewTagsServerTransport instead. type TagsServerTransport struct { - srv *TagsServer - newListPager *tracker[azfake.PagerResponder[armresources.TagsClientListResponse]] + srv *TagsServer + beginCreateOrUpdateAtScope *tracker[azfake.PollerResponder[armresources.TagsClientCreateOrUpdateAtScopeResponse]] + beginDeleteAtScope *tracker[azfake.PollerResponder[armresources.TagsClientDeleteAtScopeResponse]] + newListPager *tracker[azfake.PagerResponder[armresources.TagsClientListResponse]] + beginUpdateAtScope *tracker[azfake.PollerResponder[armresources.TagsClientUpdateAtScopeResponse]] } // Do implements the policy.Transporter interface for TagsServerTransport. @@ -92,22 +98,22 @@ func (t *TagsServerTransport) Do(req *http.Request) (*http.Response, error) { switch method { case "TagsClient.CreateOrUpdate": resp, err = t.dispatchCreateOrUpdate(req) - case "TagsClient.CreateOrUpdateAtScope": - resp, err = t.dispatchCreateOrUpdateAtScope(req) + case "TagsClient.BeginCreateOrUpdateAtScope": + resp, err = t.dispatchBeginCreateOrUpdateAtScope(req) case "TagsClient.CreateOrUpdateValue": resp, err = t.dispatchCreateOrUpdateValue(req) case "TagsClient.Delete": resp, err = t.dispatchDelete(req) - case "TagsClient.DeleteAtScope": - resp, err = t.dispatchDeleteAtScope(req) + case "TagsClient.BeginDeleteAtScope": + resp, err = t.dispatchBeginDeleteAtScope(req) case "TagsClient.DeleteValue": resp, err = t.dispatchDeleteValue(req) case "TagsClient.GetAtScope": resp, err = t.dispatchGetAtScope(req) case "TagsClient.NewListPager": resp, err = t.dispatchNewListPager(req) - case "TagsClient.UpdateAtScope": - resp, err = t.dispatchUpdateAtScope(req) + case "TagsClient.BeginUpdateAtScope": + resp, err = t.dispatchBeginUpdateAtScope(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -148,36 +154,47 @@ func (t *TagsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.R return resp, nil } -func (t *TagsServerTransport) dispatchCreateOrUpdateAtScope(req *http.Request) (*http.Response, error) { - if t.srv.CreateOrUpdateAtScope == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateAtScope not implemented")} +func (t *TagsServerTransport) dispatchBeginCreateOrUpdateAtScope(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreateOrUpdateAtScope == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateAtScope not implemented")} } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armresources.TagsResource](req) - if err != nil { - return nil, err + beginCreateOrUpdateAtScope := t.beginCreateOrUpdateAtScope.get(req) + if beginCreateOrUpdateAtScope == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armresources.TagsResource](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreateOrUpdateAtScope(req.Context(), scopeParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateAtScope = &respr + t.beginCreateOrUpdateAtScope.add(req, beginCreateOrUpdateAtScope) } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + + resp, err := server.PollerResponderNext(beginCreateOrUpdateAtScope, req) if err != nil { return nil, err } - respr, errRespr := t.srv.CreateOrUpdateAtScope(req.Context(), scopeParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginCreateOrUpdateAtScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagsResource, req) - if err != nil { - return nil, err + if !server.PollerResponderMore(beginCreateOrUpdateAtScope) { + t.beginCreateOrUpdateAtScope.remove(req) } + return resp, nil } @@ -243,32 +260,43 @@ func (t *TagsServerTransport) dispatchDelete(req *http.Request) (*http.Response, return resp, nil } -func (t *TagsServerTransport) dispatchDeleteAtScope(req *http.Request) (*http.Response, error) { - if t.srv.DeleteAtScope == nil { - return nil, &nonRetriableError{errors.New("fake for method DeleteAtScope not implemented")} +func (t *TagsServerTransport) dispatchBeginDeleteAtScope(req *http.Request) (*http.Response, error) { + if t.srv.BeginDeleteAtScope == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAtScope not implemented")} } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + beginDeleteAtScope := t.beginDeleteAtScope.get(req) + if beginDeleteAtScope == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDeleteAtScope(req.Context(), scopeParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteAtScope = &respr + t.beginDeleteAtScope.add(req, beginDeleteAtScope) } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + + resp, err := server.PollerResponderNext(beginDeleteAtScope, req) if err != nil { return nil, err } - respr, errRespr := t.srv.DeleteAtScope(req.Context(), scopeParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginDeleteAtScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - resp, err := server.NewResponse(respContent, req, nil) - if err != nil { - return nil, err + if !server.PollerResponderMore(beginDeleteAtScope) { + t.beginDeleteAtScope.remove(req) } + return resp, nil } @@ -367,35 +395,46 @@ func (t *TagsServerTransport) dispatchNewListPager(req *http.Request) (*http.Res return resp, nil } -func (t *TagsServerTransport) dispatchUpdateAtScope(req *http.Request) (*http.Response, error) { - if t.srv.UpdateAtScope == nil { - return nil, &nonRetriableError{errors.New("fake for method UpdateAtScope not implemented")} +func (t *TagsServerTransport) dispatchBeginUpdateAtScope(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdateAtScope == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdateAtScope not implemented")} } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armresources.TagsPatchResource](req) - if err != nil { - return nil, err + beginUpdateAtScope := t.beginUpdateAtScope.get(req) + if beginUpdateAtScope == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Resources/tags/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armresources.TagsPatchResource](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdateAtScope(req.Context(), scopeParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdateAtScope = &respr + t.beginUpdateAtScope.add(req, beginUpdateAtScope) } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + + resp, err := server.PollerResponderNext(beginUpdateAtScope, req) if err != nil { return nil, err } - respr, errRespr := t.srv.UpdateAtScope(req.Context(), scopeParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.beginUpdateAtScope.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TagsResource, req) - if err != nil { - return nil, err + if !server.PollerResponderMore(beginUpdateAtScope) { + t.beginUpdateAtScope.remove(req) } + return resp, nil } diff --git a/sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armresources/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armresources/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/resources/armresources/go.mod b/sdk/resourcemanager/resources/armresources/go.mod index 75ac079700a5..d6ac401734ca 100644 --- a/sdk/resourcemanager/resources/armresources/go.mod +++ b/sdk/resourcemanager/resources/armresources/go.mod @@ -1,10 +1,9 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2 go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v1.2.0 // indirect diff --git a/sdk/resourcemanager/resources/armresources/models.go b/sdk/resourcemanager/resources/armresources/models.go index ce98f859a61d..887b6140c05d 100644 --- a/sdk/resourcemanager/resources/armresources/models.go +++ b/sdk/resourcemanager/resources/armresources/models.go @@ -221,6 +221,15 @@ type DeploymentOperationsListResult struct { NextLink *string } +// DeploymentParameter - Deployment parameter for the template. +type DeploymentParameter struct { + // Azure Key Vault parameter reference. + Reference *KeyVaultParameterReference + + // Input value to the parameter . + Value any +} + // DeploymentProperties - Deployment properties. type DeploymentProperties struct { // REQUIRED; The mode that is used to deploy resources. This value can be either Incremental or Complete. In Incremental mode, @@ -244,7 +253,7 @@ type DeploymentProperties struct { // the parameter values directly in the request rather than link to an existing // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or // a well formed JSON string. - Parameters any + Parameters map[string]*DeploymentParameter // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink // property or the parameters property, but not both. @@ -354,7 +363,7 @@ type DeploymentWhatIfProperties struct { // the parameter values directly in the request rather than link to an existing // parameter file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or // a well formed JSON string. - Parameters any + Parameters map[string]*DeploymentParameter // The URI of parameters file. You use this element to link to an existing parameters file. Use either the parametersLink // property or the parameters property, but not both. @@ -413,6 +422,9 @@ type ExportTemplateRequest struct { // 'SkipAllParameterization' Options *string + // The output format for the exported resources. + OutputFormat *ExportTemplateOutputFormat + // The IDs of the resources to filter the export by. To export all resources, supply an array with single entry '*'. Resources []*string } @@ -563,6 +575,24 @@ type IdentityUserAssignedIdentitiesValue struct { PrincipalID *string } +// KeyVaultParameterReference - Azure Key Vault parameter reference. +type KeyVaultParameterReference struct { + // REQUIRED; Azure Key Vault reference. + KeyVault *KeyVaultReference + + // REQUIRED; Azure Key Vault secret name. + SecretName *string + + // Azure Key Vault secret version. + SecretVersion *string +} + +// KeyVaultReference - Azure Key Vault reference. +type KeyVaultReference struct { + // REQUIRED; Azure Key Vault resource id. + ID *string +} + // MoveInfo - Parameters of move resources. type MoveInfo struct { // The IDs of the resources. @@ -838,7 +868,10 @@ type ResourceGroupExportResult struct { // The template export error. Error *ErrorResponse - // The template content. + // The formatted export content. Used if outputFormat is set to 'Bicep'. + Output *string + + // The template content. Used if outputFormat is empty or set to 'Json'. Template any } diff --git a/sdk/resourcemanager/resources/armresources/models_serde.go b/sdk/resourcemanager/resources/armresources/models_serde.go index 5c6e3ac77c19..340d78f4cab3 100644 --- a/sdk/resourcemanager/resources/armresources/models_serde.go +++ b/sdk/resourcemanager/resources/armresources/models_serde.go @@ -595,6 +595,37 @@ func (d *DeploymentOperationsListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DeploymentParameter. +func (d DeploymentParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reference", d.Reference) + populateAny(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentParameter. +func (d *DeploymentParameter) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "reference": + err = unpopulate(val, "Reference", &d.Reference) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type DeploymentProperties. func (d DeploymentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -602,7 +633,7 @@ func (d DeploymentProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) populate(objectMap, "mode", d.Mode) populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) - populateAny(objectMap, "parameters", d.Parameters) + populate(objectMap, "parameters", d.Parameters) populate(objectMap, "parametersLink", d.ParametersLink) populateAny(objectMap, "template", d.Template) populate(objectMap, "templateLink", d.TemplateLink) @@ -810,7 +841,7 @@ func (d DeploymentWhatIfProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "expressionEvaluationOptions", d.ExpressionEvaluationOptions) populate(objectMap, "mode", d.Mode) populate(objectMap, "onErrorDeployment", d.OnErrorDeployment) - populateAny(objectMap, "parameters", d.Parameters) + populate(objectMap, "parameters", d.Parameters) populate(objectMap, "parametersLink", d.ParametersLink) populateAny(objectMap, "template", d.Template) populate(objectMap, "templateLink", d.TemplateLink) @@ -967,6 +998,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { func (e ExportTemplateRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "options", e.Options) + populate(objectMap, "outputFormat", e.OutputFormat) populate(objectMap, "resources", e.Resources) return json.Marshal(objectMap) } @@ -983,6 +1015,9 @@ func (e *ExportTemplateRequest) UnmarshalJSON(data []byte) error { case "options": err = unpopulate(val, "Options", &e.Options) delete(rawMsg, key) + case "outputFormat": + err = unpopulate(val, "OutputFormat", &e.OutputFormat) + delete(rawMsg, key) case "resources": err = unpopulate(val, "Resources", &e.Resources) delete(rawMsg, key) @@ -1338,6 +1373,68 @@ func (i *IdentityUserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type KeyVaultParameterReference. +func (k KeyVaultParameterReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVault", k.KeyVault) + populate(objectMap, "secretName", k.SecretName) + populate(objectMap, "secretVersion", k.SecretVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultParameterReference. +func (k *KeyVaultParameterReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyVault": + err = unpopulate(val, "KeyVault", &k.KeyVault) + delete(rawMsg, key) + case "secretName": + err = unpopulate(val, "SecretName", &k.SecretName) + delete(rawMsg, key) + case "secretVersion": + err = unpopulate(val, "SecretVersion", &k.SecretVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultReference. +func (k KeyVaultReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", k.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultReference. +func (k *KeyVaultReference) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type MoveInfo. func (m MoveInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2082,6 +2179,7 @@ func (r *ResourceGroup) UnmarshalJSON(data []byte) error { func (r ResourceGroupExportResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "error", r.Error) + populate(objectMap, "output", r.Output) populateAny(objectMap, "template", r.Template) return json.Marshal(objectMap) } @@ -2098,6 +2196,9 @@ func (r *ResourceGroupExportResult) UnmarshalJSON(data []byte) error { case "error": err = unpopulate(val, "Error", &r.Error) delete(rawMsg, key) + case "output": + err = unpopulate(val, "Output", &r.Output) + delete(rawMsg, key) case "template": err = unpopulate(val, "Template", &r.Template) delete(rawMsg, key) @@ -3098,7 +3199,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/resources/armresources/operations_client.go b/sdk/resourcemanager/resources/armresources/operations_client.go index e0fc6b961f4f..6693790e954c 100644 --- a/sdk/resourcemanager/resources/armresources/operations_client.go +++ b/sdk/resourcemanager/resources/armresources/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available Microsoft.Resources REST API operations. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - 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", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/options.go b/sdk/resourcemanager/resources/armresources/options.go index dfdb23b0cc8f..a7335a3e4f75 100644 --- a/sdk/resourcemanager/resources/armresources/options.go +++ b/sdk/resourcemanager/resources/armresources/options.go @@ -130,7 +130,7 @@ type ClientListOptions struct { // identity/principalId. Filter *string - // The number of results to return. If null is passed, returns all resources. + // The number of recommendations per page if a paged version of this API is being used. Top *int32 } @@ -608,9 +608,23 @@ type ResourceGroupsClientUpdateOptions struct { // placeholder for future optional parameters } -// TagsClientCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.CreateOrUpdateAtScope method. -type TagsClientCreateOrUpdateAtScopeOptions struct { - // placeholder for future optional parameters +// TagsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginCreateOrUpdateAtScope +// method. +type TagsClientBeginCreateOrUpdateAtScopeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TagsClientBeginDeleteAtScopeOptions contains the optional parameters for the TagsClient.BeginDeleteAtScope method. +type TagsClientBeginDeleteAtScopeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// TagsClientBeginUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginUpdateAtScope method. +type TagsClientBeginUpdateAtScopeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // TagsClientCreateOrUpdateOptions contains the optional parameters for the TagsClient.CreateOrUpdate method. @@ -623,11 +637,6 @@ type TagsClientCreateOrUpdateValueOptions struct { // placeholder for future optional parameters } -// TagsClientDeleteAtScopeOptions contains the optional parameters for the TagsClient.DeleteAtScope method. -type TagsClientDeleteAtScopeOptions struct { - // placeholder for future optional parameters -} - // TagsClientDeleteOptions contains the optional parameters for the TagsClient.Delete method. type TagsClientDeleteOptions struct { // placeholder for future optional parameters @@ -647,8 +656,3 @@ type TagsClientGetAtScopeOptions struct { type TagsClientListOptions struct { // placeholder for future optional parameters } - -// TagsClientUpdateAtScopeOptions contains the optional parameters for the TagsClient.UpdateAtScope method. -type TagsClientUpdateAtScopeOptions struct { - // placeholder for future optional parameters -} diff --git a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go index a64c08f0217d..db41ea955df7 100644 --- a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go +++ b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client.go @@ -46,7 +46,7 @@ func NewProviderResourceTypesClient(subscriptionID string, credential azcore.Tok // List - List the resource types for a specified resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProviderResourceTypesClientListOptions contains the optional parameters for the ProviderResourceTypesClient.List // method. @@ -91,7 +91,7 @@ func (client *ProviderResourceTypesClient) listCreateRequest(ctx context.Context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go b/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go deleted file mode 100644 index 1dcaf8920e8e..000000000000 --- a/sdk/resourcemanager/resources/armresources/providerresourcetypes_client_example_test.go +++ /dev/null @@ -1,67 +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 armresources_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json -func ExampleProviderResourceTypesClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProviderResourceTypesClient().List(ctx, "Microsoft.TestRP", &armresources.ProviderResourceTypesClientListOptions{Expand: 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.ProviderResourceTypeListResult = armresources.ProviderResourceTypeListResult{ - // Value: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/providers_client.go b/sdk/resourcemanager/resources/armresources/providers_client.go index e1612d16090a..7a4fdf300dea 100644 --- a/sdk/resourcemanager/resources/armresources/providers_client.go +++ b/sdk/resourcemanager/resources/armresources/providers_client.go @@ -46,7 +46,7 @@ func NewProvidersClient(subscriptionID string, credential azcore.TokenCredential // Get - Gets the specified resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientGetOptions contains the optional parameters for the ProvidersClient.Get method. func (client *ProvidersClient) Get(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientGetOptions) (ProvidersClientGetResponse, error) { @@ -90,7 +90,7 @@ func (client *ProvidersClient) getCreateRequest(ctx context.Context, resourcePro if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -108,7 +108,7 @@ func (client *ProvidersClient) getHandleResponse(resp *http.Response) (Providers // GetAtTenantScope - Gets the specified resource provider at the tenant level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientGetAtTenantScopeOptions contains the optional parameters for the ProvidersClient.GetAtTenantScope // method. @@ -149,7 +149,7 @@ func (client *ProvidersClient) getAtTenantScopeCreateRequest(ctx context.Context if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -166,7 +166,7 @@ func (client *ProvidersClient) getAtTenantScopeHandleResponse(resp *http.Respons // NewListPager - Gets all resource providers for a subscription. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - ProvidersClientListOptions contains the optional parameters for the ProvidersClient.NewListPager method. func (client *ProvidersClient) NewListPager(options *ProvidersClientListOptions) *runtime.Pager[ProvidersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProvidersClientListResponse]{ @@ -206,7 +206,7 @@ func (client *ProvidersClient) listCreateRequest(ctx context.Context, options *P if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -223,7 +223,7 @@ func (client *ProvidersClient) listHandleResponse(resp *http.Response) (Provider // NewListAtTenantScopePager - Gets all resource providers for the tenant. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - ProvidersClientListAtTenantScopeOptions contains the optional parameters for the ProvidersClient.NewListAtTenantScopePager // method. func (client *ProvidersClient) NewListAtTenantScopePager(options *ProvidersClientListAtTenantScopeOptions) *runtime.Pager[ProvidersClientListAtTenantScopeResponse] { @@ -260,7 +260,7 @@ func (client *ProvidersClient) listAtTenantScopeCreateRequest(ctx context.Contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -278,7 +278,7 @@ func (client *ProvidersClient) listAtTenantScopeHandleResponse(resp *http.Respon // ProviderPermissions - Get the provider permissions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider. // - options - ProvidersClientProviderPermissionsOptions contains the optional parameters for the ProvidersClient.ProviderPermissions // method. @@ -320,7 +320,7 @@ func (client *ProvidersClient) providerPermissionsCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,7 +338,7 @@ func (client *ProvidersClient) providerPermissionsHandleResponse(resp *http.Resp // Register - Registers a subscription with a resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider to register. // - options - ProvidersClientRegisterOptions contains the optional parameters for the ProvidersClient.Register method. func (client *ProvidersClient) Register(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientRegisterOptions) (ProvidersClientRegisterResponse, error) { @@ -379,7 +379,7 @@ func (client *ProvidersClient) registerCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Properties != nil { @@ -400,10 +400,12 @@ func (client *ProvidersClient) registerHandleResponse(resp *http.Response) (Prov return result, nil } -// RegisterAtManagementGroupScope - Registers a management group with a resource provider. +// RegisterAtManagementGroupScope - Registers a management group with a resource provider. Use this operation to register +// a resource provider with resource types that can be deployed at the management group scope. It does not +// recursively register subscriptions within the management group. Instead, you must register subscriptions individually. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider to register. // - groupID - The management group ID. // - options - ProvidersClientRegisterAtManagementGroupScopeOptions contains the optional parameters for the ProvidersClient.RegisterAtManagementGroupScope @@ -445,7 +447,7 @@ func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -454,7 +456,7 @@ func (client *ProvidersClient) registerAtManagementGroupScopeCreateRequest(ctx c // Unregister - Unregisters a subscription from a resource provider. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceProviderNamespace - The namespace of the resource provider to unregister. // - options - ProvidersClientUnregisterOptions contains the optional parameters for the ProvidersClient.Unregister method. func (client *ProvidersClient) Unregister(ctx context.Context, resourceProviderNamespace string, options *ProvidersClientUnregisterOptions) (ProvidersClientUnregisterResponse, error) { @@ -495,7 +497,7 @@ func (client *ProvidersClient) unregisterCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armresources/providers_client_example_test.go b/sdk/resourcemanager/resources/armresources/providers_client_example_test.go deleted file mode 100644 index da8fa377cdc9..000000000000 --- a/sdk/resourcemanager/resources/armresources/providers_client_example_test.go +++ /dev/null @@ -1,532 +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 armresources_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/resources/armresources" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json -func ExampleProvidersClient_ProviderPermissions() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().ProviderPermissions(ctx, "Microsoft.TestRP", 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.ProviderPermissionListResult = armresources.ProviderPermissionListResult{ - // Value: []*armresources.ProviderPermission{ - // { - // ApplicationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ProviderAuthorizationConsentState: to.Ptr(armresources.ProviderAuthorizationConsentStateConsented), - // RoleDefinition: &armresources.RoleDefinition{ - // Name: to.Ptr("Contoso service role"), - // ID: to.Ptr("00000000000000000000000000000000"), - // IsServiceRole: to.Ptr(true), - // Permissions: []*armresources.Permission{ - // { - // Actions: []*string{ - // to.Ptr("Microsoft.Contoso/*")}, - // DataActions: []*string{ - // }, - // NotActions: []*string{ - // }, - // NotDataActions: []*string{ - // }, - // }}, - // Scopes: []*string{ - // to.Ptr("/")}, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json -func ExampleProvidersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewProvidersClient().NewListPager(&armresources.ProvidersClientListOptions{Expand: 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.ProviderListResult = armresources.ProviderListResult{ - // Value: []*armresources.Provider{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP1"), - // Namespace: to.Ptr("Microsoft.TestRP1"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("Registering"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Resources"), - // Namespace: to.Ptr("Microsoft.Resources"), - // RegistrationPolicy: to.Ptr("RegistrationFree"), - // RegistrationState: to.Ptr("Registered"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("eastus"), - // to.Ptr("eastus2"), - // to.Ptr("westus")}, - // ResourceType: to.Ptr("subscriptions"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("centralus"), - // to.Ptr("eastasia"), - // to.Ptr("southeastasia")}, - // ResourceType: to.Ptr("resourceGroups"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2016-09-01"), - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("eastus"), - // to.Ptr("eastus2"), - // to.Ptr("westus")}, - // ResourceType: to.Ptr("subscriptions/resourceGroups"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2014-04-01-preview")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("centralus"), - // to.Ptr("eastasia")}, - // ResourceType: to.Ptr("bulkDelete"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // to.Ptr("2017-08-01"), - // to.Ptr("2017-06-01")}, - // Capabilities: to.Ptr("SupportsTags"), - // Locations: []*string{ - // }, - // ResourceType: to.Ptr("deployments"), - // }, - // { - // Aliases: []*armresources.Alias{ - // }, - // APIVersions: []*string{ - // }, - // Capabilities: to.Ptr("SupportsExtension"), - // Locations: []*string{ - // to.Ptr("DevFabric")}, - // ResourceType: to.Ptr("tags"), - // }}, - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP2"), - // Namespace: to.Ptr("Microsoft.TestRP2"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("NotRegistered"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json -func ExampleProvidersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().Get(ctx, "Microsoft.TestRP1", &armresources.ProvidersClientGetOptions{Expand: 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.Provider = armresources.Provider{ - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.TestRP1"), - // Namespace: to.Ptr("Microsoft.TestRP1"), - // RegistrationPolicy: to.Ptr("RegistrationRequired"), - // RegistrationState: to.Ptr("Registering"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // LocationMappings: []*armresources.ProviderExtendedLocation{ - // { - // Type: to.Ptr("EdgeZone"), - // ExtendedLocations: []*string{ - // to.Ptr("LosAngeles"), - // to.Ptr("LosAngeles2")}, - // Location: to.Ptr("West US"), - // }}, - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceType"), - // }, - // { - // APIVersions: []*string{ - // to.Ptr("2018-01-01"), - // to.Ptr("2015-05-01")}, - // Capabilities: to.Ptr("CrossResourceGroupResourceMove, CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"), - // Locations: []*string{ - // to.Ptr("West US")}, - // ResourceType: to.Ptr("TestResourceTypeSibling"), - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json -func ExampleProvidersClient_GetAtTenantScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewProvidersClient().GetAtTenantScope(ctx, "Microsoft.Storage", &armresources.ProvidersClientGetAtTenantScopeOptions{Expand: to.Ptr("resourceTypes/aliases")}) - 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.Provider = armresources.Provider{ - // Namespace: to.Ptr("Microsoft.Storage"), - // ResourceTypes: []*armresources.ProviderResourceType{ - // { - // Aliases: []*armresources.Alias{ - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/accountType"), - // DefaultPath: to.Ptr("sku.name"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accountType"), - // APIVersions: []*string{ - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }, - // { - // Path: to.Ptr("sku.name"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/sku.name"), - // DefaultPath: to.Ptr("sku.name"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accountType"), - // APIVersions: []*string{ - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }, - // { - // Path: to.Ptr("sku.name"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/accessTier"), - // DefaultPath: to.Ptr("properties.accessTier"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.accessTier"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/enableBlobEncryption"), - // DefaultPath: to.Ptr("properties.encryption.services.blob.enabled"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.encryption.services.blob.enabled"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/enableFileEncryption"), - // DefaultPath: to.Ptr("properties.encryption.services.file.enabled"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.encryption.services.file.enabled"), - // APIVersions: []*string{ - // to.Ptr("2018-11-01"), - // to.Ptr("2018-11-09"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // }}, - // }, - // { - // Name: to.Ptr("Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly"), - // DefaultMetadata: &armresources.AliasPathMetadata{ - // Type: to.Ptr(armresources.AliasPathTokenTypeBoolean), - // Attributes: to.Ptr(armresources.AliasPathAttributesModifiable), - // }, - // DefaultPath: to.Ptr("properties.supportsHttpsTrafficOnly"), - // Paths: []*armresources.AliasPath{ - // { - // Path: to.Ptr("properties.supportsHttpsTrafficOnly"), - // APIVersions: []*string{ - // to.Ptr("2018-11-09"), - // to.Ptr("2018-03-01-Preview"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // Metadata: &armresources.AliasPathMetadata{ - // Type: to.Ptr(armresources.AliasPathTokenTypeNotSpecified), - // Attributes: to.Ptr(armresources.AliasPathAttributesNone), - // }, - // }}, - // }}, - // APIProfiles: []*armresources.APIProfile{ - // { - // APIVersion: to.Ptr("2017-10-01"), - // ProfileVersion: to.Ptr("2019-03-01-hybrid"), - // }, - // { - // APIVersion: to.Ptr("2016-01-01"), - // ProfileVersion: to.Ptr("2017-03-09-profile"), - // }, - // { - // APIVersion: to.Ptr("2016-01-01"), - // ProfileVersion: to.Ptr("2018-03-01-hybrid"), - // }, - // { - // APIVersion: to.Ptr("2017-10-01"), - // ProfileVersion: to.Ptr("2018-06-01-profile"), - // }}, - // APIVersions: []*string{ - // to.Ptr("2019-06-01"), - // to.Ptr("2019-04-01"), - // to.Ptr("2018-11-01"), - // to.Ptr("2018-07-01"), - // to.Ptr("2018-03-01-preview"), - // to.Ptr("2018-02-01"), - // to.Ptr("2017-10-01"), - // to.Ptr("2017-06-01"), - // to.Ptr("2016-12-01"), - // to.Ptr("2016-05-01"), - // to.Ptr("2016-01-01"), - // to.Ptr("2015-06-15"), - // to.Ptr("2015-05-01-preview")}, - // Capabilities: to.Ptr("SupportsTags, SupportsLocation"), - // DefaultAPIVersion: to.Ptr("2019-06-01"), - // Locations: []*string{ - // to.Ptr("East US"), - // to.Ptr("East US 2"), - // to.Ptr("East US 2 (Stage)"), - // to.Ptr("West US"), - // to.Ptr("West Europe"), - // to.Ptr("East Asia"), - // to.Ptr("Southeast Asia"), - // to.Ptr("Japan East"), - // to.Ptr("Japan West"), - // to.Ptr("North Central US"), - // to.Ptr("South Central US"), - // to.Ptr("Central US"), - // to.Ptr("North Europe"), - // to.Ptr("Brazil South"), - // to.Ptr("Australia East"), - // to.Ptr("Australia Southeast"), - // to.Ptr("South India"), - // to.Ptr("Central India"), - // to.Ptr("West India"), - // to.Ptr("Canada East"), - // to.Ptr("Canada Central"), - // to.Ptr("West US 2"), - // to.Ptr("West Central US"), - // to.Ptr("UK South"), - // to.Ptr("UK West"), - // to.Ptr("Korea Central"), - // to.Ptr("Korea South"), - // to.Ptr("East US 2 EUAP"), - // to.Ptr("Central US EUAP"), - // to.Ptr("France Central"), - // to.Ptr("France South"), - // to.Ptr("Australia Central"), - // to.Ptr("Australia Central 2"), - // to.Ptr("South Africa West"), - // to.Ptr("South Africa North"), - // to.Ptr("UAE Central"), - // to.Ptr("UAE North"), - // to.Ptr("Switzerland North"), - // to.Ptr("Switzerland West"), - // to.Ptr("Germany West Central"), - // to.Ptr("Germany North"), - // to.Ptr("Norway East"), - // to.Ptr("Norway West"), - // to.Ptr("South Central US STG"), - // to.Ptr("Brazil Southeast")}, - // ResourceType: to.Ptr("storageAccounts"), - // }}, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client.go index b228d9f643c1..80f9aef223dd 100644 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client.go +++ b/sdk/resourcemanager/resources/armresources/resourcegroups_client.go @@ -46,7 +46,7 @@ func NewResourceGroupsClient(subscriptionID string, credential azcore.TokenCrede // CheckExistence - Checks whether a resource group exists. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to check. The name is case insensitive. // - options - ResourceGroupsClientCheckExistenceOptions contains the optional parameters for the ResourceGroupsClient.CheckExistence // method. @@ -87,7 +87,7 @@ func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -96,7 +96,7 @@ func (client *ResourceGroupsClient) checkExistenceCreateRequest(ctx context.Cont // CreateOrUpdate - Creates or updates a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to create or update. Can include alphanumeric, underscore, parentheses, // hyphen, period (except at end), and Unicode characters that match the allowed characters. // - parameters - Parameters supplied to the create or update a resource group. @@ -140,7 +140,7 @@ func (client *ResourceGroupsClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -162,7 +162,7 @@ func (client *ResourceGroupsClient) createOrUpdateHandleResponse(resp *http.Resp // all of its template deployments and currently stored operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to delete. The name is case insensitive. // - options - ResourceGroupsClientBeginDeleteOptions contains the optional parameters for the ResourceGroupsClient.BeginDelete // method. @@ -187,7 +187,7 @@ func (client *ResourceGroupsClient) BeginDelete(ctx context.Context, resourceGro // of its template deployments and currently stored operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *ResourceGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ResourceGroupsClient.BeginDelete" @@ -225,10 +225,10 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-03-01") if options != nil && options.ForceDeletionTypes != nil { reqQP.Set("forceDeletionTypes", *options.ForceDeletionTypes) } - reqQP.Set("api-version", "2021-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -237,7 +237,7 @@ func (client *ResourceGroupsClient) deleteCreateRequest(ctx context.Context, res // BeginExportTemplate - Captures the specified resource group as a template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - parameters - Parameters for exporting the template. // - options - ResourceGroupsClientBeginExportTemplateOptions contains the optional parameters for the ResourceGroupsClient.BeginExportTemplate @@ -263,7 +263,7 @@ func (client *ResourceGroupsClient) BeginExportTemplate(ctx context.Context, res // ExportTemplate - Captures the specified resource group as a template. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 func (client *ResourceGroupsClient) exportTemplate(ctx context.Context, resourceGroupName string, parameters ExportTemplateRequest, options *ResourceGroupsClientBeginExportTemplateOptions) (*http.Response, error) { var err error const operationName = "ResourceGroupsClient.BeginExportTemplate" @@ -301,7 +301,7 @@ func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -313,7 +313,7 @@ func (client *ResourceGroupsClient) exportTemplateCreateRequest(ctx context.Cont // Get - Gets a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to get. The name is case insensitive. // - options - ResourceGroupsClientGetOptions contains the optional parameters for the ResourceGroupsClient.Get method. func (client *ResourceGroupsClient) Get(ctx context.Context, resourceGroupName string, options *ResourceGroupsClientGetOptions) (ResourceGroupsClientGetResponse, error) { @@ -354,7 +354,7 @@ func (client *ResourceGroupsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +371,7 @@ func (client *ResourceGroupsClient) getHandleResponse(resp *http.Response) (Reso // NewListPager - Gets all the resource groups for a subscription. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - ResourceGroupsClientListOptions contains the optional parameters for the ResourceGroupsClient.NewListPager method. func (client *ResourceGroupsClient) NewListPager(options *ResourceGroupsClientListOptions) *runtime.Pager[ResourceGroupsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceGroupsClientListResponse]{ @@ -414,7 +414,7 @@ func (client *ResourceGroupsClient) listCreateRequest(ctx context.Context, optio if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -434,7 +434,7 @@ func (client *ResourceGroupsClient) listHandleResponse(resp *http.Response) (Res // value is retained. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - resourceGroupName - The name of the resource group to update. The name is case insensitive. // - parameters - Parameters supplied to update a resource group. // - options - ResourceGroupsClientUpdateOptions contains the optional parameters for the ResourceGroupsClient.Update method. @@ -476,7 +476,7 @@ func (client *ResourceGroupsClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go deleted file mode 100644 index e745e503371d..000000000000 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client_example_test.go +++ /dev/null @@ -1,220 +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 armresources_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/resources/armresources" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json -func ExampleResourceGroupsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGroupsClient().CreateOrUpdate(ctx, "my-resource-group", armresources.ResourceGroup{ - Location: to.Ptr("eastus"), - }, 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.ResourceGroup = armresources.ResourceGroup{ - // Name: to.Ptr("my-resource-group"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group"), - // Location: to.Ptr("eastus"), - // Properties: &armresources.ResourceGroupProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json -func ExampleResourceGroupsClient_BeginDelete_forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginDelete(ctx, "my-resource-group", &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr("Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets")}) - 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/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsInResourceGroup.json -func ExampleResourceGroupsClient_BeginDelete_forceDeleteAllTheVirtualMachinesInAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginDelete(ctx, "my-resource-group", &armresources.ResourceGroupsClientBeginDeleteOptions{ForceDeletionTypes: to.Ptr("Microsoft.Compute/virtualMachines")}) - 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/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json -func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{ - Options: to.Ptr("IncludeParameterDefaultValue,IncludeComments"), - Resources: []*string{ - to.Ptr("*")}, - }, 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.ResourceGroupExportResult = armresources.ResourceGroupExportResult{ - // Error: &armresources.ErrorResponse{ - // Code: to.Ptr("ExportTemplateCompletedWithErrors"), - // Message: to.Ptr("Export template operation completed with errors. Some resources were not exported. Please see details for more information."), - // Details: []*armresources.ErrorResponse{ - // }, - // }, - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // "myResourceType_myFirstResource_name":map[string]any{ - // "type": "String", - // "defaultValue": "myFirstResource", - // }, - // "myResourceType_myFirstResource_secret":map[string]any{ - // "type": "SecureString", - // "defaultValue": nil, - // }, - // "myResourceType_mySecondResource_name":map[string]any{ - // "type": "String", - // "defaultValue": "mySecondResource", - // }, - // }, - // "resources":[]any{ - // map[string]any{ - // "name": "[parameters('myResourceType_myFirstResource_name')]", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "secret": "[parameters('myResourceType_myFirstResource_secret')]", - // }, - // }, - // map[string]any{ - // "name": "[parameters('myResourceType_mySecondResource_name')]", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "customProperty": "hello!", - // }, - // }, - // }, - // "variables":map[string]any{ - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json -func ExampleResourceGroupsClient_BeginExportTemplate_exportAResourceGroupWithFiltering() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewResourceGroupsClient().BeginExportTemplate(ctx, "my-resource-group", armresources.ExportTemplateRequest{ - Options: to.Ptr("SkipResourceNameParameterization"), - Resources: []*string{ - to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource")}, - }, 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.ResourceGroupExportResult = armresources.ResourceGroupExportResult{ - // Template: map[string]any{ - // "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // "myResourceType_myFirstResource_secret":map[string]any{ - // "type": "SecureString", - // "defaultValue": nil, - // }, - // }, - // "resources":[]any{ - // map[string]any{ - // "name": "myFirstResource", - // "type": "My.RP/myResourceType", - // "apiVersion": "2019-01-01", - // "location": "West US", - // "properties":map[string]any{ - // "secret": "[parameters('myResourceType_myFirstResource_secret')]", - // }, - // }, - // }, - // "variables":map[string]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go b/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go index 8ca83b8660fd..bd26df218277 100644 --- a/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/resourcegroups_client_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/resources_client_live_test.go b/sdk/resourcemanager/resources/armresources/resources_client_live_test.go index 2543b4e39cdb..5c7fddbddaa0 100644 --- a/sdk/resourcemanager/resources/armresources/resources_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/resources_client_live_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/response_types.go b/sdk/resourcemanager/resources/armresources/responses.go similarity index 99% rename from sdk/resourcemanager/resources/armresources/response_types.go rename to sdk/resourcemanager/resources/armresources/responses.go index fb04138cd76c..76df28e353b2 100644 --- a/sdk/resourcemanager/resources/armresources/response_types.go +++ b/sdk/resourcemanager/resources/armresources/responses.go @@ -509,7 +509,7 @@ type ResourceGroupsClientUpdateResponse struct { ResourceGroup } -// TagsClientCreateOrUpdateAtScopeResponse contains the response from method TagsClient.CreateOrUpdateAtScope. +// TagsClientCreateOrUpdateAtScopeResponse contains the response from method TagsClient.BeginCreateOrUpdateAtScope. type TagsClientCreateOrUpdateAtScopeResponse struct { // Wrapper resource for tags API requests and responses. TagsResource @@ -527,7 +527,7 @@ type TagsClientCreateOrUpdateValueResponse struct { TagValue } -// TagsClientDeleteAtScopeResponse contains the response from method TagsClient.DeleteAtScope. +// TagsClientDeleteAtScopeResponse contains the response from method TagsClient.BeginDeleteAtScope. type TagsClientDeleteAtScopeResponse struct { // placeholder for future response values } @@ -554,7 +554,7 @@ type TagsClientListResponse struct { TagsListResult } -// TagsClientUpdateAtScopeResponse contains the response from method TagsClient.UpdateAtScope. +// TagsClientUpdateAtScopeResponse contains the response from method TagsClient.BeginUpdateAtScope. type TagsClientUpdateAtScopeResponse struct { // Wrapper resource for tags API requests and responses. TagsResource diff --git a/sdk/resourcemanager/resources/armresources/tags_client.go b/sdk/resourcemanager/resources/armresources/tags_client.go index b6d0fc249279..98e53f427973 100644 --- a/sdk/resourcemanager/resources/armresources/tags_client.go +++ b/sdk/resourcemanager/resources/armresources/tags_client.go @@ -48,7 +48,7 @@ func NewTagsClient(subscriptionID string, credential azcore.TokenCredential, opt // following prefixes which are reserved for Azure use: 'microsoft', 'azure', 'windows'. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - tagName - The name of the tag to create. // - options - TagsClientCreateOrUpdateOptions contains the optional parameters for the TagsClient.CreateOrUpdate method. func (client *TagsClient) CreateOrUpdate(ctx context.Context, tagName string, options *TagsClientCreateOrUpdateOptions) (TagsClientCreateOrUpdateResponse, error) { @@ -89,7 +89,7 @@ func (client *TagsClient) createOrUpdateCreateRequest(ctx context.Context, tagNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -104,38 +104,59 @@ func (client *TagsClient) createOrUpdateHandleResponse(resp *http.Response) (Tag return result, nil } -// CreateOrUpdateAtScope - This operation allows adding or replacing the entire set of tags on the specified resource or subscription. -// The specified entity can have a maximum of 50 tags. +// BeginCreateOrUpdateAtScope - This operation allows adding or replacing the entire set of tags on the specified resource +// or subscription. The specified entity can have a maximum of 50 tags. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. -// - options - TagsClientCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.CreateOrUpdateAtScope +// - options - TagsClientBeginCreateOrUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginCreateOrUpdateAtScope // method. -func (client *TagsClient) CreateOrUpdateAtScope(ctx context.Context, scope string, parameters TagsResource, options *TagsClientCreateOrUpdateAtScopeOptions) (TagsClientCreateOrUpdateAtScopeResponse, error) { +func (client *TagsClient) BeginCreateOrUpdateAtScope(ctx context.Context, scope string, parameters TagsResource, options *TagsClientBeginCreateOrUpdateAtScopeOptions) (*runtime.Poller[TagsClientCreateOrUpdateAtScopeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtScope(ctx, scope, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagsClientCreateOrUpdateAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TagsClientCreateOrUpdateAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateAtScope - This operation allows adding or replacing the entire set of tags on the specified resource or subscription. +// The specified entity can have a maximum of 50 tags. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *TagsClient) createOrUpdateAtScope(ctx context.Context, scope string, parameters TagsResource, options *TagsClientBeginCreateOrUpdateAtScopeOptions) (*http.Response, error) { var err error - const operationName = "TagsClient.CreateOrUpdateAtScope" + const operationName = "TagsClient.BeginCreateOrUpdateAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.createOrUpdateAtScopeCreateRequest(ctx, scope, parameters, options) if err != nil { - return TagsClientCreateOrUpdateAtScopeResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TagsClientCreateOrUpdateAtScopeResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return TagsClientCreateOrUpdateAtScopeResponse{}, err + return nil, err } - resp, err := client.createOrUpdateAtScopeHandleResponse(httpResp) - return resp, err + return httpResp, nil } // createOrUpdateAtScopeCreateRequest creates the CreateOrUpdateAtScope request. -func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsResource, options *TagsClientCreateOrUpdateAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsResource, options *TagsClientBeginCreateOrUpdateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -143,7 +164,7 @@ func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -152,20 +173,11 @@ func (client *TagsClient) createOrUpdateAtScopeCreateRequest(ctx context.Context return req, nil } -// createOrUpdateAtScopeHandleResponse handles the CreateOrUpdateAtScope response. -func (client *TagsClient) createOrUpdateAtScopeHandleResponse(resp *http.Response) (TagsClientCreateOrUpdateAtScopeResponse, error) { - result := TagsClientCreateOrUpdateAtScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TagsResource); err != nil { - return TagsClientCreateOrUpdateAtScopeResponse{}, err - } - return result, nil -} - // CreateOrUpdateValue - This operation allows adding a value to the list of predefined values for an existing predefined // tag name. A tag value can have a maximum of 256 characters. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - tagName - The name of the tag. // - tagValue - The value of the tag to create. // - options - TagsClientCreateOrUpdateValueOptions contains the optional parameters for the TagsClient.CreateOrUpdateValue @@ -212,7 +224,7 @@ func (client *TagsClient) createOrUpdateValueCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -232,7 +244,7 @@ func (client *TagsClient) createOrUpdateValueHandleResponse(resp *http.Response) // for the given name must have already been deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - tagName - The name of the tag. // - options - TagsClientDeleteOptions contains the optional parameters for the TagsClient.Delete method. func (client *TagsClient) Delete(ctx context.Context, tagName string, options *TagsClientDeleteOptions) (TagsClientDeleteResponse, error) { @@ -272,41 +284,62 @@ func (client *TagsClient) deleteCreateRequest(ctx context.Context, tagName strin return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// DeleteAtScope - Deletes the entire set of tags on a resource or subscription. +// BeginDeleteAtScope - Deletes the entire set of tags on a resource or subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. -// - options - TagsClientDeleteAtScopeOptions contains the optional parameters for the TagsClient.DeleteAtScope method. -func (client *TagsClient) DeleteAtScope(ctx context.Context, scope string, options *TagsClientDeleteAtScopeOptions) (TagsClientDeleteAtScopeResponse, error) { +// - options - TagsClientBeginDeleteAtScopeOptions contains the optional parameters for the TagsClient.BeginDeleteAtScope method. +func (client *TagsClient) BeginDeleteAtScope(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*runtime.Poller[TagsClientDeleteAtScopeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtScope(ctx, scope, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagsClientDeleteAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TagsClientDeleteAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteAtScope - Deletes the entire set of tags on a resource or subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +func (client *TagsClient) deleteAtScope(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*http.Response, error) { var err error - const operationName = "TagsClient.DeleteAtScope" + const operationName = "TagsClient.BeginDeleteAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.deleteAtScopeCreateRequest(ctx, scope, options) if err != nil { - return TagsClientDeleteAtScopeResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TagsClientDeleteAtScopeResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return TagsClientDeleteAtScopeResponse{}, err + return nil, err } - return TagsClientDeleteAtScopeResponse{}, nil + return httpResp, nil } // deleteAtScopeCreateRequest creates the DeleteAtScope request. -func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope string, options *TagsClientDeleteAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope string, options *TagsClientBeginDeleteAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -314,7 +347,7 @@ func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -325,7 +358,7 @@ func (client *TagsClient) deleteAtScopeCreateRequest(ctx context.Context, scope // resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - tagName - The name of the tag. // - tagValue - The value of the tag to delete. // - options - TagsClientDeleteValueOptions contains the optional parameters for the TagsClient.DeleteValue method. @@ -370,7 +403,7 @@ func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -379,7 +412,7 @@ func (client *TagsClient) deleteValueCreateRequest(ctx context.Context, tagName // GetAtScope - Gets the entire set of tags on a resource or subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - scope - The resource scope. // - options - TagsClientGetAtScopeOptions contains the optional parameters for the TagsClient.GetAtScope method. func (client *TagsClient) GetAtScope(ctx context.Context, scope string, options *TagsClientGetAtScopeOptions) (TagsClientGetAtScopeResponse, error) { @@ -413,7 +446,7 @@ func (client *TagsClient) getAtScopeCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -432,7 +465,7 @@ func (client *TagsClient) getAtScopeHandleResponse(resp *http.Response) (TagsCli // tags, and returns a summary of usage for each tag name and value under the given subscription. // In case of a large number of tags, this operation may return a previously cached result. // -// Generated from API version 2021-04-01 +// Generated from API version 2024-03-01 // - options - TagsClientListOptions contains the optional parameters for the TagsClient.NewListPager method. func (client *TagsClient) NewListPager(options *TagsClientListOptions) *runtime.Pager[TagsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TagsClientListResponse]{ @@ -469,7 +502,7 @@ func (client *TagsClient) listCreateRequest(ctx context.Context, options *TagsCl return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -484,6 +517,33 @@ func (client *TagsClient) listHandleResponse(resp *http.Response) (TagsClientLis return result, nil } +// BeginUpdateAtScope - This operation allows replacing, merging or selectively deleting tags on the specified resource or +// subscription. The specified entity can have a maximum of 50 tags at the end of the operation. The +// 'replace' option replaces the entire set of existing tags with a new set. The 'merge' option allows adding tags with new +// names and updating the values of tags with existing names. The 'delete' option +// allows selectively deleting tags based on given names or name/value pairs. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-03-01 +// - scope - The resource scope. +// - options - TagsClientBeginUpdateAtScopeOptions contains the optional parameters for the TagsClient.BeginUpdateAtScope method. +func (client *TagsClient) BeginUpdateAtScope(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*runtime.Poller[TagsClientUpdateAtScopeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateAtScope(ctx, scope, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TagsClientUpdateAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TagsClientUpdateAtScopeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + // UpdateAtScope - This operation allows replacing, merging or selectively deleting tags on the specified resource or subscription. // The specified entity can have a maximum of 50 tags at the end of the operation. The // 'replace' option replaces the entire set of existing tags with a new set. The 'merge' option allows adding tags with new @@ -491,33 +551,30 @@ func (client *TagsClient) listHandleResponse(resp *http.Response) (TagsClientLis // allows selectively deleting tags based on given names or name/value pairs. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 -// - scope - The resource scope. -// - options - TagsClientUpdateAtScopeOptions contains the optional parameters for the TagsClient.UpdateAtScope method. -func (client *TagsClient) UpdateAtScope(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientUpdateAtScopeOptions) (TagsClientUpdateAtScopeResponse, error) { +// Generated from API version 2024-03-01 +func (client *TagsClient) updateAtScope(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*http.Response, error) { var err error - const operationName = "TagsClient.UpdateAtScope" + const operationName = "TagsClient.BeginUpdateAtScope" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() req, err := client.updateAtScopeCreateRequest(ctx, scope, parameters, options) if err != nil { - return TagsClientUpdateAtScopeResponse{}, err + return nil, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return TagsClientUpdateAtScopeResponse{}, err + return nil, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { err = runtime.NewResponseError(httpResp) - return TagsClientUpdateAtScopeResponse{}, err + return nil, err } - resp, err := client.updateAtScopeHandleResponse(httpResp) - return resp, err + return httpResp, nil } // updateAtScopeCreateRequest creates the UpdateAtScope request. -func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientUpdateAtScopeOptions) (*policy.Request, error) { +func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope string, parameters TagsPatchResource, options *TagsClientBeginUpdateAtScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Resources/tags/default" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -525,7 +582,7 @@ func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2024-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -533,12 +590,3 @@ func (client *TagsClient) updateAtScopeCreateRequest(ctx context.Context, scope } return req, nil } - -// updateAtScopeHandleResponse handles the UpdateAtScope response. -func (client *TagsClient) updateAtScopeHandleResponse(resp *http.Response) (TagsClientUpdateAtScopeResponse, error) { - result := TagsClientUpdateAtScopeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.TagsResource); err != nil { - return TagsClientUpdateAtScopeResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/resources/armresources/tags_client_example_test.go b/sdk/resourcemanager/resources/armresources/tags_client_example_test.go deleted file mode 100644 index a48a04768c1e..000000000000 --- a/sdk/resourcemanager/resources/armresources/tags_client_example_test.go +++ /dev/null @@ -1,145 +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 armresources_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/resources/armresources" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json -func ExampleTagsClient_CreateOrUpdateAtScope_updateTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().CreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", armresources.TagsResource{ - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json -func ExampleTagsClient_CreateOrUpdateAtScope_updateTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().CreateOrUpdateAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armresources.TagsResource{ - Properties: &armresources.Tags{ - Tags: map[string]*string{ - "tagKey1": to.Ptr("tag-value-1"), - "tagKey2": to.Ptr("tag-value-2"), - }, - }, - }, 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.TagsResource = armresources.TagsResource{ - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json -func ExampleTagsClient_GetAtScope_getTagsOnAResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().GetAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm", 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.TagsResource = armresources.TagsResource{ - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4fd842fb73656039ec94ce367bcedee25a57bd18/specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsSubscription.json -func ExampleTagsClient_GetAtScope_getTagsOnASubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armresources.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().GetAtScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", 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.TagsResource = armresources.TagsResource{ - // Properties: &armresources.Tags{ - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tag-value-1"), - // "tagKey2": to.Ptr("tag-value-2"), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armresources/tags_client_live_test.go b/sdk/resourcemanager/resources/armresources/tags_client_live_test.go index c6ead6806b6b..3c32b914aa0d 100644 --- a/sdk/resourcemanager/resources/armresources/tags_client_live_test.go +++ b/sdk/resourcemanager/resources/armresources/tags_client_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/resources/armresources/time_rfc3339.go b/sdk/resourcemanager/resources/armresources/time_rfc3339.go index 5026e349b272..1b75ec3bc085 100644 --- a/sdk/resourcemanager/resources/armresources/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armresources/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/resources/armsubscriptions/CHANGELOG.md b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md index 560cd95d6568..bc520fa1f487 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.3.1 (2024-05-02) +### Other Changes + + ## 1.3.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armsubscriptions/autorest.md b/sdk/resourcemanager/resources/armsubscriptions/autorest.md index 77616e287acf..2380dfc42066 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/autorest.md +++ b/sdk/resourcemanager/resources/armsubscriptions/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.3.0 +module-version: 1.3.1 package-subscriptions: true -tag: package-subscriptions-2022-12 ``` diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go deleted file mode 100644 index 32fdb7da7cf4..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go +++ /dev/null @@ -1,408 +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 armsubscriptions_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/resources/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json -func ExampleClient_NewListLocationsPager_getLocationsWithASubscriptionId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListLocationsPager("a1ffc958-d2c7-493e-9f1e-125a0477f536", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: 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.LocationListResult = armsubscriptions.LocationListResult{ - // Value: []*armsubscriptions.Location{ - // { - // Name: to.Ptr("eastus"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus-az2"), - // }}, - // DisplayName: to.Ptr("East US"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("37.3719"), - // Longitude: to.Ptr("-79.8164"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("westus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US"), - // }, - // { - // Name: to.Ptr("eastus2"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus2-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus2-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus2-az2"), - // }}, - // DisplayName: to.Ptr("East US 2"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("36.6681"), - // Longitude: to.Ptr("-78.3889"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("centralus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US 2"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json -func ExampleClient_NewListLocationsPager_getLocationsWithExtendedLocations() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListLocationsPager("a1ffc958-d2c7-493e-9f1e-125a0477f536", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: to.Ptr(true)}) - 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.LocationListResult = armsubscriptions.LocationListResult{ - // Value: []*armsubscriptions.Location{ - // { - // Name: to.Ptr("eastus"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus-az2"), - // }}, - // DisplayName: to.Ptr("East US"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("37.3719"), - // Longitude: to.Ptr("-79.8164"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("westus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US"), - // }, - // { - // Name: to.Ptr("eastus2"), - // Type: to.Ptr(armsubscriptions.LocationTypeRegion), - // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ - // { - // LogicalZone: to.Ptr("1"), - // PhysicalZone: to.Ptr("eastus2-az1"), - // }, - // { - // LogicalZone: to.Ptr("2"), - // PhysicalZone: to.Ptr("eastus2-az3"), - // }, - // { - // LogicalZone: to.Ptr("3"), - // PhysicalZone: to.Ptr("eastus2-az2"), - // }}, - // DisplayName: to.Ptr("East US 2"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("36.6681"), - // Longitude: to.Ptr("-78.3889"), - // PairedRegion: []*armsubscriptions.PairedRegion{ - // { - // Name: to.Ptr("centralus"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), - // }}, - // PhysicalLocation: to.Ptr("Virginia"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) East US 2"), - // }, - // { - // Name: to.Ptr("ezecustomerlabboston1"), - // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), - // DisplayName: to.Ptr("EZE Customer Lab Boston 1"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus/edgeZones/ezecustomerlabboston1"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("42.301218"), - // Longitude: to.Ptr("-71.219038"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Boston 1"), - // }, - // { - // Name: to.Ptr("ezecustomerlabhouston1"), - // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), - // DisplayName: to.Ptr("EZE Customer Lab Houston 1"), - // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/southcentralus/edgeZones/ezecustomerlabhouston1"), - // Metadata: &armsubscriptions.LocationMetadata{ - // Geography: to.Ptr("United States"), - // GeographyGroup: to.Ptr("US"), - // Latitude: to.Ptr("29.9411"), - // Longitude: to.Ptr("-95.41452"), - // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), - // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), - // }, - // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Houston 1"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "291bba3f-e0a5-47bc-a099-3bdcb2a50a05", 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.Subscription = armsubscriptions.Subscription{ - // AuthorizationSource: to.Ptr("Bypassed"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json -func ExampleClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().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.SubscriptionListResult = armsubscriptions.SubscriptionListResult{ - // Value: []*armsubscriptions.Subscription{ - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // }, - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription2"), - // ID: to.Ptr("/subscriptions/72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }, - // { - // TenantID: to.Ptr("f7fb6af2-321d-47c8-9c0f-b0239eaad39a"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("2a0ff0de-96b2-4859-bb7c-a430d07a3e0c"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/PostCheckZonePeers.json -func ExampleClient_CheckZonePeers() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().CheckZonePeers(ctx, "8d65815f-a5b6-402f-9298-045155da7d74", armsubscriptions.CheckZonePeersRequest{ - Location: to.Ptr("eastus"), - SubscriptionIDs: []*string{ - to.Ptr("subscriptions/11111111-1111-1111-1111-111111111111")}, - }, 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.CheckZonePeersResult = armsubscriptions.CheckZonePeersResult{ - // AvailabilityZonePeers: []*armsubscriptions.AvailabilityZonePeers{ - // { - // AvailabilityZone: to.Ptr("1"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("3"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("2"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("2"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("3"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("1"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }}, - // Location: to.Ptr("eastus2"), - // SubscriptionID: to.Ptr("8d65815f-a5b6-402f-9298-045155da7d74"), - // } -} diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go index a6c5e5a37a85..89732293273c 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go @@ -16,8 +16,7 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,36 +24,39 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(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{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.credential, c.options) - return subClient + return &Client{ + 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, + } } // NewSubscriptionClient creates a new instance of SubscriptionClient. func (c *ClientFactory) NewSubscriptionClient() *SubscriptionClient { - subClient, _ := NewSubscriptionClient(c.credential, c.options) - return subClient + return &SubscriptionClient{ + internal: c.internal, + } } // NewTenantsClient creates a new instance of TenantsClient. func (c *ClientFactory) NewTenantsClient() *TenantsClient { - subClient, _ := NewTenantsClient(c.credential, c.options) - return subClient + return &TenantsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armsubscriptions/constants.go b/sdk/resourcemanager/resources/armsubscriptions/constants.go index a8a453259982..43620cb5a1e3 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/constants.go +++ b/sdk/resourcemanager/resources/armsubscriptions/constants.go @@ -10,7 +10,7 @@ package armsubscriptions const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" - moduleVersion = "v1.3.0" + moduleVersion = "v1.3.1" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/resources/armsubscriptions/go.mod b/sdk/resourcemanager/resources/armsubscriptions/go.mod index 5307cfefbb7b..a52f9f6ac6ec 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/go.mod +++ b/sdk/resourcemanager/resources/armsubscriptions/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go index 586cf8640841..7c6ba06779d8 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go +++ b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go @@ -1053,7 +1053,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/resources/armsubscriptions/response_types.go b/sdk/resourcemanager/resources/armsubscriptions/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armsubscriptions/response_types.go rename to sdk/resourcemanager/resources/armsubscriptions/responses.go diff --git a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go deleted file mode 100644 index b49b1c435dea..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go +++ /dev/null @@ -1,43 +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 armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/CheckResourceName.json -func ExampleSubscriptionClient_CheckResourceName() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().CheckResourceName(ctx, &armsubscriptions.SubscriptionClientCheckResourceNameOptions{ResourceNameDefinition: 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.CheckResourceNameResult = armsubscriptions.CheckResourceNameResult{ - // Name: to.Ptr("isxbox"), - // Type: to.Ptr("ResourceProviderTestHost/TestResourceType"), - // Status: to.Ptr(armsubscriptions.ResourceNameStatusAllowed), - // } -} diff --git a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go deleted file mode 100644 index fa85a8e6395d..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go +++ /dev/null @@ -1,82 +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 armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json -func ExampleTenantsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTenantsClient().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.TenantListResult = armsubscriptions.TenantListResult{ - // Value: []*armsubscriptions.TenantIDDescription{ - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("aad50.ccsctp.net"), - // DisplayName: to.Ptr("Test_Test_aad50"), - // Domains: []*string{ - // to.Ptr("aad50.ccsctp.net")}, - // ID: to.Ptr("/tenants/a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryManagedBy), - // TenantID: to.Ptr("a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("auxteststagemanual.ccsctp.net"), - // DisplayName: to.Ptr("Contoso Corp."), - // Domains: []*string{ - // to.Ptr("auxteststagemanual.ccsctp.net")}, - // ID: to.Ptr("/tenants/83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryHome), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("rdvmohoro.ccsctp.net"), - // DisplayName: to.Ptr("TEST_TEST_RDV"), - // Domains: []*string{ - // to.Ptr("rdvmohoro.ccsctp.net"), - // to.Ptr("rdvmohoro.mail.ccsctp.net"), - // to.Ptr("rdvmohoro.com")}, - // ID: to.Ptr("/tenants/daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantBrandingLogoURL: to.Ptr("logo1.logo.rdvmohoro.com"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryProjectedBy), - // TenantID: to.Ptr("daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantType: to.Ptr("AAD"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md b/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md index 77d85f2008c5..aab9464a4098 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armtemplatespecs/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (2024-05-02) +### Other Changes + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/resources/armtemplatespecs/autorest.md b/sdk/resourcemanager/resources/armtemplatespecs/autorest.md index 60f48c4e22ef..66ea67c8b872 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/autorest.md +++ b/sdk/resourcemanager/resources/armtemplatespecs/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.2.1 package-templatespecs: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armtemplatespecs/client_example_test.go b/sdk/resourcemanager/resources/armtemplatespecs/client_example_test.go deleted file mode 100644 index 608583e397a7..000000000000 --- a/sdk/resourcemanager/resources/armtemplatespecs/client_example_test.go +++ /dev/null @@ -1,371 +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 armtemplatespecs_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/resources/armtemplatespecs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsCreate.json -func ExampleClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().CreateOrUpdate(ctx, "templateSpecRG", "simpleTemplateSpec", armtemplatespecs.TemplateSpec{ - Location: to.Ptr("eastus"), - Properties: &armtemplatespecs.TemplateSpecProperties{ - Description: to.Ptr("A very simple Template Spec"), - }, - }, 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.TemplateSpec = armtemplatespecs.TemplateSpec{ - // Name: to.Ptr("simpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("A very simple Template Spec"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsPatch.json -func ExampleClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Update(ctx, "templateSpecRG", "simpleTemplateSpec", &armtemplatespecs.ClientUpdateOptions{TemplateSpec: &armtemplatespecs.TemplateSpecUpdateModel{ - Tags: map[string]*string{ - "myTag": to.Ptr("My Value"), - }, - }, - }) - 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.TemplateSpec = armtemplatespecs.TemplateSpec{ - // Name: to.Ptr("simpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("A very simple Template Spec"), - // }, - // Tags: map[string]*string{ - // "myTag": to.Ptr("My Value"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsGet.json -func ExampleClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "templateSpecRG", "simpleTemplateSpec", &armtemplatespecs.ClientGetOptions{Expand: 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.TemplateSpec = armtemplatespecs.TemplateSpec{ - // Name: to.Ptr("simpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("A very simple Template Spec"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsDelete.json -func ExampleClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewClient().Delete(ctx, "templateSpecRG", "simpleTemplateSpec", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsListBySubscription.json -func ExampleClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListBySubscriptionPager(&armtemplatespecs.ClientListBySubscriptionOptions{Expand: 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.ListResult = armtemplatespecs.ListResult{ - // Value: []*armtemplatespecs.TemplateSpec{ - // { - // Name: to.Ptr("simpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("A very simple Template Spec"), - // }, - // }, - // { - // Name: to.Ptr("anotherSimpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG2/providers/Microsoft.Resources/templateSpecs/anotherSimpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("westus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("Another very simple Template Spec"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecsListByResourceGroup.json -func ExampleClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListByResourceGroupPager("templateSpecRG", &armtemplatespecs.ClientListByResourceGroupOptions{Expand: 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.ListResult = armtemplatespecs.ListResult{ - // Value: []*armtemplatespecs.TemplateSpec{ - // { - // Name: to.Ptr("simpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("A very simple Template Spec"), - // }, - // }, - // { - // Name: to.Ptr("anotherSimpleTemplateSpec"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/anotherSimpleTemplateSpec"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("westus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("Another very simple Template Spec"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/BuiltInTemplateSpecsGet.json -func ExampleClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetBuiltIn(ctx, "nameOfTheBuiltIn", &armtemplatespecs.ClientGetBuiltInOptions{Expand: 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.TemplateSpec = armtemplatespecs.TemplateSpec{ - // Name: to.Ptr("nameOfTheBuiltIn"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfTheBuiltIn"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-02T02:03:01.197Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("The description of the built-in template spec"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/BuiltInTemplateSpecsList.json -func ExampleClient_NewListBuiltInsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListBuiltInsPager(&armtemplatespecs.ClientListBuiltInsOptions{Expand: 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.ListResult = armtemplatespecs.ListResult{ - // Value: []*armtemplatespecs.TemplateSpec{ - // { - // Name: to.Ptr("nameOfBuiltIn"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfBuiltIn"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-02T02:03:01.197Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("The description of the built-in template spec"), - // }, - // }, - // { - // Name: to.Ptr("nameOfAnotherBuiltIn"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfAnotherBuiltIn"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-03T03:01:01.128Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-03T05:22:06.197Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecProperties{ - // Description: to.Ptr("The description of another built-in template spec"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/resources/armtemplatespecs/client_factory.go b/sdk/resourcemanager/resources/armtemplatespecs/client_factory.go index eee0635c465c..3cf25221f716 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/client_factory.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/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. @@ -27,24 +26,28 @@ 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 } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) - return subClient + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewTemplateSpecVersionsClient creates a new instance of TemplateSpecVersionsClient. func (c *ClientFactory) NewTemplateSpecVersionsClient() *TemplateSpecVersionsClient { - subClient, _ := NewTemplateSpecVersionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &TemplateSpecVersionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armtemplatespecs/constants.go b/sdk/resourcemanager/resources/armtemplatespecs/constants.go index 62aa26651d79..51dc579791ba 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/constants.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/constants.go @@ -10,7 +10,7 @@ package armtemplatespecs const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armtemplatespecs" - moduleVersion = "v1.2.0" + moduleVersion = "v1.2.1" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armtemplatespecs/fake/time_rfc3339.go b/sdk/resourcemanager/resources/armtemplatespecs/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/fake/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/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/resources/armtemplatespecs/go.mod b/sdk/resourcemanager/resources/armtemplatespecs/go.mod index 097c9d1d10f8..329ae4e229ef 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/go.mod +++ b/sdk/resourcemanager/resources/armtemplatespecs/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/sdk/resourcemanager/resources/armtemplatespecs/models_serde.go b/sdk/resourcemanager/resources/armtemplatespecs/models_serde.go index a0bc4a7fed16..dd7283844996 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/models_serde.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/models_serde.go @@ -621,7 +621,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/resources/armtemplatespecs/response_types.go b/sdk/resourcemanager/resources/armtemplatespecs/responses.go similarity index 100% rename from sdk/resourcemanager/resources/armtemplatespecs/response_types.go rename to sdk/resourcemanager/resources/armtemplatespecs/responses.go diff --git a/sdk/resourcemanager/resources/armtemplatespecs/templatespecversions_client_example_test.go b/sdk/resourcemanager/resources/armtemplatespecs/templatespecversions_client_example_test.go deleted file mode 100644 index 8bc288acc81b..000000000000 --- a/sdk/resourcemanager/resources/armtemplatespecs/templatespecversions_client_example_test.go +++ /dev/null @@ -1,339 +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 armtemplatespecs_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/resources/armtemplatespecs" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecVersionsCreate.json -func ExampleTemplateSpecVersionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTemplateSpecVersionsClient().CreateOrUpdate(ctx, "templateSpecRG", "simpleTemplateSpec", "v1.0", armtemplatespecs.TemplateSpecVersion{ - Location: to.Ptr("eastus"), - Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - Description: to.Ptr("This is version v1.0 of our template content"), - MainTemplate: map[string]any{ - "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": map[string]any{}, - "resources": []any{}, - }, - }, - }, 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.TemplateSpecVersion = armtemplatespecs.TemplateSpecVersion{ - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs/versions"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0 of our template content"), - // MainTemplate: map[string]any{ - // "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // }, - // "resources":[]any{ - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecVersionsPatch.json -func ExampleTemplateSpecVersionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTemplateSpecVersionsClient().Update(ctx, "templateSpecRG", "simpleTemplateSpec", "v1.0", &armtemplatespecs.TemplateSpecVersionsClientUpdateOptions{TemplateSpecVersionUpdateModel: &armtemplatespecs.TemplateSpecVersionUpdateModel{ - Tags: map[string]*string{ - "myTag": to.Ptr("My Value"), - }, - }, - }) - 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.TemplateSpecVersion = armtemplatespecs.TemplateSpecVersion{ - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs/versions"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0 of our template content"), - // MainTemplate: map[string]any{ - // "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // }, - // "resources":[]any{ - // }, - // }, - // }, - // Tags: map[string]*string{ - // "myTag": to.Ptr("My Value"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecVersionsGet.json -func ExampleTemplateSpecVersionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTemplateSpecVersionsClient().Get(ctx, "templateSpecRG", "simpleTemplateSpec", "v1.0", 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.TemplateSpecVersion = armtemplatespecs.TemplateSpecVersion{ - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs/versions"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0 of our template content"), - // MainTemplate: map[string]any{ - // "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - // "contentVersion": "1.0.0.0", - // "parameters":map[string]any{ - // }, - // "resources":[]any{ - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecVersionsDelete.json -func ExampleTemplateSpecVersionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewTemplateSpecVersionsClient().Delete(ctx, "templateSpecRG", "simpleTemplateSpec", "v1.0", 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/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/TemplateSpecVersionsList.json -func ExampleTemplateSpecVersionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTemplateSpecVersionsClient().NewListPager("templateSpecRG", "simpleTemplateSpec", 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.TemplateSpecVersionsListResult = armtemplatespecs.TemplateSpecVersionsListResult{ - // Value: []*armtemplatespecs.TemplateSpecVersion{ - // { - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs/versions"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-02T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0"), - // }, - // }, - // { - // Name: to.Ptr("v2.0"), - // Type: to.Ptr("Microsoft.Resources/templateSpecs/versions"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/templateSpecRG/providers/Microsoft.Resources/templateSpecs/simpleTemplateSpec/versions/v2.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-03T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-04T02:03:01.197Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armtemplatespecs.CreatedByTypeApplication), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is another version (v2.0)"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/BuiltInTemplateSpecVersionsList.json -func ExampleTemplateSpecVersionsClient_NewListBuiltInsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTemplateSpecVersionsClient().NewListBuiltInsPager("nameOfTheBuiltIn", 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.TemplateSpecVersionsListResult = armtemplatespecs.TemplateSpecVersionsListResult{ - // Value: []*armtemplatespecs.TemplateSpecVersion{ - // { - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs/versions"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfTheBuiltIn/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0"), - // }, - // }, - // { - // Name: to.Ptr("v2.0"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs/versions"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfTheBuiltIn/versions/v2.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-02T02:03:01.197Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-02T02:03:01.197Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is another version (v2.0)"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2022-02-01/examples/BuiltInTemplateSpecVersionsGet.json -func ExampleTemplateSpecVersionsClient_GetBuiltIn() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armtemplatespecs.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTemplateSpecVersionsClient().GetBuiltIn(ctx, "nameOfTheBuiltIn", "v1.0", 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.TemplateSpecVersion = armtemplatespecs.TemplateSpecVersion{ - // Name: to.Ptr("v1.0"), - // Type: to.Ptr("Microsoft.Resources/builtInTemplateSpecs/versions"), - // ID: to.Ptr("/providers/Microsoft.Resources/builtInTemplateSpecs/nameOfTheBuiltIn/versions/v1.0"), - // SystemData: &armtemplatespecs.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-01T01:01:01.107Z"); return t}()), - // }, - // Location: to.Ptr("eastus"), - // Properties: &armtemplatespecs.TemplateSpecVersionProperties{ - // Description: to.Ptr("This is version v1.0"), - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armtemplatespecs/time_rfc3339.go b/sdk/resourcemanager/resources/armtemplatespecs/time_rfc3339.go index 444174807531..751fb58824c6 100644 --- a/sdk/resourcemanager/resources/armtemplatespecs/time_rfc3339.go +++ b/sdk/resourcemanager/resources/armtemplatespecs/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