From 625b5040662b5fc14f448bf57dbfe6c3c2193523 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 18 Apr 2022 06:16:43 +0000 Subject: [PATCH] CodeGen from PR 18685 in Azure/azure-rest-api-specs [Resources] config readme.python (#18685) * config readme.python * Update readme.python.md * Update readme.python.md * Update readme.python.md * Update readme.python.md Co-authored-by: Yuchao Yan --- .../resources/armpolicy/CHANGELOG.md | 4 + .../resources/armpolicy/autorest.md | 6 +- .../resources/armpolicy/go.mod | 2 +- ...example_datapolicymanifests_client_test.go | 68 ---- ...d_example_policyassignments_client_test.go | 267 ------------- ...d_example_policydefinitions_client_test.go | 343 ----------------- ...ed_example_policyexemptions_client_test.go | 219 ----------- ...xample_policysetdefinitions_client_test.go | 350 ------------------ .../armpolicy/zz_generated_constants.go | 2 +- 9 files changed, 9 insertions(+), 1252 deletions(-) delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go delete mode 100644 sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go diff --git a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md index b9a6cf2fde0a..9731b9b1d2bf 100644 --- a/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armpolicy/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.5.1 (2022-04-18) +### Other Changes + + ## 0.5.0 (2022-04-18) ### Breaking Changes diff --git a/sdk/resourcemanager/resources/armpolicy/autorest.md b/sdk/resourcemanager/resources/armpolicy/autorest.md index c11c330263d4..6f39c568bde2 100644 --- a/sdk/resourcemanager/resources/armpolicy/autorest.md +++ b/sdk/resourcemanager/resources/armpolicy/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/f92aaf88f4c9d1ffb9a014eba196d887a9288c3a/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/f92aaf88f4c9d1ffb9a014eba196d887a9288c3a/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.5.0 +module-version: 0.5.1 package-policy: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armpolicy/go.mod b/sdk/resourcemanager/resources/armpolicy/go.mod index 9edbf230193b..2c6cb5cb94dc 100644 --- a/sdk/resourcemanager/resources/armpolicy/go.mod +++ b/sdk/resourcemanager/resources/armpolicy/go.mod @@ -4,12 +4,12 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v0.3.0 github.com/stretchr/testify v1.7.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.14.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v0.4.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go deleted file mode 100644 index 91248d8e7e92..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_datapolicymanifests_client_test.go +++ /dev/null @@ -1,68 +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. - -package armpolicy_test - -import ( - "context" - "log" - - "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/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDataPolicyManifestsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.GetByPolicyMode(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json -func ExampleDataPolicyManifestsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewDataPolicyManifestsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListPager(&armpolicy.DataPolicyManifestsClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go deleted file mode 100644 index 9960b0eca427..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyassignments_client_test.go +++ /dev/null @@ -1,267 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Delete(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json -func ExampleAssignmentsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.Create(ctx, - "", - "", - armpolicy.Assignment{ - Properties: &armpolicy.AssignmentProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - Metadata: map[string]interface{}{ - "assignedBy": "Special Someone", - }, - NonComplianceMessages: []*armpolicy.NonComplianceMessage{ - { - Message: to.Ptr(""), - }}, - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr(""), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json -func ExampleAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Get(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json -func ExampleAssignmentsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Update(ctx, - "", - "", - armpolicy.AssignmentUpdate{ - Identity: &armpolicy.Identity{ - Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned), - }, - Location: to.Ptr(""), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForResourceGroupPager("", - &armpolicy.AssignmentsClientListForResourceGroupOptions{Filter: to.Ptr(""), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForResourcePager("", - "", - "", - "", - "", - &armpolicy.AssignmentsClientListForResourceOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForManagementGroupPager("", - &armpolicy.AssignmentsClientListForManagementGroupOptions{Filter: to.Ptr(""), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewAssignmentsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListPager(&armpolicy.AssignmentsClientListOptions{Filter: to.Ptr(""), - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go deleted file mode 100644 index f1858bd3b1eb..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policydefinitions_client_test.go +++ /dev/null @@ -1,343 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json -func ExampleDefinitionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.CreateOrUpdate(ctx, - "", - armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - Metadata: map[string]interface{}{ - "category": "Naming", - }, - Mode: to.Ptr(""), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - }, - }, - }, - PolicyRule: map[string]interface{}{ - "if": map[string]interface{}{ - "not": map[string]interface{}{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]interface{}{ - "effect": "deny", - }, - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.Delete(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Get(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.GetBuiltIn(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.CreateOrUpdateAtManagementGroup(ctx, - "", - "", - armpolicy.Definition{ - Properties: &armpolicy.DefinitionProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - Metadata: map[string]interface{}{ - "category": "Naming", - }, - Mode: to.Ptr(""), - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "prefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - }, - }, - "suffix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - }, - }, - }, - PolicyRule: map[string]interface{}{ - "if": map[string]interface{}{ - "not": map[string]interface{}{ - "field": "name", - "like": "[concat(parameters('prefix'), '*', parameters('suffix'))]", - }, - }, - "then": map[string]interface{}{ - "effect": "deny", - }, - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.DeleteAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.GetAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListPager(&armpolicy.DefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListBuiltInPager(&armpolicy.DefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListByManagementGroupPager("", - &armpolicy.DefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go deleted file mode 100644 index 9eb985b3c1e5..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policyexemptions_client_test.go +++ /dev/null @@ -1,219 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.Delete(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json -func ExampleExemptionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.CreateOrUpdate(ctx, - "", - "", - armpolicy.Exemption{ - Properties: &armpolicy.ExemptionProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - ExemptionCategory: to.Ptr(armpolicy.ExemptionCategoryWaiver), - Metadata: map[string]interface{}{ - "reason": "Temporary exemption for a expensive VM demo", - }, - PolicyAssignmentID: to.Ptr(""), - PolicyDefinitionReferenceIDs: []*string{ - to.Ptr("Limit_Skus")}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json -func ExampleExemptionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Get(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListPager(&armpolicy.ExemptionsClientListOptions{Filter: to.Ptr("")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForResourceGroupPager("", - &armpolicy.ExemptionsClientListForResourceGroupOptions{Filter: to.Ptr("")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForResourcePager("", - "", - "", - "", - "", - &armpolicy.ExemptionsClientListForResourceOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/preview/2020-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) - return - } - ctx := context.Background() - client, err := armpolicy.NewExemptionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListForManagementGroupPager("", - &armpolicy.ExemptionsClientListForManagementGroupOptions{Filter: to.Ptr("")}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go b/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go deleted file mode 100644 index be0cfdfb3c6a..000000000000 --- a/sdk/resourcemanager/resources/armpolicy/ze_generated_example_policysetdefinitions_client_test.go +++ /dev/null @@ -1,350 +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. - -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/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json -func ExampleSetDefinitionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.CreateOrUpdate(ctx, - "", - armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - Metadata: map[string]interface{}{ - "category": "Cost Management", - }, - Parameters: map[string]*armpolicy.ParameterDefinitionsValue{ - "namePrefix": { - Type: to.Ptr(armpolicy.ParameterTypeString), - DefaultValue: "myPrefix", - Metadata: &armpolicy.ParameterDefinitionsValueMetadata{ - DisplayName: to.Ptr(""), - }, - }, - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []interface{}{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr(""), - PolicyDefinitionReferenceID: to.Ptr(""), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "[parameters('namePrefix')]", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr(""), - PolicyDefinitionReferenceID: to.Ptr(""), - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.Delete(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.Get(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.GetBuiltIn(ctx, - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListPager(&armpolicy.SetDefinitionsClientListOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListBuiltInPager(&armpolicy.SetDefinitionsClientListBuiltInOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json -func ExampleSetDefinitionsClient_CreateOrUpdateAtManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.CreateOrUpdateAtManagementGroup(ctx, - "", - "", - armpolicy.SetDefinition{ - Properties: &armpolicy.SetDefinitionProperties{ - Description: to.Ptr(""), - DisplayName: to.Ptr(""), - Metadata: map[string]interface{}{ - "category": "Cost Management", - }, - PolicyDefinitions: []*armpolicy.DefinitionReference{ - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "listOfAllowedSKUs": { - Value: []interface{}{ - "Standard_GRS", - "Standard_LRS", - }, - }, - }, - PolicyDefinitionID: to.Ptr(""), - PolicyDefinitionReferenceID: to.Ptr(""), - }, - { - Parameters: map[string]*armpolicy.ParameterValuesValue{ - "prefix": { - Value: "DeptA", - }, - "suffix": { - Value: "-LC", - }, - }, - PolicyDefinitionID: to.Ptr(""), - PolicyDefinitionReferenceID: to.Ptr(""), - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - _, err = client.DeleteAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - res, err := client.GetAtManagementGroup(ctx, - "", - "", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - return - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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) - return - } - ctx := context.Background() - client, err := armpolicy.NewSetDefinitionsClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - return - } - pager := client.NewListByManagementGroupPager("", - &armpolicy.SetDefinitionsClientListByManagementGroupOptions{Filter: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - return - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go b/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go index b8d2e611120b..9a6824503f71 100644 --- a/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armpolicy/zz_generated_constants.go @@ -10,7 +10,7 @@ package armpolicy const ( moduleName = "armpolicy" - moduleVersion = "v0.5.0" + moduleVersion = "v0.5.1" ) // AliasPathAttributes - The attributes of the token that the alias path is referring to.