diff --git a/internal/clients/client.go b/internal/clients/client.go index 32d90814c3889..79e854ed4e9b5 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 bef6f82bfcf71..74cbca396375e 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 Domais 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 164952b7715b7..9d0e1d867353e 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_resource.go b/internal/services/managementgroup/management_group_resource.go index 7e2555140f451..8a7a08789a712 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,11 @@ 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), + Recurse: &recurse, + }) if err != nil { return fmt.Errorf("unable to retrieve Management Group %q: %+v", groupName, err) } @@ -184,18 +190,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.UbscriptionsDelete(ctx, managementgroups.NewSubscriptionID(groupName, subscriptionId), managementgroups.UbscriptionsDeleteOperationOptions{ + 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 +216,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.UbscriptionsCreate(ctx, managementgroups.NewSubscriptionID(groupName, subscriptionId), managementgroups.UbscriptionsCreateOperationOptions{ + CacheControl: &managementGroupCacheControl, + }); err != nil { return fmt.Errorf("[DEBUG] Error assigning Subscription ID %q to Management Group %q: %+v", subscriptionId, groupName, err) } } @@ -220,19 +232,23 @@ 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, + 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 +257,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 +286,65 @@ 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, + 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.UbscriptionsDelete(ctx, *subscriptionId, managementgroups.UbscriptionsDeleteOperationOptions{ + 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) - if err != nil { - return fmt.Errorf("unable to delete Management Group %q: %+v", id.Name, err) - } - - err = resp.WaitForCompletionRef(ctx, client.Client) + err = client.DeleteThenPoll(ctx, *id, managementgroups.DeleteOperationOptions{ + CacheControl: &managementGroupCacheControl, + }) 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 +362,52 @@ 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 { continue } - id, err := parseManagementGroupSubscriptionID(*child.ID) + if child.Id == nil { + continue + } + + 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 { + continue + } + + if 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 +417,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 ec6b51109425b..57a4ef2fd9123 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/subscription_association_resource.go b/internal/services/managementgroup/subscription_association_resource.go index 1a57a9cf405d0..cdf064e0da761 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.UbscriptionsCreate(ctx, id, managementgroups.UbscriptionsCreateOperationOptions{}); 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.UbscriptionsDelete(ctx, *id, managementgroups.UbscriptionsDeleteOperationOptions{}) 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 9172b325895b1..4f5b799ab927a 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/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 0000000000000..145e784f34633 --- /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.UbscriptionsCreate` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.UbscriptionsCreate(ctx, id, managementgroups.DefaultUbscriptionsCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.UbscriptionsDelete` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.UbscriptionsDelete(ctx, id, managementgroups.DefaultUbscriptionsDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.UbscriptionsGetSubscription` + +```go +ctx := context.TODO() +id := managementgroups.NewSubscriptionID("groupIdValue", "12345678-1234-9876-4563-123456789012") + +read, err := client.UbscriptionsGetSubscription(ctx, id, managementgroups.DefaultUbscriptionsGetSubscriptionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagementGroupsClient.UbscriptionsGetSubscriptionsUnderManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +// alternatively `client.UbscriptionsGetSubscriptionsUnderManagementGroup(ctx, id)` can be used to do batched pagination +items, err := client.UbscriptionsGetSubscriptionsUnderManagementGroupComplete(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 0000000000000..732b46ac1a449 --- /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 0000000000000..fbb80a7495229 --- /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 0000000000000..6359734004cd0 --- /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 0000000000000..ce7479fb2be5f --- /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, + Path: id.ID(), + OptionsObject: options, + } + + 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 0000000000000..451a9966d3343 --- /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, + Path: id.ID(), + OptionsObject: options, + } + + 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 0000000000000..34b1a41e5b27d --- /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, + Path: id.ID(), + OptionsObject: options, + } + + 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 0000000000000..0fba766591105 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_getdescendants.go @@ -0,0 +1,121 @@ +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 +} + +// 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, + Path: fmt.Sprintf("%s/descendants", id.ID()), + OptionsObject: options, + } + + 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 0000000000000..3f1794604e578 --- /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 0000000000000..2927e428a0dbb --- /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 0000000000000..bb7c557f1fe8e --- /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 0000000000000..038617f4220ea --- /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 0000000000000..6b7e694b1560c --- /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 0000000000000..4790de8646da5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_list.go @@ -0,0 +1,120 @@ +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 +} + +// 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, + Path: "/providers/Microsoft.Management/managementGroups", + OptionsObject: options, + } + + 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_ubscriptionscreate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionscreate.go new file mode 100644 index 0000000000000..d019e363be43d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionscreate.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 UbscriptionsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionUnderManagementGroup +} + +type UbscriptionsCreateOperationOptions struct { + CacheControl *string +} + +func DefaultUbscriptionsCreateOperationOptions() UbscriptionsCreateOperationOptions { + return UbscriptionsCreateOperationOptions{} +} + +func (o UbscriptionsCreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o UbscriptionsCreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UbscriptionsCreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UbscriptionsCreate ... +func (c ManagementGroupsClient) UbscriptionsCreate(ctx context.Context, id SubscriptionId, options UbscriptionsCreateOperationOptions) (result UbscriptionsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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_ubscriptionsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsdelete.go new file mode 100644 index 0000000000000..86b22491ea8ad --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsdelete.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 UbscriptionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UbscriptionsDeleteOperationOptions struct { + CacheControl *string +} + +func DefaultUbscriptionsDeleteOperationOptions() UbscriptionsDeleteOperationOptions { + return UbscriptionsDeleteOperationOptions{} +} + +func (o UbscriptionsDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o UbscriptionsDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UbscriptionsDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UbscriptionsDelete ... +func (c ManagementGroupsClient) UbscriptionsDelete(ctx context.Context, id SubscriptionId, options UbscriptionsDeleteOperationOptions) (result UbscriptionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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_ubscriptionsgetsubscription.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsgetsubscription.go new file mode 100644 index 0000000000000..76476b18cc7d5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsgetsubscription.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 UbscriptionsGetSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionUnderManagementGroup +} + +type UbscriptionsGetSubscriptionOperationOptions struct { + CacheControl *string +} + +func DefaultUbscriptionsGetSubscriptionOperationOptions() UbscriptionsGetSubscriptionOperationOptions { + return UbscriptionsGetSubscriptionOperationOptions{} +} + +func (o UbscriptionsGetSubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.CacheControl != nil { + out.Append("Cache-Control", fmt.Sprintf("%v", *o.CacheControl)) + } + return &out +} + +func (o UbscriptionsGetSubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UbscriptionsGetSubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UbscriptionsGetSubscription ... +func (c ManagementGroupsClient) UbscriptionsGetSubscription(ctx context.Context, id SubscriptionId, options UbscriptionsGetSubscriptionOperationOptions) (result UbscriptionsGetSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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_ubscriptionsgetsubscriptionsundermanagementgroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsgetsubscriptionsundermanagementgroup.go new file mode 100644 index 0000000000000..91a91f2d93945 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/managementgroups/2020-05-01/managementgroups/method_ubscriptionsgetsubscriptionsundermanagementgroup.go @@ -0,0 +1,93 @@ +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 UbscriptionsGetSubscriptionsUnderManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SubscriptionUnderManagementGroup +} + +type UbscriptionsGetSubscriptionsUnderManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SubscriptionUnderManagementGroup +} + +// UbscriptionsGetSubscriptionsUnderManagementGroup ... +func (c ManagementGroupsClient) UbscriptionsGetSubscriptionsUnderManagementGroup(ctx context.Context, id commonids.ManagementGroupId) (result UbscriptionsGetSubscriptionsUnderManagementGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} + +// UbscriptionsGetSubscriptionsUnderManagementGroupComplete retrieves all the results into a single object +func (c ManagementGroupsClient) UbscriptionsGetSubscriptionsUnderManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId) (UbscriptionsGetSubscriptionsUnderManagementGroupCompleteResult, error) { + return c.UbscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate(ctx, id, SubscriptionUnderManagementGroupOperationPredicate{}) +} + +// UbscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagementGroupsClient) UbscriptionsGetSubscriptionsUnderManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, predicate SubscriptionUnderManagementGroupOperationPredicate) (result UbscriptionsGetSubscriptionsUnderManagementGroupCompleteResult, err error) { + items := make([]SubscriptionUnderManagementGroup, 0) + + resp, err := c.UbscriptionsGetSubscriptionsUnderManagementGroup(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 = UbscriptionsGetSubscriptionsUnderManagementGroupCompleteResult{ + 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 0000000000000..5b586aac06d6c --- /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, + Path: id.ID(), + OptionsObject: options, + } + + 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 0000000000000..7b6662273600c --- /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 0000000000000..cad7e9197be7f --- /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 0000000000000..310a2b87b356a --- /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 0000000000000..8c6ea42250f60 --- /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 0000000000000..b8103f9d93c34 --- /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 0000000000000..54fe1d49b1d34 --- /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 0000000000000..d4d600ef0b87e --- /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 0000000000000..930bf409bc786 --- /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 0000000000000..80d5f6519f601 --- /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 0000000000000..828513c36698e --- /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 0000000000000..fb721e9d5c651 --- /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 0000000000000..6f9a61f2cf79d --- /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 0000000000000..61a337b299e4e --- /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 0000000000000..d9f9b853a411a --- /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 0000000000000..25e8886ba170d --- /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 0000000000000..57cbc9b2094bf --- /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 0000000000000..9992212a850f1 --- /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 0000000000000..173c8e81c02cd --- /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 0000000000000..d6f44c383e64a --- /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 0000000000000..e9c67c3e83de7 --- /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 0000000000000..71f71d49b9f82 --- /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 0000000000000..1236f68ef7cf6 --- /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 0000000000000..e376167a8ea12 --- /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 0000000000000..a34ec5f98decb --- /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 0000000000000..de3b510092d1d --- /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 0000000000000..10af6a9e8e60e --- /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 0000000000000..0ae74d4138b4e --- /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 0000000000000..8446424fbd4f5 --- /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 60c83a615b4ad..b339f17529115 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -629,6 +629,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