From 9ebec06d0bb1e6ae55db1728b8719394065f3d08 Mon Sep 17 00:00:00 2001 From: marcoquerque Date: Wed, 7 Sep 2022 16:59:47 -0400 Subject: [PATCH] Support HiddenValueDomainWhitelist (#35) * Support HiddenValueDomainWhitelist * Run make docs Co-authored-by: hirosassa --- docs/resources/user_attribute.md | 1 + pkg/looker/resource_user_attribute.go | 40 +++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/resources/user_attribute.md b/docs/resources/user_attribute.md index ed4cfb7..4976a92 100644 --- a/docs/resources/user_attribute.md +++ b/docs/resources/user_attribute.md @@ -34,6 +34,7 @@ resource "looker_user_attribute" "my_user_attribute" { ### Optional - `default_value` (String) +- `hidden_value_domain_whitelist` (String) - `id` (String) The ID of this resource. - `user_can_edit` (Boolean) - `user_can_view` (Boolean) diff --git a/pkg/looker/resource_user_attribute.go b/pkg/looker/resource_user_attribute.go index c1a395c..5890a1b 100644 --- a/pkg/looker/resource_user_attribute.go +++ b/pkg/looker/resource_user_attribute.go @@ -48,6 +48,11 @@ func resourceUserAttribute() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "hidden_value_domain_whitelist": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -61,15 +66,17 @@ func resourceUserAttributeCreate(ctx context.Context, d *schema.ResourceData, m userAttributeValueIsHidden := d.Get("value_is_hidden").(bool) userAttributeUserCanView := d.Get("user_can_view").(bool) userAttributeUserCanEdit := d.Get("user_can_edit").(bool) + userAttributeHiddenValueDomainWhitelist := d.Get("hidden_value_domain_whitelist").(string) writeUserAttribute := apiclient.WriteUserAttribute{ - Name: userAttributeName, - Label: userAttributeLabel, - Type: userAttributeType, - DefaultValue: &userAttributeDefaultValue, - ValueIsHidden: &userAttributeValueIsHidden, - UserCanView: &userAttributeUserCanView, - UserCanEdit: &userAttributeUserCanEdit, + Name: userAttributeName, + Label: userAttributeLabel, + Type: userAttributeType, + DefaultValue: &userAttributeDefaultValue, + ValueIsHidden: &userAttributeValueIsHidden, + UserCanView: &userAttributeUserCanView, + UserCanEdit: &userAttributeUserCanEdit, + HiddenValueDomainWhitelist: &userAttributeHiddenValueDomainWhitelist, } log.Printf("[DEBUG] Create user attribute %s", userAttributeName) @@ -116,6 +123,9 @@ func resourceUserAttributeRead(ctx context.Context, d *schema.ResourceData, m in if err = d.Set("user_can_edit", userAttribute.UserCanEdit); err != nil { return diag.FromErr(err) } + if err = d.Set("hidden_value_domain_whitelist", userAttribute.HiddenValueDomainWhitelist); err != nil { + return diag.FromErr(err) + } return nil } @@ -132,15 +142,17 @@ func resourceUserAttributeUpdate(ctx context.Context, d *schema.ResourceData, m userAttributeValueIsHidden := d.Get("value_is_hidden").(bool) userAttributeUserCanView := d.Get("user_can_view").(bool) userAttributeUserCanEdit := d.Get("user_can_edit").(bool) + userAttributeHiddenValueDomainWhitelist := d.Get("hidden_value_domain_whitelist").(string) writeUserAttribute := apiclient.WriteUserAttribute{ - Name: userAttributeName, - Label: userAttributeLabel, - Type: userAttributeType, - DefaultValue: &userAttributeDefaultValue, - ValueIsHidden: &userAttributeValueIsHidden, - UserCanView: &userAttributeUserCanView, - UserCanEdit: &userAttributeUserCanEdit, + Name: userAttributeName, + Label: userAttributeLabel, + Type: userAttributeType, + DefaultValue: &userAttributeDefaultValue, + ValueIsHidden: &userAttributeValueIsHidden, + UserCanView: &userAttributeUserCanView, + UserCanEdit: &userAttributeUserCanEdit, + HiddenValueDomainWhitelist: &userAttributeHiddenValueDomainWhitelist, } log.Printf("[DEBUG] Update user attribute %s", userAttributeID)