4.10.0
This commit is contained in:
@@ -53,6 +53,7 @@ func flattenUserDataSource(d *schema.ResourceData, details *user.ItemUser) {
|
||||
d.Set("active", details.Active)
|
||||
d.Set("authkey", details.AuthKey)
|
||||
d.Set("auth_keys", flattenItemUser(details.AuthKeys))
|
||||
d.Set("blocked", details.Blocked)
|
||||
d.Set("data", details.Data)
|
||||
d.Set("description", details.Description)
|
||||
d.Set("domain", details.Domain)
|
||||
@@ -80,6 +81,7 @@ func flattenUserResource(d *schema.ResourceData, details *user.ItemUser) {
|
||||
d.Set("active", details.Active)
|
||||
d.Set("authkey", details.AuthKey)
|
||||
d.Set("auth_keys", flattenItemUser(details.AuthKeys))
|
||||
d.Set("blocked", details.Blocked)
|
||||
d.Set("data", details.Data)
|
||||
d.Set("description", details.Description)
|
||||
d.Set("domain", details.Domain)
|
||||
@@ -144,6 +146,7 @@ func flattenUserList(users *user.ListUsers) []map[string]interface{} {
|
||||
"active": item.Active,
|
||||
"authkey": item.AuthKey,
|
||||
"authkeys": flattenItemUser(item.AuthKeys),
|
||||
"blocked": item.Blocked,
|
||||
"data": item.Data,
|
||||
"description": item.Description,
|
||||
"domain": item.Domain,
|
||||
|
||||
@@ -38,6 +38,10 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
createReq.Password = passwd.(string)
|
||||
}
|
||||
|
||||
if provider, ok := d.GetOk("provider_name"); ok {
|
||||
createReq.Provider = provider.(string)
|
||||
}
|
||||
|
||||
if aa, ok := d.GetOk("apiaccess"); ok {
|
||||
|
||||
apiaccess := aa.(*schema.Set)
|
||||
@@ -48,14 +52,6 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
}
|
||||
}
|
||||
|
||||
if groups, ok := d.GetOk("groups"); ok {
|
||||
|
||||
for _, v := range groups.([]interface{}) {
|
||||
|
||||
createReq.Groups = append(createReq.Groups, v.(string))
|
||||
}
|
||||
}
|
||||
|
||||
_, err := c.CloudBroker().User().Create(ctx, createReq)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
@@ -90,10 +86,33 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, m interface
|
||||
|
||||
err := utilityUserAPIAccessGroupsConfigure(ctx, d, m)
|
||||
if err != nil {
|
||||
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
c := m.(*controller.ControllerCfg)
|
||||
|
||||
if d.HasChange("blocked") {
|
||||
blocked := d.Get("blocked").(bool)
|
||||
if blocked {
|
||||
req := user.BlockRequest{
|
||||
UserID: d.Id(),
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().User().Block(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
} else {
|
||||
req := user.UnblockRequest{
|
||||
UserID: d.Id(),
|
||||
}
|
||||
|
||||
if _, err := c.CloudBroker().User().Unblock(ctx, req); err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resourceUserRead(ctx, d, m)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -51,6 +52,11 @@ func dataSourceUserSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "authkeys",
|
||||
},
|
||||
"blocked": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "is the user blocked",
|
||||
},
|
||||
"data": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -225,6 +231,11 @@ func dataSourceUserListSchemaMake() map[string]*schema.Schema {
|
||||
Optional: true,
|
||||
Description: "find by active. True or False",
|
||||
},
|
||||
"email": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "find by email",
|
||||
},
|
||||
"service_account": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
@@ -290,6 +301,11 @@ func dataSourceUserListSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "authkeys",
|
||||
},
|
||||
"blocked": {
|
||||
Type: schema.TypeBool,
|
||||
Computed: true,
|
||||
Description: "is the user blocked",
|
||||
},
|
||||
"data": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
@@ -409,12 +425,18 @@ func resourceUserSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Default: "strongpassword",
|
||||
Optional: true,
|
||||
Description: "password of user",
|
||||
},
|
||||
"provider_name": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Description: "provider",
|
||||
ValidateFunc: validation.StringInSlice([]string{"bvs", "decs3o"}, false),
|
||||
},
|
||||
"groups": {
|
||||
Type: schema.TypeList,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
@@ -448,6 +470,12 @@ func resourceUserSchemaMake() map[string]*schema.Schema {
|
||||
},
|
||||
Description: "list of apiaccess groups this user belongs to",
|
||||
},
|
||||
"blocked": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "is the user blocked",
|
||||
},
|
||||
"authkey": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
|
||||
@@ -52,6 +52,10 @@ func utilityUserListCheckPresence(ctx context.Context, d *schema.ResourceData, m
|
||||
req.Active = active.(bool)
|
||||
}
|
||||
|
||||
if email, ok := d.GetOk("email"); ok {
|
||||
req.Email = email.(string)
|
||||
}
|
||||
|
||||
if serviceAccount, ok := d.GetOk("service_account"); ok {
|
||||
req.ServiceAccount = serviceAccount.(bool)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user