From 83e9a334851d1c7f02538afc60c960a59a85e9ef Mon Sep 17 00:00:00 2001 From: Julia Zolotarev Date: Wed, 27 Nov 2024 10:30:04 -0500 Subject: [PATCH] APP-15799 - Update dashboard resourceGroupId --- jupiterone/internal/client/dashboard.graphql | 1 - jupiterone/internal/client/generated.go | 2 +- jupiterone/resource_dashboard.go | 21 +++++++++++++------- jupiterone/resource_dashboard_test.go | 2 ++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/jupiterone/internal/client/dashboard.graphql b/jupiterone/internal/client/dashboard.graphql index feb3bbac..b2935383 100644 --- a/jupiterone/internal/client/dashboard.graphql +++ b/jupiterone/internal/client/dashboard.graphql @@ -27,7 +27,6 @@ mutation DeleteDashboard($dashboardId: String!) { # @genqlient(for: "PatchInsightsDashboardInput.layouts", omitempty: true, pointer:true) # @genqlient(for: "PatchInsightsDashboardInput.category", omitempty: true) -# @genqlient(for: "PatchInsightsDashboardInput.resourceGroupId", omitempty: true) mutation UpdateDashboard( $input: PatchInsightsDashboardInput! ) { diff --git a/jupiterone/internal/client/generated.go b/jupiterone/internal/client/generated.go index 3d3e1f7a..e0bc13e3 100644 --- a/jupiterone/internal/client/generated.go +++ b/jupiterone/internal/client/generated.go @@ -2852,7 +2852,7 @@ type PatchInsightsDashboardInput struct { Published bool `json:"published"` PublishedToUserIds []string `json:"publishedToUserIds"` PublishedToGroupIds []string `json:"publishedToGroupIds"` - ResourceGroupId string `json:"resourceGroupId,omitempty"` + ResourceGroupId string `json:"resourceGroupId"` } // GetDashboardId returns PatchInsightsDashboardInput.DashboardId, and is useful for accessing the field via an interface. diff --git a/jupiterone/resource_dashboard.go b/jupiterone/resource_dashboard.go index 0bf5e9fb..a3dff35e 100644 --- a/jupiterone/resource_dashboard.go +++ b/jupiterone/resource_dashboard.go @@ -35,9 +35,10 @@ func NewDashboard() resource.Resource { } type DashboardModel struct { - Id types.String `json:"id,omitempty" tfsdk:"id"` - Name types.String `json:"name,omitempty" tfsdk:"name"` - Type types.String `json:"type,omitempty" tfsdk:"type"` + Id types.String `json:"id,omitempty" tfsdk:"id"` + Name types.String `json:"name,omitempty" tfsdk:"name"` + Type types.String `json:"type,omitempty" tfsdk:"type"` + ResourceGroupId types.String `json:"resource_group_id" tfsdk:"resource_group_id"` } func NewDashboardResource() resource.Resource { @@ -176,6 +177,10 @@ func (*DashboardResource) Schema(ctx context.Context, req resource.SchemaRequest stringvalidator.OneOf(DashboardTypes...), }, }, + "resource_group_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the resource group that the dashboard belongs to.", + }, }, } } @@ -216,8 +221,9 @@ func (r *DashboardResource) Update(ctx context.Context, req resource.UpdateReque func (r *DashboardModel) BuildCreateInsightsDashboardInput() (client.CreateInsightsDashboardInput, error) { dashboard := client.CreateInsightsDashboardInput{ - Name: r.Name.ValueString(), - Type: client.BoardType(r.Type.ValueString()), + Name: r.Name.ValueString(), + Type: client.BoardType(r.Type.ValueString()), + ResourceGroupId: r.ResourceGroupId.ValueString(), } return dashboard, nil @@ -225,8 +231,9 @@ func (r *DashboardModel) BuildCreateInsightsDashboardInput() (client.CreateInsig func (r *DashboardModel) BuildPatchInsightsDashboardInput() (client.PatchInsightsDashboardInput, error) { dashboard := client.PatchInsightsDashboardInput{ - Name: r.Name.ValueString(), - DashboardId: r.Id.ValueString(), + Name: r.Name.ValueString(), + DashboardId: r.Id.ValueString(), + ResourceGroupId: r.ResourceGroupId.ValueString(), } return dashboard, nil diff --git a/jupiterone/resource_dashboard_test.go b/jupiterone/resource_dashboard_test.go index 1693c0bc..ea452d9e 100644 --- a/jupiterone/resource_dashboard_test.go +++ b/jupiterone/resource_dashboard_test.go @@ -66,6 +66,7 @@ func TestDashboard_BasicImport(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "id"), resource.TestCheckResourceAttr(resourceName, "name", dashboardName), resource.TestCheckResourceAttr(resourceName, "type", string(dashboardType)), + resource.TestCheckResourceAttr(resourceName, "resource_group_id", "rg-123456"), ), }, }, @@ -172,6 +173,7 @@ func testDashboardBasicConfig(rName string) string { resource "jupiterone_dashboard" "test" { name = %q type = "Account" + resource_group_id = "rg-123456" } `, rName) }