Skip to content

Commit

Permalink
APP-15799 - Update dashboard resourceGroupId
Browse files Browse the repository at this point in the history
  • Loading branch information
jzolo22 committed Nov 27, 2024
1 parent 1fc244f commit 83e9a33
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion jupiterone/internal/client/dashboard.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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!
) {
Expand Down
2 changes: 1 addition & 1 deletion jupiterone/internal/client/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions jupiterone/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.",
},
},
}
}
Expand Down Expand Up @@ -216,17 +221,19 @@ 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
}

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
Expand Down
2 changes: 2 additions & 0 deletions jupiterone/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -172,6 +173,7 @@ func testDashboardBasicConfig(rName string) string {
resource "jupiterone_dashboard" "test" {
name = %q
type = "Account"
resource_group_id = "rg-123456"
}
`, rName)
}

0 comments on commit 83e9a33

Please sign in to comment.