Skip to content

Commit fa2f1e2

Browse files
committed
new dashboard ordering resource with test and docs
1 parent b949af1 commit fa2f1e2

7 files changed

Lines changed: 867 additions & 5 deletions

File tree

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "squaredup_dashboard_ordering Resource - squaredup"
4+
subcategory: ""
5+
description: |-
6+
Manage the order of dashboards in a workspace. It also allows you to create dashboard folders.
7+
---
8+
9+
# squaredup_dashboard_ordering (Resource)
10+
11+
Manage the order of dashboards in a workspace. It also allows you to create dashboard folders.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "squaredup_workspace" "application_workspace" {
17+
display_name = "Application Team"
18+
description = "Workspace with Dashboards for Application Team"
19+
}
20+
21+
resource "squaredup_dashboard" "application1" {
22+
workspace_id = squaredup_workspace.application_workspace.id
23+
display_name = "Application 1"
24+
dashboard_template = <<EOT
25+
{
26+
"_type": "layout/grid",
27+
"columns": 4,
28+
"contents": [
29+
{
30+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
31+
"x": 0,
32+
"y": 0,
33+
"w": 4,
34+
"h": 2,
35+
"config": {
36+
"title": "",
37+
"description": ""
38+
}
39+
}
40+
]
41+
}
42+
EOT
43+
}
44+
45+
resource "squaredup_dashboard" "application1_api" {
46+
workspace_id = squaredup_workspace.application_workspace.id
47+
display_name = "Application 1 (API)"
48+
dashboard_template = <<EOT
49+
{
50+
"_type": "layout/grid",
51+
"columns": 4,
52+
"contents": [
53+
{
54+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
55+
"x": 0,
56+
"y": 0,
57+
"w": 4,
58+
"h": 2,
59+
"config": {
60+
"title": "",
61+
"description": ""
62+
}
63+
}
64+
]
65+
}
66+
EOT
67+
}
68+
69+
resource "squaredup_dashboard" "application2" {
70+
workspace_id = squaredup_workspace.application_workspace.id
71+
display_name = "Application 2"
72+
dashboard_template = <<EOT
73+
{
74+
"_type": "layout/grid",
75+
"columns": 4,
76+
"contents": [
77+
{
78+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
79+
"x": 0,
80+
"y": 0,
81+
"w": 4,
82+
"h": 2,
83+
"config": {
84+
"title": "",
85+
"description": ""
86+
}
87+
}
88+
]
89+
}
90+
EOT
91+
}
92+
93+
resource "squaredup_dashboard" "application3" {
94+
workspace_id = squaredup_workspace.application_workspace.id
95+
display_name = "Application 3"
96+
dashboard_template = <<EOT
97+
{
98+
"_type": "layout/grid",
99+
"columns": 4,
100+
"contents": [
101+
{
102+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
103+
"x": 0,
104+
"y": 0,
105+
"w": 4,
106+
"h": 2,
107+
"config": {
108+
"title": "",
109+
"description": ""
110+
}
111+
}
112+
]
113+
}
114+
EOT
115+
}
116+
117+
resource "random_uuid" "application_1_folder_id" {}
118+
119+
resource "random_uuid" "app1_api_folder_id" {}
120+
121+
resource "squaredup_dashboard_ordering" "example_ordering" {
122+
workspace_id = squaredup_workspace.application_workspace.id
123+
# Example with dashboards in top level and nested folders
124+
# Folders needs to be as an object with name, id and dashboardIdOrder
125+
# dashboardIdOrder is a list of dashboard ids or nested folders
126+
order = jsonencode([
127+
{
128+
name = "Application 1"
129+
id = random_uuid.application_1_folder_id.result
130+
dashboardIdOrder = [
131+
{
132+
name = "API"
133+
id = random_uuid.app1_api_folder_id.result
134+
dashboardIdOrder = [
135+
squaredup_dashboard.application1_api.id
136+
]
137+
},
138+
squaredup_dashboard.application1.id
139+
]
140+
},
141+
squaredup_dashboard.application2.id,
142+
squaredup_dashboard.application3.id
143+
])
144+
}
145+
```
146+
147+
<!-- schema generated by tfplugindocs -->
148+
## Schema
149+
150+
### Required
151+
152+
- `order` (String) The order of the dashboards and folders in the workspace.
153+
- `workspace_id` (String) The ID of the workspace to manage.
154+
155+
### Read-Only
156+
157+
- `id` (String) The ID of the workspace.
158+
- `last_updated` (String) The last time the workspace order was updated.
159+
160+
## Import
161+
162+
Import is supported using the following syntax:
163+
164+
```shell
165+
# Dashboard Ordering can be imported by specifying the workspace id
166+
terraform import squaredup_dashboard_ordering.example space-123
167+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Dashboard Ordering can be imported by specifying the workspace id
2+
terraform import squaredup_dashboard_ordering.example space-123
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
resource "squaredup_workspace" "application_workspace" {
2+
display_name = "Application Team"
3+
description = "Workspace with Dashboards for Application Team"
4+
}
5+
6+
resource "squaredup_dashboard" "application1" {
7+
workspace_id = squaredup_workspace.application_workspace.id
8+
display_name = "Application 1"
9+
dashboard_template = <<EOT
10+
{
11+
"_type": "layout/grid",
12+
"columns": 4,
13+
"contents": [
14+
{
15+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
16+
"x": 0,
17+
"y": 0,
18+
"w": 4,
19+
"h": 2,
20+
"config": {
21+
"title": "",
22+
"description": ""
23+
}
24+
}
25+
]
26+
}
27+
EOT
28+
}
29+
30+
resource "squaredup_dashboard" "application1_api" {
31+
workspace_id = squaredup_workspace.application_workspace.id
32+
display_name = "Application 1 (API)"
33+
dashboard_template = <<EOT
34+
{
35+
"_type": "layout/grid",
36+
"columns": 4,
37+
"contents": [
38+
{
39+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
40+
"x": 0,
41+
"y": 0,
42+
"w": 4,
43+
"h": 2,
44+
"config": {
45+
"title": "",
46+
"description": ""
47+
}
48+
}
49+
]
50+
}
51+
EOT
52+
}
53+
54+
resource "squaredup_dashboard" "application2" {
55+
workspace_id = squaredup_workspace.application_workspace.id
56+
display_name = "Application 2"
57+
dashboard_template = <<EOT
58+
{
59+
"_type": "layout/grid",
60+
"columns": 4,
61+
"contents": [
62+
{
63+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
64+
"x": 0,
65+
"y": 0,
66+
"w": 4,
67+
"h": 2,
68+
"config": {
69+
"title": "",
70+
"description": ""
71+
}
72+
}
73+
]
74+
}
75+
EOT
76+
}
77+
78+
resource "squaredup_dashboard" "application3" {
79+
workspace_id = squaredup_workspace.application_workspace.id
80+
display_name = "Application 3"
81+
dashboard_template = <<EOT
82+
{
83+
"_type": "layout/grid",
84+
"columns": 4,
85+
"contents": [
86+
{
87+
"i": "07bb1be5-e210-4fa1-81e7-728a750ed247",
88+
"x": 0,
89+
"y": 0,
90+
"w": 4,
91+
"h": 2,
92+
"config": {
93+
"title": "",
94+
"description": ""
95+
}
96+
}
97+
]
98+
}
99+
EOT
100+
}
101+
102+
resource "random_uuid" "application_1_folder_id" {}
103+
104+
resource "random_uuid" "app1_api_folder_id" {}
105+
106+
resource "squaredup_dashboard_ordering" "example_ordering" {
107+
workspace_id = squaredup_workspace.application_workspace.id
108+
# Example with dashboards in top level and nested folders
109+
# Folders needs to be as an object with name, id and dashboardIdOrder
110+
# dashboardIdOrder is a list of dashboard ids or nested folders
111+
order = jsonencode([
112+
{
113+
name = "Application 1"
114+
id = random_uuid.application_1_folder_id.result
115+
dashboardIdOrder = [
116+
{
117+
name = "API"
118+
id = random_uuid.app1_api_folder_id.result
119+
dashboardIdOrder = [
120+
squaredup_dashboard.application1_api.id
121+
]
122+
},
123+
squaredup_dashboard.application1.id
124+
]
125+
},
126+
squaredup_dashboard.application2.id,
127+
squaredup_dashboard.application3.id
128+
])
129+
}

internal/provider/models.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ type WorkspaceReadData struct {
3434
}
3535

3636
type WorkspaceProperties struct {
37-
DashboardSharingEnabled bool `json:"openAccessEnabled"`
38-
Tags []string `json:"tags"`
39-
Description string `json:"description"`
40-
Type string `json:"type,omitempty"`
41-
AuthorizedEmailDomains []string `json:"authorizedEmailDomains"`
37+
DashboardSharingEnabled bool `json:"openAccessEnabled"`
38+
Tags []string `json:"tags"`
39+
Description string `json:"description"`
40+
Type string `json:"type,omitempty"`
41+
AuthorizedEmailDomains []string `json:"authorizedEmailDomains"`
42+
DashboardIdOrder []interface{} `json:"dashboardIdOrder,omitempty"`
4243
}
4344

4445
type WorkspaceLinks struct {

internal/provider/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,6 @@ func (p *squaredupProvider) Resources(_ context.Context) []func() resource.Resou
164164
SquaredupWorkspaceAlertResource,
165165
SquaredUpScriptResource,
166166
SquaredUpScopeResource,
167+
SquaredUpDashboardOrderingResource,
167168
}
168169
}

0 commit comments

Comments
 (0)