diff --git a/go.mod b/go.mod index 4379d4f83c..29aee5fb98 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 - github.com/manicminer/hamilton v0.47.1 + github.com/manicminer/hamilton v0.49.0 golang.org/x/text v0.3.7 ) diff --git a/go.sum b/go.sum index c9b2f4efc1..813f825da0 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/manicminer/hamilton v0.47.1 h1:nMH4oOa2lPAfCeLGEB1o+XzhyJUHPRimlWz/hB2WC5E= -github.com/manicminer/hamilton v0.47.1/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk= +github.com/manicminer/hamilton v0.49.0 h1:n4GDhEZgpsKANu7G1Q1CI2FVLiQTNJQ684U6NX94AVk= +github.com/manicminer/hamilton v0.49.0/go.mod h1:lbVyngC+/nCWuDp8UhC6Bw+bh7jcP/E+YwqzHTmzemk= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= diff --git a/internal/services/groups/group_data_source.go b/internal/services/groups/group_data_source.go index c4edd2bb90..5e7c6c2047 100644 --- a/internal/services/groups/group_data_source.go +++ b/internal/services/groups/group_data_source.go @@ -315,7 +315,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter d.SetId(*group.ID) tf.Set(d, "assignable_to_role", group.IsAssignableToRole) - tf.Set(d, "behaviors", tf.FlattenStringSlice(group.ResourceBehaviorOptions)) + tf.Set(d, "behaviors", tf.FlattenStringSlicePtr(group.ResourceBehaviorOptions)) tf.Set(d, "description", group.Description) tf.Set(d, "display_name", group.DisplayName) tf.Set(d, "mail", group.Mail) @@ -328,7 +328,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter tf.Set(d, "onpremises_security_identifier", group.OnPremisesSecurityIdentifier) tf.Set(d, "onpremises_sync_enabled", group.OnPremisesSyncEnabled) tf.Set(d, "preferred_language", group.PreferredLanguage) - tf.Set(d, "provisioning_options", tf.FlattenStringSlice(group.ResourceProvisioningOptions)) + tf.Set(d, "provisioning_options", tf.FlattenStringSlicePtr(group.ResourceProvisioningOptions)) tf.Set(d, "proxy_addresses", tf.FlattenStringSlicePtr(group.ProxyAddresses)) tf.Set(d, "security_enabled", group.SecurityEnabled) tf.Set(d, "theme", group.Theme) @@ -349,7 +349,7 @@ func groupDataSourceRead(ctx context.Context, d *schema.ResourceData, meta inter tf.Set(d, "dynamic_membership", dynamicMembership) var allowExternalSenders, autoSubscribeNewMembers, hideFromAddressLists, hideFromOutlookClients bool - if hasGroupType(group.GroupTypes, msgraph.GroupTypeUnified) { + if group.GroupTypes != nil && hasGroupType(*group.GroupTypes, msgraph.GroupTypeUnified) { groupExtra, err := groupGetAdditional(ctx, client, d.Id()) if err != nil { return tf.ErrorDiagF(err, "Could not retrieve group with object ID %q", d.Id()) diff --git a/internal/services/groups/group_resource.go b/internal/services/groups/group_resource.go index d7bee273c3..1080591de1 100644 --- a/internal/services/groups/group_resource.go +++ b/internal/services/groups/group_resource.go @@ -461,13 +461,13 @@ func groupResourceCreate(ctx context.Context, d *schema.ResourceData, meta inter properties := msgraph.Group{ Description: utils.NullableString(description), DisplayName: utils.String(tempDisplayName), - GroupTypes: groupTypes, + GroupTypes: &groupTypes, IsAssignableToRole: utils.Bool(d.Get("assignable_to_role").(bool)), MailEnabled: utils.Bool(mailEnabled), MailNickname: utils.String(mailNickname), MembershipRule: utils.NullableString(""), - ResourceBehaviorOptions: behaviorOptions, - ResourceProvisioningOptions: provisioningOptions, + ResourceBehaviorOptions: &behaviorOptions, + ResourceProvisioningOptions: &provisioningOptions, SecurityEnabled: utils.Bool(securityEnabled), } @@ -1083,7 +1083,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa } tf.Set(d, "assignable_to_role", group.IsAssignableToRole) - tf.Set(d, "behaviors", tf.FlattenStringSlice(group.ResourceBehaviorOptions)) + tf.Set(d, "behaviors", tf.FlattenStringSlicePtr(group.ResourceBehaviorOptions)) tf.Set(d, "description", group.Description) tf.Set(d, "display_name", group.DisplayName) tf.Set(d, "mail_enabled", group.MailEnabled) @@ -1096,7 +1096,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa tf.Set(d, "onpremises_security_identifier", group.OnPremisesSecurityIdentifier) tf.Set(d, "onpremises_sync_enabled", group.OnPremisesSyncEnabled) tf.Set(d, "preferred_language", group.PreferredLanguage) - tf.Set(d, "provisioning_options", tf.FlattenStringSlice(group.ResourceProvisioningOptions)) + tf.Set(d, "provisioning_options", tf.FlattenStringSlicePtr(group.ResourceProvisioningOptions)) tf.Set(d, "proxy_addresses", tf.FlattenStringSlicePtr(group.ProxyAddresses)) tf.Set(d, "security_enabled", group.SecurityEnabled) tf.Set(d, "theme", group.Theme) @@ -1117,7 +1117,7 @@ func groupResourceRead(ctx context.Context, d *schema.ResourceData, meta interfa tf.Set(d, "dynamic_membership", dynamicMembership) var allowExternalSenders, autoSubscribeNewMembers, hideFromAddressLists, hideFromOutlookClients bool - if hasGroupType(group.GroupTypes, msgraph.GroupTypeUnified) { + if group.GroupTypes != nil && hasGroupType(*group.GroupTypes, msgraph.GroupTypeUnified) { groupExtra, err := groupGetAdditional(ctx, client, d.Id()) if err != nil { return tf.ErrorDiagF(err, "Could not retrieve group with object UID %q", d.Id()) diff --git a/internal/services/serviceprincipals/client/client.go b/internal/services/serviceprincipals/client/client.go index 2b105e53b2..ca7d3c0f64 100644 --- a/internal/services/serviceprincipals/client/client.go +++ b/internal/services/serviceprincipals/client/client.go @@ -19,6 +19,7 @@ func NewClient(o *common.ClientOptions) *Client { o.ConfigureClient(&directoryObjectsClient.BaseClient) servicePrincipalsClient := msgraph.NewServicePrincipalsClient(o.TenantID) + servicePrincipalsClient.BaseClient.ApiVersion = msgraph.Version10 o.ConfigureClient(&servicePrincipalsClient.BaseClient) return &Client{ diff --git a/internal/services/serviceprincipals/service_principal_data_source.go b/internal/services/serviceprincipals/service_principal_data_source.go index 628fa443d3..4f38dd765a 100644 --- a/internal/services/serviceprincipals/service_principal_data_source.go +++ b/internal/services/serviceprincipals/service_principal_data_source.go @@ -390,8 +390,8 @@ func servicePrincipalDataSourceRead(ctx context.Context, d *schema.ResourceData, tf.Set(d, "login_url", servicePrincipal.LoginUrl) tf.Set(d, "notes", servicePrincipal.Notes) tf.Set(d, "notification_email_addresses", tf.FlattenStringSlicePtr(servicePrincipal.NotificationEmailAddresses)) - tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.PublishedPermissionScopes)) - tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.PublishedPermissionScopes)) + tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.OAuth2PermissionScopes)) + tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.OAuth2PermissionScopes)) tf.Set(d, "object_id", servicePrincipal.ID) tf.Set(d, "preferred_single_sign_on_mode", servicePrincipal.PreferredSingleSignOnMode) tf.Set(d, "redirect_uris", tf.FlattenStringSlicePtr(servicePrincipal.ReplyUrls)) diff --git a/internal/services/serviceprincipals/service_principal_resource.go b/internal/services/serviceprincipals/service_principal_resource.go index ed3f8f9808..61eb29e830 100644 --- a/internal/services/serviceprincipals/service_principal_resource.go +++ b/internal/services/serviceprincipals/service_principal_resource.go @@ -615,8 +615,8 @@ func servicePrincipalResourceRead(ctx context.Context, d *schema.ResourceData, m tf.Set(d, "login_url", servicePrincipal.LoginUrl) tf.Set(d, "notes", servicePrincipal.Notes) tf.Set(d, "notification_email_addresses", tf.FlattenStringSlicePtr(servicePrincipal.NotificationEmailAddresses)) - tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.PublishedPermissionScopes)) - tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.PublishedPermissionScopes)) + tf.Set(d, "oauth2_permission_scope_ids", helpers.ApplicationFlattenOAuth2PermissionScopeIDs(servicePrincipal.OAuth2PermissionScopes)) + tf.Set(d, "oauth2_permission_scopes", helpers.ApplicationFlattenOAuth2PermissionScopes(servicePrincipal.OAuth2PermissionScopes)) tf.Set(d, "object_id", servicePrincipal.ID) tf.Set(d, "preferred_single_sign_on_mode", servicePrincipal.PreferredSingleSignOnMode) tf.Set(d, "redirect_uris", tf.FlattenStringSlicePtr(servicePrincipal.ReplyUrls)) diff --git a/vendor/github.com/manicminer/hamilton/environments/published.go b/vendor/github.com/manicminer/hamilton/environments/published.go index f6af732e02..2d1944f779 100644 --- a/vendor/github.com/manicminer/hamilton/environments/published.go +++ b/vendor/github.com/manicminer/hamilton/environments/published.go @@ -75,6 +75,8 @@ var PublishedApis = map[string]ApiAppId{ "MileIqRestService": "b692184e-b47f-4706-b352-84b288d2d9ee", "MixedReality": "c7ddd9b4-5172-4e28-bd29-1e0792947d18", "MicrosoftAzureCli": "04b07795-8ddb-461a-bbee-02f9e1bf7b46", + "MicrosoftAzureFrontDoor": "ad0e1c7e-6d38-4ba4-9efd-0bc77ba9f037", + "MicrosoftAzureFrontDoorCdn": "205478c0-bd83-4e1b-a9d6-db63a3e1e1c8", "Microsoft365DataAtRestEncryption": "c066d759-24ae-40e7-a56f-027002b5d3e4", "MicrosoftGraph": "00000003-0000-0000-c000-000000000000", "MicrosoftInvoicing": "b6b84568-6c01-4981-a80f-09da9a20bbed", diff --git a/vendor/github.com/manicminer/hamilton/internal/utils/pointers.go b/vendor/github.com/manicminer/hamilton/internal/utils/pointers.go index fc7802079e..967186d40e 100644 --- a/vendor/github.com/manicminer/hamilton/internal/utils/pointers.go +++ b/vendor/github.com/manicminer/hamilton/internal/utils/pointers.go @@ -24,3 +24,8 @@ func StringPtr(s string) *string { func ArrayStringPtr(s []string) *[]string { return &s } + +// Float32Ptr returns a pointer to the provided float32 variable. +func Float32Ptr(f float32) *float32 { + return &f +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go b/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go index 85611d9c41..d6aa1d33b3 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/app_role_assignments.go @@ -50,9 +50,10 @@ func NewServicePrincipalsAppRoleAssignmentsClient(tenantId string) *AppRoleAssig } // List returns a list of app role assignments. -func (c *AppRoleAssignmentsClient) List(ctx context.Context, id string) (*[]AppRoleAssignment, int, error) { +func (c *AppRoleAssignmentsClient) List(ctx context.Context, id string, query odata.Query) (*[]AppRoleAssignment, int, error) { resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ ValidStatusCodes: []int{http.StatusOK}, + OData: query, Uri: Uri{ Entity: fmt.Sprintf("/%s/%s/appRoleAssignments", c.resourceType, id), HasTenantId: true, diff --git a/vendor/github.com/manicminer/hamilton/msgraph/b2c_userflow.go b/vendor/github.com/manicminer/hamilton/msgraph/b2c_userflow.go new file mode 100644 index 0000000000..a37e0d928c --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/msgraph/b2c_userflow.go @@ -0,0 +1,171 @@ +package msgraph + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + + "github.com/manicminer/hamilton/odata" +) + +// B2CUserFlowClient performs operations on B2CUserFlow. +type B2CUserFlowClient struct { + BaseClient Client +} + +// NewB2CUserFlowClient returns a new B2CUserFlowClient. +func NewB2CUserFlowClient(tenantId string) *B2CUserFlowClient { + return &B2CUserFlowClient{ + BaseClient: NewClient(VersionBeta, tenantId), + } +} + +// List returns a list of B2C UserFlows, optionally queried using OData. +func (c *B2CUserFlowClient) List(ctx context.Context, query odata.Query) (*[]B2CUserFlow, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: "/identity/b2cUserFlows", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("B2CUserFlowClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + UserFlows []B2CUserFlow `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &data.UserFlows, status, nil +} + +// Create creates a new B2CUserFlow. +func (c *B2CUserFlowClient) Create(ctx context.Context, userflow B2CUserFlow) (*B2CUserFlow, int, error) { + var status int + + body, err := json.Marshal(userflow) + if err != nil { + return nil, status, fmt.Errorf("json.Marshal(): %v", err) + } + + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ + Body: body, + OData: odata.Query{ + Metadata: odata.MetadataFull, + }, + ValidStatusCodes: []int{http.StatusCreated}, + Uri: Uri{ + Entity: "/identity/b2cUserFlows", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("B2CUserFlowClient.BaseClient.Post(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var newUserFlow B2CUserFlow + if err := json.Unmarshal(respBody, &newUserFlow); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &newUserFlow, status, nil +} + +// Get returns an existing B2CUserFlow. +func (c *B2CUserFlowClient) Get(ctx context.Context, id string, query odata.Query) (*B2CUserFlow, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/b2cUserFlows/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("B2CUserFlowClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var userflow B2CUserFlow + if err := json.Unmarshal(respBody, &userflow); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &userflow, status, nil +} + +// Update amends an existing B2CUserFlow. +func (c *B2CUserFlowClient) Update(ctx context.Context, userflow B2CUserFlow) (int, error) { + var status int + if userflow.ID == nil { + return status, fmt.Errorf("cannot update userflow with nil ID") + } + + userflowID := *userflow.ID + userflow.ID = nil + + body, err := json.Marshal(userflow) + if err != nil { + return status, fmt.Errorf("json.Marshal(): %v", err) + } + + _, status, _, err = c.BaseClient.Patch(ctx, PatchHttpRequestInput{ + Body: body, + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{ + http.StatusOK, + http.StatusNoContent, + }, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/b2cUserFlows//%s", userflowID), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("B2CUserFlowClient.BaseClient.Patch(): %v", err) + } + + return status, nil +} + +// Delete removes a B2CUserFlow. +func (c *B2CUserFlowClient) Delete(ctx context.Context, id string) (int, error) { + _, status, _, err := c.BaseClient.Delete(ctx, DeleteHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/b2cUserFlows/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("B2CUserFlowClient.BaseClient.Delete(): %v", err) + } + + return status, nil +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go index 4fb2ccec56..689fe1eef4 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/directory_objects.go @@ -46,11 +46,13 @@ func (c *DirectoryObjectsClient) Get(ctx context.Context, id string, query odata return nil, status, fmt.Errorf("io.ReadAll(): %v", err) } - var directoryObject DirectoryObject - if err := json.Unmarshal(respBody, &directoryObject); err != nil { + var data map[string]interface{} + if err := json.Unmarshal(respBody, &data); err != nil { return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) } + directoryObject := c.translateResultToDirectoryObject(data) + return &directoryObject, status, nil } @@ -88,11 +90,19 @@ func (c *DirectoryObjectsClient) GetByIds(ctx context.Context, ids []string, typ return nil, status, fmt.Errorf("io.ReadAll(): %v", err) } + var rawData struct { + Objects []map[string]interface{} `json:"value"` + } + if err := json.Unmarshal(respBody, &rawData); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + var data struct { Objects []DirectoryObject `json:"value"` } - if err := json.Unmarshal(respBody, &data); err != nil { - return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + + for _, row := range rawData.Objects { + data.Objects = append(data.Objects, c.translateResultToDirectoryObject(row)) } return &data.Objects, status, nil @@ -210,3 +220,38 @@ func (c *DirectoryObjectsClient) GetMemberObjects(ctx context.Context, id string return &result, status, nil } + +// translateResultToDirectoryObject translates directory object data into DirectoryObject +func (c *DirectoryObjectsClient) translateResultToDirectoryObject(data map[string]interface{}) DirectoryObject { + object := DirectoryObject{ + AdditionalData: data, + } + + if val, exists := data["@odata.id"]; exists { + if v, ok := val.(string); ok { + odataId := odata.Id(v) + object.ODataId = &odataId + } + } + + if val, exists := data["@odata.type"]; exists { + if v, ok := val.(string); ok { + odataType := odata.Type(v) + object.ODataType = &odataType + } + } + + if val, exists := data["id"]; exists { + if v, ok := val.(string); ok { + object.ID = &v + } + } + + if val, exists := data["displayName"]; exists { + if v, ok := val.(string); ok { + object.DisplayName = &v + } + } + + return object +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/models.go b/vendor/github.com/manicminer/hamilton/msgraph/models.go index ed99f78a08..9019862a3e 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/models.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/models.go @@ -747,9 +747,11 @@ type DirectoryAudit struct { } type DirectoryObject struct { - ODataId *odata.Id `json:"@odata.id,omitempty"` - ODataType *odata.Type `json:"@odata.type,omitempty"` - ID *string `json:"id,omitempty"` + ODataId *odata.Id `json:"@odata.id,omitempty"` + ODataType *odata.Type `json:"@odata.type,omitempty"` + ID *string `json:"id,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + AdditionalData map[string]interface{} `json:"-"` } func (o *DirectoryObject) Uri(endpoint environments.ApiEndpoint, apiVersion ApiVersion) string { @@ -865,7 +867,7 @@ type Group struct { Description *StringNullWhenEmpty `json:"description,omitempty"` DisplayName *string `json:"displayName,omitempty"` ExpirationDateTime *time.Time `json:"expirationDateTime,omitempty"` - GroupTypes []GroupType `json:"groupTypes,omitempty"` + GroupTypes *[]GroupType `json:"groupTypes,omitempty"` HasMembersWithLicenseErrors *bool `json:"hasMembersWithLicenseErrors,omitempty"` HideFromAddressLists *bool `json:"hideFromAddressLists,omitempty"` HideFromOutlookClients *bool `json:"hideFromOutlookClients,omitempty"` @@ -887,8 +889,8 @@ type Group struct { PreferredLanguage *string `json:"preferredLanguage,omitempty"` ProxyAddresses *[]string `json:"proxyAddresses,omitempty"` RenewedDateTime *time.Time `json:"renewedDateTime,omitempty"` - ResourceBehaviorOptions []GroupResourceBehaviorOption `json:"resourceBehaviorOptions,omitempty"` - ResourceProvisioningOptions []GroupResourceProvisioningOption `json:"resourceProvisioningOptions,omitempty"` + ResourceBehaviorOptions *[]GroupResourceBehaviorOption `json:"resourceBehaviorOptions,omitempty"` + ResourceProvisioningOptions *[]GroupResourceProvisioningOption `json:"resourceProvisioningOptions,omitempty"` SecurityEnabled *bool `json:"securityEnabled,omitempty"` SecurityIdentifier *string `json:"securityIdentifier,omitempty"` Theme *GroupTheme `json:"theme,omitempty"` @@ -945,7 +947,7 @@ func (g *Group) UnmarshalJSON(data []byte) error { func (g *Group) HasTypes(types []GroupType) bool { for _, t := range types { found := false - for _, gt := range g.GroupTypes { + for _, gt := range *g.GroupTypes { if t == gt { found = true break @@ -1280,6 +1282,7 @@ type ServicePrincipal struct { LogoutUrl *string `json:"logoutUrl,omitempty"` Notes *StringNullWhenEmpty `json:"notes,omitempty"` NotificationEmailAddresses *[]string `json:"notificationEmailAddresses,omitempty"` + OAuth2PermissionScopes *[]PermissionScope `json:"oauth2PermissionScopes,omitempty"` PasswordCredentials *[]PasswordCredential `json:"passwordCredentials,omitempty"` PasswordSingleSignOnSettings *PasswordSingleSignOnSettings `json:"passwordSingleSignOnSettings,omitempty"` PreferredSingleSignOnMode *PreferredSingleSignOnMode `json:"preferredSingleSignOnMode,omitempty"` @@ -1315,7 +1318,7 @@ type SynchronizationSchedule struct { type SynchronizationTaskExecution struct { ActivityIdentifier *string `json:"activityIdentifier,omitempty"` - CountEntitled *string `json:"countEntitled,omitempty"` + CountEntitled *int64 `json:"countEntitled,omitempty"` State *string `json:"state,omitempty"` } @@ -1685,3 +1688,21 @@ type EmployeeOrgData struct { CostCenter *string `json:"costCenter,omitempty"` Division *string `json:"division,omitempty"` } + +type B2CUserFlow struct { + ID *string `json:"id,omitempty"` + UserFlowType *string `json:"userFlowType,omitempty"` + UserFlowTypeVersion *float32 `json:"userFlowTypeVersion,omitempty"` + // The property that determines whether language customization is enabled within the B2C user flow. Language customization is not enabled by default for B2C user flows. + IsLanguageCustomizationEnabled *bool `json:"IsLanguageCustomizationEnabled,omitempty"` + // Indicates the default language of the b2cIdentityUserFlow that is used when no ui_locale tag is specified in the request. This field is RFC 5646 compliant. + DefaultLanguageTag *string `json:"defaultLanguageTag,omitempty"` +} + +type UserFlowAttribute struct { + ID *string `json:"id,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + UserFlowAttributeType *string `json:"userFlowAttributeType,omitempty"` + DataType *UserflowAttributeDataType `json:"dataType,omitempty"` +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/userflow_attributes.go b/vendor/github.com/manicminer/hamilton/msgraph/userflow_attributes.go new file mode 100644 index 0000000000..e086327dba --- /dev/null +++ b/vendor/github.com/manicminer/hamilton/msgraph/userflow_attributes.go @@ -0,0 +1,171 @@ +package msgraph + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + + "github.com/manicminer/hamilton/odata" +) + +// UserFlowAttributesClient performs operations on UserFlowAttributes. +type UserFlowAttributesClient struct { + BaseClient Client +} + +// NewUserFlowAttributesClient returns a new UserFlowAttributesClient. +func NewUserFlowAttributesClient(tenantId string) *UserFlowAttributesClient { + return &UserFlowAttributesClient{ + BaseClient: NewClient(Version10, tenantId), + } +} + +// List returns a list of UserFlowAttributes, optionally queried using OData. +func (c *UserFlowAttributesClient) List(ctx context.Context, query odata.Query) (*[]UserFlowAttribute, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: "/identity/userFlowAttributes", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("UserFlowAttributesClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var data struct { + UserFlowAttributes []UserFlowAttribute `json:"value"` + } + if err := json.Unmarshal(respBody, &data); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &data.UserFlowAttributes, status, nil +} + +// Create creates a new UserFlowAttribute. +func (c *UserFlowAttributesClient) Create(ctx context.Context, userFlowAttribute UserFlowAttribute) (*UserFlowAttribute, int, error) { + var status int + + body, err := json.Marshal(userFlowAttribute) + if err != nil { + return nil, status, fmt.Errorf("json.Marshal(): %v", err) + } + + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ + Body: body, + OData: odata.Query{ + Metadata: odata.MetadataFull, + }, + ValidStatusCodes: []int{http.StatusCreated}, + Uri: Uri{ + Entity: "/identity/userFlowAttributes", + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("UserFlowAttributesClient.BaseClient.Post(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var newUserFlowAttribute UserFlowAttribute + if err := json.Unmarshal(respBody, &newUserFlowAttribute); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &newUserFlowAttribute, status, nil +} + +// Delete returns a UserFlowAttribute. +func (c *UserFlowAttributesClient) Get(ctx context.Context, id string, query odata.Query) (*UserFlowAttribute, int, error) { + resp, status, _, err := c.BaseClient.Get(ctx, GetHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + OData: query, + ValidStatusCodes: []int{http.StatusOK}, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/userFlowAttributes/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return nil, status, fmt.Errorf("UserFlowAttributesClient.BaseClient.Get(): %v", err) + } + + defer resp.Body.Close() + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, status, fmt.Errorf("io.ReadAll(): %v", err) + } + + var userflowAttribute UserFlowAttribute + if err := json.Unmarshal(respBody, &userflowAttribute); err != nil { + return nil, status, fmt.Errorf("json.Unmarshal(): %v", err) + } + + return &userflowAttribute, status, nil +} + +// Update amends an existing UserFlowAttribute. +func (c *UserFlowAttributesClient) Update(ctx context.Context, userflowAttribute UserFlowAttribute) (int, error) { + var status int + if userflowAttribute.ID == nil { + return status, fmt.Errorf("cannot update userflowAttribute with nil ID") + } + + userflowID := *userflowAttribute.ID + userflowAttribute.ID = nil + + body, err := json.Marshal(userflowAttribute) + if err != nil { + return status, fmt.Errorf("json.Marshal(): %v", err) + } + + _, status, _, err = c.BaseClient.Patch(ctx, PatchHttpRequestInput{ + Body: body, + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{ + http.StatusOK, + http.StatusNoContent, + }, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/userFlowAttributes//%s", userflowID), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("UserFlowAttributesClient.BaseClient.Patch(): %v", err) + } + + return status, nil +} + +// Delete removes a UserFlowAttribute. +func (c *UserFlowAttributesClient) Delete(ctx context.Context, id string) (int, error) { + _, status, _, err := c.BaseClient.Delete(ctx, DeleteHttpRequestInput{ + ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, + ValidStatusCodes: []int{http.StatusNoContent}, + Uri: Uri{ + Entity: fmt.Sprintf("/identity/userFlowAttributes/%s", id), + HasTenantId: true, + }, + }) + if err != nil { + return status, fmt.Errorf("UserFlowAttributesClient.BaseClient.Delete(): %v", err) + } + + return status, nil +} diff --git a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go index cdf6cd3c10..1c59775636 100644 --- a/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go +++ b/vendor/github.com/manicminer/hamilton/msgraph/valuetypes.go @@ -627,3 +627,11 @@ const ( IncludedUserTypesMember IncludedUserTypes = "member" IncludedUserTypesGuest IncludedUserTypes = "guest" ) + +type UserflowAttributeDataType = string + +const ( + UserflowAttributeDataTypeString UserflowAttributeDataType = "string" + UserflowAttributeDataTypeBoolean UserflowAttributeDataType = "boolean" + UserflowAttributeDataTypeInt64 UserflowAttributeDataType = "int64" +) diff --git a/vendor/github.com/manicminer/hamilton/odata/query.go b/vendor/github.com/manicminer/hamilton/odata/query.go index d66bfe890e..5752802c47 100644 --- a/vendor/github.com/manicminer/hamilton/odata/query.go +++ b/vendor/github.com/manicminer/hamilton/odata/query.go @@ -12,6 +12,7 @@ type ConsistencyLevel string const ( ConsistencyLevelEventual ConsistencyLevel = "eventual" + ConsistencyLevelSession ConsistencyLevel = "session" ) type Metadata string diff --git a/vendor/modules.txt b/vendor/modules.txt index 56cbe997ec..75e371df9b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -146,7 +146,7 @@ github.com/hashicorp/terraform-svchost # github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 ## explicit; go 1.15 github.com/hashicorp/yamux -# github.com/manicminer/hamilton v0.47.1 +# github.com/manicminer/hamilton v0.49.0 ## explicit; go 1.16 github.com/manicminer/hamilton/auth github.com/manicminer/hamilton/environments