From 3bf6b24b65344fdb01a7c0e065e44337c7e5e6e2 Mon Sep 17 00:00:00 2001 From: obs-gh-abhinavpappu <141665106+obs-gh-abhinavpappu@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:25:10 -0700 Subject: [PATCH] feat: support isHome field for bookmark_group (#156) --- .../meta/operation/bookmark_group.graphql | 1 + client/meta/genqlient.generated.go | 6 ++++ docs/resources/bookmark_group.md | 6 ++-- observe/descriptions/bookmark_group.yaml | 12 +++++++ observe/resource_bookmark_group.go | 35 ++++++++++--------- 5 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 observe/descriptions/bookmark_group.yaml diff --git a/client/internal/meta/operation/bookmark_group.graphql b/client/internal/meta/operation/bookmark_group.graphql index d75881f6..f46a0237 100644 --- a/client/internal/meta/operation/bookmark_group.graphql +++ b/client/internal/meta/operation/bookmark_group.graphql @@ -4,6 +4,7 @@ fragment BookmarkGroup on BookmarkGroup { description iconUrl workspaceId + isHome } mutation createOrUpdateBookmarkGroup( diff --git a/client/meta/genqlient.generated.go b/client/meta/genqlient.generated.go index 18cb2378..dcef88d6 100644 --- a/client/meta/genqlient.generated.go +++ b/client/meta/genqlient.generated.go @@ -345,6 +345,7 @@ type BookmarkGroup struct { Description string `json:"description"` IconUrl string `json:"iconUrl"` WorkspaceId string `json:"workspaceId"` + IsHome bool `json:"isHome"` } // GetId returns BookmarkGroup.Id, and is useful for accessing the field via an interface. @@ -362,6 +363,9 @@ func (v *BookmarkGroup) GetIconUrl() string { return v.IconUrl } // GetWorkspaceId returns BookmarkGroup.WorkspaceId, and is useful for accessing the field via an interface. func (v *BookmarkGroup) GetWorkspaceId() string { return v.WorkspaceId } +// GetIsHome returns BookmarkGroup.IsHome, and is useful for accessing the field via an interface. +func (v *BookmarkGroup) GetIsHome() bool { return v.IsHome } + type BookmarkGroupInput struct { Name *string `json:"name"` Description *string `json:"description"` @@ -12945,6 +12949,7 @@ fragment BookmarkGroup on BookmarkGroup { description iconUrl workspaceId + isHome } ` @@ -14804,6 +14809,7 @@ fragment BookmarkGroup on BookmarkGroup { description iconUrl workspaceId + isHome } ` diff --git a/docs/resources/bookmark_group.md b/docs/resources/bookmark_group.md index 4f76d1b3..9e9d6731 100644 --- a/docs/resources/bookmark_group.md +++ b/docs/resources/bookmark_group.md @@ -25,18 +25,20 @@ resource "observe_bookmark_group" "example" { ### Required - `name` (String) Name of bookmark group. -- `workspace` (String) OID of workspace bookmark group belongs to. +- `workspace` (String) OID of the workspace this object is contained in. ### Optional - `description` (String) Description of bookmark group. - `icon_url` (String) Icon used when presenting bookmark group. +- `is_home` (Boolean) Whether to add this bookmark group to the home page - `presentation` (String) ### Read-Only - `id` (String) The ID of this resource. -- `oid` (String) Observe ID of the bookmark group. +- `oid` (String) OID (Observe ID) for this object. This is the canonical identifier that +should be used when referring to this object in terraform manifests. ## Import Import is supported using the following syntax: ```shell diff --git a/observe/descriptions/bookmark_group.yaml b/observe/descriptions/bookmark_group.yaml new file mode 100644 index 00000000..97e81f30 --- /dev/null +++ b/observe/descriptions/bookmark_group.yaml @@ -0,0 +1,12 @@ +description: | + Manages a bookmark group. +schema: + name: | + Name of bookmark group. + description: | + Description of bookmark group. + icon_url: | + Icon used when presenting bookmark group. + presentation: "" + is_home: | + Whether to add this bookmark group to the home page diff --git a/observe/resource_bookmark_group.go b/observe/resource_bookmark_group.go index 29507020..12d8fc04 100644 --- a/observe/resource_bookmark_group.go +++ b/observe/resource_bookmark_group.go @@ -10,20 +10,12 @@ import ( observe "github.com/observeinc/terraform-provider-observe/client" gql "github.com/observeinc/terraform-provider-observe/client/meta" "github.com/observeinc/terraform-provider-observe/client/oid" -) - -const ( - schemaBookmarkGroupOIDDescription = "Observe ID of the bookmark group." - schemaBookmarkGroupWorkspaceDescription = "OID of workspace bookmark group belongs to." - schemaBookmarkGroupNameDescription = "Name of bookmark group." - schemaBookmarkGroupDescriptionDescription = "Description of bookmark group." - schemaBookmarkGroupIconDescription = "Icon used when presenting bookmark group." - schemaBookmarkGroupPresentationDescription = "" + "github.com/observeinc/terraform-provider-observe/observe/descriptions" ) func resourceBookmarkGroup() *schema.Resource { return &schema.Resource{ - Description: "Manages a bookmark group.", + Description: descriptions.Get("bookmark_group", "description"), CreateContext: resourceBookmarkGroupCreate, ReadContext: resourceBookmarkGroupRead, UpdateContext: resourceBookmarkGroupUpdate, @@ -35,29 +27,29 @@ func resourceBookmarkGroup() *schema.Resource { "oid": { Type: schema.TypeString, Computed: true, - Description: schemaBookmarkGroupOIDDescription, + Description: descriptions.Get("common", "schema", "oid"), }, "workspace": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateDiagFunc: validateOID(oid.TypeWorkspace), - Description: schemaBookmarkGroupWorkspaceDescription, + Description: descriptions.Get("common", "schema", "workspace"), }, "name": { Type: schema.TypeString, Required: true, - Description: schemaBookmarkGroupNameDescription, + Description: descriptions.Get("bookmark_group", "schema", "name"), }, "description": { Type: schema.TypeString, Optional: true, - Description: schemaBookmarkGroupDescriptionDescription, + Description: descriptions.Get("bookmark_group", "schema", "description"), }, "icon_url": { Type: schema.TypeString, Optional: true, - Description: schemaBookmarkGroupIconDescription, + Description: descriptions.Get("bookmark_group", "schema", "icon_url"), }, "presentation": { Type: schema.TypeString, @@ -67,7 +59,13 @@ func resourceBookmarkGroup() *schema.Resource { }, false), Default: gql.BookmarkGroupPresentationPercustomerworkspace, Optional: true, - Description: schemaBookmarkGroupPresentationDescription, + Description: descriptions.Get("bookmark_group", "schema", "presentation"), + }, + "is_home": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: descriptions.Get("bookmark_group", "schema", "is_home"), }, }, } @@ -77,6 +75,7 @@ func newBookmarkGroupConfig(data *schema.ResourceData) (input *gql.BookmarkGroup input = &gql.BookmarkGroupInput{ Name: stringPtr(data.Get("name").(string)), Description: stringPtr(data.Get("description").(string)), + IsHome: boolPtr(data.Get("is_home").(bool)), } p := gql.BookmarkGroupPresentation(data.Get("presentation").(string)) @@ -104,6 +103,10 @@ func bookmarkGroupToResourceData(bg *gql.BookmarkGroup, data *schema.ResourceDat } } + if err := data.Set("is_home", bg.IsHome); err != nil { + diags = append(diags, diag.FromErr(err)...) + } + if diags.HasError() { return diags }