From a7d350d70e9bfbd7dcf503fc53f0ce8458684ef9 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 18 Nov 2024 21:46:31 +0000 Subject: [PATCH] CodeGen from PR 31587 in Azure/azure-rest-api-specs Merge 59c21134f920c495c3bbe0fe62108814c15b5495 into 4ae412cf228fb0320ced6fd6020435296752bf68 --- .../armdataboundaries/CHANGELOG.md | 8 + .../armdataboundaries/autorest.md | 6 +- .../armdataboundaries/client_example_test.go | 107 -- .../armdataboundaries/client_factory.go | 7 + .../armdataboundaries/constants.go | 2 +- .../fake/operations_server.go | 96 ++ .../armdataboundaries/fake/server_factory.go | 13 +- .../databoundaries/armdataboundaries/go.mod | 12 +- .../databoundaries/armdataboundaries/go.sum | 23 - .../armdataboundaries/operations_client.go | 88 ++ .../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 | 17 - .../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 | 7 +- .../client_example_test.go | 1335 ---------------- .../armdeploymentstacks/constants.go | 2 +- .../resources/armdeploymentstacks/go.mod | 12 +- .../resources/armdeploymentstacks/go.sum | 17 - .../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 | 17 - .../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 | 17 - .../armmanagedapplications/models_serde.go | 2 +- .../{response_types.go => responses.go} | 0 .../resources/armpolicy/CHANGELOG.md | 127 ++ .../resources/armpolicy/README.md | 2 +- .../resources/armpolicy/assignments_client.go | 84 +- .../assignments_client_example_test.go | 1365 ----------------- .../resources/armpolicy/autorest.md | 7 +- .../resources/armpolicy/client_factory.go | 61 +- .../resources/armpolicy/constants.go | 142 +- .../armpolicy/datapolicymanifests_client.go | 157 -- ...datapolicymanifests_client_example_test.go | 278 ---- .../resources/armpolicy/definitions_client.go | 114 +- .../definitions_client_example_test.go | 806 ---------- .../armpolicy/definitionversions_client.go | 846 ++++++++++ .../resources/armpolicy/exemptions_client.go | 586 ------- .../exemptions_client_example_test.go | 639 -------- .../armpolicy/fake/assignments_server.go | 60 +- .../fake/datapolicymanifests_server.go | 146 -- .../armpolicy/fake/definitions_server.go | 24 +- .../fake/definitionversions_server.go | 651 ++++++++ .../armpolicy/fake/exemptions_server.go | 468 ------ .../armpolicy/fake/server_factory.go | 52 +- .../armpolicy/fake/setdefinitions_server.go | 86 +- .../fake/setdefinitionversions_server.go | 705 +++++++++ .../resources/armpolicy/fake/time_rfc3339.go | 42 +- .../armpolicy/fake/variables_server.go | 380 ----- .../armpolicy/fake/variablevalues_server.go | 412 ----- .../resources/armpolicy/go.mod | 2 +- .../resources/armpolicy/models.go | 403 ++--- .../resources/armpolicy/models_serde.go | 956 +++--------- .../resources/armpolicy/options.go | 354 +++-- .../{response_types.go => responses.go} | 261 ++-- .../armpolicy/setdefinitions_client.go | 132 +- .../setdefinitions_client_example_test.go | 1028 ------------- .../armpolicy/setdefinitionversions_client.go | 867 +++++++++++ .../resources/armpolicy/time_rfc3339.go | 42 +- .../resources/armpolicy/variables_client.go | 510 ------ .../variables_client_example_test.go | 355 ----- .../armpolicy/variablevalues_client.go | 553 ------- .../variablevalues_client_example_test.go | 395 ----- .../resources/armresources/CHANGELOG.md | 36 + .../resources/armresources/README.md | 2 +- .../resources/armresources/autorest.md | 6 +- .../resources/armresources/client.go | 68 +- .../resources/armresources/client_factory.go | 56 +- .../resources/armresources/constants.go | 36 +- .../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 | 94 +- .../resources/armresources/models_serde.go | 217 ++- .../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} | 26 +- .../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 +- 178 files changed, 5990 insertions(+), 17893 deletions(-) delete mode 100644 sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go create mode 100644 sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go create mode 100644 sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go 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 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.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.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/exemptions_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go create mode 100644 sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go create mode 100644 sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/fake/variables_server.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go rename sdk/resourcemanager/resources/armpolicy/{response_types.go => responses.go} (53%) 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.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/variables_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/variablevalues_client.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} (97%) 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/databoundaries/armdataboundaries/CHANGELOG.md b/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md index 77c8ce7f50b4..415cdf41d362 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 1.0.0 (2024-11-18) +### Features Added + +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `NewOperationsClient(azcore.TokenCredential, *arm.ClientOptions) (*OperationsClient, error)` +- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` + + ## 0.1.0 (2024-10-21) ### Other Changes diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md b/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md index fad32155fb5b..f92a2f9dba3b 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/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.1.0 +module-version: 1.0.0 package-databoundaries: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go b/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go deleted file mode 100644 index e702cac12b62..000000000000 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/client_example_test.go +++ /dev/null @@ -1,107 +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 armdataboundaries_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/databoundaries/armdataboundaries" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json -func ExampleClient_Put() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Put(ctx, armdataboundaries.DefaultNameDefault, armdataboundaries.DataBoundaryDefinition{ - Properties: &armdataboundaries.DataBoundaryProperties{ - DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - }, - }, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json -func ExampleClient_GetTenant() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetTenant(ctx, armdataboundaries.DefaultNameDefault, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d426a4238db8dcd4da1c03c2c380fa27628093e7/specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetScopedDataBoundary.json -func ExampleClient_GetScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataboundaries.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().GetScope(ctx, "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group", armdataboundaries.DefaultNameDefault, 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.DataBoundaryDefinition = armdataboundaries.DataBoundaryDefinition{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Resources/dataBoundaries/00000000-0000-0000-0000-000000000000"), - // Properties: &armdataboundaries.DataBoundaryProperties{ - // DataBoundary: to.Ptr(armdataboundaries.DataBoundaryEU), - // ProvisioningState: to.Ptr(armdataboundaries.ProvisioningStateSucceeded), - // }, - // } -} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go b/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go index e4a53e320d26..a69481a34e26 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/client_factory.go @@ -39,3 +39,10 @@ func (c *ClientFactory) NewClient() *Client { internal: c.internal, } } + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go b/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go index 61798902032e..27e3c2bea739 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/constants.go @@ -10,7 +10,7 @@ package armdataboundaries const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armdataboundaries" - moduleVersion = "v0.1.0" + moduleVersion = "v1.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go new file mode 100644 index 000000000000..e03383c5a848 --- /dev/null +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/databoundaries/armdataboundaries" + "net/http" +) + +// OperationsServer is a fake server for instances of the armdataboundaries.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armdataboundaries.OperationsClientListOptions) (resp azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armdataboundaries.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armdataboundaries.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armdataboundaries.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataboundaries.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go index b324dbd1c1c9..5616a0a4d5dc 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/fake/server_factory.go @@ -19,7 +19,8 @@ import ( // ServerFactory is a fake server for instances of the armdataboundaries.ClientFactory type. type ServerFactory struct { - Server Server + Server Server + OperationsServer OperationsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -34,9 +35,10 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armdataboundaries.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trServer *ServerTransport + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trOperationsServer *OperationsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -55,6 +57,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "Client": initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) resp, err = s.trServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod b/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod index be0bd26fade2..5f3726ccd60b 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/databoundaries/armd go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.27.0 // indirect golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.18.0 // indirect ) diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum b/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum index 12666d02f378..4dbaa681eac2 100644 --- a/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/go.sum @@ -1,35 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 h1:nyQWyZvwGTvunIMxi1Y9uXkcyr+I7TeNrr/foo4Kpk8= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0/go.mod h1:fiPSssYvltE08HJchL04dOy+RD4hgrjph0cwGGMntdI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0 h1:+m0M/LFxN43KvULkDNfdXOgrjtg6UYJPFBJyuEcRCAw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go b/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go new file mode 100644 index 000000000000..2ae18499271f --- /dev/null +++ b/sdk/resourcemanager/databoundaries/armdataboundaries/operations_client.go @@ -0,0 +1,88 @@ +//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 armdataboundaries + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all of the available Microsoft.Resources REST API operations. +// +// Generated from API version 2024-08-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]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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 OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armchanges/CHANGELOG.md b/sdk/resourcemanager/resources/armchanges/CHANGELOG.md index 7e46a86ac2b8..65578d9210fc 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-11-18) +### 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 ee9f88ceaa90..cf83bc0fa20d 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armchanges/go.sum b/sdk/resourcemanager/resources/armchanges/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/resources/armchanges/go.sum +++ b/sdk/resourcemanager/resources/armchanges/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/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..4ee981ca5745 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-11-18) +### 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 51b806ebc3f6..b283c7743ac7 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.2.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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 99447c5ae4ae..72e74f2d37dc 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.0.1 (2024-11-18) +### Other Changes + + ## 1.0.0 (2024-06-21) ### Breaking Changes diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md index a885c1b071cf..8aad0b32c4f9 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md +++ b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md @@ -5,10 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/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.0.0 +module-version: 1.0.1 package-deploymentstacks: true -tag: package-deploymentstacks-2024-03 ``` \ No newline at end of file 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 4b128ac90019..000000000000 --- a/sdk/resourcemanager/resources/armdeploymentstacks/client_example_test.go +++ /dev/null @@ -1,1335 +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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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, - UnmanageActionManagementGroups: nil, - BypassStackOutOfSyncError: 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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, - UnmanageActionManagementGroups: nil, - BypassStackOutOfSyncError: 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - 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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // }, - // Tags: map[string]*string{ - // "tagkey": to.Ptr("tagVal"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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.ActionOnUnmanage{ - // 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]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Value: "a string", - // }, - // }, - // ProvisioningState: to.Ptr(armdeploymentstacks.DeploymentStackProvisioningState("Succeeded")), - // 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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, - BypassStackOutOfSyncError: 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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/DeploymentStackResourceGroupValidate.json -func ExampleClient_BeginValidateStackAtResourceGroup() { - 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().BeginValidateStackAtResourceGroup(ctx, "deploymentStacksRG", "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.ActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - Value: "a string", - }, - }, - TemplateLink: &armdeploymentstacks.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - 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.DeploymentStackValidateResult = armdeploymentstacks.DeploymentStackValidateResult{ - // 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"), - // Properties: &armdeploymentstacks.DeploymentStackValidateProperties{ - // Description: to.Ptr("A validation description."), - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentScope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG"), - // Parameters: map[string]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Type: to.Ptr("string"), - // Value: "a string", - // }, - // }, - // ValidatedResources: []*armdeploymentstacks.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Sql/servers/server1"), - // }, - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/deploymentStacksRG/providers/Microsoft.Sql/servers/server2"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/DeploymentStackSubscriptionValidate.json -func ExampleClient_BeginValidateStackAtSubscription() { - 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().BeginValidateStackAtSubscription(ctx, "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Location: to.Ptr("eastus"), - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.ActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDelete), - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - Value: "a string", - }, - }, - TemplateLink: &armdeploymentstacks.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - 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.DeploymentStackValidateResult = armdeploymentstacks.DeploymentStackValidateResult{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // Properties: &armdeploymentstacks.DeploymentStackValidateProperties{ - // Description: to.Ptr("A validation description."), - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentScope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000"), - // Parameters: map[string]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Type: to.Ptr("string"), - // Value: "a string", - // }, - // }, - // ValidatedResources: []*armdeploymentstacks.ResourceReference{ - // { - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignment/roleassignment1"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/f4c6c8697c59f966db0d1e36b62df3af3bca9065/specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/DeploymentStackManagementGroupValidate.json -func ExampleClient_BeginValidateStackAtManagementGroup() { - 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().BeginValidateStackAtManagementGroup(ctx, "myMg", "simpleDeploymentStack", armdeploymentstacks.DeploymentStack{ - Location: to.Ptr("eastus"), - Properties: &armdeploymentstacks.DeploymentStackProperties{ - ActionOnUnmanage: &armdeploymentstacks.ActionOnUnmanage{ - ManagementGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - ResourceGroups: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - Resources: to.Ptr(armdeploymentstacks.DeploymentStacksDeleteDetachEnumDetach), - }, - 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]*armdeploymentstacks.DeploymentParameter{ - "parameter1": { - Value: "a string", - }, - }, - TemplateLink: &armdeploymentstacks.TemplateLink{ - URI: to.Ptr("https://example.com/exampleTemplate.json"), - }, - }, - 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.DeploymentStackValidateResult = armdeploymentstacks.DeploymentStackValidateResult{ - // Name: to.Ptr("simpleDeploymentStack"), - // Type: to.Ptr("Microsoft.Resources/deploymentStacks"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Resources/deploymentStacks/simpleDeploymentStack"), - // Properties: &armdeploymentstacks.DeploymentStackValidateProperties{ - // Description: to.Ptr("A validation description."), - // CorrelationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // DenySettings: &armdeploymentstacks.DenySettings{ - // ApplyToChildScopes: to.Ptr(false), - // ExcludedActions: []*string{ - // to.Ptr("action")}, - // ExcludedPrincipals: []*string{ - // to.Ptr("principal")}, - // Mode: to.Ptr(armdeploymentstacks.DenySettingsModeDenyDelete), - // }, - // DeploymentScope: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg"), - // Parameters: map[string]*armdeploymentstacks.DeploymentParameter{ - // "parameter1": &armdeploymentstacks.DeploymentParameter{ - // Type: to.Ptr("string"), - // Value: "a string", - // }, - // }, - // ValidatedResources: []*armdeploymentstacks.ResourceReference{ - // { - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/myMg/providers/Microsoft.Authorization/policyDefinitions/Policy1"), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/constants.go b/sdk/resourcemanager/resources/armdeploymentstacks/constants.go index 16a5f286635b..05ee36079405 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 = "v1.0.0" + moduleVersion = "v1.0.1" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/go.mod b/sdk/resourcemanager/resources/armdeploymentstacks/go.mod index b0d8fca11846..bf357b173da5 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/go.sum b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/resources/armdeploymentstacks/go.sum +++ b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md b/sdk/resourcemanager/resources/armfeatures/CHANGELOG.md index d653480c8669..274794c6fc1a 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-11-18) +### 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 ffd37c857985..819b3568b09f 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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..7041853884c2 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-11-18) +### 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..3e89b6284ba8 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-11-18) +### 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 ef5996bd562a..a05108b8c06a 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armlocks/go.sum b/sdk/resourcemanager/resources/armlocks/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/resources/armlocks/go.sum +++ b/sdk/resourcemanager/resources/armlocks/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/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..8ce704050350 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-11-18) +### 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 e681e2a0e440..e3780ed810a8 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/README.md +++ b/sdk/resourcemanager/resources/armmanagedapplications/README.md @@ -55,7 +55,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 7779c85ba06e..b992bc2fe91d 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/sdk/resourcemanager/resources/armmanagedapplications/go.sum b/sdk/resourcemanager/resources/armmanagedapplications/go.sum index 09d275cb9a37..917448a001b7 100644 --- a/sdk/resourcemanager/resources/armmanagedapplications/go.sum +++ b/sdk/resourcemanager/resources/armmanagedapplications/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0 h1:GJHeeA2N7xrG3q30L2UXDyuWRzDM900/65j70wcM4Ww= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.13.0/go.mod h1:l38EPgmsp71HHLq9j7De57JcKOWPyhrsW1Awm1JS6K0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/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..69462cb04708 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,132 @@ # Release History +## 1.0.0 (2024-11-18) +### Breaking Changes + +- Enum `AliasPathAttributes` has been removed +- Enum `AliasPathTokenType` has been removed +- Enum `AliasPatternType` has been removed +- Enum `AliasType` has been removed +- Enum `AssignmentScopeValidation` has been removed +- Enum `ExemptionCategory` has been removed +- Function `*ClientFactory.NewDataPolicyManifestsClient` has been removed +- Function `*ClientFactory.NewExemptionsClient` has been removed +- Function `*ClientFactory.NewVariableValuesClient` has been removed +- Function `*ClientFactory.NewVariablesClient` has been removed +- Function `NewDataPolicyManifestsClient` has been removed +- Function `*DataPolicyManifestsClient.GetByPolicyMode` has been removed +- Function `*DataPolicyManifestsClient.NewListPager` has been removed +- Function `NewExemptionsClient` has been removed +- Function `*ExemptionsClient.CreateOrUpdate` has been removed +- Function `*ExemptionsClient.Delete` has been removed +- Function `*ExemptionsClient.Get` has been removed +- Function `*ExemptionsClient.NewListForManagementGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourceGroupPager` has been removed +- Function `*ExemptionsClient.NewListForResourcePager` has been removed +- Function `*ExemptionsClient.NewListPager` has been removed +- Function `*ExemptionsClient.Update` has been removed +- Function `NewVariableValuesClient` has been removed +- Function `*VariableValuesClient.CreateOrUpdate` has been removed +- Function `*VariableValuesClient.CreateOrUpdateAtManagementGroup` has been removed +- Function `*VariableValuesClient.Delete` has been removed +- Function `*VariableValuesClient.DeleteAtManagementGroup` has been removed +- Function `*VariableValuesClient.Get` has been removed +- Function `*VariableValuesClient.GetAtManagementGroup` has been removed +- Function `*VariableValuesClient.NewListForManagementGroupPager` has been removed +- Function `*VariableValuesClient.NewListPager` has been removed +- Function `NewVariablesClient` has been removed +- Function `*VariablesClient.CreateOrUpdate` has been removed +- Function `*VariablesClient.CreateOrUpdateAtManagementGroup` has been removed +- Function `*VariablesClient.Delete` has been removed +- Function `*VariablesClient.DeleteAtManagementGroup` has been removed +- Function `*VariablesClient.Get` has been removed +- Function `*VariablesClient.GetAtManagementGroup` has been removed +- Function `*VariablesClient.NewListForManagementGroupPager` has been removed +- Function `*VariablesClient.NewListPager` has been removed +- Struct `Alias` has been removed +- Struct `AliasPath` has been removed +- Struct `AliasPathMetadata` has been removed +- Struct `AliasPattern` has been removed +- Struct `DataEffect` has been removed +- Struct `DataManifestCustomResourceFunctionDefinition` has been removed +- Struct `DataManifestResourceFunctionsDefinition` has been removed +- Struct `DataPolicyManifest` has been removed +- Struct `DataPolicyManifestListResult` has been removed +- Struct `DataPolicyManifestProperties` has been removed +- Struct `Exemption` has been removed +- Struct `ExemptionListResult` has been removed +- Struct `ExemptionProperties` has been removed +- Struct `ExemptionUpdate` has been removed +- Struct `ExemptionUpdateProperties` has been removed +- Struct `ResourceTypeAliases` has been removed +- Struct `Variable` has been removed +- Struct `VariableColumn` has been removed +- Struct `VariableListResult` has been removed +- Struct `VariableProperties` has been removed +- Struct `VariableValue` has been removed +- Struct `VariableValueColumnValue` has been removed +- Struct `VariableValueListResult` has been removed +- Struct `VariableValueProperties` has been removed + +### Features Added + +- New value `OverrideKindDefinitionVersion` added to enum type `OverrideKind` +- New enum type `AssignmentType` with values `AssignmentTypeCustom`, `AssignmentTypeNotSpecified`, `AssignmentTypeSystem`, `AssignmentTypeSystemHidden` +- New function `*ClientFactory.NewDefinitionVersionsClient() *DefinitionVersionsClient` +- New function `*ClientFactory.NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient` +- New function `NewDefinitionVersionsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DefinitionVersionsClient, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdate(context.Context, string, string, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateOptions) (DefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*DefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, string, DefinitionVersion, *DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Delete(context.Context, string, string, *DefinitionVersionsClientDeleteOptions) (DefinitionVersionsClientDeleteResponse, error)` +- New function `*DefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, string, string, *DefinitionVersionsClientDeleteAtManagementGroupOptions) (DefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.Get(context.Context, string, string, *DefinitionVersionsClientGetOptions) (DefinitionVersionsClientGetResponse, error)` +- New function `*DefinitionVersionsClient.GetAtManagementGroup(context.Context, string, string, string, *DefinitionVersionsClientGetAtManagementGroupOptions) (DefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*DefinitionVersionsClient.GetBuiltIn(context.Context, string, string, *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(string, *DefinitionVersionsClientListBuiltInOptions) *runtime.Pager[DefinitionVersionsClientListBuiltInResponse]` +- New function `*DefinitionVersionsClient.NewListByManagementGroupPager(string, string, *DefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[DefinitionVersionsClientListByManagementGroupResponse]` +- New function `*DefinitionVersionsClient.NewListPager(string, *DefinitionVersionsClientListOptions) *runtime.Pager[DefinitionVersionsClientListResponse]` +- New function `NewSetDefinitionVersionsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*SetDefinitionVersionsClient, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdate(context.Context, string, string, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateOptions) (SetDefinitionVersionsClientCreateOrUpdateResponse, error)` +- New function `*SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup(context.Context, string, string, string, SetDefinitionVersion, *SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions) (SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Delete(context.Context, string, string, *SetDefinitionVersionsClientDeleteOptions) (SetDefinitionVersionsClientDeleteResponse, error)` +- New function `*SetDefinitionVersionsClient.DeleteAtManagementGroup(context.Context, string, string, string, *SetDefinitionVersionsClientDeleteAtManagementGroupOptions) (SetDefinitionVersionsClientDeleteAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.Get(context.Context, string, string, *SetDefinitionVersionsClientGetOptions) (SetDefinitionVersionsClientGetResponse, error)` +- New function `*SetDefinitionVersionsClient.GetAtManagementGroup(context.Context, string, string, string, *SetDefinitionVersionsClientGetAtManagementGroupOptions) (SetDefinitionVersionsClientGetAtManagementGroupResponse, error)` +- New function `*SetDefinitionVersionsClient.GetBuiltIn(context.Context, string, string, *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(string, *SetDefinitionVersionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionVersionsClientListBuiltInResponse]` +- New function `*SetDefinitionVersionsClient.NewListByManagementGroupPager(string, string, *SetDefinitionVersionsClientListByManagementGroupOptions) *runtime.Pager[SetDefinitionVersionsClientListByManagementGroupResponse]` +- New function `*SetDefinitionVersionsClient.NewListPager(string, *SetDefinitionVersionsClientListOptions) *runtime.Pager[SetDefinitionVersionsClientListResponse]` +- New struct `DefinitionVersion` +- New struct `DefinitionVersionListResult` +- New struct `DefinitionVersionProperties` +- New struct `SetDefinitionVersion` +- New struct `SetDefinitionVersionListResult` +- New struct `SetDefinitionVersionProperties` +- New field `AssignmentType`, `DefinitionVersion`, `EffectiveDefinitionVersion`, `LatestDefinitionVersion` in struct `AssignmentProperties` +- New field `Expand` in struct `AssignmentsClientGetByIDOptions` +- New field `Expand` in struct `AssignmentsClientGetOptions` +- New field `Expand` in struct `AssignmentsClientListForManagementGroupOptions` +- New field `Expand` in struct `AssignmentsClientListForResourceGroupOptions` +- New field `Expand` in struct `AssignmentsClientListForResourceOptions` +- New field `Expand` in struct `AssignmentsClientListOptions` +- New field `Version`, `Versions` in struct `DefinitionProperties` +- New field `DefinitionVersion`, `EffectiveDefinitionVersion`, `LatestDefinitionVersion` in struct `DefinitionReference` +- New field `Schema` in struct `ParameterDefinitionsValue` +- New field `Version`, `Versions` in struct `SetDefinitionProperties` +- New field `Expand` in struct `SetDefinitionsClientGetAtManagementGroupOptions` +- New field `Expand` in struct `SetDefinitionsClientGetBuiltInOptions` +- New field `Expand` in struct `SetDefinitionsClientGetOptions` +- New field `Expand` in struct `SetDefinitionsClientListBuiltInOptions` +- New field `Expand` in struct `SetDefinitionsClientListByManagementGroupOptions` +- New field `Expand` in struct `SetDefinitionsClientListOptions` + + ## 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 da3dc5d439cb..a469ce636928 100644 --- a/sdk/resourcemanager/resources/armpolicy/README.md +++ b/sdk/resourcemanager/resources/armpolicy/README.md @@ -55,7 +55,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..cde67b89e8f1 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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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,10 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -364,7 +367,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 2024-05-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 +401,10 @@ func (client *AssignmentsClient) getByIDCreateRequest(ctx context.Context, polic return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-06-01") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -425,7 +431,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 2024-05-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]{ @@ -462,10 +468,13 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, options return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } 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", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -493,7 +502,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 2024-05-01 // - managementGroupID - The ID of the management group. // - options - AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager // method. @@ -532,10 +541,13 @@ func (client *AssignmentsClient) listForManagementGroupCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } 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", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -577,7 +589,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 2024-05-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 +624,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,19 +642,18 @@ 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 } reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } 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", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -670,7 +685,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 2024-05-01 // - resourceGroupName - The name of the resource group that contains policy assignments. // - options - AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager // method. @@ -700,23 +715,26 @@ 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 } reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } 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", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -741,7 +759,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 2024-05-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 +803,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", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -813,7 +831,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 2024-05-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 +866,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", "2024-05-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..9cc6a7d96ac3 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: 1.0.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..2957a4807123 100644 --- a/sdk/resourcemanager/resources/armpolicy/client_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/client_factory.go @@ -17,64 +17,61 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - 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 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 } // 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, + internal: c.internal, + } } -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient. -func (c *ClientFactory) NewDataPolicyManifestsClient() *DataPolicyManifestsClient { - subClient, _ := NewDataPolicyManifestsClient(c.credential, c.options) - return subClient +// NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient. +func (c *ClientFactory) NewDefinitionVersionsClient() *DefinitionVersionsClient { + return &DefinitionVersionsClient{ + subscriptionID: c.subscriptionID, + 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, + 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 +// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient. +func (c *ClientFactory) NewSetDefinitionVersionsClient() *SetDefinitionVersionsClient { + return &SetDefinitionVersionsClient{ + subscriptionID: c.subscriptionID, + 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 -} - -// NewVariableValuesClient creates a new instance of VariableValuesClient. -func (c *ClientFactory) NewVariableValuesClient() *VariableValuesClient { - subClient, _ := NewVariableValuesClient(c.subscriptionID, c.credential, c.options) - return subClient -} - -// NewVariablesClient creates a new instance of VariablesClient. -func (c *ClientFactory) NewVariablesClient() *VariablesClient { - subClient, _ := NewVariablesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &SetDefinitionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/resources/armpolicy/constants.go b/sdk/resourcemanager/resources/armpolicy/constants.go index 341a352cfd93..63df9d1c5c5c 100644 --- a/sdk/resourcemanager/resources/armpolicy/constants.go +++ b/sdk/resourcemanager/resources/armpolicy/constants.go @@ -10,118 +10,26 @@ package armpolicy const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armpolicy" - moduleVersion = "v0.9.0" + moduleVersion = "v1.0.0" ) -// AliasPathAttributes - The attributes of the token that the alias path is referring to. -type AliasPathAttributes string +// AssignmentType - The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. +type AssignmentType string const ( - // AliasPathAttributesModifiable - The token that the alias path is referring to is modifiable by policies with 'modify' effect. - AliasPathAttributesModifiable AliasPathAttributes = "Modifiable" - // AliasPathAttributesNone - The token that the alias path is referring to has no attributes. - AliasPathAttributesNone AliasPathAttributes = "None" + AssignmentTypeCustom AssignmentType = "Custom" + AssignmentTypeNotSpecified AssignmentType = "NotSpecified" + AssignmentTypeSystem AssignmentType = "System" + AssignmentTypeSystemHidden AssignmentType = "SystemHidden" ) -// PossibleAliasPathAttributesValues returns the possible values for the AliasPathAttributes const type. -func PossibleAliasPathAttributesValues() []AliasPathAttributes { - return []AliasPathAttributes{ - AliasPathAttributesModifiable, - AliasPathAttributesNone, - } -} - -// AliasPathTokenType - The type of the token that the alias path is referring to. -type AliasPathTokenType string - -const ( - // AliasPathTokenTypeAny - The token type can be anything. - AliasPathTokenTypeAny AliasPathTokenType = "Any" - // AliasPathTokenTypeArray - The token type is array. - AliasPathTokenTypeArray AliasPathTokenType = "Array" - // AliasPathTokenTypeBoolean - The token type is boolean. - AliasPathTokenTypeBoolean AliasPathTokenType = "Boolean" - // AliasPathTokenTypeInteger - The token type is integer. - AliasPathTokenTypeInteger AliasPathTokenType = "Integer" - // AliasPathTokenTypeNotSpecified - The token type is not specified. - AliasPathTokenTypeNotSpecified AliasPathTokenType = "NotSpecified" - // AliasPathTokenTypeNumber - The token type is number. - AliasPathTokenTypeNumber AliasPathTokenType = "Number" - // AliasPathTokenTypeObject - The token type is object. - AliasPathTokenTypeObject AliasPathTokenType = "Object" - // AliasPathTokenTypeString - The token type is string. - AliasPathTokenTypeString AliasPathTokenType = "String" -) - -// PossibleAliasPathTokenTypeValues returns the possible values for the AliasPathTokenType const type. -func PossibleAliasPathTokenTypeValues() []AliasPathTokenType { - return []AliasPathTokenType{ - AliasPathTokenTypeAny, - AliasPathTokenTypeArray, - AliasPathTokenTypeBoolean, - AliasPathTokenTypeInteger, - AliasPathTokenTypeNotSpecified, - AliasPathTokenTypeNumber, - AliasPathTokenTypeObject, - AliasPathTokenTypeString, - } -} - -// AliasPatternType - The type of alias pattern -type AliasPatternType string - -const ( - // AliasPatternTypeExtract - Extract is the only allowed value. - AliasPatternTypeExtract AliasPatternType = "Extract" - // AliasPatternTypeNotSpecified - NotSpecified is not allowed. - AliasPatternTypeNotSpecified AliasPatternType = "NotSpecified" -) - -// PossibleAliasPatternTypeValues returns the possible values for the AliasPatternType const type. -func PossibleAliasPatternTypeValues() []AliasPatternType { - return []AliasPatternType{ - AliasPatternTypeExtract, - AliasPatternTypeNotSpecified, - } -} - -// AliasType - The type of the alias. -type AliasType string - -const ( - // AliasTypeMask - Alias value is secret. - AliasTypeMask AliasType = "Mask" - // AliasTypeNotSpecified - Alias type is unknown (same as not providing alias type). - AliasTypeNotSpecified AliasType = "NotSpecified" - // AliasTypePlainText - Alias value is not secret. - AliasTypePlainText AliasType = "PlainText" -) - -// PossibleAliasTypeValues returns the possible values for the AliasType const type. -func PossibleAliasTypeValues() []AliasType { - return []AliasType{ - AliasTypeMask, - AliasTypeNotSpecified, - AliasTypePlainText, - } -} - -// AssignmentScopeValidation - The option whether validate the exemption is at or under the assignment scope. -type AssignmentScopeValidation string - -const ( - // AssignmentScopeValidationDefault - This option will validate the exemption is at or under the assignment scope. - AssignmentScopeValidationDefault AssignmentScopeValidation = "Default" - // AssignmentScopeValidationDoNotValidate - This option will bypass the validation the exemption scope is at or under the - // policy assignment scope. - AssignmentScopeValidationDoNotValidate AssignmentScopeValidation = "DoNotValidate" -) - -// PossibleAssignmentScopeValidationValues returns the possible values for the AssignmentScopeValidation const type. -func PossibleAssignmentScopeValidationValues() []AssignmentScopeValidation { - return []AssignmentScopeValidation{ - AssignmentScopeValidationDefault, - AssignmentScopeValidationDoNotValidate, +// PossibleAssignmentTypeValues returns the possible values for the AssignmentType const type. +func PossibleAssignmentTypeValues() []AssignmentType { + return []AssignmentType{ + AssignmentTypeCustom, + AssignmentTypeNotSpecified, + AssignmentTypeSystem, + AssignmentTypeSystemHidden, } } @@ -163,29 +71,12 @@ func PossibleEnforcementModeValues() []EnforcementMode { } } -// ExemptionCategory - The policy exemption category. Possible values are Waiver and Mitigated. -type ExemptionCategory string - -const ( - // ExemptionCategoryMitigated - This category of exemptions usually means the mitigation actions have been applied to the - // scope. - ExemptionCategoryMitigated ExemptionCategory = "Mitigated" - // ExemptionCategoryWaiver - This category of exemptions usually means the scope is not applicable for the policy. - ExemptionCategoryWaiver ExemptionCategory = "Waiver" -) - -// PossibleExemptionCategoryValues returns the possible values for the ExemptionCategory const type. -func PossibleExemptionCategoryValues() []ExemptionCategory { - return []ExemptionCategory{ - ExemptionCategoryMitigated, - ExemptionCategoryWaiver, - } -} - // OverrideKind - The override kind. type OverrideKind string const ( + // OverrideKindDefinitionVersion - It will override the definition version property value of the policy assignment. + OverrideKindDefinitionVersion OverrideKind = "definitionVersion" // OverrideKindPolicyEffect - It will override the policy effect type. OverrideKindPolicyEffect OverrideKind = "policyEffect" ) @@ -193,6 +84,7 @@ const ( // PossibleOverrideKindValues returns the possible values for the OverrideKind const type. func PossibleOverrideKindValues() []OverrideKind { return []OverrideKind{ + OverrideKindDefinitionVersion, OverrideKindPolicyEffect, } } diff --git a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go b/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go deleted file mode 100644 index 998169d2761c..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/datapolicymanifests_client.go +++ /dev/null @@ -1,157 +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. 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" - "strings" -) - -// DataPolicyManifestsClient contains the methods for the DataPolicyManifests group. -// Don't use this type directly, use NewDataPolicyManifestsClient() instead. -type DataPolicyManifestsClient struct { - internal *arm.Client -} - -// NewDataPolicyManifestsClient creates a new instance of DataPolicyManifestsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewDataPolicyManifestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DataPolicyManifestsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &DataPolicyManifestsClient{ - internal: cl, - } - return client, nil -} - -// GetByPolicyMode - This operation retrieves the data policy manifest with the given policy mode. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2020-09-01 -// - policyMode - The policy mode of the data policy manifest to get. -// - options - DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode -// method. -func (client *DataPolicyManifestsClient) GetByPolicyMode(ctx context.Context, policyMode string, options *DataPolicyManifestsClientGetByPolicyModeOptions) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - var err error - const operationName = "DataPolicyManifestsClient.GetByPolicyMode" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getByPolicyModeCreateRequest(ctx, policyMode, options) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - resp, err := client.getByPolicyModeHandleResponse(httpResp) - return resp, err -} - -// getByPolicyModeCreateRequest creates the GetByPolicyMode request. -func (client *DataPolicyManifestsClient) getByPolicyModeCreateRequest(ctx context.Context, policyMode string, options *DataPolicyManifestsClientGetByPolicyModeOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests/{policyMode}" - if policyMode == "" { - return nil, errors.New("parameter policyMode cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyMode}", url.PathEscape(policyMode)) - 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", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getByPolicyModeHandleResponse handles the GetByPolicyMode response. -func (client *DataPolicyManifestsClient) getByPolicyModeHandleResponse(resp *http.Response) (DataPolicyManifestsClientGetByPolicyModeResponse, error) { - result := DataPolicyManifestsClientGetByPolicyModeResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifest); err != nil { - return DataPolicyManifestsClientGetByPolicyModeResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves a list of all the data policy manifests that match the optional given $filter. -// Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the -// unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned -// list only includes all data policy manifests that have a namespace matching -// the provided value. -// -// Generated from API version 2020-09-01 -// - options - DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager -// method. -func (client *DataPolicyManifestsClient) NewListPager(options *DataPolicyManifestsClientListOptions) *runtime.Pager[DataPolicyManifestsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[DataPolicyManifestsClientListResponse]{ - More: func(page DataPolicyManifestsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *DataPolicyManifestsClientListResponse) (DataPolicyManifestsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataPolicyManifestsClient.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 DataPolicyManifestsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *DataPolicyManifestsClient) listCreateRequest(ctx context.Context, options *DataPolicyManifestsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Authorization/dataPolicyManifests" - 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", "2020-09-01") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *DataPolicyManifestsClient) listHandleResponse(resp *http.Response) (DataPolicyManifestsClientListResponse, error) { - result := DataPolicyManifestsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.DataPolicyManifestListResult); err != nil { - return DataPolicyManifestsClientListResponse{}, err - } - return result, nil -} 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..ecc5e3d14893 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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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..6e439feccf75 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/definitionversions_client.go @@ -0,0 +1,846 @@ +//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 +} + +// NewDefinitionVersionsClient creates a new instance of DefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDefinitionVersionsClient(subscriptionID 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, + 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 2024-05-01 +// - 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 +// - parameters - The policy definition properties. +// - options - DefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdate +// method. +func (client *DefinitionVersionsClient) CreateOrUpdate(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion string, 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - 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 +// - 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, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - 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 +// - options - DefinitionVersionsClientDeleteOptions contains the optional parameters for the DefinitionVersionsClient.Delete +// method. +func (client *DefinitionVersionsClient) Delete(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion string, 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - 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 +// - options - DefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *DefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - 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 +// - options - DefinitionVersionsClientGetOptions contains the optional parameters for the DefinitionVersionsClient.Get method. +func (client *DefinitionVersionsClient) Get(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion string, 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - 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 +// - options - DefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *DefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion 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 policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - 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 +// - options - DefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.GetBuiltIn +// method. +func (client *DefinitionVersionsClient) GetBuiltIn(ctx context.Context, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName, policyDefinitionVersion, 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, policyDefinitionName string, policyDefinitionVersion string, options *DefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions/{policyDefinitionVersion}" + if policyDefinitionName == "" { + return nil, errors.New("parameter policyDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionName}", url.PathEscape(policyDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - policyDefinitionName - The name of the policy definition. +// - options - DefinitionVersionsClientListOptions contains the optional parameters for the DefinitionVersionsClient.NewListPager +// method. +func (client *DefinitionVersionsClient) NewListPager(policyDefinitionName string, 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, policyDefinitionName, 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, policyDefinitionName string, 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 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() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-01 +// - policyDefinitionName - The name of the policy definition. +// - options - DefinitionVersionsClientListBuiltInOptions contains the optional parameters for the DefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *DefinitionVersionsClient) NewListBuiltInPager(policyDefinitionName string, 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, policyDefinitionName, 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, policyDefinitionName string, options *DefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}/versions" + 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() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - policyDefinitionName - The name of the policy definition. +// - options - DefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *DefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, policyDefinitionName 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, policyDefinitionName, 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, policyDefinitionName 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 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() + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 deleted file mode 100644 index b0dead1ca36a..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/exemptions_client.go +++ /dev/null @@ -1,586 +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. 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" - "strings" -) - -// ExemptionsClient contains the methods for the PolicyExemptions group. -// Don't use this type directly, use NewExemptionsClient() instead. -type ExemptionsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewExemptionsClient creates a new instance of ExemptionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. -// - 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) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &ExemptionsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a policy exemption with the given scope and name. Policy exemptions -// apply to all resources contained within their scope. For example, when you create a policy -// exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable -// resources in the resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for the policy exemption. -// - options - ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate -// method. -func (client *ExemptionsClient) CreateOrUpdate(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, options *ExemptionsClientCreateOrUpdateOptions) (ExemptionsClientCreateOrUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.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, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExemptionsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters Exemption, options *ExemptionsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - 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", "2022-07-01-preview") - 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 *ExemptionsClient) createOrUpdateHandleResponse(resp *http.Response) (ExemptionsClientCreateOrUpdateResponse, error) { - result := ExemptionsClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy -// exemption is the part of its ID preceding -// '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -func (client *ExemptionsClient) Delete(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientDeleteOptions) (ExemptionsClientDeleteResponse, error) { - var err error - const operationName = "ExemptionsClient.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, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientDeleteResponse{}, err - } - return ExemptionsClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ExemptionsClient) deleteCreateRequest(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - 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", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single policy exemption, 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-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - options - ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -func (client *ExemptionsClient) Get(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientGetOptions) (ExemptionsClientGetResponse, error) { - var err error - const operationName = "ExemptionsClient.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, scope, policyExemptionName, options) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *ExemptionsClient) getCreateRequest(ctx context.Context, scope string, policyExemptionName string, options *ExemptionsClientGetOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - 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", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ExemptionsClient) getHandleResponse(resp *http.Response) (ExemptionsClientGetResponse, error) { - result := ExemptionsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all policy exemptions associated with the given subscription that match -// the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the unfiltered list includes all policy -// exemptions associated with the subscription, including those that apply -// directly or from management groups that contain the given subscription, as well as any applied to objects contained within -// the subscription. -// -// Generated from API version 2022-07-01-preview -// - options - ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -func (client *ExemptionsClient) NewListPager(options *ExemptionsClientListOptions) *runtime.Pager[ExemptionsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListResponse]{ - More: func(page ExemptionsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListResponse) (ExemptionsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.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 ExemptionsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *ExemptionsClient) listCreateRequest(ctx context.Context, options *ExemptionsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ExemptionsClient) listHandleResponse(resp *http.Response) (ExemptionsClientListResponse, error) { - result := ExemptionsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all policy exemptions applicable to the management -// group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', -// 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter=atScope() is provided, the returned list includes all -// policy exemptions that are assigned to the management group or the management -// group's ancestors. -// -// Generated from API version 2022-07-01-preview -// - managementGroupID - The ID of the management group. -// - options - ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager -// method. -func (client *ExemptionsClient) NewListForManagementGroupPager(managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) *runtime.Pager[ExemptionsClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForManagementGroupResponse]{ - More: func(page ExemptionsClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForManagementGroupResponse) (ExemptionsClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForManagementGroupPager") - 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.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *ExemptionsClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *ExemptionsClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/policyExemptions" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - 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", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *ExemptionsClient) listForManagementGroupHandleResponse(resp *http.Response) (ExemptionsClientListForManagementGroupResponse, error) { - result := ExemptionsClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForManagementGroupResponse{}, err - } - return result, nil -} - -// NewListForResourcePager - This operation retrieves the list of all policy exemptions associated with the specified resource -// in the given resource group and subscription that match the optional given $filter. Valid values for -// $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not -// provided, the unfiltered list includes all policy exemptions associated with the -// resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained -// within the resource. Three parameters plus the resource name are used to -// identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource -// path should not be provided (or provided as ”). For example a web app could -// be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == ”, {resourceType} == 'sites', -// {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, -// then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} -// == 'Microsoft.Compute', {parentResourcePath} == -// 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient -// alternative to providing the namespace and type name separately is to provide -// both in the {resourceType} parameter, format: ({resourceProviderNamespace} == ”, {parentResourcePath} == ”, {resourceType} -// == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). -// -// Generated from API version 2022-07-01-preview -// - 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) -// - parentResourcePath - The parent resource path. Use empty string if there is none. -// - resourceType - The resource type name. For example the type name of a web app is 'sites' (from Microsoft.Web/sites). -// - resourceName - The name of the resource. -// - options - ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager -// method. -func (client *ExemptionsClient) NewListForResourcePager(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) *runtime.Pager[ExemptionsClientListForResourceResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceResponse]{ - More: func(page ExemptionsClientListForResourceResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceResponse) (ExemptionsClientListForResourceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourcePager") - 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.listForResourceCreateRequest(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return client.listForResourceHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceCreateRequest creates the ListForResource request. -func (client *ExemptionsClient) listForResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *ExemptionsClientListForResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if resourceProviderNamespace == "" { - return nil, errors.New("parameter resourceProviderNamespace cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceProviderNamespace}", url.PathEscape(resourceProviderNamespace)) - urlPath = strings.ReplaceAll(urlPath, "{parentResourcePath}", parentResourcePath) - urlPath = strings.ReplaceAll(urlPath, "{resourceType}", resourceType) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - 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", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceHandleResponse handles the ListForResource response. -func (client *ExemptionsClient) listForResourceHandleResponse(resp *http.Response) (ExemptionsClientListForResourceResponse, error) { - result := ExemptionsClientListForResourceResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceResponse{}, err - } - return result, nil -} - -// NewListForResourceGroupPager - This operation retrieves the list of all policy exemptions associated with the given resource -// group in the given subscription that match the optional given $filter. Valid values for $filter are: -// 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}”. If $filter is not provided, the -// unfiltered list includes all policy exemptions associated with the resource -// group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained -// within the resource group. -// -// Generated from API version 2022-07-01-preview -// - resourceGroupName - The name of the resource group containing the resource. -// - options - ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager -// method. -func (client *ExemptionsClient) NewListForResourceGroupPager(resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) *runtime.Pager[ExemptionsClientListForResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[ExemptionsClientListForResourceGroupResponse]{ - More: func(page ExemptionsClientListForResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *ExemptionsClientListForResourceGroupResponse) (ExemptionsClientListForResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExemptionsClient.NewListForResourceGroupPager") - 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.listForResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return client.listForResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForResourceGroupCreateRequest creates the ListForResourceGroup request. -func (client *ExemptionsClient) listForResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ExemptionsClientListForResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyExemptions" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - unencodedParams := []string{req.Raw().URL.RawQuery} - if options != nil && options.Filter != nil { - unencodedParams = append(unencodedParams, "$filter="+*options.Filter) - } - req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&") - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForResourceGroupHandleResponse handles the ListForResourceGroup response. -func (client *ExemptionsClient) listForResourceGroupHandleResponse(resp *http.Response) (ExemptionsClientListForResourceGroupResponse, error) { - result := ExemptionsClientListForResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExemptionListResult); err != nil { - return ExemptionsClientListForResourceGroupResponse{}, err - } - return result, nil -} - -// Update - This operation updates a policy exemption with the given scope and name. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-07-01-preview -// - scope - The scope of the policy exemption. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), -// subscription (format: -// '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', -// or resource (format: -// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' -// - policyExemptionName - The name of the policy exemption to delete. -// - parameters - Parameters for policy exemption patch request. -// - options - ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -func (client *ExemptionsClient) Update(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, options *ExemptionsClientUpdateOptions) (ExemptionsClientUpdateResponse, error) { - var err error - const operationName = "ExemptionsClient.Update" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, scope, policyExemptionName, parameters, options) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExemptionsClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExemptionsClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *ExemptionsClient) updateCreateRequest(ctx context.Context, scope string, policyExemptionName string, parameters ExemptionUpdate, options *ExemptionsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/{scope}/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}" - urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) - if policyExemptionName == "" { - return nil, errors.New("parameter policyExemptionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{policyExemptionName}", url.PathEscape(policyExemptionName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-07-01-preview") - 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 -} - -// updateHandleResponse handles the Update response. -func (client *ExemptionsClient) updateHandleResponse(resp *http.Response) (ExemptionsClientUpdateResponse, error) { - result := ExemptionsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Exemption); err != nil { - return ExemptionsClientUpdateResponse{}, err - } - return result, nil -} 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/assignments_server.go b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go index 9f49acfd55f0..20dcda06845e 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/assignments_server.go @@ -286,6 +286,7 @@ func (a *AssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Respo if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) if err != nil { return nil, err @@ -294,7 +295,18 @@ func (a *AssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := a.srv.Get(req.Context(), scopeParam, policyAssignmentNameParam, nil) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.AssignmentsClientGetOptions + if expandParam != nil { + options = &armpolicy.AssignmentsClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := a.srv.Get(req.Context(), scopeParam, policyAssignmentNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -319,11 +331,23 @@ func (a *AssignmentsServerTransport) dispatchGetByID(req *http.Request) (*http.R if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() policyAssignmentIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyAssignmentId")]) if err != nil { return nil, err } - respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, nil) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.AssignmentsClientGetByIDOptions + if expandParam != nil { + options = &armpolicy.AssignmentsClientGetByIDOptions{ + Expand: expandParam, + } + } + respr, errRespr := a.srv.GetByID(req.Context(), policyAssignmentIDParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -356,6 +380,11 @@ func (a *AssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*h return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -371,9 +400,10 @@ func (a *AssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*h return nil, err } var options *armpolicy.AssignmentsClientListOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.AssignmentsClientListOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } @@ -420,6 +450,11 @@ func (a *AssignmentsServerTransport) dispatchNewListForManagementGroupPager(req return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -435,9 +470,10 @@ func (a *AssignmentsServerTransport) dispatchNewListForManagementGroupPager(req return nil, err } var options *armpolicy.AssignmentsClientListForManagementGroupOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.AssignmentsClientListForManagementGroupOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } @@ -500,6 +536,11 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourcePager(req *http.R return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -515,9 +556,10 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourcePager(req *http.R return nil, err } var options *armpolicy.AssignmentsClientListForResourceOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.AssignmentsClientListForResourceOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } @@ -564,6 +606,11 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourceGroupPager(req *h return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -579,9 +626,10 @@ func (a *AssignmentsServerTransport) dispatchNewListForResourceGroupPager(req *h return nil, err } var options *armpolicy.AssignmentsClientListForResourceGroupOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.AssignmentsClientListForResourceGroupOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go b/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go deleted file mode 100644 index 982133638f68..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/datapolicymanifests_server.go +++ /dev/null @@ -1,146 +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. 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" -) - -// DataPolicyManifestsServer is a fake server for instances of the armpolicy.DataPolicyManifestsClient type. -type DataPolicyManifestsServer struct { - // GetByPolicyMode is the fake for method DataPolicyManifestsClient.GetByPolicyMode - // HTTP status codes to indicate success: http.StatusOK - GetByPolicyMode func(ctx context.Context, policyMode string, options *armpolicy.DataPolicyManifestsClientGetByPolicyModeOptions) (resp azfake.Responder[armpolicy.DataPolicyManifestsClientGetByPolicyModeResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method DataPolicyManifestsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.DataPolicyManifestsClientListOptions) (resp azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]) -} - -// NewDataPolicyManifestsServerTransport creates a new instance of DataPolicyManifestsServerTransport with the provided implementation. -// The returned DataPolicyManifestsServerTransport instance is connected to an instance of armpolicy.DataPolicyManifestsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewDataPolicyManifestsServerTransport(srv *DataPolicyManifestsServer) *DataPolicyManifestsServerTransport { - return &DataPolicyManifestsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]](), - } -} - -// DataPolicyManifestsServerTransport connects instances of armpolicy.DataPolicyManifestsClient to instances of DataPolicyManifestsServer. -// Don't use this type directly, use NewDataPolicyManifestsServerTransport instead. -type DataPolicyManifestsServerTransport struct { - srv *DataPolicyManifestsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.DataPolicyManifestsClientListResponse]] -} - -// Do implements the policy.Transporter interface for DataPolicyManifestsServerTransport. -func (d *DataPolicyManifestsServerTransport) 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 "DataPolicyManifestsClient.GetByPolicyMode": - resp, err = d.dispatchGetByPolicyMode(req) - case "DataPolicyManifestsClient.NewListPager": - resp, err = d.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (d *DataPolicyManifestsServerTransport) dispatchGetByPolicyMode(req *http.Request) (*http.Response, error) { - if d.srv.GetByPolicyMode == nil { - return nil, &nonRetriableError{errors.New("fake for method GetByPolicyMode not implemented")} - } - const regexStr = `/providers/Microsoft\.Authorization/dataPolicyManifests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - 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) - } - policyModeParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyMode")]) - if err != nil { - return nil, err - } - respr, errRespr := d.srv.GetByPolicyMode(req.Context(), policyModeParam, 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).DataPolicyManifest, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (d *DataPolicyManifestsServerTransport) 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 { - qp := req.URL.Query() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.DataPolicyManifestsClientListOptions - if filterParam != nil { - options = &armpolicy.DataPolicyManifestsClientListOptions{ - Filter: filterParam, - } - } - resp := d.srv.NewListPager(options) - newListPager = &resp - d.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.DataPolicyManifestsClientListResponse, 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 -} 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..9b8c01645f7a --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/definitionversions_server.go @@ -0,0 +1,651 @@ +//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, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName string, policyDefinitionVersion string, 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, policyDefinitionName string, policyDefinitionVersion 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, policyDefinitionName string, policyDefinitionVersion string, 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(policyDefinitionName string, 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(policyDefinitionName string, 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, policyDefinitionName 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 + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), policyDefinitionNameParam, policyDefinitionVersionParam, 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 + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupNameParam, policyDefinitionNameParam, policyDefinitionVersionParam, 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) + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Delete(req.Context(), policyDefinitionNameParam, policyDefinitionVersionParam, 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 + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.DeleteAtManagementGroup(req.Context(), managementGroupNameParam, policyDefinitionNameParam, policyDefinitionVersionParam, 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) + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), policyDefinitionNameParam, policyDefinitionVersionParam, 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 + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.GetAtManagementGroup(req.Context(), managementGroupNameParam, policyDefinitionNameParam, policyDefinitionVersionParam, 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) + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.GetBuiltIn(req.Context(), policyDefinitionNameParam, policyDefinitionVersionParam, 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() + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + 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.DefinitionVersionsClientListOptions + if topParam != nil { + options = &armpolicy.DefinitionVersionsClientListOptions{ + Top: topParam, + } + } + resp := d.srv.NewListPager(policyDefinitionNameParam, 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() + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + 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.DefinitionVersionsClientListBuiltInOptions + if topParam != nil { + options = &armpolicy.DefinitionVersionsClientListBuiltInOptions{ + Top: topParam, + } + } + resp := d.srv.NewListBuiltInPager(policyDefinitionNameParam, 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 + } + policyDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionName")]) + 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, policyDefinitionNameParam, 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/exemptions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go deleted file mode 100644 index 484ed861a636..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/exemptions_server.go +++ /dev/null @@ -1,468 +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. 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" -) - -// ExemptionsServer is a fake server for instances of the armpolicy.ExemptionsClient type. -type ExemptionsServer struct { - // CreateOrUpdate is the fake for method ExemptionsClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.Exemption, options *armpolicy.ExemptionsClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method ExemptionsClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientDeleteOptions) (resp azfake.Responder[armpolicy.ExemptionsClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method ExemptionsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, scope string, policyExemptionName string, options *armpolicy.ExemptionsClientGetOptions) (resp azfake.Responder[armpolicy.ExemptionsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method ExemptionsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.ExemptionsClientListOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]) - - // NewListForManagementGroupPager is the fake for method ExemptionsClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.ExemptionsClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]) - - // NewListForResourcePager is the fake for method ExemptionsClient.NewListForResourcePager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourcePager func(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, options *armpolicy.ExemptionsClientListForResourceOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]) - - // NewListForResourceGroupPager is the fake for method ExemptionsClient.NewListForResourceGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForResourceGroupPager func(resourceGroupName string, options *armpolicy.ExemptionsClientListForResourceGroupOptions) (resp azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]) - - // Update is the fake for method ExemptionsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, scope string, policyExemptionName string, parameters armpolicy.ExemptionUpdate, options *armpolicy.ExemptionsClientUpdateOptions) (resp azfake.Responder[armpolicy.ExemptionsClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewExemptionsServerTransport creates a new instance of ExemptionsServerTransport with the provided implementation. -// The returned ExemptionsServerTransport instance is connected to an instance of armpolicy.ExemptionsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewExemptionsServerTransport(srv *ExemptionsServer) *ExemptionsServerTransport { - return &ExemptionsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]](), - newListForResourcePager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]](), - newListForResourceGroupPager: newTracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]](), - } -} - -// ExemptionsServerTransport connects instances of armpolicy.ExemptionsClient to instances of ExemptionsServer. -// Don't use this type directly, use NewExemptionsServerTransport instead. -type ExemptionsServerTransport struct { - srv *ExemptionsServer - newListPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForManagementGroupResponse]] - newListForResourcePager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceResponse]] - newListForResourceGroupPager *tracker[azfake.PagerResponder[armpolicy.ExemptionsClientListForResourceGroupResponse]] -} - -// Do implements the policy.Transporter interface for ExemptionsServerTransport. -func (e *ExemptionsServerTransport) 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 "ExemptionsClient.CreateOrUpdate": - resp, err = e.dispatchCreateOrUpdate(req) - case "ExemptionsClient.Delete": - resp, err = e.dispatchDelete(req) - case "ExemptionsClient.Get": - resp, err = e.dispatchGet(req) - case "ExemptionsClient.NewListPager": - resp, err = e.dispatchNewListPager(req) - case "ExemptionsClient.NewListForManagementGroupPager": - resp, err = e.dispatchNewListForManagementGroupPager(req) - case "ExemptionsClient.NewListForResourcePager": - resp, err = e.dispatchNewListForResourcePager(req) - case "ExemptionsClient.NewListForResourceGroupPager": - resp, err = e.dispatchNewListForResourceGroupPager(req) - case "ExemptionsClient.Update": - resp, err = e.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if e.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Exemption](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.CreateOrUpdate(req.Context(), scopeParam, policyExemptionNameParam, 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).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if e.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?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) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Delete(req.Context(), scopeParam, policyExemptionNameParam, 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 (e *ExemptionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if e.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?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) - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Get(req.Context(), scopeParam, policyExemptionNameParam, 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).Exemption, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := e.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - 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() - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListPager(options) - newListPager = &resp - e.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.ExemptionsClientListResponse, 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) { - e.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - e.newListPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := e.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - 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() - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForManagementGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForManagementGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForManagementGroupPager(managementGroupIDParam, options) - newListForManagementGroupPager = &resp - e.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.ExemptionsClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - e.newListForManagementGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourcePager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourcePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourcePager not implemented")} - } - newListForResourcePager := e.newListForResourcePager.get(req) - if newListForResourcePager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 6 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - qp := req.URL.Query() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resourceProviderNamespaceParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceProviderNamespace")]) - if err != nil { - return nil, err - } - parentResourcePathParam, err := url.PathUnescape(matches[regex.SubexpIndex("parentResourcePath")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourcePager(resourceGroupNameParam, resourceProviderNamespaceParam, parentResourcePathParam, resourceTypeParam, resourceNameParam, options) - newListForResourcePager = &resp - e.newListForResourcePager.add(req, newListForResourcePager) - server.PagerResponderInjectNextLinks(newListForResourcePager, req, func(page *armpolicy.ExemptionsClientListForResourceResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourcePager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourcePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourcePager) { - e.newListForResourcePager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchNewListForResourceGroupPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListForResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForResourceGroupPager not implemented")} - } - newListForResourceGroupPager := e.newListForResourceGroupPager.get(req) - if newListForResourceGroupPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions` - 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() - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) - if err != nil { - return nil, err - } - filterParam := getOptional(filterUnescaped) - var options *armpolicy.ExemptionsClientListForResourceGroupOptions - if filterParam != nil { - options = &armpolicy.ExemptionsClientListForResourceGroupOptions{ - Filter: filterParam, - } - } - resp := e.srv.NewListForResourceGroupPager(resourceGroupNameParam, options) - newListForResourceGroupPager = &resp - e.newListForResourceGroupPager.add(req, newListForResourceGroupPager) - server.PagerResponderInjectNextLinks(newListForResourceGroupPager, req, func(page *armpolicy.ExemptionsClientListForResourceGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForResourceGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListForResourceGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForResourceGroupPager) { - e.newListForResourceGroupPager.remove(req) - } - return resp, nil -} - -func (e *ExemptionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if e.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/policyExemptions/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.ExemptionUpdate](req) - if err != nil { - return nil, err - } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) - if err != nil { - return nil, err - } - policyExemptionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyExemptionName")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Update(req.Context(), scopeParam, policyExemptionNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Exemption, req) - if err != nil { - return nil, err - } - 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..789470069ced 100644 --- a/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go +++ b/sdk/resourcemanager/resources/armpolicy/fake/server_factory.go @@ -19,13 +19,11 @@ 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 + DefinitionVersionsServer DefinitionVersionsServer + DefinitionsServer DefinitionsServer + SetDefinitionVersionsServer SetDefinitionVersionsServer + SetDefinitionsServer SetDefinitionsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,15 +38,13 @@ 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 + trDefinitionVersionsServer *DefinitionVersionsServerTransport + trDefinitionsServer *DefinitionsServerTransport + trSetDefinitionVersionsServer *SetDefinitionVersionsServerTransport + trSetDefinitionsServer *SetDefinitionsServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -67,30 +63,24 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "AssignmentsClient": initServer(s, &s.trAssignmentsServer, func() *AssignmentsServerTransport { return NewAssignmentsServerTransport(&s.srv.AssignmentsServer) }) resp, err = s.trAssignmentsServer.Do(req) - case "DataPolicyManifestsClient": - initServer(s, &s.trDataPolicyManifestsServer, func() *DataPolicyManifestsServerTransport { - return NewDataPolicyManifestsServerTransport(&s.srv.DataPolicyManifestsServer) + case "DefinitionVersionsClient": + initServer(s, &s.trDefinitionVersionsServer, func() *DefinitionVersionsServerTransport { + return NewDefinitionVersionsServerTransport(&s.srv.DefinitionVersionsServer) }) - resp, err = s.trDataPolicyManifestsServer.Do(req) + 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) }) resp, err = s.trSetDefinitionsServer.Do(req) - case "VariableValuesClient": - initServer(s, &s.trVariableValuesServer, func() *VariableValuesServerTransport { - return NewVariableValuesServerTransport(&s.srv.VariableValuesServer) - }) - resp, err = s.trVariableValuesServer.Do(req) - case "VariablesClient": - initServer(s, &s.trVariablesServer, func() *VariablesServerTransport { return NewVariablesServerTransport(&s.srv.VariablesServer) }) - resp, err = s.trVariablesServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitions_server.go index fc89147e3008..2cf67cf86756 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 } @@ -272,11 +272,23 @@ func (s *SetDefinitionsServerTransport) dispatchGet(req *http.Request) (*http.Re if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.Get(req.Context(), policySetDefinitionNameParam, nil) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionsClientGetOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionsClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.Get(req.Context(), policySetDefinitionNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -301,15 +313,27 @@ 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) } + qp := req.URL.Query() + managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + if err != nil { + return nil, err + } policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) if err != nil { return nil, err } - respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), policySetDefinitionNameParam, managementGroupIDParam, nil) + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionsClientGetAtManagementGroupOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionsClientGetAtManagementGroupOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, policySetDefinitionNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -334,11 +358,23 @@ func (s *SetDefinitionsServerTransport) dispatchGetBuiltIn(req *http.Request) (* if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + qp := req.URL.Query() policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) if err != nil { return nil, err } - respr, errRespr := s.srv.GetBuiltIn(req.Context(), policySetDefinitionNameParam, nil) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionsClientGetBuiltInOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionsClientGetBuiltInOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetBuiltIn(req.Context(), policySetDefinitionNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -371,6 +407,11 @@ func (s *SetDefinitionsServerTransport) dispatchNewListPager(req *http.Request) return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -386,9 +427,10 @@ func (s *SetDefinitionsServerTransport) dispatchNewListPager(req *http.Request) return nil, err } var options *armpolicy.SetDefinitionsClientListOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.SetDefinitionsClientListOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } @@ -425,6 +467,11 @@ func (s *SetDefinitionsServerTransport) dispatchNewListBuiltInPager(req *http.Re return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -440,9 +487,10 @@ func (s *SetDefinitionsServerTransport) dispatchNewListBuiltInPager(req *http.Re return nil, err } var options *armpolicy.SetDefinitionsClientListBuiltInOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.SetDefinitionsClientListBuiltInOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } @@ -489,6 +537,11 @@ func (s *SetDefinitionsServerTransport) dispatchNewListByManagementGroupPager(re return nil, err } filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) topUnescaped, err := url.QueryUnescape(qp.Get("$top")) if err != nil { return nil, err @@ -504,9 +557,10 @@ func (s *SetDefinitionsServerTransport) dispatchNewListByManagementGroupPager(re return nil, err } var options *armpolicy.SetDefinitionsClientListByManagementGroupOptions - if filterParam != nil || topParam != nil { + if filterParam != nil || expandParam != nil || topParam != nil { options = &armpolicy.SetDefinitionsClientListByManagementGroupOptions{ Filter: filterParam, + Expand: expandParam, Top: topParam, } } 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..938304995210 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/fake/setdefinitionversions_server.go @@ -0,0 +1,705 @@ +//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, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName string, policyDefinitionVersion string, 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(policySetDefinitionName string, 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(policySetDefinitionName string, 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, policySetDefinitionName 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 + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), policySetDefinitionNameParam, policyDefinitionVersionParam, 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 + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupNameParam, policySetDefinitionNameParam, policyDefinitionVersionParam, 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) + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), policySetDefinitionNameParam, policyDefinitionVersionParam, 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 + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.DeleteAtManagementGroup(req.Context(), managementGroupNameParam, policySetDefinitionNameParam, policyDefinitionVersionParam, 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) + } + qp := req.URL.Query() + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionVersionsClientGetOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionVersionsClientGetOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.Get(req.Context(), policySetDefinitionNameParam, policyDefinitionVersionParam, options) + 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) + } + qp := req.URL.Query() + managementGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupName")]) + if err != nil { + return nil, err + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionVersionsClientGetAtManagementGroupOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionVersionsClientGetAtManagementGroupOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetAtManagementGroup(req.Context(), managementGroupNameParam, policySetDefinitionNameParam, policyDefinitionVersionParam, options) + 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) + } + qp := req.URL.Query() + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + policyDefinitionVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("policyDefinitionVersion")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armpolicy.SetDefinitionVersionsClientGetBuiltInOptions + if expandParam != nil { + options = &armpolicy.SetDefinitionVersionsClientGetBuiltInOptions{ + Expand: expandParam, + } + } + respr, errRespr := s.srv.GetBuiltIn(req.Context(), policySetDefinitionNameParam, policyDefinitionVersionParam, options) + 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() + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + 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 expandParam != nil || topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListOptions{ + Expand: expandParam, + Top: topParam, + } + } + resp := s.srv.NewListPager(policySetDefinitionNameParam, 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() + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + 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 expandParam != nil || topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListBuiltInOptions{ + Expand: expandParam, + Top: topParam, + } + } + resp := s.srv.NewListBuiltInPager(policySetDefinitionNameParam, 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 + } + policySetDefinitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("policySetDefinitionName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + 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 expandParam != nil || topParam != nil { + options = &armpolicy.SetDefinitionVersionsClientListByManagementGroupOptions{ + Expand: expandParam, + Top: topParam, + } + } + resp := s.srv.NewListByManagementGroupPager(managementGroupNameParam, policySetDefinitionNameParam, 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/fake/variables_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go deleted file mode 100644 index 05fbf5ea665d..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variables_server.go +++ /dev/null @@ -1,380 +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. 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" -) - -// VariablesServer is a fake server for instances of the armpolicy.VariablesClient type. -type VariablesServer struct { - // CreateOrUpdate is the fake for method VariablesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariablesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, parameters armpolicy.Variable, options *armpolicy.VariablesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariablesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, options *armpolicy.VariablesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariablesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariablesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, options *armpolicy.VariablesClientGetOptions) (resp azfake.Responder[armpolicy.VariablesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariablesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, options *armpolicy.VariablesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariablesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariablesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armpolicy.VariablesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariablesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, options *armpolicy.VariablesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]) -} - -// NewVariablesServerTransport creates a new instance of VariablesServerTransport with the provided implementation. -// The returned VariablesServerTransport instance is connected to an instance of armpolicy.VariablesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariablesServerTransport(srv *VariablesServer) *VariablesServerTransport { - return &VariablesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]](), - } -} - -// VariablesServerTransport connects instances of armpolicy.VariablesClient to instances of VariablesServer. -// Don't use this type directly, use NewVariablesServerTransport instead. -type VariablesServerTransport struct { - srv *VariablesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariablesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariablesServerTransport. -func (v *VariablesServerTransport) 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 "VariablesClient.CreateOrUpdate": - resp, err = v.dispatchCreateOrUpdate(req) - case "VariablesClient.CreateOrUpdateAtManagementGroup": - resp, err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariablesClient.Delete": - resp, err = v.dispatchDelete(req) - case "VariablesClient.DeleteAtManagementGroup": - resp, err = v.dispatchDeleteAtManagementGroup(req) - case "VariablesClient.Get": - resp, err = v.dispatchGet(req) - case "VariablesClient.GetAtManagementGroup": - resp, err = v.dispatchGetAtManagementGroup(req) - case "VariablesClient.NewListPager": - resp, err = v.dispatchNewListPager(req) - case "VariablesClient.NewListForManagementGroupPager": - resp, err = v.dispatchNewListForManagementGroupPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, 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).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - body, err := server.UnmarshalRequestAsJSON[armpolicy.Variable](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, 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).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, 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 (v *VariablesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, 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 (v *VariablesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, 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).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, 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).Variable, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resp := v.srv.NewListPager(nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariablesClientListResponse, 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) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariablesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables` - 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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariablesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go b/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go deleted file mode 100644 index f63f4ae48ac8..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/fake/variablevalues_server.go +++ /dev/null @@ -1,412 +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. 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" -) - -// VariableValuesServer is a fake server for instances of the armpolicy.VariableValuesClient type. -type VariableValuesServer struct { - // CreateOrUpdate is the fake for method VariableValuesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // CreateOrUpdateAtManagementGroup is the fake for method VariableValuesClient.CreateOrUpdateAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters armpolicy.VariableValue, options *armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientCreateOrUpdateAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Delete is the fake for method VariableValuesClient.Delete - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteResponse], errResp azfake.ErrorResponder) - - // DeleteAtManagementGroup is the fake for method VariableValuesClient.DeleteAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientDeleteAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientDeleteAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method VariableValuesClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetResponse], errResp azfake.ErrorResponder) - - // GetAtManagementGroup is the fake for method VariableValuesClient.GetAtManagementGroup - // HTTP status codes to indicate success: http.StatusOK - GetAtManagementGroup func(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *armpolicy.VariableValuesClientGetAtManagementGroupOptions) (resp azfake.Responder[armpolicy.VariableValuesClientGetAtManagementGroupResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method VariableValuesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(variableName string, options *armpolicy.VariableValuesClientListOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]) - - // NewListForManagementGroupPager is the fake for method VariableValuesClient.NewListForManagementGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListForManagementGroupPager func(managementGroupID string, variableName string, options *armpolicy.VariableValuesClientListForManagementGroupOptions) (resp azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]) -} - -// NewVariableValuesServerTransport creates a new instance of VariableValuesServerTransport with the provided implementation. -// The returned VariableValuesServerTransport instance is connected to an instance of armpolicy.VariableValuesClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewVariableValuesServerTransport(srv *VariableValuesServer) *VariableValuesServerTransport { - return &VariableValuesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]](), - newListForManagementGroupPager: newTracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]](), - } -} - -// VariableValuesServerTransport connects instances of armpolicy.VariableValuesClient to instances of VariableValuesServer. -// Don't use this type directly, use NewVariableValuesServerTransport instead. -type VariableValuesServerTransport struct { - srv *VariableValuesServer - newListPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListResponse]] - newListForManagementGroupPager *tracker[azfake.PagerResponder[armpolicy.VariableValuesClientListForManagementGroupResponse]] -} - -// Do implements the policy.Transporter interface for VariableValuesServerTransport. -func (v *VariableValuesServerTransport) 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 "VariableValuesClient.CreateOrUpdate": - resp, err = v.dispatchCreateOrUpdate(req) - case "VariableValuesClient.CreateOrUpdateAtManagementGroup": - resp, err = v.dispatchCreateOrUpdateAtManagementGroup(req) - case "VariableValuesClient.Delete": - resp, err = v.dispatchDelete(req) - case "VariableValuesClient.DeleteAtManagementGroup": - resp, err = v.dispatchDeleteAtManagementGroup(req) - case "VariableValuesClient.Get": - resp, err = v.dispatchGet(req) - case "VariableValuesClient.GetAtManagementGroup": - resp, err = v.dispatchGetAtManagementGroup(req) - case "VariableValuesClient.NewListPager": - resp, err = v.dispatchNewListPager(req) - case "VariableValuesClient.NewListForManagementGroupPager": - resp, err = v.dispatchNewListForManagementGroupPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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.VariableValue](req) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdate(req.Context(), variableNameParam, variableValueNameParam, 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).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchCreateOrUpdateAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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.VariableValue](req) - if err != nil { - return nil, err - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.CreateOrUpdateAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, 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).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Delete(req.Context(), variableNameParam, variableValueNameParam, 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 (v *VariableValuesServerTransport) dispatchDeleteAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.DeleteAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, 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 (v *VariableValuesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.Get(req.Context(), variableNameParam, variableValueNameParam, 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).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchGetAtManagementGroup(req *http.Request) (*http.Response, error) { - if v.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/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values/(?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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - variableValueNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableValueName")]) - if err != nil { - return nil, err - } - respr, errRespr := v.srv.GetAtManagementGroup(req.Context(), managementGroupIDParam, variableNameParam, variableValueNameParam, 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).VariableValue, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := v.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - 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) - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListPager(variableNameParam, nil) - newListPager = &resp - v.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armpolicy.VariableValuesClientListResponse, 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) { - v.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - v.newListPager.remove(req) - } - return resp, nil -} - -func (v *VariableValuesServerTransport) dispatchNewListForManagementGroupPager(req *http.Request) (*http.Response, error) { - if v.srv.NewListForManagementGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListForManagementGroupPager not implemented")} - } - newListForManagementGroupPager := v.newListForManagementGroupPager.get(req) - if newListForManagementGroupPager == nil { - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Authorization/variables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/values` - 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) - } - managementGroupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("managementGroupId")]) - if err != nil { - return nil, err - } - variableNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("variableName")]) - if err != nil { - return nil, err - } - resp := v.srv.NewListForManagementGroupPager(managementGroupIDParam, variableNameParam, nil) - newListForManagementGroupPager = &resp - v.newListForManagementGroupPager.add(req, newListForManagementGroupPager) - server.PagerResponderInjectNextLinks(newListForManagementGroupPager, req, func(page *armpolicy.VariableValuesClientListForManagementGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListForManagementGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - v.newListForManagementGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListForManagementGroupPager) { - v.newListForManagementGroupPager.remove(req) - } - return resp, nil -} diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 67815ec03e30..dcde1d2ab52d 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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..92961ec8eb56 100644 --- a/sdk/resourcemanager/resources/armpolicy/models.go +++ b/sdk/resourcemanager/resources/armpolicy/models.go @@ -10,62 +10,6 @@ package armpolicy import "time" -// Alias - The alias type. -type Alias struct { - // The default path for an alias. - DefaultPath *string - - // The default pattern for an alias. - DefaultPattern *AliasPattern - - // The alias name. - Name *string - - // The paths for an alias. - Paths []*AliasPath - - // The type of the alias. - Type *AliasType - - // READ-ONLY; The default alias path metadata. Applies to the default path and to any alias path that doesn't have metadata - DefaultMetadata *AliasPathMetadata -} - -// AliasPath - The type of the paths for alias. -type AliasPath struct { - // The API versions. - APIVersions []*string - - // The path of an alias. - Path *string - - // The pattern for an alias path. - Pattern *AliasPattern - - // READ-ONLY; The metadata of the alias path. If missing, fall back to the default metadata of the alias. - Metadata *AliasPathMetadata -} - -type AliasPathMetadata struct { - // READ-ONLY; The attributes of the token that the alias path is referring to. - Attributes *AliasPathAttributes - - // READ-ONLY; The type of the token that the alias path is referring to. - Type *AliasPathTokenType -} - -// AliasPattern - The type of the pattern for an alias path. -type AliasPattern struct { - // The alias pattern phrase. - Phrase *string - - // The type of alias pattern - Type *AliasPatternType - - // The alias pattern variable. - Variable *string -} - // Assignment - The policy assignment. type Assignment struct { // The managed identity associated with the policy assignment. @@ -101,6 +45,12 @@ type AssignmentListResult struct { // AssignmentProperties - The policy assignment properties. type AssignmentProperties struct { + // The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. + AssignmentType *AssignmentType + + // The version of the policy definition to use. + DefinitionVersion *string + // This message will be part of response in case of policy violation. Description *string @@ -131,6 +81,14 @@ type AssignmentProperties struct { // The resource selector list to filter policies by resource properties. ResourceSelectors []*ResourceSelector + // READ-ONLY; The effective version of the policy definition in use. This is only present if requested via the $expand query + // parameter. + EffectiveDefinitionVersion *string + + // READ-ONLY; The latest version of the policy definition available. This is only present if requested via the $expand query + // parameter. + LatestDefinitionVersion *string + // READ-ONLY; The scope for the policy assignment. Scope *string } @@ -156,89 +114,6 @@ type AssignmentUpdateProperties struct { ResourceSelectors []*ResourceSelector } -// DataEffect - The data effect definition. -type DataEffect struct { - // The data effect details schema. - DetailsSchema any - - // The data effect name. - Name *string -} - -// DataManifestCustomResourceFunctionDefinition - The custom resource function definition. -type DataManifestCustomResourceFunctionDefinition struct { - // A value indicating whether the custom properties within the property bag are allowed. Needs api-version to be specified - // in the policy rule eg - vault('2019-06-01'). - AllowCustomProperties *bool - - // The top-level properties that can be selected on the function's output. eg - [ "name", "location" ] if vault().name and - // vault().location are supported - DefaultProperties []*string - - // The fully qualified control plane resource type that this function represents. eg - 'Microsoft.KeyVault/vaults'. - FullyQualifiedResourceType *string - - // The function name as it will appear in the policy rule. eg - 'vault'. - Name *string -} - -// DataManifestResourceFunctionsDefinition - The resource functions supported by a manifest -type DataManifestResourceFunctionsDefinition struct { - // An array of data manifest custom resource definition. - Custom []*DataManifestCustomResourceFunctionDefinition - - // The standard resource functions (subscription and/or resourceGroup). - Standard []*string -} - -// DataPolicyManifest - The data policy manifest. -type DataPolicyManifest struct { - // The data policy manifest properties. - Properties *DataPolicyManifestProperties - - // READ-ONLY; The ID of the data policy manifest. - ID *string - - // READ-ONLY; The name of the data policy manifest (it's the same as the Policy Mode). - Name *string - - // READ-ONLY; The type of the resource (Microsoft.Authorization/dataPolicyManifests). - Type *string -} - -// DataPolicyManifestListResult - List of data policy manifests. -type DataPolicyManifestListResult struct { - // The URL to use for getting the next set of results. - NextLink *string - - // An array of data policy manifests. - Value []*DataPolicyManifest -} - -// DataPolicyManifestProperties - The properties of the data policy manifest. -type DataPolicyManifestProperties struct { - // The effect definition. - Effects []*DataEffect - - // The non-alias field accessor values that can be used in the policy rule. - FieldValues []*string - - // A value indicating whether policy mode is allowed only in built-in definitions. - IsBuiltInOnly *bool - - // The list of namespaces for the data policy manifest. - Namespaces []*string - - // The policy mode of the data policy manifest. - PolicyMode *string - - // The resource functions definition specified in the data manifest. - ResourceFunctions *DataManifestResourceFunctionsDefinition - - // An array of resource type aliases. - ResourceTypeAliases []*ResourceTypeAliases -} - // Definition - The policy definition. type Definition struct { // The policy definition properties. @@ -306,6 +181,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. @@ -313,6 +194,9 @@ type DefinitionReference struct { // REQUIRED; The ID of the policy definition or policy set definition. PolicyDefinitionID *string + // The version of the policy definition to use. + DefinitionVersion *string + // The name of the groups that this policy definition reference belongs to. GroupNames []*string @@ -321,78 +205,68 @@ type DefinitionReference struct { // A unique id (within the policy set definition) for this policy definition reference. PolicyDefinitionReferenceID *string + + // READ-ONLY; The effective version of the policy definition in use. This is only present if requested via the $expand query + // parameter. + EffectiveDefinitionVersion *string + + // READ-ONLY; The latest version of the policy definition available. This is only present if requested via the $expand query + // parameter. + LatestDefinitionVersion *string } -// Exemption - The policy exemption. -type Exemption struct { - // REQUIRED; Properties for the policy exemption. - Properties *ExemptionProperties +// 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 exemption. + // READ-ONLY; The ID of the policy definition version. ID *string - // READ-ONLY; The name of the policy exemption. + // READ-ONLY; The name of the policy definition version. Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + // READ-ONLY; The system metadata relating to this resource. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/policyExemptions). + // READ-ONLY; The type of the resource (Microsoft.Authorization/policyDefinitions/versions). Type *string } -// ExemptionListResult - List of policy exemptions. -type ExemptionListResult struct { - // An array of policy exemptions. - Value []*Exemption - - // READ-ONLY; The URL to use for getting the next set of results. +// DefinitionVersionListResult - List of policy definition versions. +type DefinitionVersionListResult struct { + // The URL to use for getting the next set of results. NextLink *string -} -// ExemptionProperties - The policy exemption properties. -type ExemptionProperties struct { - // REQUIRED; The policy exemption category. Possible values are Waiver and Mitigated. - ExemptionCategory *ExemptionCategory - - // REQUIRED; The ID of the policy assignment that is being exempted. - PolicyAssignmentID *string - - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation + // An array of policy definitions versions. + Value []*DefinitionVersion +} - // The description of the policy exemption. +// DefinitionVersionProperties - The policy definition properties. +type DefinitionVersionProperties struct { + // The policy definition description. Description *string - // The display name of the policy exemption. + // The display name of the policy definition. DisplayName *string - // The expiration date and time (in UTC ISO 8601 format yyyy-MM-ddTHH:mm:ssZ) of the policy exemption. - ExpiresOn *time.Time - - // The policy exemption metadata. Metadata is an open ended object and is typically a collection of key value pairs. + // The policy definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. Metadata any - // The policy definition reference ID list when the associated policy assignment is an assignment of a policy set definition. - PolicyDefinitionReferenceIDs []*string + // The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. + Mode *string - // The resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector -} + // The parameter definitions for parameters used in the policy rule. The keys are the parameter names. + Parameters map[string]*ParameterDefinitionsValue -// ExemptionUpdate - The policy exemption for Patch request. -type ExemptionUpdate struct { - // The policy exemption properties for Patch request. - Properties *ExemptionUpdateProperties -} + // The policy rule. + PolicyRule any -// ExemptionUpdateProperties - The policy exemption properties for Patch request. -type ExemptionUpdateProperties struct { - // The option whether validate the exemption is at or under the assignment scope. - AssignmentScopeValidation *AssignmentScopeValidation + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType - // The resource selector list to filter policies by resource properties. - ResourceSelectors []*ResourceSelector + // The policy definition version in #.#.# format. + Version *string } // Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity @@ -449,6 +323,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 } @@ -489,15 +368,6 @@ type ResourceSelector struct { Selectors []*Selector } -// ResourceTypeAliases - The resource type aliases definition. -type ResourceTypeAliases struct { - // The aliases for property names. - Aliases []*Alias - - // The resource type name. - ResourceType *string -} - // Selector - The selector expression. type Selector struct { // The list of values to filter in. @@ -512,7 +382,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,116 +427,95 @@ type SetDefinitionProperties struct { // 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. + // The type of policy set definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. PolicyType *PolicyType -} - -// SystemData - Metadata pertaining to creation and last modification of the resource. -type SystemData struct { - // The timestamp of resource creation (UTC). - CreatedAt *time.Time - // The identity that created the resource. - CreatedBy *string + // The policy set definition version in #.#.# format. + Version *string - // The type of identity that created the resource. - CreatedByType *CreatedByType - - // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time - - // The identity that last modified the resource. - LastModifiedBy *string - - // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType + // A list of available versions for this policy set definition. + Versions []*string } -type UserAssignedIdentitiesValue struct { - // READ-ONLY; The client id of user assigned identity. - ClientID *string +// SetDefinitionVersion - The policy set definition version. +type SetDefinitionVersion struct { + // The policy set definition version properties. + Properties *SetDefinitionVersionProperties - // READ-ONLY; The principal id of user assigned identity. - PrincipalID *string -} - -// Variable - The variable. -type Variable struct { - // REQUIRED; Properties for the variable. - Properties *VariableProperties - - // READ-ONLY; The ID of the variable. + // READ-ONLY; The ID of the policy set definition version. ID *string - // READ-ONLY; The name of the variable. + // READ-ONLY; The name of the policy set definition version. Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + // READ-ONLY; The system metadata relating to this resource. SystemData *SystemData - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables). + // READ-ONLY; The type of the resource (Microsoft.Authorization/policySetDefinitions/versions). Type *string } -// VariableColumn - The variable column. -type VariableColumn struct { - // REQUIRED; The name of this policy variable column. - ColumnName *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 } -// VariableListResult - List of variables. -type VariableListResult struct { - // An array of variables. - Value []*Variable +// SetDefinitionVersionProperties - The policy set definition properties. +type SetDefinitionVersionProperties struct { + // REQUIRED; An array of policy definition references. + PolicyDefinitions []*DefinitionReference - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string -} + // The policy set definition description. + Description *string -// VariableProperties - The variable properties. -type VariableProperties struct { - // REQUIRED; Variable column definitions. - Columns []*VariableColumn -} + // The display name of the policy set definition. + DisplayName *string -// VariableValue - The variable value. -type VariableValue struct { - // REQUIRED; Properties for the variable value. - Properties *VariableValueProperties + // The policy set definition metadata. Metadata is an open ended object and is typically a collection of key value pairs. + Metadata any - // READ-ONLY; The ID of the variable. - ID *string + // The policy set definition parameters that can be used in policy definition references. + Parameters map[string]*ParameterDefinitionsValue - // READ-ONLY; The name of the variable. - Name *string + // The metadata describing groups of policy definition references within the policy set definition. + PolicyDefinitionGroups []*DefinitionGroup - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData + // The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. + PolicyType *PolicyType - // READ-ONLY; The type of the resource (Microsoft.Authorization/variables/values). - Type *string + // The policy set definition version in #.#.# format. + Version *string } -// VariableValueColumnValue - The name value tuple for this variable value column. -type VariableValueColumnValue struct { - // REQUIRED; Column name for the variable value - ColumnName *string +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string - // REQUIRED; Column value for the variable value; this can be an integer, double, boolean, null or a string. - ColumnValue any -} + // The type of identity that created the resource. + CreatedByType *CreatedByType -// VariableValueListResult - List of variable values. -type VariableValueListResult struct { - // An array of variable values. - Value []*VariableValue + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time - // READ-ONLY; The URL to use for getting the next set of results. - NextLink *string + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType } -// VariableValueProperties - The variable value properties. -type VariableValueProperties struct { - // REQUIRED; Variable value column value array. - Values []*VariableValueColumnValue +type UserAssignedIdentitiesValue struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string } diff --git a/sdk/resourcemanager/resources/armpolicy/models_serde.go b/sdk/resourcemanager/resources/armpolicy/models_serde.go index 74cb09e1e08b..37591f7c4226 100644 --- a/sdk/resourcemanager/resources/armpolicy/models_serde.go +++ b/sdk/resourcemanager/resources/armpolicy/models_serde.go @@ -15,158 +15,6 @@ import ( "reflect" ) -// MarshalJSON implements the json.Marshaller interface for type Alias. -func (a Alias) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "defaultMetadata", a.DefaultMetadata) - populate(objectMap, "defaultPath", a.DefaultPath) - populate(objectMap, "defaultPattern", a.DefaultPattern) - populate(objectMap, "name", a.Name) - populate(objectMap, "paths", a.Paths) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Alias. -func (a *Alias) 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", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "defaultMetadata": - err = unpopulate(val, "DefaultMetadata", &a.DefaultMetadata) - delete(rawMsg, key) - case "defaultPath": - err = unpopulate(val, "DefaultPath", &a.DefaultPath) - delete(rawMsg, key) - case "defaultPattern": - err = unpopulate(val, "DefaultPattern", &a.DefaultPattern) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "paths": - err = unpopulate(val, "Paths", &a.Paths) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPath. -func (a AliasPath) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "apiVersions", a.APIVersions) - populate(objectMap, "metadata", a.Metadata) - populate(objectMap, "path", a.Path) - populate(objectMap, "pattern", a.Pattern) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPath. -func (a *AliasPath) 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", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "apiVersions": - err = unpopulate(val, "APIVersions", &a.APIVersions) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &a.Metadata) - delete(rawMsg, key) - case "path": - err = unpopulate(val, "Path", &a.Path) - delete(rawMsg, key) - case "pattern": - err = unpopulate(val, "Pattern", &a.Pattern) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPathMetadata. -func (a AliasPathMetadata) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "attributes", a.Attributes) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPathMetadata. -func (a *AliasPathMetadata) 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", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "attributes": - err = unpopulate(val, "Attributes", &a.Attributes) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AliasPattern. -func (a AliasPattern) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "phrase", a.Phrase) - populate(objectMap, "type", a.Type) - populate(objectMap, "variable", a.Variable) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AliasPattern. -func (a *AliasPattern) 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", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "phrase": - err = unpopulate(val, "Phrase", &a.Phrase) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - case "variable": - err = unpopulate(val, "Variable", &a.Variable) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Assignment. func (a Assignment) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -252,9 +100,13 @@ func (a *AssignmentListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. func (a AssignmentProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "assignmentType", a.AssignmentType) + populate(objectMap, "definitionVersion", a.DefinitionVersion) populate(objectMap, "description", a.Description) populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "effectiveDefinitionVersion", a.EffectiveDefinitionVersion) populate(objectMap, "enforcementMode", a.EnforcementMode) + populate(objectMap, "latestDefinitionVersion", a.LatestDefinitionVersion) populateAny(objectMap, "metadata", a.Metadata) populate(objectMap, "nonComplianceMessages", a.NonComplianceMessages) populate(objectMap, "notScopes", a.NotScopes) @@ -275,15 +127,27 @@ func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "assignmentType": + err = unpopulate(val, "AssignmentType", &a.AssignmentType) + delete(rawMsg, key) + case "definitionVersion": + err = unpopulate(val, "DefinitionVersion", &a.DefinitionVersion) + delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &a.Description) delete(rawMsg, key) case "displayName": err = unpopulate(val, "DisplayName", &a.DisplayName) delete(rawMsg, key) + case "effectiveDefinitionVersion": + err = unpopulate(val, "EffectiveDefinitionVersion", &a.EffectiveDefinitionVersion) + delete(rawMsg, key) case "enforcementMode": err = unpopulate(val, "EnforcementMode", &a.EnforcementMode) delete(rawMsg, key) + case "latestDefinitionVersion": + err = unpopulate(val, "LatestDefinitionVersion", &a.LatestDefinitionVersion) + delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &a.Metadata) delete(rawMsg, key) @@ -382,228 +246,6 @@ func (a *AssignmentUpdateProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DataEffect. -func (d DataEffect) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateAny(objectMap, "detailsSchema", d.DetailsSchema) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataEffect. -func (d *DataEffect) 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 "detailsSchema": - err = unpopulate(val, "DetailsSchema", &d.DetailsSchema) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - 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 DataManifestCustomResourceFunctionDefinition. -func (d DataManifestCustomResourceFunctionDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "allowCustomProperties", d.AllowCustomProperties) - populate(objectMap, "defaultProperties", d.DefaultProperties) - populate(objectMap, "fullyQualifiedResourceType", d.FullyQualifiedResourceType) - populate(objectMap, "name", d.Name) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestCustomResourceFunctionDefinition. -func (d *DataManifestCustomResourceFunctionDefinition) 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 "allowCustomProperties": - err = unpopulate(val, "AllowCustomProperties", &d.AllowCustomProperties) - delete(rawMsg, key) - case "defaultProperties": - err = unpopulate(val, "DefaultProperties", &d.DefaultProperties) - delete(rawMsg, key) - case "fullyQualifiedResourceType": - err = unpopulate(val, "FullyQualifiedResourceType", &d.FullyQualifiedResourceType) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &d.Name) - 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 DataManifestResourceFunctionsDefinition. -func (d DataManifestResourceFunctionsDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "custom", d.Custom) - populate(objectMap, "standard", d.Standard) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataManifestResourceFunctionsDefinition. -func (d *DataManifestResourceFunctionsDefinition) 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 "custom": - err = unpopulate(val, "Custom", &d.Custom) - delete(rawMsg, key) - case "standard": - err = unpopulate(val, "Standard", &d.Standard) - 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 DataPolicyManifest. -func (d DataPolicyManifest) 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, "type", d.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifest. -func (d *DataPolicyManifest) 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 "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 DataPolicyManifestListResult. -func (d DataPolicyManifestListResult) 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 DataPolicyManifestListResult. -func (d *DataPolicyManifestListResult) 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 DataPolicyManifestProperties. -func (d DataPolicyManifestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "effects", d.Effects) - populate(objectMap, "fieldValues", d.FieldValues) - populate(objectMap, "isBuiltInOnly", d.IsBuiltInOnly) - populate(objectMap, "namespaces", d.Namespaces) - populate(objectMap, "policyMode", d.PolicyMode) - populate(objectMap, "resourceFunctions", d.ResourceFunctions) - populate(objectMap, "resourceTypeAliases", d.ResourceTypeAliases) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DataPolicyManifestProperties. -func (d *DataPolicyManifestProperties) 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 "effects": - err = unpopulate(val, "Effects", &d.Effects) - delete(rawMsg, key) - case "fieldValues": - err = unpopulate(val, "FieldValues", &d.FieldValues) - delete(rawMsg, key) - case "isBuiltInOnly": - err = unpopulate(val, "IsBuiltInOnly", &d.IsBuiltInOnly) - delete(rawMsg, key) - case "namespaces": - err = unpopulate(val, "Namespaces", &d.Namespaces) - delete(rawMsg, key) - case "policyMode": - err = unpopulate(val, "PolicyMode", &d.PolicyMode) - delete(rawMsg, key) - case "resourceFunctions": - err = unpopulate(val, "ResourceFunctions", &d.ResourceFunctions) - delete(rawMsg, key) - case "resourceTypeAliases": - err = unpopulate(val, "ResourceTypeAliases", &d.ResourceTypeAliases) - 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 Definition. func (d Definition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -731,6 +373,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 +408,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) @@ -775,7 +425,10 @@ func (d *DefinitionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DefinitionReference. func (d DefinitionReference) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "definitionVersion", d.DefinitionVersion) + populate(objectMap, "effectiveDefinitionVersion", d.EffectiveDefinitionVersion) populate(objectMap, "groupNames", d.GroupNames) + populate(objectMap, "latestDefinitionVersion", d.LatestDefinitionVersion) populate(objectMap, "parameters", d.Parameters) populate(objectMap, "policyDefinitionId", d.PolicyDefinitionID) populate(objectMap, "policyDefinitionReferenceId", d.PolicyDefinitionReferenceID) @@ -791,9 +444,18 @@ func (d *DefinitionReference) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "definitionVersion": + err = unpopulate(val, "DefinitionVersion", &d.DefinitionVersion) + delete(rawMsg, key) + case "effectiveDefinitionVersion": + err = unpopulate(val, "EffectiveDefinitionVersion", &d.EffectiveDefinitionVersion) + delete(rawMsg, key) case "groupNames": err = unpopulate(val, "GroupNames", &d.GroupNames) delete(rawMsg, key) + case "latestDefinitionVersion": + err = unpopulate(val, "LatestDefinitionVersion", &d.LatestDefinitionVersion) + delete(rawMsg, key) case "parameters": err = unpopulate(val, "Parameters", &d.Parameters) delete(rawMsg, key) @@ -811,192 +473,130 @@ func (d *DefinitionReference) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Exemption. -func (e Exemption) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersion. +func (d DefinitionVersion) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "type", e.Type) + 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 Exemption. -func (e *Exemption) UnmarshalJSON(data []byte) error { +// 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", e, err) + 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", &e.ID) + err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &e.Name) + err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &e.Properties) + err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) case "systemData": - err = unpopulate(val, "SystemData", &e.SystemData) + err = unpopulate(val, "SystemData", &d.SystemData) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &e.Type) + err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionListResult. -func (e ExemptionListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersionListResult. +func (d DefinitionVersionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionListResult. -func (e *ExemptionListResult) UnmarshalJSON(data []byte) error { +// 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", e, err) + 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", &e.NextLink) + err = unpopulate(val, "NextLink", &d.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &e.Value) + err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ExemptionProperties. -func (e ExemptionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DefinitionVersionProperties. +func (d DefinitionVersionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "description", e.Description) - populate(objectMap, "displayName", e.DisplayName) - populate(objectMap, "exemptionCategory", e.ExemptionCategory) - populateDateTimeRFC3339(objectMap, "expiresOn", e.ExpiresOn) - populateAny(objectMap, "metadata", e.Metadata) - populate(objectMap, "policyAssignmentId", e.PolicyAssignmentID) - populate(objectMap, "policyDefinitionReferenceIds", e.PolicyDefinitionReferenceIDs) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) + 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 ExemptionProperties. -func (e *ExemptionProperties) UnmarshalJSON(data []byte) error { +// 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) - delete(rawMsg, key) case "description": - err = unpopulate(val, "Description", &e.Description) + err = unpopulate(val, "Description", &d.Description) delete(rawMsg, key) case "displayName": - err = unpopulate(val, "DisplayName", &e.DisplayName) - delete(rawMsg, key) - case "exemptionCategory": - err = unpopulate(val, "ExemptionCategory", &e.ExemptionCategory) - delete(rawMsg, key) - case "expiresOn": - err = unpopulateDateTimeRFC3339(val, "ExpiresOn", &e.ExpiresOn) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, "Metadata", &e.Metadata) - delete(rawMsg, key) - case "policyAssignmentId": - err = unpopulate(val, "PolicyAssignmentID", &e.PolicyAssignmentID) - delete(rawMsg, key) - case "policyDefinitionReferenceIds": - err = unpopulate(val, "PolicyDefinitionReferenceIDs", &e.PolicyDefinitionReferenceIDs) - delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExemptionUpdate. -func (e ExemptionUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "properties", e.Properties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdate. -func (e *ExemptionUpdate) 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", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExemptionUpdateProperties. -func (e ExemptionUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "assignmentScopeValidation", e.AssignmentScopeValidation) - populate(objectMap, "resourceSelectors", e.ResourceSelectors) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExemptionUpdateProperties. -func (e *ExemptionUpdateProperties) 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", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assignmentScopeValidation": - err = unpopulate(val, "AssignmentScopeValidation", &e.AssignmentScopeValidation) + err = unpopulate(val, "DisplayName", &d.DisplayName) delete(rawMsg, key) - case "resourceSelectors": - err = unpopulate(val, "ResourceSelectors", &e.ResourceSelectors) + 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", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil @@ -1113,6 +713,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 +736,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) @@ -1258,37 +862,6 @@ func (r *ResourceSelector) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ResourceTypeAliases. -func (r ResourceTypeAliases) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "aliases", r.Aliases) - populate(objectMap, "resourceType", r.ResourceType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceTypeAliases. -func (r *ResourceTypeAliases) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "aliases": - err = unpopulate(val, "Aliases", &r.Aliases) - delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &r.ResourceType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type Selector. func (s Selector) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1408,6 +981,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,52 +1016,11 @@ func (s *SetDefinitionProperties) UnmarshalJSON(data []byte) error { case "policyType": err = unpopulate(val, "PolicyType", &s.PolicyType) 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 SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) 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 "createdAt": - err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + case "version": + err = unpopulate(val, "Version", &s.Version) delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + case "versions": + err = unpopulate(val, "Versions", &s.Versions) delete(rawMsg, key) } if err != nil { @@ -1496,292 +1030,208 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. -func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "clientId", u.ClientID) - populate(objectMap, "principalId", u.PrincipalID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. -func (u *UserAssignedIdentitiesValue) 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", u, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "clientId": - err = unpopulate(val, "ClientID", &u.ClientID) - delete(rawMsg, key) - case "principalId": - err = unpopulate(val, "PrincipalID", &u.PrincipalID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", u, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Variable. -func (v Variable) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersion. +func (s SetDefinitionVersion) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) + 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 Variable. -func (v *Variable) UnmarshalJSON(data []byte) error { +// 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", v, err) + 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", &v.ID) + err = unpopulate(val, "ID", &s.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &v.Name) + err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &v.Properties) + err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) + err = unpopulate(val, "SystemData", &s.SystemData) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &v.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableColumn. -func (v VariableColumn) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableColumn. -func (v *VariableColumn) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableListResult. -func (v VariableListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionListResult. +func (s SetDefinitionVersionListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableListResult. -func (v *VariableListResult) UnmarshalJSON(data []byte) error { +// 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", v, err) + 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", &v.NextLink) + err = unpopulate(val, "NextLink", &s.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &v.Value) + err = unpopulate(val, "Value", &s.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableProperties. -func (v VariableProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SetDefinitionVersionProperties. +func (s SetDefinitionVersionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "columns", v.Columns) + 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 VariableProperties. -func (v *VariableProperties) UnmarshalJSON(data []byte) error { +// 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", v, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { - case "columns": - err = unpopulate(val, "Columns", &v.Columns) + case "description": + err = unpopulate(val, "Description", &s.Description) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValue. -func (v VariableValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", v.ID) - populate(objectMap, "name", v.Name) - populate(objectMap, "properties", v.Properties) - populate(objectMap, "systemData", v.SystemData) - populate(objectMap, "type", v.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValue. -func (v *VariableValue) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &v.ID) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &v.Name) + case "metadata": + err = unpopulate(val, "Metadata", &s.Metadata) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &v.Properties) + case "parameters": + err = unpopulate(val, "Parameters", &s.Parameters) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &v.SystemData) + case "policyDefinitionGroups": + err = unpopulate(val, "PolicyDefinitionGroups", &s.PolicyDefinitionGroups) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &v.Type) + case "policyDefinitions": + err = unpopulate(val, "PolicyDefinitions", &s.PolicyDefinitions) delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VariableValueColumnValue. -func (v VariableValueColumnValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "columnName", v.ColumnName) - populateAny(objectMap, "columnValue", v.ColumnValue) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueColumnValue. -func (v *VariableValueColumnValue) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "columnName": - err = unpopulate(val, "ColumnName", &v.ColumnName) + case "policyType": + err = unpopulate(val, "PolicyType", &s.PolicyType) delete(rawMsg, key) - case "columnValue": - err = unpopulate(val, "ColumnValue", &v.ColumnValue) + case "version": + err = unpopulate(val, "Version", &s.Version) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableValueListResult. -func (v VariableValueListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", v.NextLink) - populate(objectMap, "value", v.Value) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueListResult. -func (v *VariableValueListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) 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", v, err) + 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", &v.NextLink) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &v.Value) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type VariableValueProperties. -func (v VariableValueProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. +func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "values", v.Values) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type VariableValueProperties. -func (v *VariableValueProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentitiesValue. +func (u *UserAssignedIdentitiesValue) 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", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { - case "values": - err = unpopulate(val, "Values", &v.Values) + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) + return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil @@ -1808,7 +1258,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..1caf1bbee564 100644 --- a/sdk/resourcemanager/resources/armpolicy/options.go +++ b/sdk/resourcemanager/resources/armpolicy/options.go @@ -30,17 +30,25 @@ type AssignmentsClientDeleteOptions struct { // AssignmentsClientGetByIDOptions contains the optional parameters for the AssignmentsClient.GetByID method. type AssignmentsClientGetByIDOptions struct { - // placeholder for future optional parameters + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } // AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. type AssignmentsClientGetOptions struct { - // placeholder for future optional parameters + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } // AssignmentsClientListForManagementGroupOptions contains the optional parameters for the AssignmentsClient.NewListForManagementGroupPager // method. type AssignmentsClientListForManagementGroupOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is @@ -57,6 +65,10 @@ type AssignmentsClientListForManagementGroupOptions struct { // AssignmentsClientListForResourceGroupOptions contains the optional parameters for the AssignmentsClient.NewListForResourceGroupPager // method. type AssignmentsClientListForResourceGroupOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is @@ -73,6 +85,10 @@ type AssignmentsClientListForResourceGroupOptions struct { // AssignmentsClientListForResourceOptions contains the optional parameters for the AssignmentsClient.NewListForResourcePager // method. type AssignmentsClientListForResourceOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is @@ -88,6 +104,10 @@ type AssignmentsClientListForResourceOptions struct { // AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. type AssignmentsClientListOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atScope() is provided, the returned list only includes all policy assignments that apply to the scope, which is @@ -111,18 +131,81 @@ type AssignmentsClientUpdateOptions struct { // placeholder for future optional parameters } -// DataPolicyManifestsClientGetByPolicyModeOptions contains the optional parameters for the DataPolicyManifestsClient.GetByPolicyMode +// DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the DefinitionVersionsClient.CreateOrUpdateAtManagementGroup // method. -type DataPolicyManifestsClientGetByPolicyModeOptions struct { +type DefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { // placeholder for future optional parameters } -// DataPolicyManifestsClientListOptions contains the optional parameters for the DataPolicyManifestsClient.NewListPager method. -type DataPolicyManifestsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: "namespace eq '{value}'". If $filter is not provided, - // no filtering is performed. If $filter=namespace eq '{value}' is provided, the - // returned list only includes all data policy manifests that have a namespace matching the provided value. - Filter *string +// 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 @@ -209,93 +292,103 @@ type DefinitionsClientListOptions struct { Top *int32 } -// ExemptionsClientCreateOrUpdateOptions contains the optional parameters for the ExemptionsClient.CreateOrUpdate method. -type ExemptionsClientCreateOrUpdateOptions struct { +// SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdateAtManagementGroup +// method. +type SetDefinitionVersionsClientCreateOrUpdateAtManagementGroupOptions struct { // placeholder for future optional parameters } -// ExemptionsClientDeleteOptions contains the optional parameters for the ExemptionsClient.Delete method. -type ExemptionsClientDeleteOptions struct { +// 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 } -// ExemptionsClientGetOptions contains the optional parameters for the ExemptionsClient.Get method. -type ExemptionsClientGetOptions struct { +// SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete method. +type SetDefinitionVersionsClientDeleteOptions struct { // placeholder for future optional parameters } -// ExemptionsClientListForManagementGroupOptions contains the optional parameters for the ExemptionsClient.NewListForManagementGroupPager +// SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup // method. -type ExemptionsClientListForManagementGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string +type SetDefinitionVersionsClientGetAtManagementGroupOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } -// ExemptionsClientListForResourceGroupOptions contains the optional parameters for the ExemptionsClient.NewListForResourceGroupPager +// SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn // method. -type ExemptionsClientListForResourceGroupOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string +type SetDefinitionVersionsClientGetBuiltInOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string +} + +// SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get method. +type SetDefinitionVersionsClientGetOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } -// ExemptionsClientListForResourceOptions contains the optional parameters for the ExemptionsClient.NewListForResourcePager +// SetDefinitionVersionsClientListAllAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllAtManagementGroup // method. -type ExemptionsClientListForResourceOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string +type SetDefinitionVersionsClientListAllAtManagementGroupOptions struct { + // placeholder for future optional parameters } -// ExemptionsClientListOptions contains the optional parameters for the ExemptionsClient.NewListPager method. -type ExemptionsClientListOptions struct { - // The filter to apply on the operation. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or - // 'policyAssignmentId eq '{value}''. If $filter is not provided, no filtering is - // performed. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the scope, including - // those that apply directly or apply from containing scopes. If - // $filter=atScope() is provided, the returned list only includes all policy exemptions that apply to the scope, which is - // everything in the unfiltered list except those applied to sub scopes contained - // within the given scope. If $filter=atExactScope() is provided, the returned list only includes all policy exemptions that - // at the given scope. If $filter=excludeExpired() is provided, the returned list - // only includes all policy exemptions that either haven't expired or didn't set expiration date. If $filter=policyAssignmentId - // eq '{value}' is provided. the returned list only includes all policy - // exemptions that are associated with the give policyAssignmentId. - Filter *string +// SetDefinitionVersionsClientListAllBuiltinsOptions contains the optional parameters for the SetDefinitionVersionsClient.ListAllBuiltins +// method. +type SetDefinitionVersionsClientListAllBuiltinsOptions struct { + // placeholder for future optional parameters } -// ExemptionsClientUpdateOptions contains the optional parameters for the ExemptionsClient.Update method. -type ExemptionsClientUpdateOptions struct { +// 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 { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + + // 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 { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + + // 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 { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + + // 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 { @@ -322,22 +415,32 @@ type SetDefinitionsClientDeleteOptions struct { // SetDefinitionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.GetAtManagementGroup // method. type SetDefinitionsClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } // SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn method. type SetDefinitionsClientGetBuiltInOptions struct { - // placeholder for future optional parameters + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } // SetDefinitionsClientGetOptions contains the optional parameters for the SetDefinitionsClient.Get method. type SetDefinitionsClientGetOptions struct { - // placeholder for future optional parameters + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string } // SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. type SetDefinitionsClientListBuiltInOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. @@ -354,6 +457,10 @@ type SetDefinitionsClientListBuiltInOptions struct { // SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager // method. type SetDefinitionsClientListByManagementGroupOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. @@ -369,6 +476,10 @@ type SetDefinitionsClientListByManagementGroupOptions struct { // SetDefinitionsClientListOptions contains the optional parameters for the SetDefinitionsClient.NewListPager method. type SetDefinitionsClientListOptions struct { + // Comma-separated list of additional properties to be included in the response. Supported values are 'LatestDefinitionVersion, + // EffectiveDefinitionVersion'. + Expand *string + // The filter to apply on the operation. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category // eq '{value}''. If $filter is not provided, no filtering is performed. If // $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given scope. @@ -381,92 +492,3 @@ type SetDefinitionsClientListOptions struct { // Maximum number of records to return. When the $top filter is not provided, it will return 500 records. Top *int32 } - -// VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -type VariableValuesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -type VariableValuesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -type VariableValuesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -type VariableValuesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -type VariableValuesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -type VariableValuesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -type VariableValuesClientListForManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -type VariableValuesClientListOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -type VariablesClientCreateOrUpdateAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate method. -type VariablesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -type VariablesClientDeleteAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -type VariablesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -type VariablesClientGetAtManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -type VariablesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager -// method. -type VariablesClientListForManagementGroupOptions struct { - // placeholder for future optional parameters -} - -// VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -type VariablesClientListOptions struct { - // placeholder for future optional parameters -} diff --git a/sdk/resourcemanager/resources/armpolicy/response_types.go b/sdk/resourcemanager/resources/armpolicy/responses.go similarity index 53% rename from sdk/resourcemanager/resources/armpolicy/response_types.go rename to sdk/resourcemanager/resources/armpolicy/responses.go index f77339d18272..f4c6bb86e675 100644 --- a/sdk/resourcemanager/resources/armpolicy/response_types.go +++ b/sdk/resourcemanager/resources/armpolicy/responses.go @@ -80,16 +80,80 @@ type AssignmentsClientUpdateResponse struct { Assignment } -// DataPolicyManifestsClientGetByPolicyModeResponse contains the response from method DataPolicyManifestsClient.GetByPolicyMode. -type DataPolicyManifestsClientGetByPolicyModeResponse struct { - // The data policy manifest. - DataPolicyManifest +// DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse contains the response from method DefinitionVersionsClient.CreateOrUpdateAtManagementGroup. +type DefinitionVersionsClientCreateOrUpdateAtManagementGroupResponse struct { + // The ID of the policy definition version. + DefinitionVersion } -// DataPolicyManifestsClientListResponse contains the response from method DataPolicyManifestsClient.NewListPager. -type DataPolicyManifestsClientListResponse struct { - // List of data policy manifests. - DataPolicyManifestListResult +// 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. @@ -150,51 +214,80 @@ type DefinitionsClientListResponse struct { DefinitionListResult } -// ExemptionsClientCreateOrUpdateResponse contains the response from method ExemptionsClient.CreateOrUpdate. -type ExemptionsClientCreateOrUpdateResponse struct { - // The policy exemption. - 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 } -// ExemptionsClientDeleteResponse contains the response from method ExemptionsClient.Delete. -type ExemptionsClientDeleteResponse struct { +// SetDefinitionVersionsClientDeleteResponse contains the response from method SetDefinitionVersionsClient.Delete. +type SetDefinitionVersionsClientDeleteResponse struct { // placeholder for future response values } -// ExemptionsClientGetResponse contains the response from method ExemptionsClient.Get. -type ExemptionsClientGetResponse struct { - // The policy exemption. - Exemption +// SetDefinitionVersionsClientGetAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.GetAtManagementGroup. +type SetDefinitionVersionsClientGetAtManagementGroupResponse struct { + // The policy set definition version. + SetDefinitionVersion } -// ExemptionsClientListForManagementGroupResponse contains the response from method ExemptionsClient.NewListForManagementGroupPager. -type ExemptionsClientListForManagementGroupResponse struct { - // List of policy exemptions. - ExemptionListResult +// SetDefinitionVersionsClientGetBuiltInResponse contains the response from method SetDefinitionVersionsClient.GetBuiltIn. +type SetDefinitionVersionsClientGetBuiltInResponse struct { + // The policy set definition version. + SetDefinitionVersion } -// ExemptionsClientListForResourceGroupResponse contains the response from method ExemptionsClient.NewListForResourceGroupPager. -type ExemptionsClientListForResourceGroupResponse struct { - // List of policy exemptions. - ExemptionListResult +// SetDefinitionVersionsClientGetResponse contains the response from method SetDefinitionVersionsClient.Get. +type SetDefinitionVersionsClientGetResponse struct { + // The policy set definition version. + SetDefinitionVersion } -// ExemptionsClientListForResourceResponse contains the response from method ExemptionsClient.NewListForResourcePager. -type ExemptionsClientListForResourceResponse struct { - // List of policy exemptions. - ExemptionListResult +// SetDefinitionVersionsClientListAllAtManagementGroupResponse contains the response from method SetDefinitionVersionsClient.ListAllAtManagementGroup. +type SetDefinitionVersionsClientListAllAtManagementGroupResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult } -// ExemptionsClientListResponse contains the response from method ExemptionsClient.NewListPager. -type ExemptionsClientListResponse struct { - // List of policy exemptions. - ExemptionListResult +// SetDefinitionVersionsClientListAllBuiltinsResponse contains the response from method SetDefinitionVersionsClient.ListAllBuiltins. +type SetDefinitionVersionsClientListAllBuiltinsResponse struct { + // List of policy set definition versions. + SetDefinitionVersionListResult } -// ExemptionsClientUpdateResponse contains the response from method ExemptionsClient.Update. -type ExemptionsClientUpdateResponse struct { - // The policy exemption. - Exemption +// 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. @@ -254,95 +347,3 @@ type SetDefinitionsClientListResponse struct { // List of policy set definitions. SetDefinitionListResult } - -// VariableValuesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariableValuesClient.CreateOrUpdateAtManagementGroup. -type VariableValuesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientCreateOrUpdateResponse contains the response from method VariableValuesClient.CreateOrUpdate. -type VariableValuesClientCreateOrUpdateResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientDeleteAtManagementGroupResponse contains the response from method VariableValuesClient.DeleteAtManagementGroup. -type VariableValuesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariableValuesClientDeleteResponse contains the response from method VariableValuesClient.Delete. -type VariableValuesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariableValuesClientGetAtManagementGroupResponse contains the response from method VariableValuesClient.GetAtManagementGroup. -type VariableValuesClientGetAtManagementGroupResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientGetResponse contains the response from method VariableValuesClient.Get. -type VariableValuesClientGetResponse struct { - // The variable value. - VariableValue -} - -// VariableValuesClientListForManagementGroupResponse contains the response from method VariableValuesClient.NewListForManagementGroupPager. -type VariableValuesClientListForManagementGroupResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariableValuesClientListResponse contains the response from method VariableValuesClient.NewListPager. -type VariableValuesClientListResponse struct { - // List of variable values. - VariableValueListResult -} - -// VariablesClientCreateOrUpdateAtManagementGroupResponse contains the response from method VariablesClient.CreateOrUpdateAtManagementGroup. -type VariablesClientCreateOrUpdateAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientCreateOrUpdateResponse contains the response from method VariablesClient.CreateOrUpdate. -type VariablesClientCreateOrUpdateResponse struct { - // The variable. - Variable -} - -// VariablesClientDeleteAtManagementGroupResponse contains the response from method VariablesClient.DeleteAtManagementGroup. -type VariablesClientDeleteAtManagementGroupResponse struct { - // placeholder for future response values -} - -// VariablesClientDeleteResponse contains the response from method VariablesClient.Delete. -type VariablesClientDeleteResponse struct { - // placeholder for future response values -} - -// VariablesClientGetAtManagementGroupResponse contains the response from method VariablesClient.GetAtManagementGroup. -type VariablesClientGetAtManagementGroupResponse struct { - // The variable. - Variable -} - -// VariablesClientGetResponse contains the response from method VariablesClient.Get. -type VariablesClientGetResponse struct { - // The variable. - Variable -} - -// VariablesClientListForManagementGroupResponse contains the response from method VariablesClient.NewListForManagementGroupPager. -type VariablesClientListForManagementGroupResponse struct { - // List of variables. - VariableListResult -} - -// VariablesClientListResponse contains the response from method VariablesClient.NewListPager. -type VariablesClientListResponse struct { - // List of variables. - VariableListResult -} diff --git a/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go b/sdk/resourcemanager/resources/armpolicy/setdefinitions_client.go index 457a89d51f08..45f96662610c 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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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,23 @@ 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") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -338,18 +341,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 2024-05-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 +369,25 @@ 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") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -399,7 +405,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 2024-05-01 // - policySetDefinitionName - The name of the policy set definition to get. // - options - SetDefinitionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionsClient.GetBuiltIn // method. @@ -437,7 +443,10 @@ func (client *SetDefinitionsClient) getBuiltInCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-06-01") + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -463,7 +472,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 2024-05-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 +509,13 @@ 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.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -527,7 +539,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 2024-05-01 // - options - SetDefinitionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionsClient.NewListBuiltInPager // method. func (client *SetDefinitionsClient) NewListBuiltInPager(options *SetDefinitionsClientListBuiltInOptions) *runtime.Pager[SetDefinitionsClientListBuiltInResponse] { @@ -561,10 +573,13 @@ 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.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2024-05-01") req.Raw().URL.RawQuery = reqQP.Encode() unencodedParams := []string{req.Raw().URL.RawQuery} if options != nil && options.Filter != nil { @@ -595,7 +610,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 2024-05-01 // - managementGroupID - The ID of the management group. // - options - SetDefinitionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionsClient.NewListByManagementGroupPager // method. @@ -634,10 +649,13 @@ 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.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2024-05-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..feb2bc46b829 --- /dev/null +++ b/sdk/resourcemanager/resources/armpolicy/setdefinitionversions_client.go @@ -0,0 +1,867 @@ +//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 +} + +// NewSetDefinitionVersionsClient creates a new instance of SetDefinitionVersionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSetDefinitionVersionsClient(subscriptionID 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, + 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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - parameters - The policy set definition properties. +// - options - SetDefinitionVersionsClientCreateOrUpdateOptions contains the optional parameters for the SetDefinitionVersionsClient.CreateOrUpdate +// method. +func (client *SetDefinitionVersionsClient) CreateOrUpdate(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion string, 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - 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, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - options - SetDefinitionVersionsClientDeleteOptions contains the optional parameters for the SetDefinitionVersionsClient.Delete +// method. +func (client *SetDefinitionVersionsClient) Delete(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion string, 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - options - SetDefinitionVersionsClientDeleteAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.DeleteAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) DeleteAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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", "2024-05-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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - options - SetDefinitionVersionsClientGetOptions contains the optional parameters for the SetDefinitionVersionsClient.Get +// method. +func (client *SetDefinitionVersionsClient) Get(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion string, 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - options - SetDefinitionVersionsClientGetAtManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.GetAtManagementGroup +// method. +func (client *SetDefinitionVersionsClient) GetAtManagementGroup(ctx context.Context, managementGroupName string, policySetDefinitionName string, policyDefinitionVersion 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion 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 policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - policyDefinitionVersion - The policy set 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 +// - options - SetDefinitionVersionsClientGetBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.GetBuiltIn +// method. +func (client *SetDefinitionVersionsClient) GetBuiltIn(ctx context.Context, policySetDefinitionName string, policyDefinitionVersion string, 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, policySetDefinitionName, policyDefinitionVersion, 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, policySetDefinitionName string, policyDefinitionVersion string, options *SetDefinitionVersionsClientGetBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions/{policyDefinitionVersion}" + if policySetDefinitionName == "" { + return nil, errors.New("parameter policySetDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policySetDefinitionName}", url.PathEscape(policySetDefinitionName)) + if policyDefinitionVersion == "" { + return nil, errors.New("parameter policyDefinitionVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyDefinitionVersion}", url.PathEscape(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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + reqQP.Set("api-version", "2024-05-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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - options - SetDefinitionVersionsClientListOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListPager +// method. +func (client *SetDefinitionVersionsClient) NewListPager(policySetDefinitionName string, 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, policySetDefinitionName, 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, policySetDefinitionName string, 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 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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-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", "2024-05-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 2024-05-01 +// - policySetDefinitionName - The name of the policy set definition. +// - options - SetDefinitionVersionsClientListBuiltInOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListBuiltInPager +// method. +func (client *SetDefinitionVersionsClient) NewListBuiltInPager(policySetDefinitionName string, 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, policySetDefinitionName, 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, policySetDefinitionName string, options *SetDefinitionVersionsClientListBuiltInOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}/versions" + 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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 2024-05-01 +// - managementGroupName - The name of the management group. The name is case insensitive. +// - policySetDefinitionName - The name of the policy set definition. +// - options - SetDefinitionVersionsClientListByManagementGroupOptions contains the optional parameters for the SetDefinitionVersionsClient.NewListByManagementGroupPager +// method. +func (client *SetDefinitionVersionsClient) NewListByManagementGroupPager(managementGroupName string, policySetDefinitionName 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, policySetDefinitionName, 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, policySetDefinitionName 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 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() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2024-05-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 deleted file mode 100644 index 40efd8d8c4dc..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variables_client.go +++ /dev/null @@ -1,510 +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. 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" - "strings" -) - -// VariablesClient contains the methods for the Variables group. -// Don't use this type directly, use NewVariablesClient() instead. -type VariablesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariablesClient creates a new instance of VariablesClient with the specified values. -// - subscriptionID - The ID of the target subscription. -// - 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) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariablesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable with the given subscription and name. Policy variables can -// only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateOptions contains the optional parameters for the VariablesClient.CreateOrUpdate -// method. -func (client *VariablesClient) CreateOrUpdate(ctx context.Context, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateOptions) (VariablesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariablesClient.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, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariablesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - 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 *VariablesClient) createOrUpdateHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateResponse, error) { - result := VariablesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable with the given management group and name. -// Policy variables can only be used by a policy definition at the scope they are created or below. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - parameters - Parameters for the variable. -// - options - VariablesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariablesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariablesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateAtManagementGroupOptions) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.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, managementGroupID, variableName, parameters, options) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariablesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, parameters Variable, options *VariablesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - 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 *VariablesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariablesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable, given its name and the subscription it was created in. The scope of a variable -// is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteOptions contains the optional parameters for the VariablesClient.Delete method. -func (client *VariablesClient) Delete(ctx context.Context, variableName string, options *VariablesClientDeleteOptions) (VariablesClientDeleteResponse, error) { - var err error - const operationName = "VariablesClient.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, variableName, options) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteResponse{}, err - } - return VariablesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariablesClient) deleteCreateRequest(ctx context.Context, variableName string, options *VariablesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable, given its name and the management group it was created in. -// The scope of a variable is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariablesClient.DeleteAtManagementGroup -// method. -func (client *VariablesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientDeleteAtManagementGroupOptions) (VariablesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.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, managementGroupID, variableName, options) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariablesClientDeleteAtManagementGroupResponse{}, err - } - return VariablesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariablesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable, given its name and the subscription it was created at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetOptions contains the optional parameters for the VariablesClient.Get method. -func (client *VariablesClient) Get(ctx context.Context, variableName string, options *VariablesClientGetOptions) (VariablesClientGetResponse, error) { - var err error - const operationName = "VariablesClient.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, variableName, options) - if err != nil { - return VariablesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariablesClient) getCreateRequest(ctx context.Context, variableName string, options *VariablesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariablesClient) getHandleResponse(resp *http.Response) (VariablesClientGetResponse, error) { - result := VariablesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable, given its name and the management group it was created -// at. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariablesClientGetAtManagementGroupOptions contains the optional parameters for the VariablesClient.GetAtManagementGroup -// method. -func (client *VariablesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientGetAtManagementGroupOptions) (VariablesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariablesClient.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, managementGroupID, variableName, options) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariablesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariablesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, options *VariablesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariablesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariablesClientGetAtManagementGroupResponse, error) { - result := VariablesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Variable); err != nil { - return VariablesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variables associated with the given subscription. -// -// Generated from API version 2022-08-01-preview -// - options - VariablesClientListOptions contains the optional parameters for the VariablesClient.NewListPager method. -func (client *VariablesClient) NewListPager(options *VariablesClientListOptions) *runtime.Pager[VariablesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListResponse]{ - More: func(page VariablesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListResponse) (VariablesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.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 VariablesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariablesClient) listCreateRequest(ctx context.Context, options *VariablesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariablesClient) listHandleResponse(resp *http.Response) (VariablesClientListResponse, error) { - result := VariablesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variables applicable to the management group. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - options - VariablesClientListForManagementGroupOptions contains the optional parameters for the VariablesClient.NewListForManagementGroupPager -// method. -func (client *VariablesClient) NewListForManagementGroupPager(managementGroupID string, options *VariablesClientListForManagementGroupOptions) *runtime.Pager[VariablesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariablesClientListForManagementGroupResponse]{ - More: func(page VariablesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariablesClientListForManagementGroupResponse) (VariablesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariablesClient.NewListForManagementGroupPager") - 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.listForManagementGroupCreateRequest(ctx, managementGroupID, options) - }, nil) - if err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariablesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *VariablesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariablesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariablesClientListForManagementGroupResponse, error) { - result := VariablesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableListResult); err != nil { - return VariablesClientListForManagementGroupResponse{}, err - } - return result, nil -} 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 deleted file mode 100644 index 97ebe9c492d3..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/variablevalues_client.go +++ /dev/null @@ -1,553 +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. 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" - "strings" -) - -// VariableValuesClient contains the methods for the VariableValues group. -// Don't use this type directly, use NewVariableValuesClient() instead. -type VariableValuesClient struct { - internal *arm.Client - subscriptionID string -} - -// NewVariableValuesClient creates a new instance of VariableValuesClient with the specified values. -// - subscriptionID - The ID of the target subscription. -// - 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) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &VariableValuesClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - This operation creates or updates a variable value with the given subscription and name for a given variable. -// Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdate -// method. -func (client *VariableValuesClient) CreateOrUpdate(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateOptions) (VariableValuesClientCreateOrUpdateResponse, error) { - var err error - const operationName = "VariableValuesClient.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, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *VariableValuesClient) createOrUpdateCreateRequest(ctx context.Context, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - 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 *VariableValuesClient) createOrUpdateHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateResponse, error) { - result := VariableValuesClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// CreateOrUpdateAtManagementGroup - This operation creates or updates a variable value with the given management group and -// name for a given variable. Variable values are scoped to the variable for which they are created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - parameters - Parameters for the variable value. -// - options - VariableValuesClientCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.CreateOrUpdateAtManagementGroup -// method. -func (client *VariableValuesClient) CreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.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, managementGroupID, variableName, variableValueName, parameters, options) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - resp, err := client.createOrUpdateAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. -func (client *VariableValuesClient) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, parameters VariableValue, options *VariableValuesClientCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - 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 *VariableValuesClient) createOrUpdateAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientCreateOrUpdateAtManagementGroupResponse, error) { - result := VariableValuesClientCreateOrUpdateAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientCreateOrUpdateAtManagementGroupResponse{}, err - } - return result, nil -} - -// Delete - This operation deletes a variable value, given its name, the subscription it was created in, and the variable -// it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteOptions contains the optional parameters for the VariableValuesClient.Delete method. -func (client *VariableValuesClient) Delete(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientDeleteOptions) (VariableValuesClientDeleteResponse, error) { - var err error - const operationName = "VariableValuesClient.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, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteResponse{}, err - } - return VariableValuesClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *VariableValuesClient) deleteCreateRequest(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// DeleteAtManagementGroup - This operation deletes a variable value, given its name, the management group it was created -// in, and the variable it belongs to. The scope of a variable value is the part of its ID preceding -// '/providers/Microsoft.Authorization/variables/{variableName}'. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientDeleteAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.DeleteAtManagementGroup -// method. -func (client *VariableValuesClient) DeleteAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientDeleteAtManagementGroupOptions) (VariableValuesClientDeleteAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.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, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientDeleteAtManagementGroupResponse{}, err - } - return VariableValuesClientDeleteAtManagementGroupResponse{}, nil -} - -// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. -func (client *VariableValuesClient) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientDeleteAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - This operation retrieves a single variable value; given its name, subscription it was created at and the variable -// it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetOptions contains the optional parameters for the VariableValuesClient.Get method. -func (client *VariableValuesClient) Get(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientGetOptions) (VariableValuesClientGetResponse, error) { - var err error - const operationName = "VariableValuesClient.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, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *VariableValuesClient) getCreateRequest(ctx context.Context, variableName string, variableValueName string, options *VariableValuesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *VariableValuesClient) getHandleResponse(resp *http.Response) (VariableValuesClientGetResponse, error) { - result := VariableValuesClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetResponse{}, err - } - return result, nil -} - -// GetAtManagementGroup - This operation retrieves a single variable value; given its name, management group it was created -// at and the variable it's created for. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - variableValueName - The name of the variable value to operate on. -// - options - VariableValuesClientGetAtManagementGroupOptions contains the optional parameters for the VariableValuesClient.GetAtManagementGroup -// method. -func (client *VariableValuesClient) GetAtManagementGroup(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientGetAtManagementGroupOptions) (VariableValuesClientGetAtManagementGroupResponse, error) { - var err error - const operationName = "VariableValuesClient.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, managementGroupID, variableName, variableValueName, options) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - resp, err := client.getAtManagementGroupHandleResponse(httpResp) - return resp, err -} - -// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. -func (client *VariableValuesClient) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, variableValueName string, options *VariableValuesClientGetAtManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values/{variableValueName}" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - if variableValueName == "" { - return nil, errors.New("parameter variableValueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableValueName}", url.PathEscape(variableValueName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. -func (client *VariableValuesClient) getAtManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientGetAtManagementGroupResponse, error) { - result := VariableValuesClientGetAtManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValue); err != nil { - return VariableValuesClientGetAtManagementGroupResponse{}, err - } - return result, nil -} - -// NewListPager - This operation retrieves the list of all variable values associated with the given variable that is at a -// subscription level. -// -// Generated from API version 2022-08-01-preview -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListOptions contains the optional parameters for the VariableValuesClient.NewListPager method. -func (client *VariableValuesClient) NewListPager(variableName string, options *VariableValuesClientListOptions) *runtime.Pager[VariableValuesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListResponse]{ - More: func(page VariableValuesClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListResponse) (VariableValuesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.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, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *VariableValuesClient) listCreateRequest(ctx context.Context, variableName string, options *VariableValuesClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *VariableValuesClient) listHandleResponse(resp *http.Response) (VariableValuesClientListResponse, error) { - result := VariableValuesClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListResponse{}, err - } - return result, nil -} - -// NewListForManagementGroupPager - This operation retrieves the list of all variable values applicable the variable indicated -// at the management group scope. -// -// Generated from API version 2022-08-01-preview -// - managementGroupID - The ID of the management group. -// - variableName - The name of the variable to operate on. -// - options - VariableValuesClientListForManagementGroupOptions contains the optional parameters for the VariableValuesClient.NewListForManagementGroupPager -// method. -func (client *VariableValuesClient) NewListForManagementGroupPager(managementGroupID string, variableName string, options *VariableValuesClientListForManagementGroupOptions) *runtime.Pager[VariableValuesClientListForManagementGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[VariableValuesClientListForManagementGroupResponse]{ - More: func(page VariableValuesClientListForManagementGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *VariableValuesClientListForManagementGroupResponse) (VariableValuesClientListForManagementGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VariableValuesClient.NewListForManagementGroupPager") - 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.listForManagementGroupCreateRequest(ctx, managementGroupID, variableName, options) - }, nil) - if err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return client.listForManagementGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listForManagementGroupCreateRequest creates the ListForManagementGroup request. -func (client *VariableValuesClient) listForManagementGroupCreateRequest(ctx context.Context, managementGroupID string, variableName string, options *VariableValuesClientListForManagementGroupOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Authorization/variables/{variableName}/values" - if managementGroupID == "" { - return nil, errors.New("parameter managementGroupID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) - if variableName == "" { - return nil, errors.New("parameter variableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{variableName}", url.PathEscape(variableName)) - 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", "2022-08-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listForManagementGroupHandleResponse handles the ListForManagementGroup response. -func (client *VariableValuesClient) listForManagementGroupHandleResponse(resp *http.Response) (VariableValuesClientListForManagementGroupResponse, error) { - result := VariableValuesClientListForManagementGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.VariableValueListResult); err != nil { - return VariableValuesClientListForManagementGroupResponse{}, err - } - return result, nil -} 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..4b3f6590899a 100644 --- a/sdk/resourcemanager/resources/armresources/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armresources/CHANGELOG.md @@ -1,5 +1,41 @@ # Release History +## 2.0.0 (2024-11-18) +### 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. +- Struct `DeploymentValidateResult` has been removed +- Field `DeploymentValidateResult` of struct `DeploymentsClientValidateAtManagementGroupScopeResponse` has been removed +- Field `DeploymentValidateResult` of struct `DeploymentsClientValidateAtScopeResponse` has been removed +- Field `DeploymentValidateResult` of struct `DeploymentsClientValidateAtSubscriptionScopeResponse` has been removed +- Field `DeploymentValidateResult` of struct `DeploymentsClientValidateAtTenantScopeResponse` has been removed +- Field `DeploymentValidateResult` of struct `DeploymentsClientValidateResponse` has been removed + +### Features Added + +- New enum type `ExportTemplateOutputFormat` with values `ExportTemplateOutputFormatBicep`, `ExportTemplateOutputFormatJSON` +- New enum type `Level` with values `LevelError`, `LevelInfo`, `LevelWarning` +- New struct `DeploymentDiagnosticsDefinition` +- New struct `DeploymentParameter` +- New struct `DeploymentValidationError` +- New struct `ErrorDetail` +- New struct `KeyVaultParameterReference` +- New struct `KeyVaultReference` +- New field `Diagnostics` in struct `DeploymentPropertiesExtended` +- New anonymous field `DeploymentExtended` in struct `DeploymentsClientValidateAtManagementGroupScopeResponse` +- New anonymous field `DeploymentExtended` in struct `DeploymentsClientValidateAtScopeResponse` +- New anonymous field `DeploymentExtended` in struct `DeploymentsClientValidateAtSubscriptionScopeResponse` +- New anonymous field `DeploymentExtended` in struct `DeploymentsClientValidateAtTenantScopeResponse` +- New anonymous field `DeploymentExtended` in struct `DeploymentsClientValidateResponse` +- New field `OutputFormat` in struct `ExportTemplateRequest` +- New field `Output` in struct `ResourceGroupExportResult` +- New field `Diagnostics`, `PotentialChanges` in struct `WhatIfOperationProperties` + + ## 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 efb8c87ec3e3..0b46b8f4a819 100644 --- a/sdk/resourcemanager/resources/armresources/README.md +++ b/sdk/resourcemanager/resources/armresources/README.md @@ -18,7 +18,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..f0a6a095fadd 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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..609ed602b1a5 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 @@ -198,6 +214,24 @@ func PossibleExtendedLocationTypeValues() []ExtendedLocationType { } } +// Level - Denotes the additional response level. +type Level string + +const ( + LevelError Level = "Error" + LevelInfo Level = "Info" + LevelWarning Level = "Warning" +) + +// PossibleLevelValues returns the possible values for the Level const type. +func PossibleLevelValues() []Level { + return []Level{ + LevelError, + LevelInfo, + LevelWarning, + } +} + // OnErrorDeploymentType - The deployment on error behavior type. Possible values are LastSuccessful and SpecificDeployment. type OnErrorDeploymentType string diff --git a/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go b/sdk/resourcemanager/resources/armresources/deploymentoperations_client.go index ec1e1ab800e4..2efb383134d1 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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..e440f0dfe777 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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 1f2bd3dd5c00..44171348fb5a 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/v3/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 f8b99ed3f3a1..0f79214505be 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.2.0 @@ -12,6 +11,7 @@ require ( ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect diff --git a/sdk/resourcemanager/resources/armresources/models.go b/sdk/resourcemanager/resources/armresources/models.go index ce98f859a61d..118e17dc5632 100644 --- a/sdk/resourcemanager/resources/armresources/models.go +++ b/sdk/resourcemanager/resources/armresources/models.go @@ -123,6 +123,23 @@ type Deployment struct { Tags map[string]*string } +type DeploymentDiagnosticsDefinition struct { + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; Denotes the additional response level. + Level *Level + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error target. + Target *string +} + // DeploymentExportResult - The deployment export result. type DeploymentExportResult struct { // The template content. @@ -221,6 +238,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 +270,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. @@ -270,6 +296,9 @@ type DeploymentPropertiesExtended struct { // READ-ONLY; The list of deployment dependencies. Dependencies []*Dependency + // READ-ONLY; Contains diagnostic information collected during validation process. + Diagnostics []*DeploymentDiagnosticsDefinition + // READ-ONLY; The duration of the template deployment. Duration *string @@ -313,13 +342,10 @@ type DeploymentPropertiesExtended struct { ValidatedResources []*ResourceReference } -// DeploymentValidateResult - Information from validate template deployment response. -type DeploymentValidateResult struct { - // The template deployment properties. - Properties *DeploymentPropertiesExtended - - // READ-ONLY; The deployment validation error. - Error *ErrorResponse +// DeploymentValidationError - The template deployment validation detected failures. +type DeploymentValidationError struct { + // The error detail. + Error *ErrorDetail } // DeploymentWhatIf - Deployment What-if operation parameters. @@ -354,7 +380,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. @@ -387,6 +413,24 @@ type ErrorAdditionalInfo struct { Type *string } +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.) type ErrorResponse struct { @@ -413,6 +457,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 +610,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 +903,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 } @@ -1133,6 +1201,12 @@ type WhatIfChange struct { type WhatIfOperationProperties struct { // List of resource changes predicted by What-If operation. Changes []*WhatIfChange + + // List of resource changes predicted by What-If operation. + PotentialChanges []*WhatIfChange + + // READ-ONLY; List of resource diagnostics detected by What-If operation. + Diagnostics []*DeploymentDiagnosticsDefinition } // WhatIfOperationResult - Result of the What-If operation. Contains a list of predicted changes and a URL link to get to diff --git a/sdk/resourcemanager/resources/armresources/models_serde.go b/sdk/resourcemanager/resources/armresources/models_serde.go index 5c6e3ac77c19..596c5d294015 100644 --- a/sdk/resourcemanager/resources/armresources/models_serde.go +++ b/sdk/resourcemanager/resources/armresources/models_serde.go @@ -334,6 +334,49 @@ func (d *Deployment) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DeploymentDiagnosticsDefinition. +func (d DeploymentDiagnosticsDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", d.AdditionalInfo) + populate(objectMap, "code", d.Code) + populate(objectMap, "level", d.Level) + populate(objectMap, "message", d.Message) + populate(objectMap, "target", d.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentDiagnosticsDefinition. +func (d *DeploymentDiagnosticsDefinition) 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 "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &d.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &d.Code) + delete(rawMsg, key) + case "level": + err = unpopulate(val, "Level", &d.Level) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &d.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &d.Target) + 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 DeploymentExportResult. func (d DeploymentExportResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -595,6 +638,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 +676,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) @@ -656,6 +730,7 @@ func (d DeploymentPropertiesExtended) MarshalJSON() ([]byte, error) { populate(objectMap, "correlationId", d.CorrelationID) populate(objectMap, "debugSetting", d.DebugSetting) populate(objectMap, "dependencies", d.Dependencies) + populate(objectMap, "diagnostics", d.Diagnostics) populate(objectMap, "duration", d.Duration) populate(objectMap, "error", d.Error) populate(objectMap, "mode", d.Mode) @@ -691,6 +766,9 @@ func (d *DeploymentPropertiesExtended) UnmarshalJSON(data []byte) error { case "dependencies": err = unpopulate(val, "Dependencies", &d.Dependencies) delete(rawMsg, key) + case "diagnostics": + err = unpopulate(val, "Diagnostics", &d.Diagnostics) + delete(rawMsg, key) case "duration": err = unpopulate(val, "Duration", &d.Duration) delete(rawMsg, key) @@ -741,16 +819,15 @@ func (d *DeploymentPropertiesExtended) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DeploymentValidateResult. -func (d DeploymentValidateResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DeploymentValidationError. +func (d DeploymentValidationError) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "error", d.Error) - populate(objectMap, "properties", d.Properties) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentValidateResult. -func (d *DeploymentValidateResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentValidationError. +func (d *DeploymentValidationError) 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) @@ -761,9 +838,6 @@ func (d *DeploymentValidateResult) UnmarshalJSON(data []byte) error { case "error": err = unpopulate(val, "Error", &d.Error) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &d.Properties) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -810,7 +884,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) @@ -920,6 +994,49 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) 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", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -967,6 +1084,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 +1101,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 +1459,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 +2265,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 +2282,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) @@ -2945,6 +3132,8 @@ func (w *WhatIfChange) UnmarshalJSON(data []byte) error { func (w WhatIfOperationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "changes", w.Changes) + populate(objectMap, "diagnostics", w.Diagnostics) + populate(objectMap, "potentialChanges", w.PotentialChanges) return json.Marshal(objectMap) } @@ -2960,6 +3149,12 @@ func (w *WhatIfOperationProperties) UnmarshalJSON(data []byte) error { case "changes": err = unpopulate(val, "Changes", &w.Changes) delete(rawMsg, key) + case "diagnostics": + err = unpopulate(val, "Diagnostics", &w.Diagnostics) + delete(rawMsg, key) + case "potentialChanges": + err = unpopulate(val, "PotentialChanges", &w.PotentialChanges) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", w, err) @@ -3098,7 +3293,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..d7d235ac4ac9 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-07-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-07-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..ddb9dc68cd1a 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-07-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-07-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..f70de124f41f 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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..ce68570f5c63 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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 d5f778c14c66..c5a867561cda 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/v3/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 8170fd2f4d7e..0479a8b6197c 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/v3/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 97% rename from sdk/resourcemanager/resources/armresources/response_types.go rename to sdk/resourcemanager/resources/armresources/responses.go index fb04138cd76c..19649b13a4f7 100644 --- a/sdk/resourcemanager/resources/armresources/response_types.go +++ b/sdk/resourcemanager/resources/armresources/responses.go @@ -356,32 +356,32 @@ type DeploymentsClientListByResourceGroupResponse struct { // DeploymentsClientValidateAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginValidateAtManagementGroupScope. type DeploymentsClientValidateAtManagementGroupScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult + // Deployment information. + DeploymentExtended } // DeploymentsClientValidateAtScopeResponse contains the response from method DeploymentsClient.BeginValidateAtScope. type DeploymentsClientValidateAtScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult + // Deployment information. + DeploymentExtended } // DeploymentsClientValidateAtSubscriptionScopeResponse contains the response from method DeploymentsClient.BeginValidateAtSubscriptionScope. type DeploymentsClientValidateAtSubscriptionScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult + // Deployment information. + DeploymentExtended } // DeploymentsClientValidateAtTenantScopeResponse contains the response from method DeploymentsClient.BeginValidateAtTenantScope. type DeploymentsClientValidateAtTenantScopeResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult + // Deployment information. + DeploymentExtended } // DeploymentsClientValidateResponse contains the response from method DeploymentsClient.BeginValidate. type DeploymentsClientValidateResponse struct { - // Information from validate template deployment response. - DeploymentValidateResult + // Deployment information. + DeploymentExtended } // DeploymentsClientWhatIfAtManagementGroupScopeResponse contains the response from method DeploymentsClient.BeginWhatIfAtManagementGroupScope. @@ -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..5bb4258196e0 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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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-07-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 1851e0cab77d..cd90cc0bbc12 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/v3/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..f990a2bc4ebd 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-11-18) +### 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 53bbfd9c876b..e38f38daf1d9 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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..713bebc0d355 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-11-18) +### 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 0a9c75b9ddf1..672fe56bc867 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.13.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 github.com/stretchr/testify v1.9.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // 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