-
Notifications
You must be signed in to change notification settings - Fork 0
New Squaredup Dashboard Image Resource #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| "tfsdk", | ||
| "timeframe", | ||
| "unmarshalling", | ||
| "uuidgen", | ||
| "visualisation" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| # generated by https://github.com/hashicorp/terraform-plugin-docs | ||
| page_title: "squaredup_dashboard_image Resource - squaredup" | ||
| subcategory: "" | ||
| description: |- | ||
| SquaredUp Dashboard Image resource allows you to upload an image to a dashboard tile. | ||
| --- | ||
|
|
||
| # squaredup_dashboard_image (Resource) | ||
|
|
||
| SquaredUp Dashboard Image resource allows you to upload an image to a dashboard tile. | ||
|
shaswot77 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| resource "squaredup_workspace" "application_workspace" { | ||
| display_name = "Application Team" | ||
| allow_dashboard_sharing = false | ||
| description = "Workspace with Dashboards for Application Team" | ||
| } | ||
|
|
||
| locals { | ||
| // unique id for the image tile which is generated using uuidgen in bash | ||
| application1_image_tile_id = "1d5ec28e-d5d5-4bc9-bbe0-dd63d9871244" | ||
| } | ||
|
|
||
| resource "squaredup_dashboard" "application1_dashboard" { | ||
| display_name = "Application 1" | ||
| workspace_id = squaredup_workspace.application_workspace.id | ||
| dashboard_template = <<EOT | ||
| { | ||
| "_type": "layout/grid", | ||
| "contents": [ | ||
| { | ||
| "x": 0, | ||
| "h": 2, | ||
| "i": "${local.application1_image_tile_id}", | ||
| "y": 0, | ||
| "config": { | ||
| "_type": "tile/image", | ||
| "description": "", | ||
| "title": "", | ||
| "visualisation": { | ||
| "config": { | ||
| "title": "Some description", | ||
| "uploaded": 123456789, | ||
| "showHealthState": false | ||
| } | ||
| } | ||
| }, | ||
| "w": 4 | ||
| } | ||
| ], | ||
| "version": 5, | ||
| "columns": 4 | ||
| } | ||
| EOT | ||
| } | ||
|
|
||
| resource "squaredup_dashboard_image" "application1_image" { | ||
| tile_id = local.application1_image_tile_id | ||
| dashboard_id = squaredup_dashboard.application1_dashboard.id | ||
| workspace_id = squaredup_workspace.application_workspace.id | ||
| image_base64_data_uri = "data:image/png;base64, ${filebase64("path/to/your/image.png")}" | ||
| image_file_name = "application1.png" | ||
| } | ||
| ``` | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Required | ||
|
|
||
| - `dashboard_id` (String) The ID of the dashboard which contains the tile where the image will be used. | ||
| - `image_base64_data_uri` (String) The base64 data URI of the image. | ||
| - `image_file_name` (String) The file name of the image. | ||
| - `tile_id` (String) The ID of the tile where the image will be used. | ||
| - `workspace_id` (String) The ID of the workspace which contains the dashboard. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `id` (String) The ID of the dashboard image which is the same as the tile ID. | ||
|
shaswot77 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Import | ||
|
|
||
| Import is supported using the following syntax: | ||
|
|
||
| ```shell | ||
| # Dashboard Image can be imported by specifying the workspace id, dashboard id and the tile id. | ||
| terraform import squaredup_dashboard_image.example space-123,dash-123,tile-guid | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Dashboard Image can be imported by specifying the workspace id, dashboard id and the tile id. | ||
| terraform import squaredup_dashboard_image.example space-123,dash-123,tile-guid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| resource "squaredup_workspace" "application_workspace" { | ||
| display_name = "Application Team" | ||
| allow_dashboard_sharing = false | ||
| description = "Workspace with Dashboards for Application Team" | ||
| } | ||
|
|
||
| locals { | ||
| // unique id for the image tile which is generated using uuidgen in bash | ||
| application1_image_tile_id = "1d5ec28e-d5d5-4bc9-bbe0-dd63d9871244" | ||
| } | ||
|
|
||
| resource "squaredup_dashboard" "application1_dashboard" { | ||
| display_name = "Application 1" | ||
| workspace_id = squaredup_workspace.application_workspace.id | ||
| dashboard_template = <<EOT | ||
| { | ||
| "_type": "layout/grid", | ||
| "contents": [ | ||
| { | ||
| "x": 0, | ||
| "h": 2, | ||
| "i": "${local.application1_image_tile_id}", | ||
| "y": 0, | ||
| "config": { | ||
| "_type": "tile/image", | ||
| "description": "", | ||
| "title": "", | ||
| "visualisation": { | ||
| "config": { | ||
| "title": "Some description", | ||
| "uploaded": 123456789, | ||
| "showHealthState": false | ||
| } | ||
| } | ||
| }, | ||
| "w": 4 | ||
| } | ||
| ], | ||
| "version": 5, | ||
| "columns": 4 | ||
| } | ||
| EOT | ||
| } | ||
|
|
||
| resource "squaredup_dashboard_image" "application1_image" { | ||
| tile_id = local.application1_image_tile_id | ||
| dashboard_id = squaredup_dashboard.application1_dashboard.id | ||
| workspace_id = squaredup_workspace.application_workspace.id | ||
| image_base64_data_uri = "data:image/png;base64, ${filebase64("path/to/your/image.png")}" | ||
| image_file_name = "application1.png" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package provider | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "net/http" | ||
| "strconv" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| func (c *SquaredUpClient) GetDashboardImage(spaceId, dashId, tileId string) (*DashboardImage, error) { | ||
| currentTimeInMillis := time.Now().UnixMilli() | ||
| currentTimeStr := strconv.FormatInt(currentTimeInMillis, 10) | ||
| url := c.baseURL + "/api/workspaces/" + spaceId + "/dashboards/" + dashId + "/images/" + tileId + "?uploaded=" + currentTimeStr | ||
| req, err := http.NewRequest("GET", url, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| body, err := c.doRequest(req) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| dashboardImage := DashboardImage{} | ||
| err = json.Unmarshal(body, &dashboardImage) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return &dashboardImage, nil | ||
| } | ||
|
|
||
| func (c *SquaredUpClient) UploadDashboardImage(spaceId, dashId, tileId string, dashboardImage *DashboardImage) error { | ||
| url := c.baseURL + "/api/workspaces/" + spaceId + "/dashboards/" + dashId + "/images/" + tileId | ||
| rb, err := json.Marshal(dashboardImage) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| req, err := http.NewRequest("PUT", url, strings.NewReader(string(rb))) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| _, err = c.doRequest(req) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (c *SquaredUpClient) DeleteDashboardImage(spaceId, dashId, tileId string) error { | ||
| url := c.baseURL + "/api/workspaces/" + spaceId + "/dashboards/" + dashId + "/images/" + tileId | ||
| req, err := http.NewRequest("DELETE", url, nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| _, err = c.doRequest(req) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.