From 0f2e562bf44fab50b6b26a706a4fdd7972846a6c Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 12:16:35 +0100 Subject: [PATCH 01/10] data.azuread_users: consolidate API requests to remove an unnecessary additional GET request per user --- internal/services/users/users_data_source.go | 77 ++++++++------------ 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/internal/services/users/users_data_source.go b/internal/services/users/users_data_source.go index 3a21e8f11..203a0bc71 100644 --- a/internal/services/users/users_data_source.go +++ b/internal/services/users/users_data_source.go @@ -190,13 +190,29 @@ func usersData() *pluginsdk.Resource { func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) pluginsdk.Diagnostics { client := meta.(*clients.Client).Users.UserClient - foundObjectIds := make([]string, 0) + foundUsers := make([]stable.User, 0) var expectedCount int ignoreMissing := d.Get("ignore_missing").(bool) returnAll := d.Get("return_all").(bool) + // Users API changes which fields it sends by default, so we explicitly select the fields we want, to guard against this + fieldsToSelect := []string{ + "accountEnabled", + "displayName", + "employeeId", + "id", + "mail", + "mailNickname", + "onPremisesImmutableId", + "onPremisesSamAccountName", + "onPremisesUserPrincipalName", + "usageLocation", + "userPrincipalName", + "userType", + } + if returnAll { - resp, err := client.ListUsers(ctx, user.ListUsersOperationOptions{Select: pointer.To([]string{"id"})}) + resp, err := client.ListUsers(ctx, user.ListUsersOperationOptions{Select: &fieldsToSelect}) if err != nil { return tf.ErrorDiagF(err, "Could not retrieve users") } @@ -208,7 +224,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in } for _, u := range *resp.Model { - foundObjectIds = append(foundObjectIds, pointer.From(u.Id)) + foundUsers = append(foundUsers, u) } } else if upns, ok := d.Get("user_principal_names").([]interface{}); ok && len(upns) > 0 { @@ -216,7 +232,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in for _, v := range upns { options := user.ListUsersOperationOptions{ Filter: pointer.To(fmt.Sprintf("userPrincipalName eq '%s'", odata.EscapeSingleQuote(v.(string)))), - Select: pointer.To([]string{"id"}), + Select: &fieldsToSelect, } resp, err := client.ListUsers(ctx, options) if err != nil { @@ -235,14 +251,14 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(err, "user_principal_names", "User with UPN %q was not found", v) } - foundObjectIds = append(foundObjectIds, pointer.From((*resp.Model)[0].Id)) + foundUsers = append(foundUsers, (*resp.Model)[0]) } } else { if objectIds, ok := d.Get("object_ids").([]interface{}); ok && len(objectIds) > 0 { expectedCount = len(objectIds) for _, v := range objectIds { - resp, err := client.GetUser(ctx, stable.NewUserID(v.(string)), user.GetUserOperationOptions{Select: pointer.To([]string{"id"})}) + resp, err := client.GetUser(ctx, stable.NewUserID(v.(string)), user.GetUserOperationOptions{Select: &fieldsToSelect}) if err != nil { if response.WasNotFound(resp.HttpResponse) { if ignoreMissing { @@ -256,7 +272,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(nil, "object_id", "User not found with object ID: %q", v) } - foundObjectIds = append(foundObjectIds, pointer.From(resp.Model.Id)) + foundUsers = append(foundUsers, *resp.Model) } } else if mailNicknames, ok := d.Get("mail_nicknames").([]interface{}); ok && len(mailNicknames) > 0 { @@ -264,7 +280,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in for _, v := range mailNicknames { options := user.ListUsersOperationOptions{ Filter: pointer.To(fmt.Sprintf("mailNickname eq '%s'", odata.EscapeSingleQuote(v.(string)))), - Select: pointer.To([]string{"id"}), + Select: &fieldsToSelect, } resp, err := client.ListUsers(ctx, options) if err != nil { @@ -284,7 +300,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(err, "mail_nicknames", "User not found with email alias: %q", v) } - foundObjectIds = append(foundObjectIds, pointer.From((*resp.Model)[0].Id)) + foundUsers = append(foundUsers, (*resp.Model)[0]) } } else if mails, ok := d.Get("mails").([]interface{}); ok && len(mails) > 0 { @@ -292,7 +308,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in for _, v := range mails { options := user.ListUsersOperationOptions{ Filter: pointer.To(fmt.Sprintf("mail eq '%s'", odata.EscapeSingleQuote(v.(string)))), - Select: pointer.To([]string{"id"}), + Select: &fieldsToSelect, } resp, err := client.ListUsers(ctx, options) if err != nil { @@ -312,7 +328,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(err, "mails", "User not found with mail address: %q", v) } - foundObjectIds = append(foundObjectIds, pointer.From((*resp.Model)[0].Id)) + foundUsers = append(foundUsers, (*resp.Model)[0]) } } else if employeeIds, ok := d.Get("employee_ids").([]interface{}); ok && len(employeeIds) > 0 { @@ -320,7 +336,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in for _, v := range employeeIds { options := user.ListUsersOperationOptions{ Filter: pointer.To(fmt.Sprintf("employeeId eq '%s'", odata.EscapeSingleQuote(v.(string)))), - Select: pointer.To([]string{"id"}), + Select: &fieldsToSelect, } resp, err := client.ListUsers(ctx, options) if err != nil { @@ -340,14 +356,14 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(err, "employee_ids", "User not found with employee ID: %q", v) } - foundObjectIds = append(foundObjectIds, pointer.From((*resp.Model)[0].Id)) + foundUsers = append(foundUsers, (*resp.Model)[0]) } } } // Check that the right number of users were returned - if !returnAll && !ignoreMissing && len(foundObjectIds) != expectedCount { - return tf.ErrorDiagF(fmt.Errorf("expected: %d, actual: %d", expectedCount, len(foundObjectIds)), "Unexpected number of users returned") + if !returnAll && !ignoreMissing && len(foundUsers) != expectedCount { + return tf.ErrorDiagF(fmt.Errorf("expected: %d, actual: %d", expectedCount, len(foundUsers)), "Unexpected number of users returned") } upns := make([]string, 0) @@ -357,36 +373,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in employeeIds := make([]string, 0) userList := make([]map[string]interface{}, 0) - // Users API changes which fields it sends by default, so we explicitly select the fields we want to guard against this - options := user.GetUserOperationOptions{ - Select: pointer.To([]string{ - "accountEnabled", - "displayName", - "employeeId", - "id", - "mail", - "mailNickname", - "onPremisesImmutableId", - "onPremisesSamAccountName", - "onPremisesUserPrincipalName", - "usageLocation", - "userPrincipalName", - "userType", - }), - } - - for _, objectId := range foundObjectIds { - id := stable.NewUserID(objectId) - resp, err := client.GetUser(ctx, id, options) - if err != nil { - return tf.ErrorDiagF(err, "Retrieving %s", id) - } - - u := resp.Model - if u == nil { - return tf.ErrorDiagF(errors.New("model was nil"), "Retrieving %s", id) - } - + for _, u := range foundUsers { if u.Id == nil || u.UserPrincipalName == nil { return tf.ErrorDiagF(errors.New("API returned user with nil object ID or userPrincipalName"), "Bad API Response") } From 00152f2a1d6128ca8ed6cb8b0f07846bb2494a05 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 12:17:08 +0100 Subject: [PATCH 02/10] data.azuread_service_principals: retry retrieval from beta API to smooth out spurious 404s --- .../serviceprincipals/service_principals_data_source.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/services/serviceprincipals/service_principals_data_source.go b/internal/services/serviceprincipals/service_principals_data_source.go index 531e36c44..05454c3fb 100644 --- a/internal/services/serviceprincipals/service_principals_data_source.go +++ b/internal/services/serviceprincipals/service_principals_data_source.go @@ -9,6 +9,7 @@ import ( "encoding/base64" "errors" "fmt" + "net/http" "strings" "time" @@ -331,6 +332,12 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD // Retrieve from beta API to get samlMetadataUrl field options := serviceprincipalBeta.GetServicePrincipalOperationOptions{ + RetryFunc: func(resp *http.Response, o *odata.OData) (bool, error) { + if resp == nil || response.WasNotFound(resp) { + return true, nil + } + return false, nil + }, Select: pointer.To([]string{"samlMetadataUrl"}), } resp, err := clientBeta.GetServicePrincipal(ctx, beta.NewServicePrincipalID(*s.Id), options) From 9784dd94a8d95158b876390497ddfbd0236ff150 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 12:39:17 +0100 Subject: [PATCH 03/10] azuread_authentication_strength_policy: consistency check after creation --- .../authentication_strength_policy_resource.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/services/policies/authentication_strength_policy_resource.go b/internal/services/policies/authentication_strength_policy_resource.go index cf83c077c..8e1e288b7 100644 --- a/internal/services/policies/authentication_strength_policy_resource.go +++ b/internal/services/policies/authentication_strength_policy_resource.go @@ -114,6 +114,21 @@ func authenticationStrengthPolicyCreate(ctx context.Context, d *pluginsdk.Resour } id := stable.NewPolicyAuthenticationStrengthPolicyID(*authenticationStrengthPolicy.Id) + + // Wait for the policy to appear consistently + if err = consistency.WaitForUpdate(ctx, func(ctx context.Context) (*bool, error) { + resp, err := client.GetAuthenticationStrengthPolicy(ctx, id, authenticationstrengthpolicy.DefaultGetAuthenticationStrengthPolicyOperationOptions()) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return pointer.To(false), nil + } + return pointer.To(false), fmt.Errorf("retrieving authentication strength policy") + } + return pointer.To(true), nil + }); err != nil { + return tf.ErrorDiagF(err, "Waiting for creation of %s", id) + } + d.SetId(id.AuthenticationStrengthPolicyId) return authenticationStrengthPolicyRead(ctx, d, meta) From a31b458574d7499d9f16986073a021114da686d9 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 12:41:34 +0100 Subject: [PATCH 04/10] azuread_directory_role_eligibility_schedule_request: extend creation timeout --- .../directory_role_eligibility_schedule_request_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go index 117d82fa6..e5e9a244f 100644 --- a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go +++ b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource.go @@ -32,7 +32,7 @@ func directoryRoleEligibilityScheduleRequestResource() *pluginsdk.Resource { DeleteContext: directoryRoleEligibilityScheduleRequestResourceDelete, Timeouts: &pluginsdk.ResourceTimeout{ - Create: pluginsdk.DefaultTimeout(5 * time.Minute), + Create: pluginsdk.DefaultTimeout(10 * time.Minute), Read: pluginsdk.DefaultTimeout(5 * time.Minute), Delete: pluginsdk.DefaultTimeout(5 * time.Minute), }, From 8d08d8bacc65cea3eb5f5cd1763fd95139aed8e5 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 13:05:27 +0100 Subject: [PATCH 05/10] azuread_administrative_unit: consistency fixes, use beta API for delete operation --- .../administrative_unit_resource.go | 51 +-- .../administrativeunits/client/client.go | 10 + .../beta/administrativeunit/README.md | 296 ++++++++++++++++++ .../beta/administrativeunit/client.go | 26 ++ .../method_checkmembergroups.go | 142 +++++++++ .../method_checkmemberobjects.go | 138 ++++++++ .../method_createadministrativeunit.go | 89 ++++++ .../method_creategetsuserownedobject.go | 96 ++++++ .../method_createvalidatesproperty.go | 89 ++++++ .../method_deleteadministrativeunit.go | 82 +++++ .../method_getadministrativeunit.go | 95 ++++++ .../method_getmembergroups.go | 142 +++++++++ .../method_getmemberobjects.go | 138 ++++++++ .../administrativeunit/method_getscount.go | 96 ++++++ .../method_listadministrativeunits.go | 173 ++++++++++ .../method_listgetsbyids.go | 158 ++++++++++ .../beta/administrativeunit/method_restore.go | 100 ++++++ .../method_updateadministrativeunit.go | 82 +++++ .../model_checkmembergroupsrequest.go | 8 + .../model_checkmemberobjectsrequest.go | 8 + .../model_creategetsuserownedobjectrequest.go | 13 + .../model_createvalidatespropertyrequest.go | 15 + .../model_getmembergroupsrequest.go | 12 + .../model_getmemberobjectsrequest.go | 12 + .../model_listgetsbyidsrequest.go | 9 + .../model_restorerequest.go | 12 + .../beta/administrativeunit/predicates.go | 22 ++ .../beta/administrativeunit/version.go | 10 + vendor/modules.txt | 1 + 29 files changed, 2106 insertions(+), 19 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmembergroups.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmemberobjects.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createadministrativeunit.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_creategetsuserownedobject.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createvalidatesproperty.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_deleteadministrativeunit.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getadministrativeunit.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmembergroups.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmemberobjects.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getscount.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listadministrativeunits.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listgetsbyids.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_restore.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_updateadministrativeunit.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmembergroupsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmemberobjectsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_creategetsuserownedobjectrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_createvalidatespropertyrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmembergroupsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmemberobjectsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_listgetsbyidsrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_restorerequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/version.go diff --git a/internal/services/administrativeunits/administrative_unit_resource.go b/internal/services/administrativeunits/administrative_unit_resource.go index 343bfda5a..76c8822ba 100644 --- a/internal/services/administrativeunits/administrative_unit_resource.go +++ b/internal/services/administrativeunits/administrative_unit_resource.go @@ -8,15 +8,19 @@ import ( "errors" "fmt" "log" + "net/http" "strings" "time" "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" + administrativeunitBeta "github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit" + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/stable" "github.com/hashicorp/go-azure-sdk/microsoft-graph/directory/stable/administrativeunit" "github.com/hashicorp/go-azure-sdk/microsoft-graph/directory/stable/administrativeunitmember" "github.com/hashicorp/go-azure-sdk/sdk/nullable" + "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-provider-azuread/internal/clients" "github.com/hashicorp/terraform-provider-azuread/internal/helpers/consistency" @@ -188,23 +192,31 @@ func administrativeUnitResourceCreate(ctx context.Context, d *pluginsdk.Resource id := stable.NewDirectoryAdministrativeUnitID(*administrativeUnit.Id) updateResp, err := client.UpdateAdministrativeUnit(ctx, id, stable.AdministrativeUnit{ DisplayName: nullable.Value(tempDisplayName), - }, administrativeunit.DefaultUpdateAdministrativeUnitOperationOptions()) + }, administrativeunit.UpdateAdministrativeUnitOperationOptions{ + RetryFunc: func(resp *http.Response, o *odata.OData) (bool, error) { + return response.WasNotFound(resp), nil + }, + }) if err != nil { if response.WasNotFound(updateResp.HttpResponse) { - return tf.ErrorDiagF(err, "Timed out whilst waiting for new administrative unit to be replicated in Azure AD") + return tf.ErrorDiagF(err, "Timed out whilst waiting for new %s to be replicated in Azure AD", id) } - return tf.ErrorDiagF(err, "Failed to patch administrative unit after creating") + return tf.ErrorDiagF(err, "Failed to patch %s after creating", id) } // Set correct original display name updateResp, err = client.UpdateAdministrativeUnit(ctx, id, stable.AdministrativeUnit{ DisplayName: nullable.Value(displayName), - }, administrativeunit.DefaultUpdateAdministrativeUnitOperationOptions()) + }, administrativeunit.UpdateAdministrativeUnitOperationOptions{ + RetryFunc: func(resp *http.Response, o *odata.OData) (bool, error) { + return response.WasNotFound(resp), nil + }, + }) if err != nil { if response.WasNotFound(updateResp.HttpResponse) { - return tf.ErrorDiagF(err, "Timed out whilst waiting for new administrative unit to be replicated in Azure AD") + return tf.ErrorDiagF(err, "Timed out whilst waiting for new %s to be replicated in Azure AD", id) } - return tf.ErrorDiagF(err, "Failed to patch administrative unit after creating") + return tf.ErrorDiagF(err, "Failed to patch %s after creating", id) } // Add members after the administrative unit is created @@ -217,7 +229,7 @@ func administrativeUnitResourceCreate(ctx context.Context, d *pluginsdk.Resource } if _, err = memberClient.AddAdministrativeUnitMemberRef(ctx, id, addMemberProperties, administrativeunitmember.DefaultAddAdministrativeUnitMemberRefOperationOptions()); err != nil { - return tf.ErrorDiagF(err, "Could not add member %q to administrative unit with object ID: %q", memberId, d.Id()) + return tf.ErrorDiagF(err, "Could not add member %q to %s", memberId, id) } } } @@ -266,13 +278,13 @@ func administrativeUnitResourceUpdate(ctx context.Context, d *pluginsdk.Resource } if _, err := client.UpdateAdministrativeUnit(ctx, id, administrativeUnit, administrativeunit.DefaultUpdateAdministrativeUnitOperationOptions()); err != nil { - return tf.ErrorDiagF(err, "Updating administrative unit with ID: %q", d.Id()) + return tf.ErrorDiagF(err, "Updating %s", id) } if d.HasChange("members") { membersResp, err := memberClient.ListAdministrativeUnitMembers(ctx, id, administrativeunitmember.DefaultListAdministrativeUnitMembersOperationOptions()) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve members for administrative unit with object ID: %q", d.Id()) + return tf.ErrorDiagF(err, "Could not retrieve members for %s", id) } existingMembers := make([]string, 0) @@ -285,7 +297,7 @@ func administrativeUnitResourceUpdate(ctx context.Context, d *pluginsdk.Resource for _, memberForRemoval := range membersForRemoval { if _, err = memberClient.RemoveAdministrativeUnitMemberRef(ctx, stable.NewDirectoryAdministrativeUnitIdMemberID(administrativeUnitId, memberForRemoval), administrativeunitmember.DefaultRemoveAdministrativeUnitMemberRefOperationOptions()); err != nil { - return tf.ErrorDiagF(err, "Could not remove members from administrative unit with object ID: %q", d.Id()) + return tf.ErrorDiagF(err, "Could not remove members from %s", id) } } @@ -297,7 +309,7 @@ func administrativeUnitResourceUpdate(ctx context.Context, d *pluginsdk.Resource } if _, err = memberClient.AddAdministrativeUnitMemberRef(ctx, id, addMemberProperties, administrativeunitmember.DefaultAddAdministrativeUnitMemberRefOperationOptions()); err != nil { - return tf.ErrorDiagF(err, "Could not add member %q to administrative unit with object ID: %q", memberId, d.Id()) + return tf.ErrorDiagF(err, "Could not add member %q to %s", memberId, id) } } } @@ -313,11 +325,11 @@ func administrativeUnitResourceRead(ctx context.Context, d *pluginsdk.ResourceDa resp, err := client.GetAdministrativeUnit(ctx, id, administrativeunit.DefaultGetAdministrativeUnitOperationOptions()) if err != nil { if response.WasNotFound(resp.HttpResponse) { - log.Printf("[DEBUG] Administrative Unit with ID %q was not found - removing from state", d.Id()) + log.Printf("[DEBUG] %s was not found - removing from state", id) d.SetId("") return nil } - return tf.ErrorDiagF(err, "Retrieving administrative unit with object ID: %q", d.Id()) + return tf.ErrorDiagF(err, "Retrieving %s", id) } administrativeUnit := resp.Model @@ -330,7 +342,7 @@ func administrativeUnitResourceRead(ctx context.Context, d *pluginsdk.ResourceDa membersResp, err := memberClient.ListAdministrativeUnitMembers(ctx, id, administrativeunitmember.DefaultListAdministrativeUnitMembersOperationOptions()) if err != nil { - return tf.ErrorDiagF(err, "Could not retrieve members for administrative unit with object ID: %q", d.Id()) + return tf.ErrorDiagF(err, "Could not retrieve members for %s", id) } members := make([]string, 0) @@ -350,15 +362,16 @@ func administrativeUnitResourceRead(ctx context.Context, d *pluginsdk.ResourceDa func administrativeUnitResourceDelete(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) pluginsdk.Diagnostics { client := meta.(*clients.Client).AdministrativeUnits.AdministrativeUnitClient - id := stable.NewDirectoryAdministrativeUnitID(d.Id()) + clientBeta := meta.(*clients.Client).AdministrativeUnits.AdministrativeUnitClientBeta + id := beta.NewAdministrativeUnitID(d.Id()) - if _, err := client.DeleteAdministrativeUnit(ctx, id, administrativeunit.DefaultDeleteAdministrativeUnitOperationOptions()); err != nil { - return tf.ErrorDiagF(err, "Deleting administrative unit with object ID: %q", id.AdministrativeUnitId) + if _, err := clientBeta.DeleteAdministrativeUnit(ctx, id, administrativeunitBeta.DefaultDeleteAdministrativeUnitOperationOptions()); err != nil { + return tf.ErrorDiagF(err, "Deleting %s", id) } // Wait for administrative unit object to be deleted if err := consistency.WaitForDeletion(ctx, func(ctx context.Context) (*bool, error) { - if resp, err := client.GetAdministrativeUnit(ctx, id, administrativeunit.DefaultGetAdministrativeUnitOperationOptions()); err != nil { + if resp, err := client.GetAdministrativeUnit(ctx, stable.NewDirectoryAdministrativeUnitID(id.AdministrativeUnitId), administrativeunit.DefaultGetAdministrativeUnitOperationOptions()); err != nil { if response.WasNotFound(resp.HttpResponse) { return pointer.To(false), nil } @@ -366,7 +379,7 @@ func administrativeUnitResourceDelete(ctx context.Context, d *pluginsdk.Resource } return pointer.To(true), nil }); err != nil { - return tf.ErrorDiagF(err, "Waiting for deletion of administrative unit with object ID %q", id.AdministrativeUnitId) + return tf.ErrorDiagF(err, "Waiting for deletion of %s", id) } return nil diff --git a/internal/services/administrativeunits/client/client.go b/internal/services/administrativeunits/client/client.go index 319badc10..8db534510 100644 --- a/internal/services/administrativeunits/client/client.go +++ b/internal/services/administrativeunits/client/client.go @@ -4,6 +4,7 @@ package client import ( + administrativeunitBeta "github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit" "github.com/hashicorp/go-azure-sdk/microsoft-graph/directory/stable/administrativeunit" "github.com/hashicorp/go-azure-sdk/microsoft-graph/directory/stable/administrativeunitmember" "github.com/hashicorp/go-azure-sdk/microsoft-graph/directory/stable/administrativeunitscopedrolemember" @@ -12,6 +13,7 @@ import ( type Client struct { AdministrativeUnitClient *administrativeunit.AdministrativeUnitClient + AdministrativeUnitClientBeta *administrativeunitBeta.AdministrativeUnitClient AdministrativeUnitMemberClient *administrativeunitmember.AdministrativeUnitMemberClient AdministrativeUnitScopedRoleMemberClient *administrativeunitscopedrolemember.AdministrativeUnitScopedRoleMemberClient } @@ -23,6 +25,13 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(administrativeUnitClient.Client) + // Beta API needed to delete administrative units - the stable API is broken and returns 404 with `{"Message":"The OData path is invalid."}` + administrativeUnitClientBeta, err := administrativeunitBeta.NewAdministrativeUnitClientWithBaseURI(o.Environment.MicrosoftGraph) + if err != nil { + return nil, err + } + o.Configure(administrativeUnitClientBeta.Client) + memberClient, err := administrativeunitmember.NewAdministrativeUnitMemberClientWithBaseURI(o.Environment.MicrosoftGraph) if err != nil { return nil, err @@ -37,6 +46,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { return &Client{ AdministrativeUnitClient: administrativeUnitClient, + AdministrativeUnitClientBeta: administrativeUnitClientBeta, AdministrativeUnitMemberClient: memberClient, AdministrativeUnitScopedRoleMemberClient: scopedRoleMemberClient, }, nil diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/README.md b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/README.md new file mode 100644 index 000000000..55584792d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/README.md @@ -0,0 +1,296 @@ + +## `github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit` Documentation + +The `administrativeunit` SDK allows for interaction with Microsoft Graph `administrativeunits` (API Version `beta`). + +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-sdk/microsoft-graph/administrativeunits/beta/administrativeunit" +``` + + +### Client Initialization + +```go +client := administrativeunit.NewAdministrativeUnitClientWithBaseURI("https://graph.microsoft.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdministrativeUnitClient.CheckMemberGroups` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.CheckMemberGroupsRequest{ + // ... +} + + +// alternatively `client.CheckMemberGroups(ctx, id, payload, administrativeunit.DefaultCheckMemberGroupsOperationOptions())` can be used to do batched pagination +items, err := client.CheckMemberGroupsComplete(ctx, id, payload, administrativeunit.DefaultCheckMemberGroupsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.CheckMemberObjects` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.CheckMemberObjectsRequest{ + // ... +} + + +// alternatively `client.CheckMemberObjects(ctx, id, payload, administrativeunit.DefaultCheckMemberObjectsOperationOptions())` can be used to do batched pagination +items, err := client.CheckMemberObjectsComplete(ctx, id, payload, administrativeunit.DefaultCheckMemberObjectsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.CreateAdministrativeUnit` + +```go +ctx := context.TODO() + +payload := administrativeunit.AdministrativeUnit{ + // ... +} + + +read, err := client.CreateAdministrativeUnit(ctx, payload, administrativeunit.DefaultCreateAdministrativeUnitOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.CreateGetsUserOwnedObject` + +```go +ctx := context.TODO() + +payload := administrativeunit.CreateGetsUserOwnedObjectRequest{ + // ... +} + + +read, err := client.CreateGetsUserOwnedObject(ctx, payload, administrativeunit.DefaultCreateGetsUserOwnedObjectOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.CreateValidatesProperty` + +```go +ctx := context.TODO() + +payload := administrativeunit.CreateValidatesPropertyRequest{ + // ... +} + + +read, err := client.CreateValidatesProperty(ctx, payload, administrativeunit.DefaultCreateValidatesPropertyOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.DeleteAdministrativeUnit` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +read, err := client.DeleteAdministrativeUnit(ctx, id, administrativeunit.DefaultDeleteAdministrativeUnitOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.GetAdministrativeUnit` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +read, err := client.GetAdministrativeUnit(ctx, id, administrativeunit.DefaultGetAdministrativeUnitOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.GetMemberGroups` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.GetMemberGroupsRequest{ + // ... +} + + +// alternatively `client.GetMemberGroups(ctx, id, payload, administrativeunit.DefaultGetMemberGroupsOperationOptions())` can be used to do batched pagination +items, err := client.GetMemberGroupsComplete(ctx, id, payload, administrativeunit.DefaultGetMemberGroupsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.GetMemberObjects` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.GetMemberObjectsRequest{ + // ... +} + + +// alternatively `client.GetMemberObjects(ctx, id, payload, administrativeunit.DefaultGetMemberObjectsOperationOptions())` can be used to do batched pagination +items, err := client.GetMemberObjectsComplete(ctx, id, payload, administrativeunit.DefaultGetMemberObjectsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.GetsCount` + +```go +ctx := context.TODO() + + +read, err := client.GetsCount(ctx, administrativeunit.DefaultGetsCountOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.ListAdministrativeUnits` + +```go +ctx := context.TODO() + + +// alternatively `client.ListAdministrativeUnits(ctx, administrativeunit.DefaultListAdministrativeUnitsOperationOptions())` can be used to do batched pagination +items, err := client.ListAdministrativeUnitsComplete(ctx, administrativeunit.DefaultListAdministrativeUnitsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.ListGetsByIds` + +```go +ctx := context.TODO() + +payload := administrativeunit.ListGetsByIdsRequest{ + // ... +} + + +// alternatively `client.ListGetsByIds(ctx, payload, administrativeunit.DefaultListGetsByIdsOperationOptions())` can be used to do batched pagination +items, err := client.ListGetsByIdsComplete(ctx, payload, administrativeunit.DefaultListGetsByIdsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AdministrativeUnitClient.Restore` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.RestoreRequest{ + // ... +} + + +read, err := client.Restore(ctx, id, payload, administrativeunit.DefaultRestoreOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdministrativeUnitClient.UpdateAdministrativeUnit` + +```go +ctx := context.TODO() +id := administrativeunit.NewAdministrativeUnitID("administrativeUnitId") + +payload := administrativeunit.AdministrativeUnit{ + // ... +} + + +read, err := client.UpdateAdministrativeUnit(ctx, id, payload, administrativeunit.DefaultUpdateAdministrativeUnitOperationOptions()) +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/microsoft-graph/administrativeunits/beta/administrativeunit/client.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/client.go new file mode 100644 index 000000000..82df8aaca --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/client.go @@ -0,0 +1,26 @@ +package administrativeunit + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/msgraph" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdministrativeUnitClient struct { + Client *msgraph.Client +} + +func NewAdministrativeUnitClientWithBaseURI(sdkApi sdkEnv.Api) (*AdministrativeUnitClient, error) { + client, err := msgraph.NewClient(sdkApi, "administrativeunit", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdministrativeUnitClient: %+v", err) + } + + return &AdministrativeUnitClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmembergroups.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmembergroups.go new file mode 100644 index 000000000..bae1ef639 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmembergroups.go @@ -0,0 +1,142 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckMemberGroupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type CheckMemberGroupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type CheckMemberGroupsOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Skip *int64 + Top *int64 +} + +func DefaultCheckMemberGroupsOperationOptions() CheckMemberGroupsOperationOptions { + return CheckMemberGroupsOperationOptions{} +} + +func (o CheckMemberGroupsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CheckMemberGroupsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o CheckMemberGroupsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type CheckMemberGroupsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *CheckMemberGroupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CheckMemberGroups - Invoke action checkMemberGroups. Check for membership in a specified list of group IDs, and +// return from that list those groups (identified by IDs) of which the specified user, group, service principal, +// organizational contact, device, or directory object is a member. This function is transitive. You can check up to a +// maximum of 20 groups per request. This function supports all groups provisioned in Microsoft Entra ID. Because +// Microsoft 365 groups cannot contain other groups, membership in a Microsoft 365 group is always direct. +func (c AdministrativeUnitClient) CheckMemberGroups(ctx context.Context, id beta.AdministrativeUnitId, input CheckMemberGroupsRequest, options CheckMemberGroupsOperationOptions) (result CheckMemberGroupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &CheckMemberGroupsCustomPager{}, + Path: fmt.Sprintf("%s/checkMemberGroups", id.ID()), + RetryFunc: options.RetryFunc, + } + + 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CheckMemberGroupsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) CheckMemberGroupsComplete(ctx context.Context, id beta.AdministrativeUnitId, input CheckMemberGroupsRequest, options CheckMemberGroupsOperationOptions) (result CheckMemberGroupsCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.CheckMemberGroups(ctx, id, input, 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 { + items = append(items, v) + } + } + + result = CheckMemberGroupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmemberobjects.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmemberobjects.go new file mode 100644 index 000000000..0eec6c221 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_checkmemberobjects.go @@ -0,0 +1,138 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckMemberObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type CheckMemberObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type CheckMemberObjectsOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Skip *int64 + Top *int64 +} + +func DefaultCheckMemberObjectsOperationOptions() CheckMemberObjectsOperationOptions { + return CheckMemberObjectsOperationOptions{} +} + +func (o CheckMemberObjectsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CheckMemberObjectsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o CheckMemberObjectsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type CheckMemberObjectsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *CheckMemberObjectsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CheckMemberObjects - Invoke action checkMemberObjects +func (c AdministrativeUnitClient) CheckMemberObjects(ctx context.Context, id beta.AdministrativeUnitId, input CheckMemberObjectsRequest, options CheckMemberObjectsOperationOptions) (result CheckMemberObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &CheckMemberObjectsCustomPager{}, + Path: fmt.Sprintf("%s/checkMemberObjects", id.ID()), + RetryFunc: options.RetryFunc, + } + + 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CheckMemberObjectsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) CheckMemberObjectsComplete(ctx context.Context, id beta.AdministrativeUnitId, input CheckMemberObjectsRequest, options CheckMemberObjectsOperationOptions) (result CheckMemberObjectsCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.CheckMemberObjects(ctx, id, input, 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 { + items = append(items, v) + } + } + + result = CheckMemberObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createadministrativeunit.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createadministrativeunit.go new file mode 100644 index 000000000..ba6e78133 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createadministrativeunit.go @@ -0,0 +1,89 @@ +package administrativeunit + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateAdministrativeUnitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *beta.AdministrativeUnit +} + +type CreateAdministrativeUnitOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultCreateAdministrativeUnitOperationOptions() CreateAdministrativeUnitOperationOptions { + return CreateAdministrativeUnitOperationOptions{} +} + +func (o CreateAdministrativeUnitOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateAdministrativeUnitOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o CreateAdministrativeUnitOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateAdministrativeUnit - Create administrativeUnit. Use this API to create a new administrativeUnit. +func (c AdministrativeUnitClient) CreateAdministrativeUnit(ctx context.Context, input beta.AdministrativeUnit, options CreateAdministrativeUnitOperationOptions) (result CreateAdministrativeUnitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: "/administrativeUnits", + RetryFunc: options.RetryFunc, + } + + 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 beta.AdministrativeUnit + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_creategetsuserownedobject.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_creategetsuserownedobject.go new file mode 100644 index 000000000..fbba6d410 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_creategetsuserownedobject.go @@ -0,0 +1,96 @@ +package administrativeunit + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateGetsUserOwnedObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model beta.DirectoryObject +} + +type CreateGetsUserOwnedObjectOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultCreateGetsUserOwnedObjectOperationOptions() CreateGetsUserOwnedObjectOperationOptions { + return CreateGetsUserOwnedObjectOperationOptions{} +} + +func (o CreateGetsUserOwnedObjectOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateGetsUserOwnedObjectOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o CreateGetsUserOwnedObjectOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateGetsUserOwnedObject - Invoke action getUserOwnedObjects. Retrieve a list of recently deleted application and +// group objects owned by the specified user. This API returns up to 1,000 deleted objects owned by the user, sorted by +// ID, and doesn't support pagination. +func (c AdministrativeUnitClient) CreateGetsUserOwnedObject(ctx context.Context, input CreateGetsUserOwnedObjectRequest, options CreateGetsUserOwnedObjectOperationOptions) (result CreateGetsUserOwnedObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: "/administrativeUnits/getUserOwnedObjects", + RetryFunc: options.RetryFunc, + } + + 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 respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := beta.UnmarshalDirectoryObjectImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createvalidatesproperty.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createvalidatesproperty.go new file mode 100644 index 000000000..8b9e0ffa5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_createvalidatesproperty.go @@ -0,0 +1,89 @@ +package administrativeunit + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateValidatesPropertyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type CreateValidatesPropertyOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultCreateValidatesPropertyOperationOptions() CreateValidatesPropertyOperationOptions { + return CreateValidatesPropertyOperationOptions{} +} + +func (o CreateValidatesPropertyOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateValidatesPropertyOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o CreateValidatesPropertyOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateValidatesProperty - Invoke action validateProperties. Validate that a Microsoft 365 group's display name or +// mail nickname complies with naming policies. Clients can use this API to determine whether a display name or mail +// nickname is valid before trying to create a Microsoft 365 group. For validating properties of an existing group, use +// the validateProperties function for groups. The following validations are performed for the display name and mail +// nickname properties: 1. Validate the prefix and suffix naming policy 2. Validate the custom banned words policy 3. +// Validate the mail nickname is unique This API returns with the first failure encountered. If one or more properties +// fail multiple validations, only the property with the first validation failure is returned. However, you can validate +// both the mail nickname and the display name and receive a collection of validation errors if you are only validating +// the prefix and suffix naming policy. +func (c AdministrativeUnitClient) CreateValidatesProperty(ctx context.Context, input CreateValidatesPropertyRequest, options CreateValidatesPropertyOperationOptions) (result CreateValidatesPropertyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: "/administrativeUnits/validateProperties", + RetryFunc: options.RetryFunc, + } + + 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 + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_deleteadministrativeunit.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_deleteadministrativeunit.go new file mode 100644 index 000000000..fbe53298b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_deleteadministrativeunit.go @@ -0,0 +1,82 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAdministrativeUnitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteAdministrativeUnitOperationOptions struct { + IfMatch *string + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultDeleteAdministrativeUnitOperationOptions() DeleteAdministrativeUnitOperationOptions { + return DeleteAdministrativeUnitOperationOptions{} +} + +func (o DeleteAdministrativeUnitOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteAdministrativeUnitOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o DeleteAdministrativeUnitOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// DeleteAdministrativeUnit - Delete administrativeUnit. Delete an administrativeUnit. +func (c AdministrativeUnitClient) DeleteAdministrativeUnit(ctx context.Context, id beta.AdministrativeUnitId, options DeleteAdministrativeUnitOperationOptions) (result DeleteAdministrativeUnitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + RetryFunc: options.RetryFunc, + } + + 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/microsoft-graph/administrativeunits/beta/administrativeunit/method_getadministrativeunit.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getadministrativeunit.go new file mode 100644 index 000000000..db3f7ffe6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getadministrativeunit.go @@ -0,0 +1,95 @@ +package administrativeunit + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAdministrativeUnitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *beta.AdministrativeUnit +} + +type GetAdministrativeUnitOperationOptions struct { + Expand *odata.Expand + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Select *[]string +} + +func DefaultGetAdministrativeUnitOperationOptions() GetAdministrativeUnitOperationOptions { + return GetAdministrativeUnitOperationOptions{} +} + +func (o GetAdministrativeUnitOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAdministrativeUnitOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Expand != nil { + out.Expand = *o.Expand + } + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Select != nil { + out.Select = *o.Select + } + return &out +} + +func (o GetAdministrativeUnitOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GetAdministrativeUnit - Get administrativeUnit. Retrieve the properties and relationships of an administrativeUnit +// object. Since the administrativeUnit resource supports extensions, you can also use the GET operation to get custom +// properties and extension data in an administrativeUnit instance. +func (c AdministrativeUnitClient) GetAdministrativeUnit(ctx context.Context, id beta.AdministrativeUnitId, options GetAdministrativeUnitOperationOptions) (result GetAdministrativeUnitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + RetryFunc: options.RetryFunc, + } + + 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 beta.AdministrativeUnit + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmembergroups.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmembergroups.go new file mode 100644 index 000000000..00a0ee2e1 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmembergroups.go @@ -0,0 +1,142 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMemberGroupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type GetMemberGroupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type GetMemberGroupsOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Skip *int64 + Top *int64 +} + +func DefaultGetMemberGroupsOperationOptions() GetMemberGroupsOperationOptions { + return GetMemberGroupsOperationOptions{} +} + +func (o GetMemberGroupsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetMemberGroupsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o GetMemberGroupsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type GetMemberGroupsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *GetMemberGroupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetMemberGroups - Invoke action getMemberGroups. Return all the group IDs for the groups that the specified user, +// group, service principal, organizational contact, device, or directory object is a member of. This function is +// transitive. This API returns up to 11,000 group IDs. If more than 11,000 results are available, it returns a 400 Bad +// Request error with the DirectoryResultSizeLimitExceeded error code. If you get the DirectoryResultSizeLimitExceeded +// error code, use the List group transitive memberOf API instead. +func (c AdministrativeUnitClient) GetMemberGroups(ctx context.Context, id beta.AdministrativeUnitId, input GetMemberGroupsRequest, options GetMemberGroupsOperationOptions) (result GetMemberGroupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &GetMemberGroupsCustomPager{}, + Path: fmt.Sprintf("%s/getMemberGroups", id.ID()), + RetryFunc: options.RetryFunc, + } + + 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetMemberGroupsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) GetMemberGroupsComplete(ctx context.Context, id beta.AdministrativeUnitId, input GetMemberGroupsRequest, options GetMemberGroupsOperationOptions) (result GetMemberGroupsCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.GetMemberGroups(ctx, id, input, 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 { + items = append(items, v) + } + } + + result = GetMemberGroupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmemberobjects.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmemberobjects.go new file mode 100644 index 000000000..94711196f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getmemberobjects.go @@ -0,0 +1,138 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMemberObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type GetMemberObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type GetMemberObjectsOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Skip *int64 + Top *int64 +} + +func DefaultGetMemberObjectsOperationOptions() GetMemberObjectsOperationOptions { + return GetMemberObjectsOperationOptions{} +} + +func (o GetMemberObjectsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetMemberObjectsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o GetMemberObjectsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type GetMemberObjectsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *GetMemberObjectsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetMemberObjects - Invoke action getMemberObjects +func (c AdministrativeUnitClient) GetMemberObjects(ctx context.Context, id beta.AdministrativeUnitId, input GetMemberObjectsRequest, options GetMemberObjectsOperationOptions) (result GetMemberObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &GetMemberObjectsCustomPager{}, + Path: fmt.Sprintf("%s/getMemberObjects", id.ID()), + RetryFunc: options.RetryFunc, + } + + 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetMemberObjectsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) GetMemberObjectsComplete(ctx context.Context, id beta.AdministrativeUnitId, input GetMemberObjectsRequest, options GetMemberObjectsOperationOptions) (result GetMemberObjectsCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.GetMemberObjects(ctx, id, input, 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 { + items = append(items, v) + } + } + + result = GetMemberObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getscount.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getscount.go new file mode 100644 index 000000000..cabf08944 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_getscount.go @@ -0,0 +1,96 @@ +package administrativeunit + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetsCountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +type GetsCountOperationOptions struct { + ConsistencyLevel *odata.ConsistencyLevel + Filter *string + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Search *string +} + +func DefaultGetsCountOperationOptions() GetsCountOperationOptions { + return GetsCountOperationOptions{} +} + +func (o GetsCountOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetsCountOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.ConsistencyLevel != nil { + out.ConsistencyLevel = *o.ConsistencyLevel + } + if o.Filter != nil { + out.Filter = *o.Filter + } + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Search != nil { + out.Search = *o.Search + } + return &out +} + +func (o GetsCountOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GetsCount - Get the number of the resource +func (c AdministrativeUnitClient) GetsCount(ctx context.Context, options GetsCountOperationOptions) (result GetsCountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "text/plain", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: "/administrativeUnits/$count", + RetryFunc: options.RetryFunc, + } + + 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 []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listadministrativeunits.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listadministrativeunits.go new file mode 100644 index 000000000..c1e790ea9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listadministrativeunits.go @@ -0,0 +1,173 @@ +package administrativeunit + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAdministrativeUnitsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]beta.AdministrativeUnit +} + +type ListAdministrativeUnitsCompleteResult struct { + LatestHttpResponse *http.Response + Items []beta.AdministrativeUnit +} + +type ListAdministrativeUnitsOperationOptions struct { + ConsistencyLevel *odata.ConsistencyLevel + Count *bool + Expand *odata.Expand + Filter *string + Metadata *odata.Metadata + OrderBy *odata.OrderBy + RetryFunc client.RequestRetryFunc + Search *string + Select *[]string + Skip *int64 + Top *int64 +} + +func DefaultListAdministrativeUnitsOperationOptions() ListAdministrativeUnitsOperationOptions { + return ListAdministrativeUnitsOperationOptions{} +} + +func (o ListAdministrativeUnitsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListAdministrativeUnitsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.ConsistencyLevel != nil { + out.ConsistencyLevel = *o.ConsistencyLevel + } + if o.Count != nil { + out.Count = *o.Count + } + if o.Expand != nil { + out.Expand = *o.Expand + } + if o.Filter != nil { + out.Filter = *o.Filter + } + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.OrderBy != nil { + out.OrderBy = *o.OrderBy + } + if o.Search != nil { + out.Search = *o.Search + } + if o.Select != nil { + out.Select = *o.Select + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o ListAdministrativeUnitsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListAdministrativeUnitsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListAdministrativeUnitsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAdministrativeUnits - List administrativeUnits. Retrieve a list of administrativeUnit objects. +func (c AdministrativeUnitClient) ListAdministrativeUnits(ctx context.Context, options ListAdministrativeUnitsOperationOptions) (result ListAdministrativeUnitsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListAdministrativeUnitsCustomPager{}, + Path: "/administrativeUnits", + RetryFunc: options.RetryFunc, + } + + 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 *[]beta.AdministrativeUnit `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAdministrativeUnitsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) ListAdministrativeUnitsComplete(ctx context.Context, options ListAdministrativeUnitsOperationOptions) (ListAdministrativeUnitsCompleteResult, error) { + return c.ListAdministrativeUnitsCompleteMatchingPredicate(ctx, options, AdministrativeUnitOperationPredicate{}) +} + +// ListAdministrativeUnitsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdministrativeUnitClient) ListAdministrativeUnitsCompleteMatchingPredicate(ctx context.Context, options ListAdministrativeUnitsOperationOptions, predicate AdministrativeUnitOperationPredicate) (result ListAdministrativeUnitsCompleteResult, err error) { + items := make([]beta.AdministrativeUnit, 0) + + resp, err := c.ListAdministrativeUnits(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 = ListAdministrativeUnitsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listgetsbyids.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listgetsbyids.go new file mode 100644 index 000000000..e84c284a2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_listgetsbyids.go @@ -0,0 +1,158 @@ +package administrativeunit + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListGetsByIdsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]beta.DirectoryObject +} + +type ListGetsByIdsCompleteResult struct { + LatestHttpResponse *http.Response + Items []beta.DirectoryObject +} + +type ListGetsByIdsOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc + Skip *int64 + Top *int64 +} + +func DefaultListGetsByIdsOperationOptions() ListGetsByIdsOperationOptions { + return ListGetsByIdsOperationOptions{} +} + +func (o ListGetsByIdsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListGetsByIdsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + if o.Skip != nil { + out.Skip = int(*o.Skip) + } + if o.Top != nil { + out.Top = int(*o.Top) + } + return &out +} + +func (o ListGetsByIdsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +type ListGetsByIdsCustomPager struct { + NextLink *odata.Link `json:"@odata.nextLink"` +} + +func (p *ListGetsByIdsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListGetsByIds - Invoke action getByIds. Return the directory objects specified in a list of IDs. Some common uses for +// this function are to +func (c AdministrativeUnitClient) ListGetsByIds(ctx context.Context, input ListGetsByIdsRequest, options ListGetsByIdsOperationOptions) (result ListGetsByIdsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &ListGetsByIdsCustomPager{}, + Path: "/administrativeUnits/getByIds", + RetryFunc: options.RetryFunc, + } + + 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 *[]json.RawMessage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + temp := make([]beta.DirectoryObject, 0) + if values.Values != nil { + for i, v := range *values.Values { + val, err := beta.UnmarshalDirectoryObjectImplementation(v) + if err != nil { + err = fmt.Errorf("unmarshalling item %d for beta.DirectoryObject (%q): %+v", i, v, err) + return result, err + } + temp = append(temp, val) + } + } + result.Model = &temp + + return +} + +// ListGetsByIdsComplete retrieves all the results into a single object +func (c AdministrativeUnitClient) ListGetsByIdsComplete(ctx context.Context, input ListGetsByIdsRequest, options ListGetsByIdsOperationOptions) (ListGetsByIdsCompleteResult, error) { + return c.ListGetsByIdsCompleteMatchingPredicate(ctx, input, options, DirectoryObjectOperationPredicate{}) +} + +// ListGetsByIdsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdministrativeUnitClient) ListGetsByIdsCompleteMatchingPredicate(ctx context.Context, input ListGetsByIdsRequest, options ListGetsByIdsOperationOptions, predicate DirectoryObjectOperationPredicate) (result ListGetsByIdsCompleteResult, err error) { + items := make([]beta.DirectoryObject, 0) + + resp, err := c.ListGetsByIds(ctx, input, 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 = ListGetsByIdsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_restore.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_restore.go new file mode 100644 index 000000000..5266ac7cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_restore.go @@ -0,0 +1,100 @@ +package administrativeunit + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model beta.DirectoryObject +} + +type RestoreOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultRestoreOperationOptions() RestoreOperationOptions { + return RestoreOperationOptions{} +} + +func (o RestoreOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestoreOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o RestoreOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Restore - Invoke action restore. Restore a recently deleted application, externalUserProfile, group, +// pendingExternalUserProfile, servicePrincipal, administrative unit, or user object from deleted items. If an item was +// accidentally deleted, you can fully restore the item. This isn't applicable to security groups, which are deleted +// permanently. Also, restoring an application doesn't restore the associated service principal automatically. You must +// call this API to explicitly restore the deleted service principal. A recently deleted item remains available for up +// to 30 days. After 30 days, the item is permanently deleted. +func (c AdministrativeUnitClient) Restore(ctx context.Context, id beta.AdministrativeUnitId, input RestoreRequest, options RestoreOperationOptions) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/restore", id.ID()), + RetryFunc: options.RetryFunc, + } + + 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 respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := beta.UnmarshalDirectoryObjectImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_updateadministrativeunit.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_updateadministrativeunit.go new file mode 100644 index 000000000..97f66d92e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/method_updateadministrativeunit.go @@ -0,0 +1,82 @@ +package administrativeunit + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAdministrativeUnitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateAdministrativeUnitOperationOptions struct { + Metadata *odata.Metadata + RetryFunc client.RequestRetryFunc +} + +func DefaultUpdateAdministrativeUnitOperationOptions() UpdateAdministrativeUnitOperationOptions { + return UpdateAdministrativeUnitOperationOptions{} +} + +func (o UpdateAdministrativeUnitOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UpdateAdministrativeUnitOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + if o.Metadata != nil { + out.Metadata = *o.Metadata + } + return &out +} + +func (o UpdateAdministrativeUnitOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UpdateAdministrativeUnit - Update administrativeunit. Update the properties of an administrativeUnit object. +func (c AdministrativeUnitClient) UpdateAdministrativeUnit(ctx context.Context, id beta.AdministrativeUnitId, input beta.AdministrativeUnit, options UpdateAdministrativeUnitOperationOptions) (result UpdateAdministrativeUnitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + RetryFunc: options.RetryFunc, + } + + 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 + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmembergroupsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmembergroupsrequest.go new file mode 100644 index 000000000..80cf8e7f6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmembergroupsrequest.go @@ -0,0 +1,8 @@ +package administrativeunit + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckMemberGroupsRequest struct { + GroupIds *[]string `json:"groupIds,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmemberobjectsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmemberobjectsrequest.go new file mode 100644 index 000000000..321ee45d0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_checkmemberobjectsrequest.go @@ -0,0 +1,8 @@ +package administrativeunit + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckMemberObjectsRequest struct { + Ids *[]string `json:"ids,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_creategetsuserownedobjectrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_creategetsuserownedobjectrequest.go new file mode 100644 index 000000000..268933338 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_creategetsuserownedobjectrequest.go @@ -0,0 +1,13 @@ +package administrativeunit + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/nullable" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateGetsUserOwnedObjectRequest struct { + Type nullable.Type[string] `json:"type,omitempty"` + UserId nullable.Type[string] `json:"userId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_createvalidatespropertyrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_createvalidatespropertyrequest.go new file mode 100644 index 000000000..36f836c8b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_createvalidatespropertyrequest.go @@ -0,0 +1,15 @@ +package administrativeunit + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/nullable" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateValidatesPropertyRequest struct { + DisplayName nullable.Type[string] `json:"displayName,omitempty"` + EntityType nullable.Type[string] `json:"entityType,omitempty"` + MailNickname nullable.Type[string] `json:"mailNickname,omitempty"` + OnBehalfOfUserId nullable.Type[string] `json:"onBehalfOfUserId,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmembergroupsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmembergroupsrequest.go new file mode 100644 index 000000000..a2179aaec --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmembergroupsrequest.go @@ -0,0 +1,12 @@ +package administrativeunit + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/nullable" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMemberGroupsRequest struct { + SecurityEnabledOnly nullable.Type[bool] `json:"securityEnabledOnly,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmemberobjectsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmemberobjectsrequest.go new file mode 100644 index 000000000..09174f08c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_getmemberobjectsrequest.go @@ -0,0 +1,12 @@ +package administrativeunit + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/nullable" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMemberObjectsRequest struct { + SecurityEnabledOnly nullable.Type[bool] `json:"securityEnabledOnly,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_listgetsbyidsrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_listgetsbyidsrequest.go new file mode 100644 index 000000000..e446e55f9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_listgetsbyidsrequest.go @@ -0,0 +1,9 @@ +package administrativeunit + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListGetsByIdsRequest struct { + Ids *[]string `json:"ids,omitempty"` + Types *[]string `json:"types,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_restorerequest.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_restorerequest.go new file mode 100644 index 000000000..c908b4d37 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/model_restorerequest.go @@ -0,0 +1,12 @@ +package administrativeunit + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/nullable" +) + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest struct { + AutoReconcileProxyConflict nullable.Type[bool] `json:"autoReconcileProxyConflict,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/predicates.go new file mode 100644 index 000000000..a2b0fd6e6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/predicates.go @@ -0,0 +1,22 @@ +package administrativeunit + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import "github.com/hashicorp/go-azure-sdk/microsoft-graph/common-types/beta" + +type AdministrativeUnitOperationPredicate struct { +} + +func (p AdministrativeUnitOperationPredicate) Matches(input beta.AdministrativeUnit) bool { + + return true +} + +type DirectoryObjectOperationPredicate struct { +} + +func (p DirectoryObjectOperationPredicate) Matches(input beta.DirectoryObject) bool { + + return true +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/version.go b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/version.go new file mode 100644 index 000000000..ab84535c5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit/version.go @@ -0,0 +1,10 @@ +package administrativeunit + +// Copyright (c) HashiCorp Inc. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "beta" + +func userAgent() string { + return "hashicorp/go-azure-sdk/administrativeunit/beta" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 808688180..0ebc23862 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -70,6 +70,7 @@ github.com/hashicorp/go-azure-helpers/resourcemanager/features github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids # github.com/hashicorp/go-azure-sdk/microsoft-graph v0.20240923.1151247 ## explicit; go 1.21 +github.com/hashicorp/go-azure-sdk/microsoft-graph/administrativeunits/beta/administrativeunit github.com/hashicorp/go-azure-sdk/microsoft-graph/applications/beta/application github.com/hashicorp/go-azure-sdk/microsoft-graph/applications/stable/application github.com/hashicorp/go-azure-sdk/microsoft-graph/applications/stable/federatedidentitycredential From f2ddb09f32893bc0c807b5918200149c72b67d95 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 13:35:44 +0100 Subject: [PATCH 06/10] azuread_application: remove importsteps for oauth2permissionscopes test due to inconsistent set handling --- .../applications/application_data_source.go | 6 +++--- .../applications/application_resource.go | 6 +++--- .../applications/application_resource_test.go | 7 ++----- internal/services/applications/applications.go | 18 +----------------- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/internal/services/applications/application_data_source.go b/internal/services/applications/application_data_source.go index 9d7de1ea7..5427f2a72 100644 --- a/internal/services/applications/application_data_source.go +++ b/internal/services/applications/application_data_source.go @@ -600,8 +600,8 @@ func applicationDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, m d.SetId(id.ID()) tf.Set(d, "api", flattenApplicationApi(app.Api, true)) - tf.Set(d, "app_roles", flattenApplicationAppRoles(app.AppRoles)) - tf.Set(d, "app_role_ids", flattenApplicationAppRoleIDs(app.AppRoles)) + tf.Set(d, "app_roles", applications.FlattenAppRoles(app.AppRoles)) + tf.Set(d, "app_role_ids", applications.FlattenAppRoleIDs(app.AppRoles)) tf.Set(d, "application_id", app.AppId.GetOrZero()) tf.Set(d, "client_id", app.AppId.GetOrZero()) tf.Set(d, "device_only_auth_enabled", app.IsDeviceOnlyAuthSupported.GetOrZero()) @@ -624,7 +624,7 @@ func applicationDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, m tf.Set(d, "web", flattenApplicationWeb(app.Web)) if app.Api != nil { - tf.Set(d, "oauth2_permission_scope_ids", flattenApplicationOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes)) + tf.Set(d, "oauth2_permission_scope_ids", applications.FlattenOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes)) } if app.Info != nil { diff --git a/internal/services/applications/application_resource.go b/internal/services/applications/application_resource.go index 55a95d794..f6363a949 100644 --- a/internal/services/applications/application_resource.go +++ b/internal/services/applications/application_resource.go @@ -1633,8 +1633,8 @@ func applicationResourceRead(ctx context.Context, d *pluginsdk.ResourceData, met } tf.Set(d, "api", flattenApplicationApi(app.Api, false)) - tf.Set(d, "app_role", flattenApplicationAppRoles(app.AppRoles)) - tf.Set(d, "app_role_ids", flattenApplicationAppRoleIDs(app.AppRoles)) + tf.Set(d, "app_role", applications.FlattenAppRoles(app.AppRoles)) + tf.Set(d, "app_role_ids", applications.FlattenAppRoleIDs(app.AppRoles)) tf.Set(d, "application_id", app.AppId.GetOrZero()) tf.Set(d, "client_id", app.AppId.GetOrZero()) tf.Set(d, "description", app.Description.GetOrZero()) @@ -1659,7 +1659,7 @@ func applicationResourceRead(ctx context.Context, d *pluginsdk.ResourceData, met tf.Set(d, "web", flattenApplicationWeb(app.Web)) if app.Api != nil { - tf.Set(d, "oauth2_permission_scope_ids", flattenApplicationOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes)) + tf.Set(d, "oauth2_permission_scope_ids", applications.FlattenOAuth2PermissionScopeIDs(app.Api.OAuth2PermissionScopes)) } if app.Info != nil { diff --git a/internal/services/applications/application_resource_test.go b/internal/services/applications/application_resource_test.go index 0f806a0c4..08a7db782 100644 --- a/internal/services/applications/application_resource_test.go +++ b/internal/services/applications/application_resource_test.go @@ -292,6 +292,8 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { data.UUID(), } + // Note: ImportSteps missing here due to inconsistencies with SDKv2 handling of sets + data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.basic(data), @@ -301,7 +303,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("0"), ), }, - data.ImportStep(), { Config: r.oauth2PermissionScopes(data, scopeIDs), Check: acceptance.ComposeTestCheckFunc( @@ -310,7 +311,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("2"), ), }, - data.ImportStep(), { Config: r.oauth2PermissionScopesUpdate(data, scopeIDs), Check: acceptance.ComposeTestCheckFunc( @@ -319,7 +319,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("3"), ), }, - data.ImportStep(), { Config: r.oauth2PermissionScopes(data, scopeIDs), Check: acceptance.ComposeTestCheckFunc( @@ -328,7 +327,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("2"), ), }, - data.ImportStep(), { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( @@ -337,7 +335,6 @@ func TestAccApplication_oauth2PermissionScopes(t *testing.T) { check.That(data.ResourceName).Key("oauth2_permission_scope_ids.%").HasValue("0"), ), }, - data.ImportStep(), }) } diff --git a/internal/services/applications/applications.go b/internal/services/applications/applications.go index bd3f50f8c..3ca1b9511 100644 --- a/internal/services/applications/applications.go +++ b/internal/services/applications/applications.go @@ -684,19 +684,11 @@ func flattenApplicationApi(in *stable.ApiApplication, dataSource bool) []map[str return []map[string]interface{}{{ "known_client_applications": tf.FlattenStringSlicePtr(in.KnownClientApplications), "mapped_claims_enabled": mappedClaims, - scopesKey: flattenApplicationOAuth2PermissionScopes(in.OAuth2PermissionScopes), + scopesKey: applications.FlattenOAuth2PermissionScopes(in.OAuth2PermissionScopes), "requested_access_token_version": accessTokenVersion, }} } -func flattenApplicationAppRoleIDs(in *[]stable.AppRole) map[string]string { - return applications.FlattenAppRoleIDs(in) -} - -func flattenApplicationAppRoles(in *[]stable.AppRole) []map[string]interface{} { - return applications.FlattenAppRoles(in) -} - func flattenApplicationGroupMembershipClaims(in nullable.Type[string]) []interface{} { if in.IsNull() { return []interface{}{} @@ -721,14 +713,6 @@ func flattenApplicationImplicitGrant(in *stable.ImplicitGrantSettings) []map[str }} } -func flattenApplicationOAuth2PermissionScopeIDs(in *[]stable.PermissionScope) map[string]string { - return applications.FlattenOAuth2PermissionScopeIDs(in) -} - -func flattenApplicationOAuth2PermissionScopes(in *[]stable.PermissionScope) []map[string]interface{} { - return applications.FlattenOAuth2PermissionScopes(in) -} - func flattenApplicationOptionalClaims(in *stable.OptionalClaims) []map[string]interface{} { if in == nil { return []map[string]interface{}{} From 93bd6de80accc323edfc75b7ab375758d4a925c3 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 13:40:17 +0100 Subject: [PATCH 07/10] azuread_synchronization_job_provision_on_demand: fix error matching in acceptance test --- .../synchronization_job_provision_on_demand_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/synchronization/synchronization_job_provision_on_demand_resource_test.go b/internal/services/synchronization/synchronization_job_provision_on_demand_resource_test.go index 416e842f7..8d2a7e4cb 100644 --- a/internal/services/synchronization/synchronization_job_provision_on_demand_resource_test.go +++ b/internal/services/synchronization/synchronization_job_provision_on_demand_resource_test.go @@ -25,7 +25,7 @@ func TestAccSynchronizationJobProvisionOnDemand_basic(t *testing.T) { { // The provisioned app isn't actually integrated so this will never work Config: r.basic(data), - ExpectError: regexp.MustCompile("CredentialsMissing: Please configure provisioning"), + ExpectError: regexp.MustCompile("CredentialsMissing"), }, }) } From f929c900a31bd0d99cf0d14157769363cb1281a5 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 13:43:21 +0100 Subject: [PATCH 08/10] linting --- internal/services/users/users_data_source.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/services/users/users_data_source.go b/internal/services/users/users_data_source.go index 203a0bc71..bce02fc56 100644 --- a/internal/services/users/users_data_source.go +++ b/internal/services/users/users_data_source.go @@ -223,9 +223,7 @@ func usersDataSourceRead(ctx context.Context, d *pluginsdk.ResourceData, meta in return tf.ErrorDiagPathF(err, "return_all", "No users found") } - for _, u := range *resp.Model { - foundUsers = append(foundUsers, u) - } + foundUsers = append(foundUsers, *resp.Model...) } else if upns, ok := d.Get("user_principal_names").([]interface{}); ok && len(upns) > 0 { expectedCount = len(upns) From 3deb4a5b5240a56ed66f645e03f0816e00547c4d Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 15:29:46 +0100 Subject: [PATCH 09/10] azuread_directory_role_eligibility_schedule_request: remove test with custom role, the API does not support it (neither v1.0 nor beta) --- ...gibility_schedule_request_resource_test.go | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go index 7a9a1012c..900e29689 100644 --- a/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go +++ b/internal/services/directoryroles/directory_role_eligibility_schedule_request_resource_test.go @@ -34,20 +34,6 @@ func TestAccRoleEligibilityScheduleRequest_builtin(t *testing.T) { }) } -func TestAccRoleEligibilityScheduleRequest_custom(t *testing.T) { - data := acceptance.BuildTestData(t, "azuread_directory_role_eligibility_schedule_request", "test") - r := RoleEligibilityScheduleRequestResource{} - - data.ResourceTestIgnoreDangling(t, r, []acceptance.TestStep{ - { - Config: r.custom(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - }) -} - func (r RoleEligibilityScheduleRequestResource) Exists(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) (*bool, error) { client := clients.DirectoryRoles.DirectoryRoleEligibilityScheduleRequestClient id := stable.NewRoleManagementDirectoryRoleEligibilityScheduleRequestID(state.ID) @@ -89,36 +75,3 @@ resource "azuread_directory_role_eligibility_schedule_request" "test" { } `, data.RandomInteger, data.RandomPassword) } - -func (r RoleEligibilityScheduleRequestResource) custom(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azuread" {} - -data "azuread_domains" "test" { - only_initial = true -} - -resource "azuread_user" "test" { - user_principal_name = "acctestManager.%[1]d@${data.azuread_domains.test.domains.0.domain_name}" - display_name = "acctestManager-%[1]d" - password = "%[2]s" -} - -resource "azuread_custom_directory_role" "test" { - display_name = "acctestCustomRole-%[1]d" - enabled = true - version = "1.0" - - permissions { - allowed_resource_actions = ["microsoft.directory/applications/standard/read"] - } -} - -resource "azuread_directory_role_eligibility_schedule_request" "test" { - role_definition_id = azuread_custom_directory_role.test.object_id - principal_id = azuread_user.test.object_id - directory_scope_id = "/" - justification = "abc" -} -`, data.RandomInteger, data.RandomPassword) -} From 7b9618934aed051342a126d7505da510294c9cdc Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Wed, 25 Sep 2024 15:46:08 +0100 Subject: [PATCH 10/10] data.azuread_service_principals: fail gracefully if beta API does not return `samlMetadataUrl` --- .../service_principals_data_source.go | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/internal/services/serviceprincipals/service_principals_data_source.go b/internal/services/serviceprincipals/service_principals_data_source.go index 05454c3fb..bcfe9bf3c 100644 --- a/internal/services/serviceprincipals/service_principals_data_source.go +++ b/internal/services/serviceprincipals/service_principals_data_source.go @@ -9,7 +9,7 @@ import ( "encoding/base64" "errors" "fmt" - "net/http" + "log" "strings" "time" @@ -207,6 +207,20 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD ignoreMissing := d.Get("ignore_missing").(bool) returnAll := d.Get("return_all").(bool) + fieldsToSelect := []string{ + "accountEnabled", + "appId", + "appOwnerOrganizationId", + "appRoleAssignmentRequired", + "displayName", + "id", + "preferredSingleSignOnMode", + "servicePrincipalNames", + "servicePrincipalType", + "signInAudience", + "tags", + } + var clientIdsToSearch []string if v, ok := d.Get("client_ids").([]interface{}); ok && len(v) > 0 { clientIdsToSearch = tf.ExpandStringSlice(v) @@ -214,7 +228,7 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD clientIdsToSearch = tf.ExpandStringSlice(v) } if returnAll { - resp, err := client.ListServicePrincipals(ctx, serviceprincipal.DefaultListServicePrincipalsOperationOptions()) + resp, err := client.ListServicePrincipals(ctx, serviceprincipal.ListServicePrincipalsOperationOptions{Select: &fieldsToSelect}) if err != nil { return tf.ErrorDiagF(err, "Could not retrieve service principals") } @@ -232,6 +246,7 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD for _, v := range clientIdsToSearch { options := serviceprincipal.ListServicePrincipalsOperationOptions{ Filter: pointer.To(fmt.Sprintf("appId eq '%s'", odata.EscapeSingleQuote(v))), + Select: &fieldsToSelect, } resp, err := client.ListServicePrincipals(ctx, options) if err != nil { @@ -259,6 +274,7 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD for _, v := range tf.ExpandStringSlice(displayNames) { options := serviceprincipal.ListServicePrincipalsOperationOptions{ Filter: pointer.To(fmt.Sprintf("displayName eq '%s'", odata.EscapeSingleQuote(v))), + Select: &fieldsToSelect, } resp, err := client.ListServicePrincipals(ctx, options) if err != nil { @@ -282,7 +298,7 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD } else if objectIds, ok := d.Get("object_ids").([]interface{}); ok && len(objectIds) > 0 { expectedCount = len(objectIds) for _, v := range objectIds { - resp, err := client.GetServicePrincipal(ctx, stable.NewServicePrincipalID(v.(string)), serviceprincipal.DefaultGetServicePrincipalOperationOptions()) + resp, err := client.GetServicePrincipal(ctx, stable.NewServicePrincipalID(v.(string)), serviceprincipal.GetServicePrincipalOperationOptions{Select: &fieldsToSelect}) if err != nil { if response.WasNotFound(resp.HttpResponse) { if ignoreMissing { @@ -330,24 +346,17 @@ func servicePrincipalsDataSourceRead(ctx context.Context, d *pluginsdk.ResourceD } } - // Retrieve from beta API to get samlMetadataUrl field + // Retrieve from beta API to get samlMetadataUrl field, intentionally don't retry and fail gracefully on error + var servicePrincipalBeta beta.ServicePrincipal options := serviceprincipalBeta.GetServicePrincipalOperationOptions{ - RetryFunc: func(resp *http.Response, o *odata.OData) (bool, error) { - if resp == nil || response.WasNotFound(resp) { - return true, nil - } - return false, nil - }, Select: pointer.To([]string{"samlMetadataUrl"}), } - resp, err := clientBeta.GetServicePrincipal(ctx, beta.NewServicePrincipalID(*s.Id), options) - if err != nil { - return tf.ErrorDiagF(err, "Retrieving %s (beta API)", beta.NewServicePrincipalID(*s.Id)) - } - - servicePrincipalBeta := resp.Model - if servicePrincipalBeta == nil { - return tf.ErrorDiagF(errors.New("model was nil"), "Retrieving %s (beta API)", beta.NewServicePrincipalID(*s.Id)) + betaId := beta.NewServicePrincipalID(*s.Id) + resp, err := clientBeta.GetServicePrincipal(ctx, betaId, options) + if err != nil || resp.Model == nil { + log.Printf("[DEBUG] Failed to retrieve `samlMetadataUrl` using beta API for %s", betaId) + } else { + servicePrincipalBeta = *resp.Model } sp := make(map[string]interface{})