diff --git a/integration/user.tf b/integration/user.tf index 92053492..ee101552 100644 --- a/integration/user.tf +++ b/integration/user.tf @@ -1,6 +1,5 @@ resource "materialize_user" "example_user" { for_each = toset(["1", "2", "3", "4", "5"]) email = "example-user${each.key}@example.com" - auth_provider = "local" roles = ["Member", "Admin"] } diff --git a/pkg/datasources/datasource_region.go b/pkg/datasources/datasource_region.go index b1448249..7736d445 100644 --- a/pkg/datasources/datasource_region.go +++ b/pkg/datasources/datasource_region.go @@ -31,8 +31,9 @@ func Region() *schema.Resource { Description: "The name of the region.", }, "url": { - Type: schema.TypeString, - Computed: true, + Type: schema.TypeString, + Computed: true, + Description: "The URL at which the Region API can be reached.", }, "cloud_provider": { Type: schema.TypeString, diff --git a/pkg/resources/resource_user.go b/pkg/resources/resource_user.go index e8b7a6ef..48df06d2 100644 --- a/pkg/resources/resource_user.go +++ b/pkg/resources/resource_user.go @@ -29,9 +29,9 @@ func User() *schema.Resource { Description: "The email address of the user. This must be unique across all users in the organization.", }, "auth_provider": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Computed: true, + Description: "The authentication provider for the user.", }, "roles": { Type: schema.TypeList, @@ -48,19 +48,14 @@ func User() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "profile_picture_url": { - Type: schema.TypeString, - Computed: true, - }, }, } } // CreateUserRequest is used to serialize the request body for creating a new user. type CreateUserRequest struct { - Email string `json:"email"` - Provider string `json:"provider"` - RoleIDs []string `json:"roleIds"` + Email string `json:"email"` + RoleIDs []string `json:"roleIds"` } // CreatedUser represents the expected structure of a user creation response. @@ -70,6 +65,7 @@ type CreatedUser struct { ProfilePictureURL string `json:"profilePictureUrl"` Verified bool `json:"verified"` Metadata string `json:"metadata"` + Provider string `json:"provider"` } type FronteggRolesResponse struct { @@ -94,7 +90,7 @@ func userCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d client := providerMeta.Frontegg email := d.Get("email").(string) - provider := d.Get("auth_provider").(string) + // provider := "local" roleNames := convertToStringSlice(d.Get("roles").([]interface{})) for _, roleName := range roleNames { @@ -120,9 +116,8 @@ func userCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d } createUserRequest := CreateUserRequest{ - Email: email, - Provider: provider, - RoleIDs: roleIDs, + Email: email, + RoleIDs: roleIDs, } requestBody, err := json.Marshal(createUserRequest) @@ -153,6 +148,9 @@ func userCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) d return diag.FromErr(fmt.Errorf("error decoding response: %s", err)) } + d.Set("verified", createdUser.Verified) + d.Set("metadata", createdUser.Metadata) + d.Set("auth_provider", createdUser.Provider) d.SetId(createdUser.ID) return nil } @@ -198,9 +196,9 @@ func userRead(ctx context.Context, d *schema.ResourceData, meta interface{}) dia // Update the Terraform state with the fetched user data d.Set("email", user.Email) - d.Set("profile_picture_url", user.ProfilePictureURL) d.Set("verified", user.Verified) d.Set("metadata", user.Metadata) + d.Set("auth_provider", user.Provider) return nil }