From 83ed3d0ee0376484e0e9696ea193e040927f8eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 1 Jul 2024 18:20:32 +0200 Subject: [PATCH] `managementgroups` - migrate to hashicorp/go-azure-sdk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- internal/clients/client.go | 4 +- .../services/managementgroup/client/client.go | 24 +- .../management_group_data_source.go | 109 +- .../management_group_data_source_test.go | 2 +- .../management_group_resource.go | 250 +- .../management_group_resource_test.go | 17 +- ...nagement_group_subscription_association.go | 53 - ...ent_group_subscription_association_test.go | 75 - .../subscription_association_resource.go | 116 +- .../subscription_association_resource_test.go | 20 +- .../2020-05-01/managementgroups/CHANGELOG.md | 2 - .../2020-05-01/managementgroups/_meta.json | 11 - .../2020-05-01/managementgroups/client.go | 253 -- .../2020-05-01/managementgroups/entities.go | 206 -- .../mgmt/2020-05-01/managementgroups/enums.go | 145 -- .../managementgroups/hierarchysettings.go | 406 ---- .../managementgroups/managementgroups.go | 638 ----- .../2020-05-01/managementgroups/models.go | 2133 ----------------- .../2020-05-01/managementgroups/operations.go | 142 -- .../managementgroups/subscriptions.go | 403 ---- .../2020-05-01/managementgroups/version.go | 19 - .../2020-05-01/managementgroups/README.md | 276 +++ .../2020-05-01/managementgroups/client.go | 26 + .../2020-05-01/managementgroups/constants.go | 92 + .../managementgroups/id_subscription.go | 121 + .../managementgroups/method_createorupdate.go | 104 + .../managementgroups/method_delete.go | 100 + .../2020-05-01/managementgroups/method_get.go | 95 + .../managementgroups/method_getdescendants.go | 134 ++ .../method_hierarchysettingscreateorupdate.go | 60 + .../method_hierarchysettingsdelete.go | 48 + .../method_hierarchysettingsget.go | 56 + .../method_hierarchysettingslist.go | 56 + .../method_hierarchysettingsupdate.go | 60 + .../managementgroups/method_list.go | 133 + .../method_subscriptionscreate.go | 83 + .../method_subscriptionsdelete.go | 76 + .../method_subscriptionsgetsubscription.go | 83 + ...onsgetsubscriptionsundermanagementgroup.go | 106 + .../managementgroups/method_update.go | 88 + .../model_azureasyncoperationresults.go | 12 + .../model_createmanagementgroupchildinfo.go | 12 + .../model_createmanagementgroupdetails.go | 29 + .../model_createmanagementgroupproperties.go | 11 + .../model_createmanagementgrouprequest.go | 11 + .../model_createorupdatesettingsproperties.go | 9 + .../model_createorupdatesettingsrequest.go | 8 + .../model_createparentgroupinfo.go | 10 + .../managementgroups/model_descendantinfo.go | 11 + .../model_descendantinfoproperties.go | 9 + .../model_descendantparentgroupinfo.go | 8 + .../model_hierarchysettings.go | 11 + .../model_hierarchysettingsinfo.go | 11 + .../model_hierarchysettingslist.go | 9 + .../model_hierarchysettingsproperties.go | 10 + .../managementgroups/model_managementgroup.go | 11 + .../model_managementgroupchildinfo.go | 12 + .../model_managementgroupdetails.go | 30 + .../model_managementgroupinfo.go | 11 + .../model_managementgroupinfoproperties.go | 9 + .../model_managementgrouppathelement.go | 9 + .../model_managementgroupproperties.go | 11 + .../managementgroups/model_parentgroupinfo.go | 10 + .../model_patchmanagementgrouprequest.go | 9 + .../model_subscriptionundermanagementgroup.go | 11 + ...scriptionundermanagementgroupproperties.go | 11 + .../2020-05-01/managementgroups/predicates.go | 73 + .../2020-05-01/managementgroups/version.go | 12 + vendor/modules.txt | 2 +- 69 files changed, 2479 insertions(+), 4738 deletions(-) delete mode 100644 internal/services/managementgroup/parse/management_group_subscription_association.go delete mode 100644 internal/services/managementgroup/parse/management_group_subscription_association_test.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/CHANGELOG.md delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/_meta.json delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/client.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/entities.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/enums.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/hierarchysettings.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/managementgroups.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/models.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/operations.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/subscriptions.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/id_subscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_getdescendants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingscreateorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionscreate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscription.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscriptionsundermanagementgroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_update.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_azureasyncoperationresults.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupchildinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgrouprequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createparentgroupinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfoproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantparentgroupinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettings.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupchildinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupdetails.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfoproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgrouppathelement.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_parentgroupinfo.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_patchmanagementgrouprequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroup.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroupproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/version.go diff --git a/internal/clients/client.go b/internal/clients/client.go index 32d90814c388..79e854ed4e9b 100644 --- a/internal/clients/client.go +++ b/internal/clients/client.go @@ -511,7 +511,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error if client.ManagedApplication, err = managedapplication.NewClient(o); err != nil { return fmt.Errorf("building clients for Managed Applications: %+v", err) } - client.ManagementGroups = managementgroup.NewClient(o) + if client.ManagementGroups, err = managementgroup.NewClient(o); err != nil { + return fmt.Errorf("building clients for Management Groups: %+v", err) + } if client.ManagedHSMs, err = managedhsm.NewClient(o); err != nil { return fmt.Errorf("building clients for ManagedHSM: %+v", err) } diff --git a/internal/services/managementgroup/client/client.go b/internal/services/managementgroup/client/client.go index bef6f82bfcf7..289f0930401e 100644 --- a/internal/services/managementgroup/client/client.go +++ b/internal/services/managementgroup/client/client.go @@ -4,24 +4,24 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" // nolint: staticcheck + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - GroupsClient *managementgroups.Client - SubscriptionClient *managementgroups.SubscriptionsClient + GroupsClient *managementgroups.ManagementGroupsClient } -func NewClient(o *common.ClientOptions) *Client { - GroupsClient := managementgroups.NewClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&GroupsClient.Client, o.ResourceManagerAuthorizer) - - SubscriptionClient := managementgroups.NewSubscriptionsClientWithBaseURI(o.ResourceManagerEndpoint) - o.ConfigureClient(&SubscriptionClient.Client, o.ResourceManagerAuthorizer) +func NewClient(o *common.ClientOptions) (*Client, error) { + groupsClient, err := managementgroups.NewManagementGroupsClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building managementgroups client: %+v", err) + } + o.Configure(groupsClient.Client, o.Authorizers.ResourceManager) return &Client{ - GroupsClient: &GroupsClient, - SubscriptionClient: &SubscriptionClient, - } + GroupsClient: groupsClient, + }, nil } diff --git a/internal/services/managementgroup/management_group_data_source.go b/internal/services/managementgroup/management_group_data_source.go index 164952b7715b..9d0e1d867353 100644 --- a/internal/services/managementgroup/management_group_data_source.go +++ b/internal/services/managementgroup/management_group_data_source.go @@ -8,13 +8,15 @@ import ( "fmt" "time" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func dataSourceManagementGroup() *pluginsdk.Resource { @@ -100,9 +102,13 @@ func dataSourceManagementGroupRead(d *pluginsdk.ResourceData, meta interface{}) } } recurse := true - resp, err := client.Get(ctx, groupName, "children", &recurse, "", managementGroupCacheControl) + resp, err := client.Get(ctx, commonids.NewManagementGroupID(groupName), managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: &recurse, + }) if err != nil { - if utils.ResponseWasForbidden(resp.Response) { + if response.WasForbidden(resp.HttpResponse) { return fmt.Errorf("Management Group %q was not found", groupName) } @@ -117,62 +123,65 @@ func dataSourceManagementGroupRead(d *pluginsdk.ResourceData, meta interface{}) tenantScopedID := parse.NewTenantScopedManagementGroupID(tenantID, id.Name) d.Set("tenant_scoped_id", tenantScopedID.TenantScopedID()) - if props := resp.Properties; props != nil { - d.Set("display_name", props.DisplayName) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("display_name", props.DisplayName) - subscriptionIds := []interface{}{} - mgmtgroupIds := []interface{}{} - if err := flattenManagementGroupDataSourceChildren(&subscriptionIds, &mgmtgroupIds, props.Children, false); err != nil { - return fmt.Errorf("flattening direct children resources: %+v", err) - } - if err := d.Set("subscription_ids", subscriptionIds); err != nil { - return fmt.Errorf("setting `subscription_ids`: %v", err) - } - if err := d.Set("management_group_ids", mgmtgroupIds); err != nil { - return fmt.Errorf("setting `management_group_ids`: %v", err) - } + subscriptionIds := []interface{}{} + mgmtgroupIds := []interface{}{} + if err := flattenManagementGroupDataSourceChildren(&subscriptionIds, &mgmtgroupIds, props.Children, false); err != nil { + return fmt.Errorf("flattening direct children resources: %+v", err) + } + if err := d.Set("subscription_ids", subscriptionIds); err != nil { + return fmt.Errorf("setting `subscription_ids`: %v", err) + } + if err := d.Set("management_group_ids", mgmtgroupIds); err != nil { + return fmt.Errorf("setting `management_group_ids`: %v", err) + } - subscriptionIds = []interface{}{} - mgmtgroupIds = []interface{}{} - if err := flattenManagementGroupDataSourceChildren(&subscriptionIds, &mgmtgroupIds, props.Children, true); err != nil { - return fmt.Errorf("flattening all children resources: %+v", err) - } - if err := d.Set("all_subscription_ids", subscriptionIds); err != nil { - return fmt.Errorf("setting `all_subscription_ids`: %v", err) - } - if err := d.Set("all_management_group_ids", mgmtgroupIds); err != nil { - return fmt.Errorf("setting `all_management_group_ids`: %v", err) - } + subscriptionIds = []interface{}{} + mgmtgroupIds = []interface{}{} + if err := flattenManagementGroupDataSourceChildren(&subscriptionIds, &mgmtgroupIds, props.Children, true); err != nil { + return fmt.Errorf("flattening all children resources: %+v", err) + } + if err := d.Set("all_subscription_ids", subscriptionIds); err != nil { + return fmt.Errorf("setting `all_subscription_ids`: %v", err) + } + if err := d.Set("all_management_group_ids", mgmtgroupIds); err != nil { + return fmt.Errorf("setting `all_management_group_ids`: %v", err) + } - parentId := "" - if details := props.Details; details != nil { - if parent := details.Parent; parent != nil { - if pid := parent.ID; pid != nil { - parentId = *pid + parentId := "" + if details := props.Details; details != nil { + if parent := details.Parent; parent != nil { + if pid := parent.Id; pid != nil { + parentId = *pid + } } } + d.Set("parent_management_group_id", parentId) } - d.Set("parent_management_group_id", parentId) } return nil } -func getManagementGroupNameByDisplayName(ctx context.Context, client *managementgroups.Client, displayName string) (string, error) { - iterator, err := client.ListComplete(ctx, managementGroupCacheControl, "") +func getManagementGroupNameByDisplayName(ctx context.Context, client *managementgroups.ManagementGroupsClient, displayName string) (string, error) { + iterator, err := client.ListComplete(ctx, managementgroups.ListOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) if err != nil { return "", fmt.Errorf("listing Management Groups: %+v", err) } var results []string - for iterator.NotDone() { - group := iterator.Value() - if group.DisplayName != nil && *group.DisplayName == displayName && group.Name != nil && *group.Name != "" { - results = append(results, *group.Name) + for _, item := range iterator.Items { + if item.Properties == nil { + continue } - if err := iterator.NextWithContext(ctx); err != nil { - return "", fmt.Errorf("listing Management Groups: %+v", err) + if item.Properties.DisplayName != nil && *item.Properties.DisplayName == displayName && item.Name != nil && *item.Name != "" { + results = append(results, *item.Name) } } @@ -189,28 +198,28 @@ func getManagementGroupNameByDisplayName(ctx context.Context, client *management return results[0], nil } -func flattenManagementGroupDataSourceChildren(subscriptionIds, mgmtgroupIds *[]interface{}, input *[]managementgroups.ChildInfo, recursive bool) error { +func flattenManagementGroupDataSourceChildren(subscriptionIds, mgmtgroupIds *[]interface{}, input *[]managementgroups.ManagementGroupChildInfo, recursive bool) error { if input == nil { return nil } for _, child := range *input { - if child.ID == nil { + if child.Id == nil || child.Type == nil { continue } - switch child.Type { - case managementgroups.Type1MicrosoftManagementmanagementGroups: - id, err := parse.ManagementGroupID(*child.ID) + switch *child.Type { + case managementgroups.ManagementGroupChildTypeMicrosoftPointManagementManagementGroups: + id, err := commonids.ParseManagementGroupID(*child.Id) if err != nil { return fmt.Errorf("Unable to parse child Management Group ID %+v", err) } *mgmtgroupIds = append(*mgmtgroupIds, id.ID()) - case managementgroups.Type1Subscriptions: - id, err := parseManagementGroupSubscriptionID(*child.ID) + case managementgroups.ManagementGroupChildTypeSubscriptions: + id, err := commonids.ParseSubscriptionID(*child.Id) if err != nil { return fmt.Errorf("Unable to parse child Subscription ID %+v", err) } - *subscriptionIds = append(*subscriptionIds, id.subscriptionId) + *subscriptionIds = append(*subscriptionIds, id.SubscriptionId) default: continue } diff --git a/internal/services/managementgroup/management_group_data_source_test.go b/internal/services/managementgroup/management_group_data_source_test.go index ef417a5d7d82..2e54ede7c7d2 100644 --- a/internal/services/managementgroup/management_group_data_source_test.go +++ b/internal/services/managementgroup/management_group_data_source_test.go @@ -43,7 +43,7 @@ func TestAccManagementGroupDataSource_basicByDisplayName(t *testing.T) { }) } -func TestAccManagementGroupDataSource_nestedManagmentGroup(t *testing.T) { +func TestAccManagementGroupDataSource_nestedManagementGroup(t *testing.T) { data := acceptance.BuildTestData(t, "data.azurerm_management_group", "test") r := ManagementGroupDataSource{} diff --git a/internal/services/managementgroup/management_group_resource.go b/internal/services/managementgroup/management_group_resource.go index 7e2555140f45..717ffde44ec0 100644 --- a/internal/services/managementgroup/management_group_resource.go +++ b/internal/services/managementgroup/management_group_resource.go @@ -7,12 +7,13 @@ import ( "context" "fmt" "log" - "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" // nolint: staticcheck "github.com/google/uuid" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/parse" @@ -68,7 +69,7 @@ func resourceManagementGroup() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: validate.ManagementGroupID, + ValidateFunc: commonids.ValidateManagementGroupID, }, "subscription_ids": { @@ -87,7 +88,6 @@ func resourceManagementGroup() *pluginsdk.Resource { func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ManagementGroups.GroupsClient - subscriptionsClient := meta.(*clients.Client).ManagementGroups.SubscriptionClient accountClient := meta.(*clients.Client) ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -102,10 +102,10 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa groupName = uuid.New().String() } - id := parse.NewManagementGroupId(groupName) + id := commonids.NewManagementGroupID(groupName) tenantID := accountClient.Account.TenantId - tenantScopedID := parse.NewTenantScopedManagementGroupID(tenantID, id.Name) + tenantScopedID := parse.NewTenantScopedManagementGroupID(tenantID, id.GroupId) d.Set("tenant_scoped_id", tenantScopedID.TenantScopedID()) parentManagementGroupId := d.Get("parent_management_group_id").(string) @@ -115,14 +115,18 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa recurse := false if d.IsNewResource() { - existing, err := client.Get(ctx, id.Name, "children", &recurse, "", managementGroupCacheControl) + existing, err := client.Get(ctx, id, managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: &recurse, + }) if err != nil { // 403 is returned if group does not exist, bug tracked at: https://github.com/Azure/azure-rest-api-specs/issues/9549 - if !utils.ResponseWasNotFound(existing.Response) && !utils.ResponseWasForbidden(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) && !response.WasForbidden(existing.HttpResponse) { return fmt.Errorf("unable to check for presence of existing Management Group %q: %s", groupName, err) } } - if !utils.ResponseWasNotFound(existing.Response) && !utils.ResponseWasForbidden(existing.Response) { + if !response.WasNotFound(existing.HttpResponse) && !response.WasForbidden(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_management_group", id.ID()) } } @@ -131,29 +135,27 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa properties := managementgroups.CreateManagementGroupRequest{ Name: utils.String(groupName), - CreateManagementGroupProperties: &managementgroups.CreateManagementGroupProperties{ - TenantID: utils.String(armTenantID), + Properties: &managementgroups.CreateManagementGroupProperties{ + TenantId: utils.String(armTenantID), Details: &managementgroups.CreateManagementGroupDetails{ Parent: &managementgroups.CreateParentGroupInfo{ - ID: utils.String(parentManagementGroupId), + Id: utils.String(parentManagementGroupId), }, }, }, } if v := d.Get("display_name"); v != "" { - properties.CreateManagementGroupProperties.DisplayName = utils.String(v.(string)) + properties.Properties.DisplayName = utils.String(v.(string)) } - future, err := client.CreateOrUpdate(ctx, id.Name, properties, managementGroupCacheControl) + err := client.CreateOrUpdateThenPoll(ctx, id, properties, managementgroups.CreateOrUpdateOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) if err != nil { return fmt.Errorf("unable to create Management Group %q: %+v", groupName, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("failed when waiting for creation of Management Group %q: %+v", groupName, err) - } - // We have a potential race condition / consistency issue whereby the implicit role assignment for the SP may not be // completed before the read-back here or an eventually consistent read is creating a temporary 403 error. stateConf := &pluginsdk.StateChangeConf{ @@ -163,7 +165,7 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa Target: []string{ "succeeded", }, - Refresh: managementgroupCreateStateRefreshFunc(ctx, client, groupName), + Refresh: managementGroupCreateStateRefreshFunc(ctx, client, id), Timeout: d.Timeout(pluginsdk.TimeoutCreate), ContinuousTargetOccurence: 5, } @@ -172,7 +174,12 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa return fmt.Errorf("failed waiting for read on Managementgroup %q", groupName) } - resp, err := client.Get(ctx, id.Name, "children", &recurse, "", managementGroupCacheControl) + resp, err := client.Get(ctx, id, managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Filter: pointer.To("children.childType eq Subscription"), + Recurse: &recurse, + }) if err != nil { return fmt.Errorf("unable to retrieve Management Group %q: %+v", groupName, err) } @@ -184,18 +191,22 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa // first remove any which need to be removed if !d.IsNewResource() { log.Printf("[DEBUG] Determine which Subscriptions should be removed from Management Group %q", groupName) - if props := resp.Properties; props != nil { - subscriptionIdsToRemove, err2 := determineManagementGroupSubscriptionsIdsToRemove(props.Children, subscriptionIds) - if err2 != nil { - return fmt.Errorf("unable to determine which subscriptions should be removed from Management Group %q: %+v", groupName, err2) - } + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + subscriptionIdsToRemove, err := determineManagementGroupSubscriptionsIdsToRemove(props.Children, subscriptionIds) + if err != nil { + return fmt.Errorf("unable to determine which subscriptions should be removed from Management Group %q: %+v", groupName, err) + } - for _, subscriptionId := range *subscriptionIdsToRemove { - log.Printf("[DEBUG] De-associating Subscription ID %q from Management Group %q", subscriptionId, groupName) - deleteResp, err2 := subscriptionsClient.Delete(ctx, groupName, subscriptionId, managementGroupCacheControl) - if err2 != nil { - if !response.WasNotFound(deleteResp.Response) { - return fmt.Errorf("unable to de-associate Subscription %q from Management Group %q: %+v", subscriptionId, groupName, err2) + for _, subscriptionId := range *subscriptionIdsToRemove { + log.Printf("[DEBUG] De-associating Subscription ID %q from Management Group %q", subscriptionId, groupName) + deleteResp, err := client.SubscriptionsDelete(ctx, managementgroups.NewSubscriptionID(groupName, subscriptionId), managementgroups.SubscriptionsDeleteOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) + if err != nil { + if !response.WasNotFound(deleteResp.HttpResponse) { + return fmt.Errorf("unable to de-associate Subscription %q from Management Group %q: %+v", subscriptionId, groupName, err) + } } } } @@ -206,7 +217,9 @@ func resourceManagementGroupCreateUpdate(d *pluginsdk.ResourceData, meta interfa log.Printf("[DEBUG] Preparing to assign Subscriptions to Management Group %q", groupName) for _, subscriptionId := range subscriptionIds { log.Printf("[DEBUG] Assigning Subscription ID %q to management group %q", subscriptionId, groupName) - if _, err := subscriptionsClient.Create(ctx, groupName, subscriptionId, managementGroupCacheControl); err != nil { + if _, err := client.SubscriptionsCreate(ctx, managementgroups.NewSubscriptionID(groupName, subscriptionId), managementgroups.SubscriptionsCreateOperationOptions{ + CacheControl: &managementGroupCacheControl, + }); err != nil { return fmt.Errorf("[DEBUG] Error assigning Subscription ID %q to Management Group %q: %+v", subscriptionId, groupName, err) } } @@ -220,19 +233,24 @@ func resourceManagementGroupRead(d *pluginsdk.ResourceData, meta interface{}) er ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagementGroupID(d.Id()) + id, err := commonids.ParseManagementGroupID(d.Id()) if err != nil { return err } tenantID := accountClient.Account.TenantId - tenantScopedID := parse.NewTenantScopedManagementGroupID(tenantID, id.Name) + tenantScopedID := parse.NewTenantScopedManagementGroupID(tenantID, id.GroupId) d.Set("tenant_scoped_id", tenantScopedID.TenantScopedID()) - recurse := utils.Bool(true) - resp, err := client.Get(ctx, id.Name, "children", recurse, "", managementGroupCacheControl) + recurse := pointer.FromBool(true) + resp, err := client.Get(ctx, *id, managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Filter: pointer.To("children.childType eq Subscription"), + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: recurse, + }) if err != nil { - if utils.ResponseWasForbidden(resp.Response) || utils.ResponseWasNotFound(resp.Response) { + if response.WasForbidden(resp.HttpResponse) || response.WasNotFound(resp.HttpResponse) { log.Printf("[INFO] Management Group %q doesn't exist - removing from state", d.Id()) d.SetId("") return nil @@ -241,26 +259,28 @@ func resourceManagementGroupRead(d *pluginsdk.ResourceData, meta interface{}) er return fmt.Errorf("unable to read Management Group %q: %+v", d.Id(), err) } - d.Set("name", id.Name) + d.Set("name", id.GroupId) - if props := resp.Properties; props != nil { - d.Set("display_name", props.DisplayName) + if model := resp.Model; model != nil { + if props := model.Properties; props != nil { + d.Set("display_name", props.DisplayName) - subscriptionIds, err := flattenManagementGroupSubscriptionIds(props.Children) - if err != nil { - return fmt.Errorf("unable to flatten `subscription_ids`: %+v", err) - } - d.Set("subscription_ids", subscriptionIds) + subscriptionIds, err := flattenManagementGroupSubscriptionIds(props.Children) + if err != nil { + return fmt.Errorf("unable to flatten `subscription_ids`: %+v", err) + } + d.Set("subscription_ids", subscriptionIds) - parentId := "" - if details := props.Details; details != nil { - if parent := details.Parent; parent != nil { - if pid := parent.ID; pid != nil { - parentId = *pid + parentId := "" + if details := props.Details; details != nil { + if parent := details.Parent; parent != nil { + if pid := parent.Id; pid != nil { + parentId = *pid + } } } + d.Set("parent_management_group_id", parentId) } - d.Set("parent_management_group_id", parentId) } return nil @@ -268,61 +288,66 @@ func resourceManagementGroupRead(d *pluginsdk.ResourceData, meta interface{}) er func resourceManagementGroupDelete(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).ManagementGroups.GroupsClient - subscriptionsClient := meta.(*clients.Client).ManagementGroups.SubscriptionClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagementGroupID(d.Id()) + id, err := commonids.ParseManagementGroupID(d.Id()) if err != nil { return err } recurse := true - group, err := client.Get(ctx, id.Name, "children", &recurse, "", managementGroupCacheControl) + group, err := client.Get(ctx, *id, managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Filter: pointer.To("children.childType eq Subscription"), + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: &recurse, + }) if err != nil { - if utils.ResponseWasNotFound(group.Response) || utils.ResponseWasForbidden(group.Response) { - log.Printf("[DEBUG] Management Group %q doesn't exist in Azure - nothing to do!", id.Name) + if response.WasNotFound(group.HttpResponse) || response.WasForbidden(group.HttpResponse) { + log.Printf("[DEBUG] Management Group %q doesn't exist in Azure - nothing to do!", id.GroupId) return nil } - return fmt.Errorf("unable to retrieve Management Group %q: %+v", id.Name, err) + return fmt.Errorf("unable to retrieve Management Group %q: %+v", id.GroupId, err) } // before deleting a management group, return any subscriptions to the root management group - if props := group.Properties; props != nil { - if children := props.Children; children != nil { - for _, v := range *children { - if v.ID == nil { - continue - } + if model := group.Model; model != nil { + if props := model.Properties; props != nil { + if children := props.Children; children != nil { + for _, v := range *children { + if v.Id == nil { + continue + } - subscriptionId, err := parseManagementGroupSubscriptionID(*v.ID) - if err != nil { - return fmt.Errorf("unable to parse child Subscription ID %+v", err) - } - if subscriptionId == nil { - continue - } - log.Printf("[DEBUG] De-associating Subscription %q from Management Group %q..", subscriptionId, id.Name) - // NOTE: whilst this says `Delete` it's actually `Deassociate` - which is /really/ helpful - deleteResp, err2 := subscriptionsClient.Delete(ctx, id.Name, subscriptionId.subscriptionId, managementGroupCacheControl) - if err2 != nil { - if !response.WasNotFound(deleteResp.Response) { - return fmt.Errorf("unable to de-associate Subscription %q from Management Group %q: %+v", subscriptionId.subscriptionId, id.Name, err2) + subscriptionId, err := managementgroups.ParseSubscriptionID(*v.Id) + if err != nil { + return fmt.Errorf("unable to parse child Subscription ID %+v", err) + } + if subscriptionId == nil { + continue + } + log.Printf("[DEBUG] De-associating Subscription %q from Management Group %q..", subscriptionId, id.GroupId) + // NOTE: whilst this says `Delete` it's actually `Deassociate` - which is /really/ helpful + deleteResp, err := client.SubscriptionsDelete(ctx, *subscriptionId, managementgroups.SubscriptionsDeleteOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) + if err != nil { + if !response.WasNotFound(deleteResp.HttpResponse) { + return fmt.Errorf("unable to de-associate Subscription %q from Management Group %q: %+v", subscriptionId.SubscriptionId, id.GroupId, err) + } } } } } } - resp, err := client.Delete(ctx, id.Name, managementGroupCacheControl) + err = client.DeleteThenPoll(ctx, *id, managementgroups.DeleteOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) if err != nil { - return fmt.Errorf("unable to delete Management Group %q: %+v", id.Name, err) - } - - err = resp.WaitForCompletionRef(ctx, client.Client) - if err != nil { - return fmt.Errorf("failed when waiting for the deletion of Management Group %q: %+v", id.Name, err) + return fmt.Errorf("unable to delete Management Group %q: %+v", id.GroupId, err) } return nil @@ -340,73 +365,44 @@ func expandManagementGroupSubscriptionIds(input *pluginsdk.Set) []string { return output } -func flattenManagementGroupSubscriptionIds(input *[]managementgroups.ChildInfo) (*pluginsdk.Set, error) { +func flattenManagementGroupSubscriptionIds(input *[]managementgroups.ManagementGroupChildInfo) (*pluginsdk.Set, error) { subscriptionIds := &pluginsdk.Set{F: pluginsdk.HashString} if input == nil { return subscriptionIds, nil } for _, child := range *input { - if child.ID == nil { + if child.Type == nil || *child.Type != managementgroups.ManagementGroupChildTypeSubscriptions || child.Id == nil { continue } - id, err := parseManagementGroupSubscriptionID(*child.ID) + id, err := commonids.ParseSubscriptionID(*child.Id) if err != nil { return nil, fmt.Errorf("unable to parse child Subscription ID %+v", err) } if id != nil { - subscriptionIds.Add(id.subscriptionId) + subscriptionIds.Add(id.SubscriptionId) } } return subscriptionIds, nil } -type subscriptionId struct { - subscriptionId string -} - -func parseManagementGroupSubscriptionID(input string) (*subscriptionId, error) { - // this is either: - // /subscriptions/00000000-0000-0000-0000-000000000000 - - // we skip out the child managementGroup ID's - if strings.HasPrefix(input, "/providers/Microsoft.Management/managementGroups/") { - return nil, nil - } - - components := strings.Split(input, "/") - - if len(components) == 0 { - return nil, fmt.Errorf("subscription Id is empty or not formatted correctly: %s", input) - } - - if len(components) != 3 { - return nil, fmt.Errorf("subscription Id should have 2 segments, got %d: %q", len(components)-1, input) - } - - id := subscriptionId{ - subscriptionId: components[2], - } - return &id, nil -} - -func determineManagementGroupSubscriptionsIdsToRemove(existing *[]managementgroups.ChildInfo, updated []string) (*[]string, error) { +func determineManagementGroupSubscriptionsIdsToRemove(existing *[]managementgroups.ManagementGroupChildInfo, updated []string) (*[]string, error) { subscriptionIdsToRemove := make([]string, 0) if existing == nil { return &subscriptionIdsToRemove, nil } for _, v := range *existing { - if v.ID == nil { + if v.Type == nil || *v.Type != managementgroups.ManagementGroupChildTypeSubscriptions || v.Id == nil { continue } - id, err := parseManagementGroupSubscriptionID(*v.ID) + id, err := commonids.ParseSubscriptionID(*v.Id) if err != nil { - return nil, fmt.Errorf("unable to parse Subscription ID %q: %+v", *v.ID, err) + return nil, fmt.Errorf("unable to parse Subscription ID %q: %+v", *v.Id, err) } // not a Subscription - so let's skip it @@ -416,25 +412,29 @@ func determineManagementGroupSubscriptionsIdsToRemove(existing *[]managementgrou found := false for _, subId := range updated { - if id.subscriptionId == subId { + if id.SubscriptionId == subId { found = true break } } if !found { - subscriptionIdsToRemove = append(subscriptionIdsToRemove, id.subscriptionId) + subscriptionIdsToRemove = append(subscriptionIdsToRemove, id.SubscriptionId) } } return &subscriptionIdsToRemove, nil } -func managementgroupCreateStateRefreshFunc(ctx context.Context, client *managementgroups.Client, groupName string) pluginsdk.StateRefreshFunc { +func managementGroupCreateStateRefreshFunc(ctx context.Context, client *managementgroups.ManagementGroupsClient, id commonids.ManagementGroupId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { - resp, err := client.Get(ctx, groupName, "children", utils.Bool(true), "", managementGroupCacheControl) + resp, err := client.Get(ctx, id, managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(true), + }) if err != nil { - if utils.ResponseWasForbidden(resp.Response) { + if response.WasForbidden(resp.HttpResponse) { return resp, "pending", nil } return resp, "failed", err diff --git a/internal/services/managementgroup/management_group_resource_test.go b/internal/services/managementgroup/management_group_resource_test.go index ec6b51109425..57a4ef2fd912 100644 --- a/internal/services/managementgroup/management_group_resource_test.go +++ b/internal/services/managementgroup/management_group_resource_test.go @@ -9,10 +9,12 @@ import ( "os" "testing" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -184,17 +186,20 @@ func TestAccManagementGroup_withSubscriptions(t *testing.T) { } func (ManagementGroupResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ManagementGroupID(state.ID) + id, err := commonids.ParseManagementGroupID(state.ID) if err != nil { return nil, err } - - resp, err := clients.ManagementGroups.GroupsClient.Get(ctx, id.Name, "children", utils.Bool(true), "", "no-cache") + resp, err := clients.ManagementGroups.GroupsClient.Get(ctx, *id, managementgroups.GetOperationOptions{ + CacheControl: pointer.FromString("no-cache"), + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(false), + }) if err != nil { - return nil, fmt.Errorf("retrieving Management Group %s: %v", id.Name, err) + return nil, fmt.Errorf("retrieving Management Group %s: %v", id.GroupId, err) } - return utils.Bool(resp.Properties != nil), nil + return utils.Bool(resp.Model.Properties != nil), nil } func (r ManagementGroupResource) basic() string { diff --git a/internal/services/managementgroup/parse/management_group_subscription_association.go b/internal/services/managementgroup/parse/management_group_subscription_association.go deleted file mode 100644 index 8c465b08aaff..000000000000 --- a/internal/services/managementgroup/parse/management_group_subscription_association.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "fmt" - - "github.com/hashicorp/go-uuid" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" -) - -type ManagementGroupSubscriptionAssociationId struct { - ManagementGroup string - SubscriptionId string -} - -func NewManagementGroupSubscriptionAssociationID(managementGroupName string, subscriptionId string) ManagementGroupSubscriptionAssociationId { - return ManagementGroupSubscriptionAssociationId{ - ManagementGroup: managementGroupName, - SubscriptionId: subscriptionId, - } -} - -func (r ManagementGroupSubscriptionAssociationId) ID() string { - managementGroupSubscriptionAssociationFmt := "/managementGroup/%s/subscription/%s" - return fmt.Sprintf(managementGroupSubscriptionAssociationFmt, r.ManagementGroup, r.SubscriptionId) -} - -func ManagementGroupSubscriptionAssociationID(input string) (*ManagementGroupSubscriptionAssociationId, error) { - id, err := azure.ParseAzureResourceIDWithoutSubscription(input) - if err != nil { - return nil, err - } - - managementGroup, err := id.PopSegment("managementGroup") - if err != nil { - return nil, err - } - - subscriptionId, err := id.PopSegment("subscription") - if err != nil { - return nil, err - } - if _, err := uuid.ParseUUID(subscriptionId); err != nil { - return nil, fmt.Errorf("expected subscription ID to be UUID, got %q", subscriptionId) - } - - return &ManagementGroupSubscriptionAssociationId{ - ManagementGroup: managementGroup, - SubscriptionId: subscriptionId, - }, nil -} diff --git a/internal/services/managementgroup/parse/management_group_subscription_association_test.go b/internal/services/managementgroup/parse/management_group_subscription_association_test.go deleted file mode 100644 index 3d96b317ac45..000000000000 --- a/internal/services/managementgroup/parse/management_group_subscription_association_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import "testing" - -func TestManagementGroupSubscriptionAssociationID(t *testing.T) { - testData := []struct { - Name string - Input string - Error bool - Expected *ManagementGroupSubscriptionAssociationId - }{ - { - Name: "Empty", - Input: "", - Error: true, - }, - { - Name: "Missing Subscription", - Input: "/managementGroup/MyManagementGroup", - Error: true, - }, - { - Name: "Missing Subscription Id", - Input: "/managementGroup/MyManagementGroup/subscription/", - Error: true, - }, - { - Name: "Missing Management Group", - Input: "/subscription/12345678-1234-1234-1234-123456789012", - Error: true, - }, - { - Name: "Missing Management Group Name", - Input: "/managementGroup/subscription/12345678-1234-1234-1234-123456789012", - Error: true, - }, - { - Name: "Wrong Case", - Input: "/MANAGEMENTGROUP/MyManagementGroup/SUBSCRIPTION/12345678-1234-1234-1234-123456789012", - Error: true, - }, - { - Name: "Valid", - Input: "/managementGroup/MyManagementGroup/subscription/12345678-1234-1234-1234-123456789012", - Expected: &ManagementGroupSubscriptionAssociationId{ - ManagementGroup: "MyManagementGroup", - SubscriptionId: "12345678-1234-1234-1234-123456789012", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) - - actual, err := ManagementGroupSubscriptionAssociationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.ManagementGroup != v.Expected.ManagementGroup { - t.Fatalf("Expected %q but got %q for Name", v.Expected.ManagementGroup, actual.ManagementGroup) - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for Name", v.Expected.SubscriptionId, actual.SubscriptionId) - } - } -} diff --git a/internal/services/managementgroup/subscription_association_resource.go b/internal/services/managementgroup/subscription_association_resource.go index 1a57a9cf405d..c6cab7a165c3 100644 --- a/internal/services/managementgroup/subscription_association_resource.go +++ b/internal/services/managementgroup/subscription_association_resource.go @@ -10,15 +10,16 @@ import ( "strings" "time" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceManagementGroupSubscriptionAssociation() *pluginsdk.Resource { @@ -34,7 +35,7 @@ func resourceManagementGroupSubscriptionAssociation() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.ManagementGroupSubscriptionAssociationID(id) + _, err := managementgroups.ParseSubscriptionID(id) return err }), @@ -57,8 +58,7 @@ func resourceManagementGroupSubscriptionAssociation() *pluginsdk.Resource { } func resourceManagementGroupSubscriptionAssociationCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ManagementGroups.SubscriptionClient - groupsClient := meta.(*clients.Client).ManagementGroups.GroupsClient + client := meta.(*clients.Client).ManagementGroups.GroupsClient ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() @@ -72,29 +72,35 @@ func resourceManagementGroupSubscriptionAssociationCreate(d *pluginsdk.ResourceD return err } - id := parse.NewManagementGroupSubscriptionAssociationID(managementGroupId.Name, subscriptionId.SubscriptionId) + id := managementgroups.NewSubscriptionID(managementGroupId.Name, subscriptionId.SubscriptionId) - existing, err := groupsClient.Get(ctx, id.ManagementGroup, "children", utils.Bool(false), "", "") + existing, err := client.Get(ctx, commonids.NewManagementGroupID(id.GroupId), managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(false), + }) if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("failed checking Management Group %q: %+v", id.ManagementGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("failed checking Management Group %q: %+v", id.GroupId, err) } } - props := existing.Properties - if props == nil { - return fmt.Errorf("could not read properties for Management Group %q to check if Subscription Association for %q already exists", id.ManagementGroup, id.SubscriptionId) - } + if model := existing.Model; model != nil { + props := model.Properties + if props == nil { + return fmt.Errorf("could not read properties for Management Group %q to check if Subscription Association for %q already exists", id.GroupId, id.SubscriptionId) + } - if props.Children != nil { - for _, v := range *props.Children { - if v.Type == managementgroups.Type1Subscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { - return tf.ImportAsExistsError("azurerm_management_group_subscription_association", id.ID()) + if props.Children != nil { + for _, v := range *props.Children { + if v.Type != nil && *v.Type == managementgroups.ManagementGroupChildTypeSubscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { + return tf.ImportAsExistsError("azurerm_management_group_subscription_association", id.ID()) + } } } } - if _, err := client.Create(ctx, id.ManagementGroup, id.SubscriptionId, ""); err != nil { + if _, err := client.SubscriptionsCreate(ctx, id, managementgroups.SubscriptionsCreateOperationOptions{}); err != nil { return fmt.Errorf("creating Management Group Subscription Association between %q and %q: %+v", managementGroupId.Name, subscriptionId, err) } @@ -109,54 +115,60 @@ func resourceManagementGroupSubscriptionAssociationRead(d *pluginsdk.ResourceDat ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagementGroupSubscriptionAssociationID(d.Id()) + id, err := managementgroups.ParseSubscriptionID(d.Id()) if err != nil { return err } - managementGroup, err := client.Get(ctx, id.ManagementGroup, "children", utils.Bool(false), "", "") + managementGroup, err := client.Get(ctx, commonids.NewManagementGroupID(id.GroupId), managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(false), + }) if err != nil { - return fmt.Errorf("reading Management Group %q for Subscription Associations: %+v", id.ManagementGroup, err) + return fmt.Errorf("reading Management Group %q for Subscription Associations: %+v", id.GroupId, err) } found := false - if props := managementGroup.Properties; props != nil { - if props.Children != nil { - for _, v := range *props.Children { - if v.Type == managementgroups.Type1Subscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { - found = true + if model := managementGroup.Model; model != nil { + if props := model.Properties; props != nil { + if props.Children != nil { + for _, v := range *props.Children { + if v.Type != nil && *v.Type == managementgroups.ManagementGroupChildTypeSubscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { + found = true + } } } - } - if !found { - log.Printf("[INFO] Subscription %q not found in Management group %q, removing from state", id.SubscriptionId, id.ManagementGroup) - d.SetId("") - return nil - } + if !found { + log.Printf("[INFO] Subscription %q not found in Management group %q, removing from state", id.SubscriptionId, id.GroupId) + d.SetId("") + return nil + } - managementGroupId := parse.NewManagementGroupId(id.ManagementGroup) - d.Set("management_group_id", managementGroupId.ID()) - subscriptionId := commonids.NewSubscriptionID(id.SubscriptionId) - d.Set("subscription_id", subscriptionId.ID()) + managementGroupId := parse.NewManagementGroupId(id.GroupId) + d.Set("management_group_id", managementGroupId.ID()) + subscriptionId := commonids.NewSubscriptionID(id.SubscriptionId) + d.Set("subscription_id", subscriptionId.ID()) + } } return nil } func resourceManagementGroupSubscriptionAssociationDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).ManagementGroups.SubscriptionClient + client := meta.(*clients.Client).ManagementGroups.GroupsClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.ManagementGroupSubscriptionAssociationID(d.Id()) + id, err := managementgroups.ParseSubscriptionID(d.Id()) if err != nil { return err } - resp, err := client.Delete(ctx, id.ManagementGroup, id.SubscriptionId, "") + resp, err := client.SubscriptionsDelete(ctx, *id, managementgroups.SubscriptionsDeleteOperationOptions{}) if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("deleting Management Group Subscription Association between Management Group %q and Subscription %q: %+v", id.ManagementGroup, id.SubscriptionId, err) + if !response.WasNotFound(resp.HttpResponse) { + return fmt.Errorf("deleting Management Group Subscription Association between Management Group %q and Subscription %q: %+v", id.GroupId, id.SubscriptionId, err) } } @@ -183,18 +195,24 @@ func resourceManagementGroupSubscriptionAssociationDelete(d *pluginsdk.ResourceD return nil } -func subscriptionAssociationRefreshFunc(ctx context.Context, client *managementgroups.Client, id parse.ManagementGroupSubscriptionAssociationId) pluginsdk.StateRefreshFunc { +func subscriptionAssociationRefreshFunc(ctx context.Context, client *managementgroups.ManagementGroupsClient, id managementgroups.SubscriptionId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { - managementGroup, err := client.Get(ctx, id.ManagementGroup, "children", utils.Bool(false), "", "") + managementGroup, err := client.Get(ctx, commonids.NewManagementGroupID(id.GroupId), managementgroups.GetOperationOptions{ + CacheControl: &managementGroupCacheControl, + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(false), + }) if err != nil { - return nil, "", fmt.Errorf("reading Management Group %q for Subscription Associations: %+v", id.ManagementGroup, err) + return nil, "", fmt.Errorf("reading Management Group %q for Subscription Associations: %+v", id.GroupId, err) } - if props := managementGroup.Properties; props != nil && props.Children != nil { - for _, v := range *props.Children { - if v.Type == managementgroups.Type1Subscriptions { - if v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { - return managementGroup, "Exists", nil + if model := managementGroup.Model; model != nil { + if props := model.Properties; props != nil && props.Children != nil { + for _, v := range *props.Children { + if v.Type != nil && *v.Type == managementgroups.ManagementGroupChildTypeSubscriptions { + if v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { + return managementGroup, "Exists", nil + } } } } diff --git a/internal/services/managementgroup/subscription_association_resource_test.go b/internal/services/managementgroup/subscription_association_resource_test.go index 9172b325895b..4f5b799ab927 100644 --- a/internal/services/managementgroup/subscription_association_resource_test.go +++ b/internal/services/managementgroup/subscription_association_resource_test.go @@ -10,11 +10,12 @@ import ( "strings" "testing" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" // nolint: staticcheck + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/managementgroup/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/utils" ) @@ -109,23 +110,28 @@ resource "azurerm_management_group_subscription_association" "import" { } func (r ManagementGroupSubscriptionAssociation) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.ManagementGroupSubscriptionAssociationID(state.ID) + id, err := managementgroups.ParseSubscriptionID(state.ID) if err != nil { return nil, err } - resp, err := client.ManagementGroups.GroupsClient.Get(ctx, id.ManagementGroup, "children", utils.Bool(false), "", "no-cache") + resp, err := client.ManagementGroups.GroupsClient.Get(ctx, commonids.NewManagementGroupID(id.GroupId), managementgroups.GetOperationOptions{ + CacheControl: pointer.FromString("no-cache"), + Expand: pointer.To(managementgroups.ExpandChildren), + Recurse: pointer.FromBool(false), + }) + if err != nil { return nil, fmt.Errorf("retrieving Management Group to check for Subscription Association: %+v", err) } - if resp.Properties == nil || resp.Properties.Children == nil { + if resp.Model == nil || resp.Model.Properties == nil || resp.Model.Properties.Children == nil { return utils.Bool(false), nil } present := false - for _, v := range *resp.Children { - if v.Type == managementgroups.Type1Subscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { + for _, v := range *resp.Model.Properties.Children { + if v.Type != nil && *v.Type == managementgroups.ManagementGroupChildTypeSubscriptions && v.Name != nil && strings.EqualFold(*v.Name, id.SubscriptionId) { present = true } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/CHANGELOG.md deleted file mode 100644 index 52911e4cc5e4..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/CHANGELOG.md +++ /dev/null @@ -1,2 +0,0 @@ -# Change History - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/_meta.json deleted file mode 100644 index 05f40085dd2e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "92ab22b49bd085116af0c61fada2c6c360702e9e", - "readme": "/_/azure-rest-api-specs/specification/managementgroups/resource-manager/readme.md", - "tag": "package-2020-05", - "use": "@microsoft.azure/autorest.go@2.1.187", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2020-05 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/managementgroups/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/client.go deleted file mode 100644 index d856a1204a17..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/client.go +++ /dev/null @@ -1,253 +0,0 @@ -// Deprecated: Please note, this package has been deprecated. A replacement package is available [github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups). We strongly encourage you to upgrade to continue receiving updates. See [Migration Guide](https://aka.ms/azsdk/golang/t2/migration) for guidance on upgrading. Refer to our [deprecation policy](https://azure.github.io/azure-sdk/policies_support.html) for more details. -// -// Package managementgroups implements the Azure ARM Managementgroups service API version 2020-05-01. -// -// The Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -// -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -const ( - // DefaultBaseURI is the default URI used for the service Managementgroups - DefaultBaseURI = "https://management.azure.com" -) - -// BaseClient is the base client for Managementgroups. -type BaseClient struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the BaseClient client. -func New() BaseClient { - return NewWithBaseURI(DefaultBaseURI) -} - -// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with -// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWithBaseURI(baseURI string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - } -} - -// CheckNameAvailability checks if the specified management group name is valid and unique -// Parameters: -// checkNameAvailabilityRequest - management group name availability check parameters. -func (client BaseClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (result CheckNameAvailabilityResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.CheckNameAvailability") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityRequest) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - resp, err := client.CheckNameAvailabilitySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckNameAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "CheckNameAvailability", resp, "Failure responding to request") - return - } - - return -} - -// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. -func (client BaseClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/checkNameAvailability"), - autorest.WithJSON(checkNameAvailabilityRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (client BaseClient) CheckNameAvailabilityResponder(resp *http.Response) (result CheckNameAvailabilityResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// StartTenantBackfill starts backfilling subscriptions for the Tenant. -func (client BaseClient) StartTenantBackfill(ctx context.Context) (result TenantBackfillStatusResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.StartTenantBackfill") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.StartTenantBackfillPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", nil, "Failure preparing request") - return - } - - resp, err := client.StartTenantBackfillSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", resp, "Failure sending request") - return - } - - result, err = client.StartTenantBackfillResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "StartTenantBackfill", resp, "Failure responding to request") - return - } - - return -} - -// StartTenantBackfillPreparer prepares the StartTenantBackfill request. -func (client BaseClient) StartTenantBackfillPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/startTenantBackfill"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// StartTenantBackfillSender sends the StartTenantBackfill request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) StartTenantBackfillSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// StartTenantBackfillResponder handles the response to the StartTenantBackfill request. The method always -// closes the http.Response Body. -func (client BaseClient) StartTenantBackfillResponder(resp *http.Response) (result TenantBackfillStatusResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// TenantBackfillStatus gets tenant backfill status -func (client BaseClient) TenantBackfillStatus(ctx context.Context) (result TenantBackfillStatusResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/BaseClient.TenantBackfillStatus") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.TenantBackfillStatusPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", nil, "Failure preparing request") - return - } - - resp, err := client.TenantBackfillStatusSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", resp, "Failure sending request") - return - } - - result, err = client.TenantBackfillStatusResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.BaseClient", "TenantBackfillStatus", resp, "Failure responding to request") - return - } - - return -} - -// TenantBackfillStatusPreparer prepares the TenantBackfillStatus request. -func (client BaseClient) TenantBackfillStatusPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/tenantBackfillStatus"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// TenantBackfillStatusSender sends the TenantBackfillStatus request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) TenantBackfillStatusSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// TenantBackfillStatusResponder handles the response to the TenantBackfillStatus request. The method always -// closes the http.Response Body. -func (client BaseClient) TenantBackfillStatusResponder(resp *http.Response) (result TenantBackfillStatusResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/entities.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/entities.go deleted file mode 100644 index 33eb48546257..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/entities.go +++ /dev/null @@ -1,206 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// EntitiesClient is the the Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -type EntitiesClient struct { - BaseClient -} - -// NewEntitiesClient creates an instance of the EntitiesClient client. -func NewEntitiesClient() EntitiesClient { - return NewEntitiesClientWithBaseURI(DefaultBaseURI) -} - -// NewEntitiesClientWithBaseURI creates an instance of the EntitiesClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewEntitiesClientWithBaseURI(baseURI string) EntitiesClient { - return EntitiesClient{NewWithBaseURI(baseURI)} -} - -// List list all entities (Management Groups, Subscriptions, etc.) for the authenticated user. -// Parameters: -// skiptoken - page continuation token is only used if a previous operation returned a partial result. -// If a previous response contains a nextLink element, the value of the nextLink element will include a token -// parameter that specifies a starting point to use for subsequent calls. -// skip - number of entities to skip over when retrieving results. Passing this in will override $skipToken. -// top - number of elements to return when retrieving results. Passing this in will override $skipToken. -// selectParameter - this parameter specifies the fields to include in the response. Can include any -// combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. -// '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter -// can override select in $skipToken. -// search - the $search parameter is used in conjunction with the $filter parameter to return three different -// outputs depending on the parameter passed in. -// With $search=AllowedParents the API will return the entity info of all groups that the requested entity will -// be able to reparent to as determined by the user's permissions. -// With $search=AllowedChildren the API will return the entity info of all entities that can be added as -// children of the requested entity. -// With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that -// the user has either direct access to or indirect access via one of their descendants. -// With $search=ParentOnly the API will return only the group if the user has access to at least one of the -// descendants of the group. -// With $search=ChildrenOnly the API will return only the first level of children of the group entity info -// specified in $filter. The user must have direct access to the children entities or one of it's descendants -// for it to show up in the results. -// filter - the filter parameter allows you to filter on the the name or display name fields. You can check for -// equality on the name field (e.g. name eq '{entityName}') and you can check for substrings on either the -// name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, -// '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' fields are checked case -// insensitively. -// view - the view parameter allows clients to filter the type of data that is returned by the getEntities -// call. -// groupName - a filter which allows the get entities call to focus on a particular group (i.e. "$filter=name -// eq 'groupName'") -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client EntitiesClient) List(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (result EntityListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.List") - defer func() { - sc := -1 - if result.elr.Response.Response != nil { - sc = result.elr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, skiptoken, skip, top, selectParameter, search, filter, view, groupName, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.elr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure sending request") - return - } - - result.elr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "List", resp, "Failure responding to request") - return - } - if result.elr.hasNextLink() && result.elr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client EntitiesClient) ListPreparer(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } - if skip != nil { - queryParameters["$skip"] = autorest.Encode("query", *skip) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - if len(selectParameter) > 0 { - queryParameters["$select"] = autorest.Encode("query", selectParameter) - } - if len(string(search)) > 0 { - queryParameters["$search"] = autorest.Encode("query", search) - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - if len(string(view)) > 0 { - queryParameters["$view"] = autorest.Encode("query", view) - } - if len(groupName) > 0 { - queryParameters["groupName"] = autorest.Encode("query", groupName) - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/getEntities"), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client EntitiesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client EntitiesClient) ListResponder(resp *http.Response) (result EntityListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client EntitiesClient) listNextResults(ctx context.Context, lastResults EntityListResult) (result EntityListResult, err error) { - req, err := lastResults.entityListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.EntitiesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client EntitiesClient) ListComplete(ctx context.Context, skiptoken string, skip *int32, top *int32, selectParameter string, search string, filter string, view string, groupName string, cacheControl string) (result EntityListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, skiptoken, skip, top, selectParameter, search, filter, view, groupName, cacheControl) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/enums.go deleted file mode 100644 index f50d78f62609..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/enums.go +++ /dev/null @@ -1,145 +0,0 @@ -package managementgroups - -// 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. - -// InheritedPermissions enumerates the values for inherited permissions. -type InheritedPermissions string - -const ( - // Delete ... - Delete InheritedPermissions = "delete" - // Edit ... - Edit InheritedPermissions = "edit" - // Noaccess ... - Noaccess InheritedPermissions = "noaccess" - // View ... - View InheritedPermissions = "view" -) - -// PossibleInheritedPermissionsValues returns an array of possible values for the InheritedPermissions const type. -func PossibleInheritedPermissionsValues() []InheritedPermissions { - return []InheritedPermissions{Delete, Edit, Noaccess, View} -} - -// Permissions enumerates the values for permissions. -type Permissions string - -const ( - // PermissionsDelete ... - PermissionsDelete Permissions = "delete" - // PermissionsEdit ... - PermissionsEdit Permissions = "edit" - // PermissionsNoaccess ... - PermissionsNoaccess Permissions = "noaccess" - // PermissionsView ... - PermissionsView Permissions = "view" -) - -// PossiblePermissionsValues returns an array of possible values for the Permissions const type. -func PossiblePermissionsValues() []Permissions { - return []Permissions{PermissionsDelete, PermissionsEdit, PermissionsNoaccess, PermissionsView} -} - -// Permissions1 enumerates the values for permissions 1. -type Permissions1 string - -const ( - // Permissions1Delete ... - Permissions1Delete Permissions1 = "delete" - // Permissions1Edit ... - Permissions1Edit Permissions1 = "edit" - // Permissions1Noaccess ... - Permissions1Noaccess Permissions1 = "noaccess" - // Permissions1View ... - Permissions1View Permissions1 = "view" -) - -// PossiblePermissions1Values returns an array of possible values for the Permissions1 const type. -func PossiblePermissions1Values() []Permissions1 { - return []Permissions1{Permissions1Delete, Permissions1Edit, Permissions1Noaccess, Permissions1View} -} - -// Reason enumerates the values for reason. -type Reason string - -const ( - // AlreadyExists ... - AlreadyExists Reason = "AlreadyExists" - // Invalid ... - Invalid Reason = "Invalid" -) - -// PossibleReasonValues returns an array of possible values for the Reason const type. -func PossibleReasonValues() []Reason { - return []Reason{AlreadyExists, Invalid} -} - -// Status enumerates the values for status. -type Status string - -const ( - // Cancelled ... - Cancelled Status = "Cancelled" - // Completed ... - Completed Status = "Completed" - // Failed ... - Failed Status = "Failed" - // NotStarted ... - NotStarted Status = "NotStarted" - // NotStartedButGroupsExist ... - NotStartedButGroupsExist Status = "NotStartedButGroupsExist" - // Started ... - Started Status = "Started" -) - -// PossibleStatusValues returns an array of possible values for the Status const type. -func PossibleStatusValues() []Status { - return []Status{Cancelled, Completed, Failed, NotStarted, NotStartedButGroupsExist, Started} -} - -// Type enumerates the values for type. -type Type string - -const ( - // MicrosoftManagementmanagementGroups ... - MicrosoftManagementmanagementGroups Type = "Microsoft.Management/managementGroups" -) - -// PossibleTypeValues returns an array of possible values for the Type const type. -func PossibleTypeValues() []Type { - return []Type{MicrosoftManagementmanagementGroups} -} - -// Type1 enumerates the values for type 1. -type Type1 string - -const ( - // Type1MicrosoftManagementmanagementGroups ... - Type1MicrosoftManagementmanagementGroups Type1 = "Microsoft.Management/managementGroups" - // Type1Subscriptions ... - Type1Subscriptions Type1 = "/subscriptions" -) - -// PossibleType1Values returns an array of possible values for the Type1 const type. -func PossibleType1Values() []Type1 { - return []Type1{Type1MicrosoftManagementmanagementGroups, Type1Subscriptions} -} - -// Type2 enumerates the values for type 2. -type Type2 string - -const ( - // Type2MicrosoftManagementmanagementGroups ... - Type2MicrosoftManagementmanagementGroups Type2 = "Microsoft.Management/managementGroups" - // Type2Subscriptions ... - Type2Subscriptions Type2 = "/subscriptions" -) - -// PossibleType2Values returns an array of possible values for the Type2 const type. -func PossibleType2Values() []Type2 { - return []Type2{Type2MicrosoftManagementmanagementGroups, Type2Subscriptions} -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/hierarchysettings.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/hierarchysettings.go deleted file mode 100644 index 50c7a2917922..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/hierarchysettings.go +++ /dev/null @@ -1,406 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// HierarchySettingsClient is the the Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -type HierarchySettingsClient struct { - BaseClient -} - -// NewHierarchySettingsClient creates an instance of the HierarchySettingsClient client. -func NewHierarchySettingsClient() HierarchySettingsClient { - return NewHierarchySettingsClientWithBaseURI(DefaultBaseURI) -} - -// NewHierarchySettingsClientWithBaseURI creates an instance of the HierarchySettingsClient client using a custom -// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure -// stack). -func NewHierarchySettingsClientWithBaseURI(baseURI string) HierarchySettingsClient { - return HierarchySettingsClient{NewWithBaseURI(baseURI)} -} - -// CreateOrUpdate creates or updates the hierarchy settings defined at the Management Group level. -// Parameters: -// groupID - management Group ID. -// createTenantSettingsRequest - tenant level settings request parameter. -func (client HierarchySettingsClient) CreateOrUpdate(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (result HierarchySettings, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.CreateOrUpdate") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, groupID, createTenantSettingsRequest) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "CreateOrUpdate", resp, "Failure responding to request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client HierarchySettingsClient) CreateOrUpdatePreparer(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters), - autorest.WithJSON(createTenantSettingsRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client HierarchySettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client HierarchySettingsClient) CreateOrUpdateResponder(resp *http.Response) (result HierarchySettings, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes the hierarchy settings defined at the Management Group level. -// Parameters: -// groupID - management Group ID. -func (client HierarchySettingsClient) Delete(ctx context.Context, groupID string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, groupID) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client HierarchySettingsClient) DeletePreparer(ctx context.Context, groupID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client HierarchySettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client HierarchySettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets the hierarchy settings defined at the Management Group level. Settings can only be set on the root -// Management Group of the hierarchy. -// Parameters: -// groupID - management Group ID. -func (client HierarchySettingsClient) Get(ctx context.Context, groupID string) (result HierarchySettings, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, groupID) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client HierarchySettingsClient) GetPreparer(ctx context.Context, groupID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client HierarchySettingsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client HierarchySettingsClient) GetResponder(resp *http.Response) (result HierarchySettings, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets all the hierarchy settings defined at the Management Group level. Settings can only be set on the root -// Management Group of the hierarchy. -// Parameters: -// groupID - management Group ID. -func (client HierarchySettingsClient) List(ctx context.Context, groupID string) (result HierarchySettingsList, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListPreparer(ctx, groupID) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "List", resp, "Failure responding to request") - return - } - - return -} - -// ListPreparer prepares the List request. -func (client HierarchySettingsClient) ListPreparer(ctx context.Context, groupID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client HierarchySettingsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client HierarchySettingsClient) ListResponder(resp *http.Response) (result HierarchySettingsList, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Update updates the hierarchy settings defined at the Management Group level. -// Parameters: -// groupID - management Group ID. -// createTenantSettingsRequest - tenant level settings request parameter. -func (client HierarchySettingsClient) Update(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (result HierarchySettings, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/HierarchySettingsClient.Update") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UpdatePreparer(ctx, groupID, createTenantSettingsRequest) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.HierarchySettingsClient", "Update", resp, "Failure responding to request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client HierarchySettingsClient) UpdatePreparer(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/settings/default", pathParameters), - autorest.WithJSON(createTenantSettingsRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client HierarchySettingsClient) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client HierarchySettingsClient) UpdateResponder(resp *http.Response) (result HierarchySettings, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/managementgroups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/managementgroups.go deleted file mode 100644 index 182af71618f2..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/managementgroups.go +++ /dev/null @@ -1,638 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// Client is the the Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -type Client struct { - BaseClient -} - -// NewClient creates an instance of the Client client. -func NewClient() Client { - return NewClientWithBaseURI(DefaultBaseURI) -} - -// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint. Use this when interacting -// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewClientWithBaseURI(baseURI string) Client { - return Client{NewWithBaseURI(baseURI)} -} - -// CreateOrUpdate create or update a management group. -// If a management group is already created and a subsequent create request is issued with different properties, the -// management group properties will be updated. -// Parameters: -// groupID - management Group ID. -// createManagementGroupRequest - management group creation parameters. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client Client) CreateOrUpdate(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, cacheControl string) (result CreateOrUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreateOrUpdatePreparer(ctx, groupID, createManagementGroupRequest, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = client.CreateOrUpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "CreateOrUpdate", result.Response(), "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client Client) CreateOrUpdatePreparer(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - createManagementGroupRequest.ID = nil - createManagementGroupRequest.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), - autorest.WithJSON(createManagementGroupRequest), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client Client) CreateOrUpdateResponder(resp *http.Response) (result SetObject, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByUnmarshallingJSON(&result.Value), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete management group. -// If a management group contains child resources, the request will fail. -// Parameters: -// groupID - management Group ID. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client Client) Delete(ctx context.Context, groupID string, cacheControl string) (result DeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete") - defer func() { - sc := -1 - if result.FutureAPI != nil && result.FutureAPI.Response() != nil { - sc = result.FutureAPI.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, groupID, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, groupID string, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) { - var resp *http.Response - future.FutureAPI = &azure.Future{} - resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if err != nil { - return - } - var azf azure.Future - azf, err = azure.NewFutureFromResponse(resp) - future.FutureAPI = &azf - future.Result = future.result - return -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result AzureAsyncOperationResults, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get the details of the management group. -// Parameters: -// groupID - management Group ID. -// expand - the $expand=children query string parameter allows clients to request inclusion of children in the -// response payload. $expand=path includes the path from the root group to the current group. -// recurse - the $recurse=true query string parameter allows clients to request inclusion of entire hierarchy -// in the response payload. Note that $expand=children must be passed up if $recurse is set to true. -// filter - a filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType -// ne Subscription') -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client Client) Get(ctx context.Context, groupID string, expand string, recurse *bool, filter string, cacheControl string) (result ManagementGroup, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, groupID, expand, recurse, filter, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, groupID string, expand string, recurse *bool, filter string, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(string(expand)) > 0 { - queryParameters["$expand"] = autorest.Encode("query", expand) - } - if recurse != nil { - queryParameters["$recurse"] = autorest.Encode("query", *recurse) - } - if len(filter) > 0 { - queryParameters["$filter"] = autorest.Encode("query", filter) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client Client) GetResponder(resp *http.Response) (result ManagementGroup, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetDescendants list all entities that descend from a management group. -// Parameters: -// groupID - management Group ID. -// skiptoken - page continuation token is only used if a previous operation returned a partial result. -// If a previous response contains a nextLink element, the value of the nextLink element will include a token -// parameter that specifies a starting point to use for subsequent calls. -// top - number of elements to return when retrieving results. Passing this in will override $skipToken. -func (client Client) GetDescendants(ctx context.Context, groupID string, skiptoken string, top *int32) (result DescendantListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetDescendants") - defer func() { - sc := -1 - if result.dlr.Response.Response != nil { - sc = result.dlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.getDescendantsNextResults - req, err := client.GetDescendantsPreparer(ctx, groupID, skiptoken, top) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "GetDescendants", nil, "Failure preparing request") - return - } - - resp, err := client.GetDescendantsSender(req) - if err != nil { - result.dlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.Client", "GetDescendants", resp, "Failure sending request") - return - } - - result.dlr, err = client.GetDescendantsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "GetDescendants", resp, "Failure responding to request") - return - } - if result.dlr.hasNextLink() && result.dlr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// GetDescendantsPreparer prepares the GetDescendants request. -func (client Client) GetDescendantsPreparer(ctx context.Context, groupID string, skiptoken string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } - if top != nil { - queryParameters["$top"] = autorest.Encode("query", *top) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/descendants", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetDescendantsSender sends the GetDescendants request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetDescendantsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// GetDescendantsResponder handles the response to the GetDescendants request. The method always -// closes the http.Response Body. -func (client Client) GetDescendantsResponder(resp *http.Response) (result DescendantListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// getDescendantsNextResults retrieves the next set of results, if any. -func (client Client) getDescendantsNextResults(ctx context.Context, lastResults DescendantListResult) (result DescendantListResult, err error) { - req, err := lastResults.descendantListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "managementgroups.Client", "getDescendantsNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.GetDescendantsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "managementgroups.Client", "getDescendantsNextResults", resp, "Failure sending next results request") - } - result, err = client.GetDescendantsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "getDescendantsNextResults", resp, "Failure responding to next results request") - } - return -} - -// GetDescendantsComplete enumerates all values, automatically crossing page boundaries as required. -func (client Client) GetDescendantsComplete(ctx context.Context, groupID string, skiptoken string, top *int32) (result DescendantListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetDescendants") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.GetDescendants(ctx, groupID, skiptoken, top) - return -} - -// List list management groups for the authenticated user. -// Parameters: -// cacheControl - indicates that the request shouldn't utilize any caches. -// skiptoken - page continuation token is only used if a previous operation returned a partial result. -// If a previous response contains a nextLink element, the value of the nextLink element will include a token -// parameter that specifies a starting point to use for subsequent calls. -func (client Client) List(ctx context.Context, cacheControl string, skiptoken string) (result ListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") - defer func() { - sc := -1 - if result.lr.Response.Response != nil { - sc = result.lr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, cacheControl, skiptoken) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.lr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", resp, "Failure sending request") - return - } - - result.lr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "List", resp, "Failure responding to request") - return - } - if result.lr.hasNextLink() && result.lr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client Client) ListPreparer(ctx context.Context, cacheControl string, skiptoken string) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/managementGroups"), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) { - req, err := lastResults.listResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client Client) ListComplete(ctx context.Context, cacheControl string, skiptoken string) (result ListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, cacheControl, skiptoken) - return -} - -// Update update a management group. -// Parameters: -// groupID - management Group ID. -// patchGroupRequest - management group patch parameters. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client Client) Update(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, cacheControl string) (result ManagementGroup, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UpdatePreparer(ctx, groupID, patchGroupRequest, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", nil, "Failure preparing request") - return - } - - resp, err := client.UpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", resp, "Failure sending request") - return - } - - result, err = client.UpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.Client", "Update", resp, "Failure responding to request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client Client) UpdatePreparer(ctx context.Context, groupID string, patchGroupRequest PatchManagementGroupRequest, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}", pathParameters), - autorest.WithJSON(patchGroupRequest), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client Client) UpdateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client Client) UpdateResponder(resp *http.Response) (result ManagementGroup, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/models.go deleted file mode 100644 index c3c8ae1a97d8..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/models.go +++ /dev/null @@ -1,2133 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups" - -// AzureAsyncOperationResults the results of Azure-AsyncOperation. -type AzureAsyncOperationResults struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - // Status - READ-ONLY; The current status of the asynchronous operation performed . For example, Running, Succeeded, Failed - Status *string `json:"status,omitempty"` - *InfoProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for AzureAsyncOperationResults. -func (aaor AzureAsyncOperationResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if aaor.InfoProperties != nil { - objectMap["properties"] = aaor.InfoProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for AzureAsyncOperationResults struct. -func (aaor *AzureAsyncOperationResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - aaor.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - aaor.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - aaor.Name = &name - } - case "status": - if v != nil { - var status string - err = json.Unmarshal(*v, &status) - if err != nil { - return err - } - aaor.Status = &status - } - case "properties": - if v != nil { - var infoProperties InfoProperties - err = json.Unmarshal(*v, &infoProperties) - if err != nil { - return err - } - aaor.InfoProperties = &infoProperties - } - } - } - - return nil -} - -// CheckNameAvailabilityRequest management group name availability check parameters. -type CheckNameAvailabilityRequest struct { - // Name - the name to check for availability - Name *string `json:"name,omitempty"` - // Type - fully qualified resource type which includes provider namespace. Possible values include: 'MicrosoftManagementmanagementGroups' - Type Type `json:"type,omitempty"` -} - -// CheckNameAvailabilityResult describes the result of the request to check management group name -// availability. -type CheckNameAvailabilityResult struct { - autorest.Response `json:"-"` - // NameAvailable - READ-ONLY; Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. - NameAvailable *bool `json:"nameAvailable,omitempty"` - // Reason - READ-ONLY; Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in use and is therefore unavailable. Possible values include: 'Invalid', 'AlreadyExists' - Reason Reason `json:"reason,omitempty"` - // Message - READ-ONLY; Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different name. - Message *string `json:"message,omitempty"` -} - -// MarshalJSON is the custom marshaler for CheckNameAvailabilityResult. -func (cnar CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// ChildInfo the child information of a management group. -type ChildInfo struct { - // Type - The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). Possible values include: 'Type1MicrosoftManagementmanagementGroups', 'Type1Subscriptions' - Type Type1 `json:"type,omitempty"` - // ID - The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Name - The name of the child entity. - Name *string `json:"name,omitempty"` - // DisplayName - The friendly name of the child resource. - DisplayName *string `json:"displayName,omitempty"` - // Children - The list of children. - Children *[]ChildInfo `json:"children,omitempty"` -} - -// CreateManagementGroupChildInfo the child information of a management group used during creation. -type CreateManagementGroupChildInfo struct { - // Type - READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups). Possible values include: 'Type2MicrosoftManagementmanagementGroups', 'Type2Subscriptions' - Type Type2 `json:"type,omitempty"` - // ID - READ-ONLY; The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the child entity. - Name *string `json:"name,omitempty"` - // DisplayName - READ-ONLY; The friendly name of the child resource. - DisplayName *string `json:"displayName,omitempty"` - // Children - READ-ONLY; The list of children. - Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateManagementGroupChildInfo. -func (cmgci CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// CreateManagementGroupDetails the details of a management group used during creation. -type CreateManagementGroupDetails struct { - // Version - READ-ONLY; The version number of the object. - Version *float64 `json:"version,omitempty"` - // UpdatedTime - READ-ONLY; The date and time when this object was last updated. - UpdatedTime *date.Time `json:"updatedTime,omitempty"` - // UpdatedBy - READ-ONLY; The identity of the principal or process that updated the object. - UpdatedBy *string `json:"updatedBy,omitempty"` - Parent *CreateParentGroupInfo `json:"parent,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateManagementGroupDetails. -func (cmgd CreateManagementGroupDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cmgd.Parent != nil { - objectMap["parent"] = cmgd.Parent - } - return json.Marshal(objectMap) -} - -// CreateManagementGroupProperties the generic properties of a management group used during creation. -type CreateManagementGroupProperties struct { - // TenantID - READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // DisplayName - The friendly name of the management group. If no value is passed then this field will be set to the groupId. - DisplayName *string `json:"displayName,omitempty"` - Details *CreateManagementGroupDetails `json:"details,omitempty"` - // Children - READ-ONLY; The list of children. - Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateManagementGroupProperties. -func (cmgp CreateManagementGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cmgp.DisplayName != nil { - objectMap["displayName"] = cmgp.DisplayName - } - if cmgp.Details != nil { - objectMap["details"] = cmgp.Details - } - return json.Marshal(objectMap) -} - -// CreateManagementGroupRequest management group creation parameters. -type CreateManagementGroupRequest struct { - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *CreateManagementGroupProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateManagementGroupRequest. -func (cmgr CreateManagementGroupRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cmgr.Name != nil { - objectMap["name"] = cmgr.Name - } - if cmgr.CreateManagementGroupProperties != nil { - objectMap["properties"] = cmgr.CreateManagementGroupProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CreateManagementGroupRequest struct. -func (cmgr *CreateManagementGroupRequest) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - cmgr.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - cmgr.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - cmgr.Name = &name - } - case "properties": - if v != nil { - var createManagementGroupProperties CreateManagementGroupProperties - err = json.Unmarshal(*v, &createManagementGroupProperties) - if err != nil { - return err - } - cmgr.CreateManagementGroupProperties = &createManagementGroupProperties - } - } - } - - return nil -} - -// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type CreateOrUpdateFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(Client) (SetObject, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *CreateOrUpdateFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for CreateOrUpdateFuture.Result. -func (future *CreateOrUpdateFuture) result(client Client) (so SetObject, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - so.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("managementgroups.CreateOrUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if so.Response.Response, err = future.GetResult(sender); err == nil && so.Response.Response.StatusCode != http.StatusNoContent { - so, err = client.CreateOrUpdateResponder(so.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.CreateOrUpdateFuture", "Result", so.Response.Response, "Failure responding to request") - } - } - return -} - -// CreateOrUpdateSettingsProperties the properties of the request to create or update Management Group -// settings -type CreateOrUpdateSettingsProperties struct { - // RequireAuthorizationForGroupCreation - Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. - RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` - // DefaultManagementGroup - Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup - DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` -} - -// CreateOrUpdateSettingsRequest parameters for creating or updating Management Group settings -type CreateOrUpdateSettingsRequest struct { - *CreateOrUpdateSettingsProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateOrUpdateSettingsRequest. -func (cousr CreateOrUpdateSettingsRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cousr.CreateOrUpdateSettingsProperties != nil { - objectMap["properties"] = cousr.CreateOrUpdateSettingsProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for CreateOrUpdateSettingsRequest struct. -func (cousr *CreateOrUpdateSettingsRequest) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var createOrUpdateSettingsProperties CreateOrUpdateSettingsProperties - err = json.Unmarshal(*v, &createOrUpdateSettingsProperties) - if err != nil { - return err - } - cousr.CreateOrUpdateSettingsProperties = &createOrUpdateSettingsProperties - } - } - } - - return nil -} - -// CreateParentGroupInfo (Optional) The ID of the parent management group used during creation. -type CreateParentGroupInfo struct { - // ID - The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the parent management group - Name *string `json:"name,omitempty"` - // DisplayName - READ-ONLY; The friendly name of the parent management group. - DisplayName *string `json:"displayName,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateParentGroupInfo. -func (cpgi CreateParentGroupInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cpgi.ID != nil { - objectMap["id"] = cpgi.ID - } - return json.Marshal(objectMap) -} - -// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. -type DeleteFuture struct { - azure.FutureAPI - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - Result func(Client) (AzureAsyncOperationResults, error) -} - -// UnmarshalJSON is the custom unmarshaller for CreateFuture. -func (future *DeleteFuture) UnmarshalJSON(body []byte) error { - var azFuture azure.Future - if err := json.Unmarshal(body, &azFuture); err != nil { - return err - } - future.FutureAPI = &azFuture - future.Result = future.result - return nil -} - -// result is the default implementation for DeleteFuture.Result. -func (future *DeleteFuture) result(client Client) (aaor AzureAsyncOperationResults, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - aaor.Response.Response = future.Response() - err = azure.NewAsyncOpIncompleteError("managementgroups.DeleteFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if aaor.Response.Response, err = future.GetResult(sender); err == nil && aaor.Response.Response.StatusCode != http.StatusNoContent { - aaor, err = client.DeleteResponder(aaor.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.DeleteFuture", "Result", aaor.Response.Response, "Failure responding to request") - } - } - return -} - -// DescendantInfo the descendant. -type DescendantInfo struct { - // ID - READ-ONLY; The fully qualified ID for the descendant. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 or /subscriptions/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups or /subscriptions - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the descendant. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *DescendantInfoProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for DescendantInfo. -func (di DescendantInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if di.DescendantInfoProperties != nil { - objectMap["properties"] = di.DescendantInfoProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for DescendantInfo struct. -func (di *DescendantInfo) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - di.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - di.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - di.Name = &name - } - case "properties": - if v != nil { - var descendantInfoProperties DescendantInfoProperties - err = json.Unmarshal(*v, &descendantInfoProperties) - if err != nil { - return err - } - di.DescendantInfoProperties = &descendantInfoProperties - } - } - } - - return nil -} - -// DescendantInfoProperties the generic properties of an descendant. -type DescendantInfoProperties struct { - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` - Parent *DescendantParentGroupInfo `json:"parent,omitempty"` -} - -// DescendantListResult describes the result of the request to view descendants. -type DescendantListResult struct { - autorest.Response `json:"-"` - // Value - The list of descendants. - Value *[]DescendantInfo `json:"value,omitempty"` - // NextLink - READ-ONLY; The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for DescendantListResult. -func (dlr DescendantListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if dlr.Value != nil { - objectMap["value"] = dlr.Value - } - return json.Marshal(objectMap) -} - -// DescendantListResultIterator provides access to a complete listing of DescendantInfo values. -type DescendantListResultIterator struct { - i int - page DescendantListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *DescendantListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DescendantListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *DescendantListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter DescendantListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter DescendantListResultIterator) Response() DescendantListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter DescendantListResultIterator) Value() DescendantInfo { - if !iter.page.NotDone() { - return DescendantInfo{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the DescendantListResultIterator type. -func NewDescendantListResultIterator(page DescendantListResultPage) DescendantListResultIterator { - return DescendantListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (dlr DescendantListResult) IsEmpty() bool { - return dlr.Value == nil || len(*dlr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (dlr DescendantListResult) hasNextLink() bool { - return dlr.NextLink != nil && len(*dlr.NextLink) != 0 -} - -// descendantListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (dlr DescendantListResult) descendantListResultPreparer(ctx context.Context) (*http.Request, error) { - if !dlr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(dlr.NextLink))) -} - -// DescendantListResultPage contains a page of DescendantInfo values. -type DescendantListResultPage struct { - fn func(context.Context, DescendantListResult) (DescendantListResult, error) - dlr DescendantListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *DescendantListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/DescendantListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.dlr) - if err != nil { - return err - } - page.dlr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *DescendantListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page DescendantListResultPage) NotDone() bool { - return !page.dlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page DescendantListResultPage) Response() DescendantListResult { - return page.dlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page DescendantListResultPage) Values() []DescendantInfo { - if page.dlr.IsEmpty() { - return nil - } - return *page.dlr.Value -} - -// Creates a new instance of the DescendantListResultPage type. -func NewDescendantListResultPage(cur DescendantListResult, getNextPage func(context.Context, DescendantListResult) (DescendantListResult, error)) DescendantListResultPage { - return DescendantListResultPage{ - fn: getNextPage, - dlr: cur, - } -} - -// DescendantParentGroupInfo the ID of the parent management group. -type DescendantParentGroupInfo struct { - // ID - The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` -} - -// Details the details of a management group. -type Details struct { - // Version - The version number of the object. - Version *float64 `json:"version,omitempty"` - // UpdatedTime - The date and time when this object was last updated. - UpdatedTime *date.Time `json:"updatedTime,omitempty"` - // UpdatedBy - The identity of the principal or process that updated the object. - UpdatedBy *string `json:"updatedBy,omitempty"` - Parent *ParentGroupInfo `json:"parent,omitempty"` -} - -// EntityHierarchyItem the management group details for the hierarchy view. -type EntityHierarchyItem struct { - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *EntityHierarchyItemProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for EntityHierarchyItem. -func (ehi EntityHierarchyItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ehi.EntityHierarchyItemProperties != nil { - objectMap["properties"] = ehi.EntityHierarchyItemProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for EntityHierarchyItem struct. -func (ehi *EntityHierarchyItem) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ehi.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ehi.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ehi.Name = &name - } - case "properties": - if v != nil { - var entityHierarchyItemProperties EntityHierarchyItemProperties - err = json.Unmarshal(*v, &entityHierarchyItemProperties) - if err != nil { - return err - } - ehi.EntityHierarchyItemProperties = &entityHierarchyItemProperties - } - } - } - - return nil -} - -// EntityHierarchyItemProperties the generic properties of a management group. -type EntityHierarchyItemProperties struct { - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` - // Permissions - Possible values include: 'Permissions1Noaccess', 'Permissions1View', 'Permissions1Edit', 'Permissions1Delete' - Permissions Permissions1 `json:"permissions,omitempty"` - // Children - The list of children. - Children *[]EntityHierarchyItem `json:"children,omitempty"` -} - -// EntityInfo the entity. -type EntityInfo struct { - // ID - READ-ONLY; The fully qualified ID for the entity. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the entity. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *EntityInfoProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for EntityInfo. -func (ei EntityInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ei.EntityInfoProperties != nil { - objectMap["properties"] = ei.EntityInfoProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for EntityInfo struct. -func (ei *EntityInfo) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ei.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ei.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ei.Name = &name - } - case "properties": - if v != nil { - var entityInfoProperties EntityInfoProperties - err = json.Unmarshal(*v, &entityInfoProperties) - if err != nil { - return err - } - ei.EntityInfoProperties = &entityInfoProperties - } - } - } - - return nil -} - -// EntityInfoProperties the generic properties of an entity. -type EntityInfoProperties struct { - // TenantID - The AAD Tenant ID associated with the entity. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` - Parent *EntityParentGroupInfo `json:"parent,omitempty"` - // Permissions - Possible values include: 'PermissionsNoaccess', 'PermissionsView', 'PermissionsEdit', 'PermissionsDelete' - Permissions Permissions `json:"permissions,omitempty"` - // InheritedPermissions - Possible values include: 'Noaccess', 'View', 'Edit', 'Delete' - InheritedPermissions InheritedPermissions `json:"inheritedPermissions,omitempty"` - NumberOfDescendants *int32 `json:"numberOfDescendants,omitempty"` - // NumberOfChildren - Number of children is the number of Groups and Subscriptions that are exactly one level underneath the current Group. - NumberOfChildren *int32 `json:"numberOfChildren,omitempty"` - // NumberOfChildGroups - Number of children is the number of Groups that are exactly one level underneath the current Group. - NumberOfChildGroups *int32 `json:"numberOfChildGroups,omitempty"` - // ParentDisplayNameChain - The parent display name chain from the root group to the immediate parent - ParentDisplayNameChain *[]string `json:"parentDisplayNameChain,omitempty"` - // ParentNameChain - The parent name chain from the root group to the immediate parent - ParentNameChain *[]string `json:"parentNameChain,omitempty"` -} - -// EntityListResult describes the result of the request to view entities. -type EntityListResult struct { - autorest.Response `json:"-"` - // Value - The list of entities. - Value *[]EntityInfo `json:"value,omitempty"` - // Count - READ-ONLY; Total count of records that match the filter - Count *int32 `json:"count,omitempty"` - // NextLink - READ-ONLY; The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for EntityListResult. -func (elr EntityListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if elr.Value != nil { - objectMap["value"] = elr.Value - } - return json.Marshal(objectMap) -} - -// EntityListResultIterator provides access to a complete listing of EntityInfo values. -type EntityListResultIterator struct { - i int - page EntityListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *EntityListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *EntityListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter EntityListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter EntityListResultIterator) Response() EntityListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter EntityListResultIterator) Value() EntityInfo { - if !iter.page.NotDone() { - return EntityInfo{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the EntityListResultIterator type. -func NewEntityListResultIterator(page EntityListResultPage) EntityListResultIterator { - return EntityListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (elr EntityListResult) IsEmpty() bool { - return elr.Value == nil || len(*elr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (elr EntityListResult) hasNextLink() bool { - return elr.NextLink != nil && len(*elr.NextLink) != 0 -} - -// entityListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (elr EntityListResult) entityListResultPreparer(ctx context.Context) (*http.Request, error) { - if !elr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(elr.NextLink))) -} - -// EntityListResultPage contains a page of EntityInfo values. -type EntityListResultPage struct { - fn func(context.Context, EntityListResult) (EntityListResult, error) - elr EntityListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *EntityListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EntityListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.elr) - if err != nil { - return err - } - page.elr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *EntityListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page EntityListResultPage) NotDone() bool { - return !page.elr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page EntityListResultPage) Response() EntityListResult { - return page.elr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page EntityListResultPage) Values() []EntityInfo { - if page.elr.IsEmpty() { - return nil - } - return *page.elr.Value -} - -// Creates a new instance of the EntityListResultPage type. -func NewEntityListResultPage(cur EntityListResult, getNextPage func(context.Context, EntityListResult) (EntityListResult, error)) EntityListResultPage { - return EntityListResultPage{ - fn: getNextPage, - elr: cur, - } -} - -// EntityParentGroupInfo (Optional) The ID of the parent management group. -type EntityParentGroupInfo struct { - // ID - The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` -} - -// ErrorDetails the details of the error. -type ErrorDetails struct { - // Code - One of a server-defined set of error codes. - Code *string `json:"code,omitempty"` - // Message - A human-readable representation of the error. - Message *string `json:"message,omitempty"` - // Details - A human-readable representation of the error's details. - Details *string `json:"details,omitempty"` -} - -// ErrorResponse the error object. -type ErrorResponse struct { - Error *ErrorDetails `json:"error,omitempty"` -} - -// HierarchySettings settings defined at the Management Group scope. -type HierarchySettings struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings. - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the object. In this case, default. - Name *string `json:"name,omitempty"` - *HierarchySettingsProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for HierarchySettings. -func (hs HierarchySettings) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if hs.HierarchySettingsProperties != nil { - objectMap["properties"] = hs.HierarchySettingsProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for HierarchySettings struct. -func (hs *HierarchySettings) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - hs.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - hs.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - hs.Name = &name - } - case "properties": - if v != nil { - var hierarchySettingsProperties HierarchySettingsProperties - err = json.Unmarshal(*v, &hierarchySettingsProperties) - if err != nil { - return err - } - hs.HierarchySettingsProperties = &hierarchySettingsProperties - } - } - } - - return nil -} - -// HierarchySettingsInfo the hierarchy settings resource. -type HierarchySettingsInfo struct { - // ID - READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings. - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the object. In this case, default. - Name *string `json:"name,omitempty"` - *HierarchySettingsProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for HierarchySettingsInfo. -func (hsi HierarchySettingsInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if hsi.HierarchySettingsProperties != nil { - objectMap["properties"] = hsi.HierarchySettingsProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for HierarchySettingsInfo struct. -func (hsi *HierarchySettingsInfo) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - hsi.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - hsi.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - hsi.Name = &name - } - case "properties": - if v != nil { - var hierarchySettingsProperties HierarchySettingsProperties - err = json.Unmarshal(*v, &hierarchySettingsProperties) - if err != nil { - return err - } - hsi.HierarchySettingsProperties = &hierarchySettingsProperties - } - } - } - - return nil -} - -// HierarchySettingsList lists all hierarchy settings. -type HierarchySettingsList struct { - autorest.Response `json:"-"` - // Value - The list of hierarchy settings. - Value *[]HierarchySettingsInfo `json:"value,omitempty"` - // NextLink - READ-ONLY; The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for HierarchySettingsList. -func (hsl HierarchySettingsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if hsl.Value != nil { - objectMap["value"] = hsl.Value - } - return json.Marshal(objectMap) -} - -// HierarchySettingsProperties the generic properties of hierarchy settings. -type HierarchySettingsProperties struct { - // TenantID - The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // RequireAuthorizationForGroupCreation - Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. - RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` - // DefaultManagementGroup - Settings that sets the default Management Group under which new subscriptions get added in this tenant. For example, /providers/Microsoft.Management/managementGroups/defaultGroup - DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` -} - -// Info the management group resource. -type Info struct { - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *InfoProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for Info. -func (i Info) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if i.InfoProperties != nil { - objectMap["properties"] = i.InfoProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Info struct. -func (i *Info) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - i.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - i.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - i.Name = &name - } - case "properties": - if v != nil { - var infoProperties InfoProperties - err = json.Unmarshal(*v, &infoProperties) - if err != nil { - return err - } - i.InfoProperties = &infoProperties - } - } - } - - return nil -} - -// InfoProperties the generic properties of a management group. -type InfoProperties struct { - // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` -} - -// ListResult describes the result of the request to list management groups. -type ListResult struct { - autorest.Response `json:"-"` - // Value - The list of management groups. - Value *[]Info `json:"value,omitempty"` - // NextLink - READ-ONLY; The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ListResult. -func (lr ListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if lr.Value != nil { - objectMap["value"] = lr.Value - } - return json.Marshal(objectMap) -} - -// ListResultIterator provides access to a complete listing of Info values. -type ListResultIterator struct { - i int - page ListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ListResultIterator) Response() ListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ListResultIterator) Value() Info { - if !iter.page.NotDone() { - return Info{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ListResultIterator type. -func NewListResultIterator(page ListResultPage) ListResultIterator { - return ListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (lr ListResult) IsEmpty() bool { - return lr.Value == nil || len(*lr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (lr ListResult) hasNextLink() bool { - return lr.NextLink != nil && len(*lr.NextLink) != 0 -} - -// listResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (lr ListResult) listResultPreparer(ctx context.Context) (*http.Request, error) { - if !lr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(lr.NextLink))) -} - -// ListResultPage contains a page of Info values. -type ListResultPage struct { - fn func(context.Context, ListResult) (ListResult, error) - lr ListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.lr) - if err != nil { - return err - } - page.lr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ListResultPage) NotDone() bool { - return !page.lr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ListResultPage) Response() ListResult { - return page.lr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ListResultPage) Values() []Info { - if page.lr.IsEmpty() { - return nil - } - return *page.lr.Value -} - -// Creates a new instance of the ListResultPage type. -func NewListResultPage(cur ListResult, getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage { - return ListResultPage{ - fn: getNextPage, - lr: cur, - } -} - -// ListSubscriptionUnderManagementGroup the details of all subscriptions under management group. -type ListSubscriptionUnderManagementGroup struct { - autorest.Response `json:"-"` - // Value - The list of subscriptions. - Value *[]SubscriptionUnderManagementGroup `json:"value,omitempty"` - // NextLink - READ-ONLY; The URL to use for getting the next set of results. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for ListSubscriptionUnderManagementGroup. -func (lsumg ListSubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if lsumg.Value != nil { - objectMap["value"] = lsumg.Value - } - return json.Marshal(objectMap) -} - -// ListSubscriptionUnderManagementGroupIterator provides access to a complete listing of -// SubscriptionUnderManagementGroup values. -type ListSubscriptionUnderManagementGroupIterator struct { - i int - page ListSubscriptionUnderManagementGroupPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ListSubscriptionUnderManagementGroupIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListSubscriptionUnderManagementGroupIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ListSubscriptionUnderManagementGroupIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ListSubscriptionUnderManagementGroupIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ListSubscriptionUnderManagementGroupIterator) Response() ListSubscriptionUnderManagementGroup { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ListSubscriptionUnderManagementGroupIterator) Value() SubscriptionUnderManagementGroup { - if !iter.page.NotDone() { - return SubscriptionUnderManagementGroup{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ListSubscriptionUnderManagementGroupIterator type. -func NewListSubscriptionUnderManagementGroupIterator(page ListSubscriptionUnderManagementGroupPage) ListSubscriptionUnderManagementGroupIterator { - return ListSubscriptionUnderManagementGroupIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (lsumg ListSubscriptionUnderManagementGroup) IsEmpty() bool { - return lsumg.Value == nil || len(*lsumg.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (lsumg ListSubscriptionUnderManagementGroup) hasNextLink() bool { - return lsumg.NextLink != nil && len(*lsumg.NextLink) != 0 -} - -// listSubscriptionUnderManagementGroupPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (lsumg ListSubscriptionUnderManagementGroup) listSubscriptionUnderManagementGroupPreparer(ctx context.Context) (*http.Request, error) { - if !lsumg.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(lsumg.NextLink))) -} - -// ListSubscriptionUnderManagementGroupPage contains a page of SubscriptionUnderManagementGroup values. -type ListSubscriptionUnderManagementGroupPage struct { - fn func(context.Context, ListSubscriptionUnderManagementGroup) (ListSubscriptionUnderManagementGroup, error) - lsumg ListSubscriptionUnderManagementGroup -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ListSubscriptionUnderManagementGroupPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ListSubscriptionUnderManagementGroupPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.lsumg) - if err != nil { - return err - } - page.lsumg = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ListSubscriptionUnderManagementGroupPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ListSubscriptionUnderManagementGroupPage) NotDone() bool { - return !page.lsumg.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ListSubscriptionUnderManagementGroupPage) Response() ListSubscriptionUnderManagementGroup { - return page.lsumg -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ListSubscriptionUnderManagementGroupPage) Values() []SubscriptionUnderManagementGroup { - if page.lsumg.IsEmpty() { - return nil - } - return *page.lsumg.Value -} - -// Creates a new instance of the ListSubscriptionUnderManagementGroupPage type. -func NewListSubscriptionUnderManagementGroupPage(cur ListSubscriptionUnderManagementGroup, getNextPage func(context.Context, ListSubscriptionUnderManagementGroup) (ListSubscriptionUnderManagementGroup, error)) ListSubscriptionUnderManagementGroupPage { - return ListSubscriptionUnderManagementGroupPage{ - fn: getNextPage, - lsumg: cur, - } -} - -// ManagementGroup the management group details. -type ManagementGroup struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *Properties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for ManagementGroup. -func (mg ManagementGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if mg.Properties != nil { - objectMap["properties"] = mg.Properties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ManagementGroup struct. -func (mg *ManagementGroup) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - mg.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - mg.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - mg.Name = &name - } - case "properties": - if v != nil { - var properties Properties - err = json.Unmarshal(*v, &properties) - if err != nil { - return err - } - mg.Properties = &properties - } - } - } - - return nil -} - -// Operation operation supported by the Microsoft.Management resource provider. -type Operation struct { - // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. - Name *string `json:"name,omitempty"` - Display *OperationDisplayProperties `json:"display,omitempty"` -} - -// MarshalJSON is the custom marshaler for Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if o.Display != nil { - objectMap["display"] = o.Display - } - return json.Marshal(objectMap) -} - -// OperationDisplayProperties the object that represents the operation. -type OperationDisplayProperties struct { - // Provider - READ-ONLY; The name of the provider. - Provider *string `json:"provider,omitempty"` - // Resource - READ-ONLY; The resource on which the operation is performed. - Resource *string `json:"resource,omitempty"` - // Operation - READ-ONLY; The operation that can be performed. - Operation *string `json:"operation,omitempty"` - // Description - READ-ONLY; Operation description. - Description *string `json:"description,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationDisplayProperties. -func (odp OperationDisplayProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResult describes the result of the request to list Microsoft.Management operations. -type OperationListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; List of operations supported by the Microsoft.Management resource provider. - Value *[]Operation `json:"value,omitempty"` - // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. - NextLink *string `json:"nextLink,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationListResult. -func (olr OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} - -// OperationListResultIterator provides access to a complete listing of Operation values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() Operation { - if !iter.page.NotDone() { - return Operation{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// hasNextLink returns true if the NextLink is not empty. -func (olr OperationListResult) hasNextLink() bool { - return olr.NextLink != nil && len(*olr.NextLink) != 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if !olr.hasNextLink() { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of Operation values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - for { - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - if !next.hasNextLink() || !next.IsEmpty() { - break - } - } - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []Operation { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{ - fn: getNextPage, - olr: cur, - } -} - -// OperationResults the results of an asynchronous operation. -type OperationResults struct { - // ID - READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *InfoProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for OperationResults. -func (or OperationResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if or.InfoProperties != nil { - objectMap["properties"] = or.InfoProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for OperationResults struct. -func (or *OperationResults) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - or.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - or.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - or.Name = &name - } - case "properties": - if v != nil { - var infoProperties InfoProperties - err = json.Unmarshal(*v, &infoProperties) - if err != nil { - return err - } - or.InfoProperties = &infoProperties - } - } - } - - return nil -} - -// ParentGroupInfo (Optional) The ID of the parent management group. -type ParentGroupInfo struct { - // ID - The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string `json:"id,omitempty"` - // Name - The name of the parent management group - Name *string `json:"name,omitempty"` - // DisplayName - The friendly name of the parent management group. - DisplayName *string `json:"displayName,omitempty"` -} - -// PatchManagementGroupRequest management group patch parameters. -type PatchManagementGroupRequest struct { - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` - // ParentGroupID - (Optional) The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ParentGroupID *string `json:"parentGroupId,omitempty"` -} - -// PathElement a path element of a management group ancestors. -type PathElement struct { - // Name - The name of the group. - Name *string `json:"name,omitempty"` - // DisplayName - The friendly name of the group. - DisplayName *string `json:"displayName,omitempty"` -} - -// Properties the generic properties of a management group. -type Properties struct { - // TenantID - The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // DisplayName - The friendly name of the management group. - DisplayName *string `json:"displayName,omitempty"` - Details *Details `json:"details,omitempty"` - // Children - The list of children. - Children *[]ChildInfo `json:"children,omitempty"` - // Path - The path from the root to the current group. - Path *[]PathElement `json:"path,omitempty"` -} - -// SetObject ... -type SetObject struct { - autorest.Response `json:"-"` - Value interface{} `json:"value,omitempty"` -} - -// SubscriptionUnderManagementGroup the details of subscription under management group. -type SubscriptionUnderManagementGroup struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The fully qualified ID for the subscription. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001 - ID *string `json:"id,omitempty"` - // Type - READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/subscriptions - Type *string `json:"type,omitempty"` - // Name - READ-ONLY; The stringified id of the subscription. For example, 00000000-0000-0000-0000-000000000000 - Name *string `json:"name,omitempty"` - *SubscriptionUnderManagementGroupProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for SubscriptionUnderManagementGroup. -func (sumg SubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if sumg.SubscriptionUnderManagementGroupProperties != nil { - objectMap["properties"] = sumg.SubscriptionUnderManagementGroupProperties - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for SubscriptionUnderManagementGroup struct. -func (sumg *SubscriptionUnderManagementGroup) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - sumg.ID = &ID - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - sumg.Type = &typeVar - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - sumg.Name = &name - } - case "properties": - if v != nil { - var subscriptionUnderManagementGroupProperties SubscriptionUnderManagementGroupProperties - err = json.Unmarshal(*v, &subscriptionUnderManagementGroupProperties) - if err != nil { - return err - } - sumg.SubscriptionUnderManagementGroupProperties = &subscriptionUnderManagementGroupProperties - } - } - } - - return nil -} - -// SubscriptionUnderManagementGroupProperties the generic properties of subscription under a management -// group. -type SubscriptionUnderManagementGroupProperties struct { - // Tenant - The AAD Tenant ID associated with the subscription. For example, 00000000-0000-0000-0000-000000000000 - Tenant *string `json:"tenant,omitempty"` - // DisplayName - The friendly name of the subscription. - DisplayName *string `json:"displayName,omitempty"` - Parent *DescendantParentGroupInfo `json:"parent,omitempty"` - // State - The state of the subscription. - State *string `json:"state,omitempty"` -} - -// TenantBackfillStatusResult the tenant backfill status -type TenantBackfillStatusResult struct { - autorest.Response `json:"-"` - // TenantID - READ-ONLY; The AAD Tenant ID associated with the management group. For example, 00000000-0000-0000-0000-000000000000 - TenantID *string `json:"tenantId,omitempty"` - // Status - READ-ONLY; The status of the Tenant Backfill. Possible values include: 'NotStarted', 'NotStartedButGroupsExist', 'Started', 'Failed', 'Cancelled', 'Completed' - Status Status `json:"status,omitempty"` -} - -// MarshalJSON is the custom marshaler for TenantBackfillStatusResult. -func (tbsr TenantBackfillStatusResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - return json.Marshal(objectMap) -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/operations.go deleted file mode 100644 index f22f614a6f58..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/operations.go +++ /dev/null @@ -1,142 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// OperationsClient is the the Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -type OperationsClient struct { - BaseClient -} - -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient() OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this -// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI)} -} - -// List lists all of the available Management REST API operations. -func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", resp, "Failure sending request") - return - } - - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "List", resp, "Failure responding to request") - return - } - if result.olr.hasNextLink() && result.olr.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.Management/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/subscriptions.go deleted file mode 100644 index b42be93c3b5e..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/subscriptions.go +++ /dev/null @@ -1,403 +0,0 @@ -package managementgroups - -// 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. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" -) - -// SubscriptionsClient is the the Azure Management Groups API enables consolidation of multiple -// subscriptions/resources into an organizational hierarchy and centrally -// manage access control, policies, alerting and reporting for those resources. -type SubscriptionsClient struct { - BaseClient -} - -// NewSubscriptionsClient creates an instance of the SubscriptionsClient client. -func NewSubscriptionsClient() SubscriptionsClient { - return NewSubscriptionsClientWithBaseURI(DefaultBaseURI) -} - -// NewSubscriptionsClientWithBaseURI creates an instance of the SubscriptionsClient client using a custom endpoint. -// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewSubscriptionsClientWithBaseURI(baseURI string) SubscriptionsClient { - return SubscriptionsClient{NewWithBaseURI(baseURI)} -} - -// Create associates existing subscription with the management group. -// Parameters: -// groupID - management Group ID. -// subscriptionID - subscription ID. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client SubscriptionsClient) Create(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (result SubscriptionUnderManagementGroup, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Create") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreatePreparer(ctx, groupID, subscriptionID, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client SubscriptionsClient) CreatePreparer(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - "subscriptionId": autorest.Encode("path", subscriptionID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) CreateSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) CreateResponder(resp *http.Response) (result SubscriptionUnderManagementGroup, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete de-associates subscription from the management group. -// Parameters: -// groupID - management Group ID. -// subscriptionID - subscription ID. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client SubscriptionsClient) Delete(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (result autorest.Response, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Delete") - defer func() { - sc := -1 - if result.Response != nil { - sc = result.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, groupID, subscriptionID, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client SubscriptionsClient) DeletePreparer(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - "subscriptionId": autorest.Encode("path", subscriptionID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} - -// GetSubscription retrieves details about given subscription which is associated with the management group. -// Parameters: -// groupID - management Group ID. -// subscriptionID - subscription ID. -// cacheControl - indicates that the request shouldn't utilize any caches. -func (client SubscriptionsClient) GetSubscription(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (result SubscriptionUnderManagementGroup, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.GetSubscription") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetSubscriptionPreparer(ctx, groupID, subscriptionID, cacheControl) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscription", nil, "Failure preparing request") - return - } - - resp, err := client.GetSubscriptionSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscription", resp, "Failure sending request") - return - } - - result, err = client.GetSubscriptionResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscription", resp, "Failure responding to request") - return - } - - return -} - -// GetSubscriptionPreparer prepares the GetSubscription request. -func (client SubscriptionsClient) GetSubscriptionPreparer(ctx context.Context, groupID string, subscriptionID string, cacheControl string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - "subscriptionId": autorest.Encode("path", subscriptionID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - if len(cacheControl) > 0 { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String(cacheControl))) - } else { - preparer = autorest.DecoratePreparer(preparer, - autorest.WithHeader("Cache-Control", autorest.String("no-cache"))) - } - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSubscriptionSender sends the GetSubscription request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) GetSubscriptionSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSubscriptionResponder handles the response to the GetSubscription request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) GetSubscriptionResponder(resp *http.Response) (result SubscriptionUnderManagementGroup, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetSubscriptionsUnderManagementGroup retrieves details about all subscriptions which are associated with the -// management group. -// Parameters: -// groupID - management Group ID. -// skiptoken - page continuation token is only used if a previous operation returned a partial result. -// If a previous response contains a nextLink element, the value of the nextLink element will include a token -// parameter that specifies a starting point to use for subsequent calls. -func (client SubscriptionsClient) GetSubscriptionsUnderManagementGroup(ctx context.Context, groupID string, skiptoken string) (result ListSubscriptionUnderManagementGroupPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.GetSubscriptionsUnderManagementGroup") - defer func() { - sc := -1 - if result.lsumg.Response.Response != nil { - sc = result.lsumg.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.getSubscriptionsUnderManagementGroupNextResults - req, err := client.GetSubscriptionsUnderManagementGroupPreparer(ctx, groupID, skiptoken) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscriptionsUnderManagementGroup", nil, "Failure preparing request") - return - } - - resp, err := client.GetSubscriptionsUnderManagementGroupSender(req) - if err != nil { - result.lsumg.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscriptionsUnderManagementGroup", resp, "Failure sending request") - return - } - - result.lsumg, err = client.GetSubscriptionsUnderManagementGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "GetSubscriptionsUnderManagementGroup", resp, "Failure responding to request") - return - } - if result.lsumg.hasNextLink() && result.lsumg.IsEmpty() { - err = result.NextWithContext(ctx) - return - } - - return -} - -// GetSubscriptionsUnderManagementGroupPreparer prepares the GetSubscriptionsUnderManagementGroup request. -func (client SubscriptionsClient) GetSubscriptionsUnderManagementGroupPreparer(ctx context.Context, groupID string, skiptoken string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "groupId": autorest.Encode("path", groupID), - } - - const APIVersion = "2020-05-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(skiptoken) > 0 { - queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Management/managementGroups/{groupId}/subscriptions", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSubscriptionsUnderManagementGroupSender sends the GetSubscriptionsUnderManagementGroup request. The method will close the -// http.Response Body if it receives an error. -func (client SubscriptionsClient) GetSubscriptionsUnderManagementGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} - -// GetSubscriptionsUnderManagementGroupResponder handles the response to the GetSubscriptionsUnderManagementGroup request. The method always -// closes the http.Response Body. -func (client SubscriptionsClient) GetSubscriptionsUnderManagementGroupResponder(resp *http.Response) (result ListSubscriptionUnderManagementGroup, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// getSubscriptionsUnderManagementGroupNextResults retrieves the next set of results, if any. -func (client SubscriptionsClient) getSubscriptionsUnderManagementGroupNextResults(ctx context.Context, lastResults ListSubscriptionUnderManagementGroup) (result ListSubscriptionUnderManagementGroup, err error) { - req, err := lastResults.listSubscriptionUnderManagementGroupPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "getSubscriptionsUnderManagementGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.GetSubscriptionsUnderManagementGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "getSubscriptionsUnderManagementGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.GetSubscriptionsUnderManagementGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "managementgroups.SubscriptionsClient", "getSubscriptionsUnderManagementGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// GetSubscriptionsUnderManagementGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client SubscriptionsClient) GetSubscriptionsUnderManagementGroupComplete(ctx context.Context, groupID string, skiptoken string) (result ListSubscriptionUnderManagementGroupIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.GetSubscriptionsUnderManagementGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.GetSubscriptionsUnderManagementGroup(ctx, groupID, skiptoken) - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/version.go deleted file mode 100644 index 568ae67b03c9..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups/version.go +++ /dev/null @@ -1,19 +0,0 @@ -package managementgroups - -import "github.com/Azure/azure-sdk-for-go/version" - -// 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. - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " managementgroups/2020-05-01" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/README.md new file mode 100644 index 000000000000..ae344feb0dfb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/README.md @@ -0,0 +1,276 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups` Documentation + +The `managementgroups` SDK allows for interaction with the Azure Resource Manager Service `managementgroups` (API Version `2020-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups" +``` + + +### Client Initialization + +```go +client := managementgroups.NewManagementGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagementGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +payload := managementgroups.CreateManagementGroupRequest{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, managementgroups.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagementGroupsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +if err := client.DeleteThenPoll(ctx, id, managementgroups.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagementGroupsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +read, err := client.Get(ctx, id, managementgroups.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.GetDescendants` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +// alternatively `client.GetDescendants(ctx, id, managementgroups.DefaultGetDescendantsOperationOptions())` can be used to do batched pagination +items, err := client.GetDescendantsComplete(ctx, id, managementgroups.DefaultGetDescendantsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementGroupsClient.HierarchySettingsCreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +payload := managementgroups.CreateOrUpdateSettingsRequest{ + // ... +} + + +read, err := client.HierarchySettingsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.HierarchySettingsDelete` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +read, err := client.HierarchySettingsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.HierarchySettingsGet` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +read, err := client.HierarchySettingsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.HierarchySettingsList` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +read, err := client.HierarchySettingsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.HierarchySettingsUpdate` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +payload := managementgroups.CreateOrUpdateSettingsRequest{ + // ... +} + + +read, err := client.HierarchySettingsUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.List` + +```go +ctx := context.TODO() + + +// alternatively `client.List(ctx, managementgroups.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, managementgroups.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementGroupsClient.SubscriptionsCreate` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.SubscriptionsCreate(ctx, id, managementgroups.DefaultSubscriptionsCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.SubscriptionsDelete` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.SubscriptionsDelete(ctx, id, managementgroups.DefaultSubscriptionsDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.SubscriptionsGetSubscription` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.SubscriptionsGetSubscription(ctx, id, managementgroups.DefaultSubscriptionsGetSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.SubscriptionsGetSubscriptionsUnderManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +// alternatively `client.SubscriptionsGetSubscriptionsUnderManagementGroup(ctx, id)` can be used to do batched pagination +items, err := client.SubscriptionsGetSubscriptionsUnderManagementGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagementGroupsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +payload := managementgroups.PatchManagementGroupRequest{ + // ... +} + + +read, err := client.Update(ctx, id, payload, managementgroups.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/client.go new file mode 100644 index 000000000000..732b46ac1a44 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/client.go @@ -0,0 +1,26 @@ +package managementgroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupsClient struct { + Client *resourcemanager.Client +} + +func NewManagementGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagementGroupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managementgroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagementGroupsClient: %+v", err) + } + + return &ManagementGroupsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/constants.go new file mode 100644 index 000000000000..fbb80a749522 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/constants.go @@ -0,0 +1,92 @@ +package managementgroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Expand string + +const ( + ExpandChildren Expand = "children" + ExpandPath Expand = "path" +) + +func PossibleValuesForExpand() []string { + return []string{ + string(ExpandChildren), + string(ExpandPath), + } +} + +func (s *Expand) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpand(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpand(input string) (*Expand, error) { + vals := map[string]Expand{ + "children": ExpandChildren, + "path": ExpandPath, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Expand(input) + return &out, nil +} + +type ManagementGroupChildType string + +const ( + ManagementGroupChildTypeMicrosoftPointManagementManagementGroups ManagementGroupChildType = "Microsoft.Management/managementGroups" + ManagementGroupChildTypeSubscriptions ManagementGroupChildType = "/subscriptions" +) + +func PossibleValuesForManagementGroupChildType() []string { + return []string{ + string(ManagementGroupChildTypeMicrosoftPointManagementManagementGroups), + string(ManagementGroupChildTypeSubscriptions), + } +} + +func (s *ManagementGroupChildType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagementGroupChildType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagementGroupChildType(input string) (*ManagementGroupChildType, error) { + vals := map[string]ManagementGroupChildType{ + "microsoft.management/managementgroups": ManagementGroupChildTypeMicrosoftPointManagementManagementGroups, + "/subscriptions": ManagementGroupChildTypeSubscriptions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagementGroupChildType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/id_subscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/id_subscription.go new file mode 100644 index 000000000000..6359734004cd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/id_subscription.go @@ -0,0 +1,121 @@ +package managementgroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SubscriptionId{}) +} + +var _ resourceids.ResourceId = &SubscriptionId{} + +// SubscriptionId is a struct representing the Resource ID for a Subscription +type SubscriptionId struct { + GroupId string + SubscriptionId string +} + +// NewSubscriptionID returns a new SubscriptionId struct +func NewSubscriptionID(groupId string, subscriptionId string) SubscriptionId { + return SubscriptionId{ + GroupId: groupId, + SubscriptionId: subscriptionId, + } +} + +// ParseSubscriptionID parses 'input' into a SubscriptionId +func ParseSubscriptionID(input string) (*SubscriptionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SubscriptionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SubscriptionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSubscriptionIDInsensitively parses 'input' case-insensitively into a SubscriptionId +// note: this method should only be used for API response data and not user input +func ParseSubscriptionIDInsensitively(input string) (*SubscriptionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SubscriptionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SubscriptionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SubscriptionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.GroupId, ok = input.Parsed["groupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "groupId", input) + } + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + return nil +} + +// ValidateSubscriptionID checks that 'input' can be parsed as a Subscription ID +func ValidateSubscriptionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSubscriptionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Subscription ID +func (id SubscriptionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/subscriptions/%s" + return fmt.Sprintf(fmtString, id.GroupId, id.SubscriptionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Subscription ID +func (id SubscriptionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("groupId", "groupIdValue"), + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + } +} + +// String returns a human-readable description of this Subscription ID +func (id SubscriptionId) String() string { + components := []string{ + fmt.Sprintf("Group: %q", id.GroupId), + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + } + return fmt.Sprintf("Subscription (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_createorupdate.go new file mode 100644 index 000000000000..ca530041f6c8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_createorupdate.go @@ -0,0 +1,104 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagementGroup +} + +type CreateOrUpdateOperationOptions struct { + CacheControl *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ManagementGroupsClient) CreateOrUpdate(ctx context.Context, id commonids.ManagementGroupId, input CreateManagementGroupRequest, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagementGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ManagementGroupId, input CreateManagementGroupRequest, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_delete.go new file mode 100644 index 000000000000..033a72547c17 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_delete.go @@ -0,0 +1,100 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AzureAsyncOperationResults +} + +type DeleteOperationOptions struct { + CacheControl *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ManagementGroupsClient) Delete(ctx context.Context, id commonids.ManagementGroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ManagementGroupsClient) DeleteThenPoll(ctx context.Context, id commonids.ManagementGroupId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_get.go new file mode 100644 index 000000000000..87fb2a218bc1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_get.go @@ -0,0 +1,95 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagementGroup +} + +type GetOperationOptions struct { + CacheControl *string + Expand *Expand + Filter *string + Recurse *bool +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Recurse != nil { + out.Append("$recurse", fmt.Sprintf("%v", *o.Recurse)) + } + return &out +} + +// Get ... +func (c ManagementGroupsClient) Get(ctx context.Context, id commonids.ManagementGroupId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagementGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_getdescendants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_getdescendants.go new file mode 100644 index 000000000000..aa6a5c146166 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_getdescendants.go @@ -0,0 +1,134 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDescendantsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DescendantInfo +} + +type GetDescendantsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DescendantInfo +} + +type GetDescendantsOperationOptions struct { + Top *int64 +} + +func DefaultGetDescendantsOperationOptions() GetDescendantsOperationOptions { + return GetDescendantsOperationOptions{} +} + +func (o GetDescendantsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetDescendantsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetDescendantsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type GetDescendantsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetDescendantsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetDescendants ... +func (c ManagementGroupsClient) GetDescendants(ctx context.Context, id commonids.ManagementGroupId, options GetDescendantsOperationOptions) (result GetDescendantsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetDescendantsCustomPager{}, + Path: fmt.Sprintf("%s/descendants", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DescendantInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDescendantsComplete retrieves all the results into a single object +func (c ManagementGroupsClient) GetDescendantsComplete(ctx context.Context, id commonids.ManagementGroupId, options GetDescendantsOperationOptions) (GetDescendantsCompleteResult, error) { + return c.GetDescendantsCompleteMatchingPredicate(ctx, id, options, DescendantInfoOperationPredicate{}) +} + +// GetDescendantsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagementGroupsClient) GetDescendantsCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options GetDescendantsOperationOptions, predicate DescendantInfoOperationPredicate) (result GetDescendantsCompleteResult, err error) { + items := make([]DescendantInfo, 0) + + resp, err := c.GetDescendants(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetDescendantsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingscreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingscreateorupdate.go new file mode 100644 index 000000000000..3f1794604e57 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingscreateorupdate.go @@ -0,0 +1,60 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HierarchySettings +} + +// HierarchySettingsCreateOrUpdate ... +func (c ManagementGroupsClient) HierarchySettingsCreateOrUpdate(ctx context.Context, id commonids.ManagementGroupId, input CreateOrUpdateSettingsRequest) (result HierarchySettingsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/settings/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HierarchySettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsdelete.go new file mode 100644 index 000000000000..2927e428a0db --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsdelete.go @@ -0,0 +1,48 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// HierarchySettingsDelete ... +func (c ManagementGroupsClient) HierarchySettingsDelete(ctx context.Context, id commonids.ManagementGroupId) (result HierarchySettingsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/settings/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsget.go new file mode 100644 index 000000000000..bb7c557f1fe8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsget.go @@ -0,0 +1,56 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HierarchySettings +} + +// HierarchySettingsGet ... +func (c ManagementGroupsClient) HierarchySettingsGet(ctx context.Context, id commonids.ManagementGroupId) (result HierarchySettingsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/settings/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HierarchySettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingslist.go new file mode 100644 index 000000000000..038617f4220e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingslist.go @@ -0,0 +1,56 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HierarchySettingsList +} + +// HierarchySettingsList ... +func (c ManagementGroupsClient) HierarchySettingsList(ctx context.Context, id commonids.ManagementGroupId) (result HierarchySettingsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/settings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HierarchySettingsList + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsupdate.go new file mode 100644 index 000000000000..6b7e694b1560 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_hierarchysettingsupdate.go @@ -0,0 +1,60 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HierarchySettings +} + +// HierarchySettingsUpdate ... +func (c ManagementGroupsClient) HierarchySettingsUpdate(ctx context.Context, id commonids.ManagementGroupId, input CreateOrUpdateSettingsRequest) (result HierarchySettingsUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/settings/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HierarchySettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_list.go new file mode 100644 index 000000000000..c9660c8df44a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_list.go @@ -0,0 +1,133 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagementGroupInfo +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagementGroupInfo +} + +type ListOperationOptions struct { + CacheControl *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"@nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ManagementGroupsClient) List(ctx context.Context, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: "/providers/Microsoft.Management/managementGroups", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagementGroupInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ManagementGroupsClient) ListComplete(ctx context.Context, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, options, ManagementGroupInfoOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagementGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, options ListOperationOptions, predicate ManagementGroupInfoOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagementGroupInfo, 0) + + resp, err := c.List(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionscreate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionscreate.go new file mode 100644 index 000000000000..66afbb5c1494 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionscreate.go @@ -0,0 +1,83 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionUnderManagementGroup +} + +type SubscriptionsCreateOperationOptions struct { + CacheControl *string +} + +func DefaultSubscriptionsCreateOperationOptions() SubscriptionsCreateOperationOptions { + return SubscriptionsCreateOperationOptions{} +} + +func (o SubscriptionsCreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o SubscriptionsCreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o SubscriptionsCreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// SubscriptionsCreate ... +func (c ManagementGroupsClient) SubscriptionsCreate(ctx context.Context, id SubscriptionId, options SubscriptionsCreateOperationOptions) (result SubscriptionsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SubscriptionUnderManagementGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsdelete.go new file mode 100644 index 000000000000..36eb415e7097 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsdelete.go @@ -0,0 +1,76 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type SubscriptionsDeleteOperationOptions struct { + CacheControl *string +} + +func DefaultSubscriptionsDeleteOperationOptions() SubscriptionsDeleteOperationOptions { + return SubscriptionsDeleteOperationOptions{} +} + +func (o SubscriptionsDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o SubscriptionsDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o SubscriptionsDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// SubscriptionsDelete ... +func (c ManagementGroupsClient) SubscriptionsDelete(ctx context.Context, id SubscriptionId, options SubscriptionsDeleteOperationOptions) (result SubscriptionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscription.go new file mode 100644 index 000000000000..ff3ac1f4ec0d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscription.go @@ -0,0 +1,83 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionsGetSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionUnderManagementGroup +} + +type SubscriptionsGetSubscriptionOperationOptions struct { + CacheControl *string +} + +func DefaultSubscriptionsGetSubscriptionOperationOptions() SubscriptionsGetSubscriptionOperationOptions { + return SubscriptionsGetSubscriptionOperationOptions{} +} + +func (o SubscriptionsGetSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o SubscriptionsGetSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o SubscriptionsGetSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// SubscriptionsGetSubscription ... +func (c ManagementGroupsClient) SubscriptionsGetSubscription(ctx context.Context, id SubscriptionId, options SubscriptionsGetSubscriptionOperationOptions) (result SubscriptionsGetSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SubscriptionUnderManagementGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscriptionsundermanagementgroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscriptionsundermanagementgroup.go new file mode 100644 index 000000000000..7845486b2765 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_subscriptionsgetsubscriptionsundermanagementgroup.go @@ -0,0 +1,106 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionsGetSubscriptionsUnderManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SubscriptionUnderManagementGroup +} + +type SubscriptionsGetSubscriptionsUnderManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SubscriptionUnderManagementGroup +} + +type SubscriptionsGetSubscriptionsUnderManagementGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *SubscriptionsGetSubscriptionsUnderManagementGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// SubscriptionsGetSubscriptionsUnderManagementGroup ... +func (c ManagementGroupsClient) SubscriptionsGetSubscriptionsUnderManagementGroup(ctx context.Context, id commonids.ManagementGroupId) (result SubscriptionsGetSubscriptionsUnderManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &SubscriptionsGetSubscriptionsUnderManagementGroupCustomPager{}, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionUnderManagementGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SubscriptionsGetSubscriptionsUnderManagementGroupComplete retrieves all the results into a single object +func (c ManagementGroupsClient) SubscriptionsGetSubscriptionsUnderManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId) (SubscriptionsGetSubscriptionsUnderManagementGroupCompleteResult, error) { + return c.SubscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate(ctx, id, SubscriptionUnderManagementGroupOperationPredicate{}) +} + +// SubscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagementGroupsClient) SubscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, predicate SubscriptionUnderManagementGroupOperationPredicate) (result SubscriptionsGetSubscriptionsUnderManagementGroupCompleteResult, err error) { + items := make([]SubscriptionUnderManagementGroup, 0) + + resp, err := c.SubscriptionsGetSubscriptionsUnderManagementGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = SubscriptionsGetSubscriptionsUnderManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_update.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_update.go new file mode 100644 index 000000000000..f730bbb607ed --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_update.go @@ -0,0 +1,88 @@ +package managementgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagementGroup +} + +type UpdateOperationOptions struct { + CacheControl *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ManagementGroupsClient) Update(ctx context.Context, id commonids.ManagementGroupId, input PatchManagementGroupRequest, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagementGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_azureasyncoperationresults.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_azureasyncoperationresults.go new file mode 100644 index 000000000000..7b6662273600 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_azureasyncoperationresults.go @@ -0,0 +1,12 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureAsyncOperationResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagementGroupInfoProperties `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupchildinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupchildinfo.go new file mode 100644 index 000000000000..cad7e9197be7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupchildinfo.go @@ -0,0 +1,12 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateManagementGroupChildInfo struct { + Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *ManagementGroupChildType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupdetails.go new file mode 100644 index 000000000000..310a2b87b356 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupdetails.go @@ -0,0 +1,29 @@ +package managementgroups + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateManagementGroupDetails struct { + Parent *CreateParentGroupInfo `json:"parent,omitempty"` + UpdatedBy *string `json:"updatedBy,omitempty"` + UpdatedTime *string `json:"updatedTime,omitempty"` + Version *float64 `json:"version,omitempty"` +} + +func (o *CreateManagementGroupDetails) GetUpdatedTimeAsTime() (*time.Time, error) { + if o.UpdatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CreateManagementGroupDetails) SetUpdatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupproperties.go new file mode 100644 index 000000000000..8c6ea42250f6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgroupproperties.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateManagementGroupProperties struct { + Children *[]CreateManagementGroupChildInfo `json:"children,omitempty"` + Details *CreateManagementGroupDetails `json:"details,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgrouprequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgrouprequest.go new file mode 100644 index 000000000000..b8103f9d93c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createmanagementgrouprequest.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateManagementGroupRequest struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CreateManagementGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsproperties.go new file mode 100644 index 000000000000..54fe1d49b1d3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsproperties.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSettingsProperties struct { + DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` + RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsrequest.go new file mode 100644 index 000000000000..d4d600ef0b87 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createorupdatesettingsrequest.go @@ -0,0 +1,8 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSettingsRequest struct { + Properties *CreateOrUpdateSettingsProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createparentgroupinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createparentgroupinfo.go new file mode 100644 index 000000000000..930bf409bc78 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_createparentgroupinfo.go @@ -0,0 +1,10 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateParentGroupInfo struct { + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfo.go new file mode 100644 index 000000000000..80d5f6519f60 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfo.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DescendantInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DescendantInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfoproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfoproperties.go new file mode 100644 index 000000000000..828513c36698 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantinfoproperties.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DescendantInfoProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Parent *DescendantParentGroupInfo `json:"parent,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantparentgroupinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantparentgroupinfo.go new file mode 100644 index 000000000000..fb721e9d5c65 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_descendantparentgroupinfo.go @@ -0,0 +1,8 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DescendantParentGroupInfo struct { + Id *string `json:"id,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettings.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettings.go new file mode 100644 index 000000000000..6f9a61f2cf79 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettings.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettings struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HierarchySettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsinfo.go new file mode 100644 index 000000000000..61a337b299e4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsinfo.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HierarchySettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingslist.go new file mode 100644 index 000000000000..d9f9b853a411 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingslist.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsList struct { + NextLink *string `json:"@nextLink,omitempty"` + Value *[]HierarchySettingsInfo `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsproperties.go new file mode 100644 index 000000000000..25e8886ba170 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_hierarchysettingsproperties.go @@ -0,0 +1,10 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HierarchySettingsProperties struct { + DefaultManagementGroup *string `json:"defaultManagementGroup,omitempty"` + RequireAuthorizationForGroupCreation *bool `json:"requireAuthorizationForGroupCreation,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroup.go new file mode 100644 index 000000000000..57cbc9b2094b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroup.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagementGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupchildinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupchildinfo.go new file mode 100644 index 000000000000..9992212a850f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupchildinfo.go @@ -0,0 +1,12 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupChildInfo struct { + Children *[]ManagementGroupChildInfo `json:"children,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *ManagementGroupChildType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupdetails.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupdetails.go new file mode 100644 index 000000000000..173c8e81c02c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupdetails.go @@ -0,0 +1,30 @@ +package managementgroups + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupDetails struct { + Parent *ParentGroupInfo `json:"parent,omitempty"` + Path *[]ManagementGroupPathElement `json:"path,omitempty"` + UpdatedBy *string `json:"updatedBy,omitempty"` + UpdatedTime *string `json:"updatedTime,omitempty"` + Version *float64 `json:"version,omitempty"` +} + +func (o *ManagementGroupDetails) GetUpdatedTimeAsTime() (*time.Time, error) { + if o.UpdatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagementGroupDetails) SetUpdatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTime = &formatted +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfo.go new file mode 100644 index 000000000000..d6f44c383e64 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfo.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupInfo struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagementGroupInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfoproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfoproperties.go new file mode 100644 index 000000000000..e9c67c3e83de --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupinfoproperties.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupInfoProperties struct { + DisplayName *string `json:"displayName,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgrouppathelement.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgrouppathelement.go new file mode 100644 index 000000000000..71f71d49b9f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgrouppathelement.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupPathElement struct { + DisplayName *string `json:"displayName,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupproperties.go new file mode 100644 index 000000000000..1236f68ef7cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_managementgroupproperties.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupProperties struct { + Children *[]ManagementGroupChildInfo `json:"children,omitempty"` + Details *ManagementGroupDetails `json:"details,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_parentgroupinfo.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_parentgroupinfo.go new file mode 100644 index 000000000000..e376167a8ea1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_parentgroupinfo.go @@ -0,0 +1,10 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParentGroupInfo struct { + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_patchmanagementgrouprequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_patchmanagementgrouprequest.go new file mode 100644 index 000000000000..a34ec5f98dec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_patchmanagementgrouprequest.go @@ -0,0 +1,9 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchManagementGroupRequest struct { + DisplayName *string `json:"displayName,omitempty"` + ParentGroupId *string `json:"parentGroupId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroup.go new file mode 100644 index 000000000000..de3b510092d1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroup.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionUnderManagementGroup struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubscriptionUnderManagementGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroupproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroupproperties.go new file mode 100644 index 000000000000..10af6a9e8e60 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/model_subscriptionundermanagementgroupproperties.go @@ -0,0 +1,11 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionUnderManagementGroupProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Parent *DescendantParentGroupInfo `json:"parent,omitempty"` + State *string `json:"state,omitempty"` + Tenant *string `json:"tenant,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/predicates.go new file mode 100644 index 000000000000..0ae74d4138b4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/predicates.go @@ -0,0 +1,73 @@ +package managementgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DescendantInfoOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DescendantInfoOperationPredicate) Matches(input DescendantInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ManagementGroupInfoOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagementGroupInfoOperationPredicate) Matches(input ManagementGroupInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SubscriptionUnderManagementGroupOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SubscriptionUnderManagementGroupOperationPredicate) Matches(input SubscriptionUnderManagementGroup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/version.go new file mode 100644 index 000000000000..8446424fbd4f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/version.go @@ -0,0 +1,12 @@ +package managementgroups + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2020-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managementgroups/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 4761b5ecabfb..f1a0277883e0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -14,7 +14,6 @@ github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql github.com/Azure/azure-sdk-for-go/services/preview/synapse/mgmt/v2.0/synapse github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2018-07-10/siterecovery github.com/Azure/azure-sdk-for-go/services/recoveryservices/mgmt/2021-12-01/backup -github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-05-01/managementgroups github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage github.com/Azure/azure-sdk-for-go/services/web/mgmt/2021-02-01/web @@ -629,6 +628,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/managedidentity/2023-01-31 github.com/hashicorp/go-azure-sdk/resource-manager/managedidentity/2023-01-31/managedidentities github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationassignments github.com/hashicorp/go-azure-sdk/resource-manager/managedservices/2022-10-01/registrationdefinitions +github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups github.com/hashicorp/go-azure-sdk/resource-manager/maps/2023-06-01/accounts github.com/hashicorp/go-azure-sdk/resource-manager/maps/2023-06-01/creators github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/configurations