Skip to content

Commit ce002ae

Browse files
author
Nishu Goel
committed
feat: Fix patch to put to update dashboards in blueprints
1 parent 9bed9bf commit ce002ae

File tree

11 files changed

+50
-57
lines changed

11 files changed

+50
-57
lines changed

.speakeasy/gen.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
lockVersion: 2.0.0
22
id: 5a857039-7f4b-42d5-86fd-449767242ed2
33
management:
4-
docChecksum: 5c72a9268be23452215b09edbe6f57e7
4+
docChecksum: dd5eb608fd0e0ea556a472c6122d83a7
55
docVersion: 0.0.1
66
speakeasyVersion: 1.477.0
77
generationVersion: 2.497.0
8-
releaseVersion: 0.15.1
9-
configChecksum: fd7797f410ce9414dce5af84c5518410
8+
releaseVersion: 0.15.2
9+
configChecksum: 6cf307147e8ddd1dcd9dba2d693aeace
1010
repoURL: https://github.com/epilot-dev/terraform-provider-epilot-product.git
1111
repoSubDirectory: .
1212
published: true

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Dashboard API: API to store the dashboard configuration for the epilot 360 dashb
2020
## Table of Contents
2121
<!-- $toc-max-depth=2 -->
2222
* [epilot-dashboard](#epilot-dashboard)
23-
* [🏗 **Welcome to your new Terraform Provider!** 🏗](#welcome-to-your-new-terraform-provider)
2423
* [Installation](#installation)
2524
* [Available Resources and Data Sources](#available-resources-and-data-sources)
2625
* [Testing the provider locally](#testing-the-provider-locally)
@@ -39,7 +38,7 @@ terraform {
3938
required_providers {
4039
epilot-dashboard = {
4140
source = "epilot-dev/epilot-dashboard"
42-
version = "0.15.1"
41+
version = "0.15.2"
4342
}
4443
}
4544
}

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ terraform {
1717
required_providers {
1818
epilot-dashboard = {
1919
source = "epilot-dev/epilot-dashboard"
20-
version = "0.15.1"
20+
version = "0.15.2"
2121
}
2222
}
2323
}

docs/resources/dashboard.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ resource "epilot-dashboard_dashboard" "my_dashboard" {
2525

2626
### Required
2727

28-
- `tiles` (String) Requires replacement if changed.; Parsed as JSON.
29-
- `title` (String) Requires replacement if changed.
28+
- `tiles` (String) Parsed as JSON.
29+
- `title` (String)
3030

3131
### Optional
3232

33-
- `id` (String) Unique identifier for dashboard. Requires replacement if changed.
33+
- `id` (String) Unique identifier for dashboard
3434

3535
## Import
3636

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TODO

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
epilot-dashboard = {
44
source = "epilot-dev/epilot-dashboard"
5-
version = "0.15.1"
5+
version = "0.15.2"
66
}
77
}
88
}

examples/resources/epilot-dashboard_dashboard/resource.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,4 @@ resource "epilot-dashboard_dashboard" "my_dashboard" {
22
id = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
33
tiles = "{ \"see\": \"documentation\" }"
44
title = "Employee Dashboard"
5-
}
6-
7-
terraform {
8-
required_providers {
9-
epilot-dashboard = {
10-
source = "epilot-dev/epilot-dashboard"
11-
version = "0.15.1"
12-
}
13-
}
14-
}
15-
16-
provider "epilot-dashboard" {
17-
# Configuration options
18-
19-
epilot_auth="eyJraWQiOiJ2ZFR0MGQrK1RMc2FQZ2tsQ3AzMDVGbEMxc1lOUCtUOXpsaElzMkJ3WERrPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIxNzEyMTkwMy1kM2JlLTRhZTktODZiZS04YjhkZDRmYzY0ZTYiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmV1LWNlbnRyYWwtMS5hbWF6b25hd3MuY29tXC9ldS1jZW50cmFsLTFfaGh6MnVJQ2xIIiwicGhvbmVfbnVtYmVyX3ZlcmlmaWVkIjp0cnVlLCJjdXN0b206aXZ5X29yZ19pZCI6IjY2IiwiY29nbml0bzp1c2VybmFtZSI6Im4uZ29lbEBlcGlsb3QuY2xvdWQiLCJjdXN0b206aXZ5X3VzZXJfaWQiOiI4MjYwMiIsImF1ZCI6ImdqOXAwanJlaWh0cTAwY3JpNmEwZmUzMDYiLCJldmVudF9pZCI6IjIwNzM0YjM3LTU5ZjctNDIwYS05NGNhLTcyY2Y0MGVlMmRiNiIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNzQ4ODc5MDk4LCJleHAiOjE3NDg5NDY2NTAsImlhdCI6MTc0ODk0MzA1MCwiZW1haWwiOiJuLmdvZWxAZXBpbG90LmNsb3VkIn0.lMMfJRH9T_7Lk5Gb1oVXgWlYCwIjZMxRyee3H7uSTBI_yxq7QDenPEmRRVyPdQIkNS15YepJ2-7r64Ny68Er0hYhbAuLFnd3KPUjlcUMwHnkgg-7Q0wcyWu1xwrLV7du0tPMZi_XgovJrXVY1PLVV_bY4q4AqZE6R2TUE4sPS9S6FmwSa6HfQbIUK55DrS3I5duAWIYAIdWEyNpekvXCC9FIT2iiBmUoEW4m7P-e_SzWpfbqlY5bpMVoeXsQs0E8x86sOxUxADJeR62_YVjgsSaVuwJgpdsrHoDFPQbK3h-hzALFz_MT97S_Dt2oh5v8DSI32L_NB-uid248cRCLOA"
20-
}
21-
22-
# import {
23-
# to = epilot-dashboard_dashboard.my_dashboard
24-
# id = "5bc69ec6-b709-4b9c-865f-a3a07375005e"
25-
# }
5+
}

gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ go:
2828
outputModelSuffix: output
2929
packageName: openapi
3030
terraform:
31-
version: 0.15.1
31+
version: 0.15.2
3232
additionalDataSources: []
3333
additionalDependencies: {}
3434
additionalResources: []

internal/provider/dashboard_resource.go

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ package provider
55
import (
66
"context"
77
"fmt"
8-
speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/planmodifiers/stringplanmodifier"
98
"github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/sdk"
109
"github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/sdk/models/operations"
1110
"github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/validators"
1211
"github.com/hashicorp/terraform-plugin-framework/path"
1312
"github.com/hashicorp/terraform-plugin-framework/resource"
1413
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
15-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
16-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
1714
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1815
"github.com/hashicorp/terraform-plugin-framework/types"
1916
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
@@ -48,32 +45,19 @@ func (r *DashboardResource) Schema(ctx context.Context, req resource.SchemaReque
4845
MarkdownDescription: "Dashboard Resource",
4946
Attributes: map[string]schema.Attribute{
5047
"id": schema.StringAttribute{
51-
Computed: true,
52-
Optional: true,
53-
PlanModifiers: []planmodifier.String{
54-
stringplanmodifier.RequiresReplaceIfConfigured(),
55-
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
56-
},
57-
Description: `Unique identifier for dashboard. Requires replacement if changed.`,
48+
Computed: true,
49+
Optional: true,
50+
Description: `Unique identifier for dashboard`,
5851
},
5952
"tiles": schema.StringAttribute{
60-
Required: true,
61-
PlanModifiers: []planmodifier.String{
62-
stringplanmodifier.RequiresReplaceIfConfigured(),
63-
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
64-
},
65-
Description: `Requires replacement if changed.; Parsed as JSON.`,
53+
Required: true,
54+
Description: `Parsed as JSON.`,
6655
Validators: []validator.String{
6756
validators.IsValidJSON(),
6857
},
6958
},
7059
"title": schema.StringAttribute{
7160
Required: true,
72-
PlanModifiers: []planmodifier.String{
73-
stringplanmodifier.RequiresReplaceIfConfigured(),
74-
speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress),
75-
},
76-
Description: `Requires replacement if changed.`,
7761
},
7862
},
7963
}
@@ -213,7 +197,36 @@ func (r *DashboardResource) Update(ctx context.Context, req resource.UpdateReque
213197
return
214198
}
215199

216-
// Not Implemented; all attributes marked as RequiresReplace
200+
dashboard := data.ToSharedDashboard()
201+
var id string
202+
id = data.ID.ValueString()
203+
204+
request := operations.PutDashboardRequest{
205+
Dashboard: dashboard,
206+
ID: id,
207+
}
208+
res, err := r.client.Dashboards.PutDashboard(ctx, request)
209+
if err != nil {
210+
resp.Diagnostics.AddError("failure to invoke API", err.Error())
211+
if res != nil && res.RawResponse != nil {
212+
resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse))
213+
}
214+
return
215+
}
216+
if res == nil {
217+
resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res))
218+
return
219+
}
220+
if res.StatusCode != 200 {
221+
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
222+
return
223+
}
224+
if !(res.Dashboard != nil) {
225+
resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse))
226+
return
227+
}
228+
data.RefreshFromSharedDashboard(res.Dashboard)
229+
refreshPlan(ctx, plan, &data, resp.Diagnostics)
217230

218231
// Save updated data into Terraform state
219232
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)

internal/sdk/sdk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ func New(opts ...SDKOption) *SDK {
149149
sdkConfiguration: sdkConfiguration{
150150
Language: "go",
151151
OpenAPIDocVersion: "0.0.1",
152-
SDKVersion: "0.15.1",
152+
SDKVersion: "0.15.2",
153153
GenVersion: "2.497.0",
154-
UserAgent: "speakeasy-sdk/terraform 0.15.1 2.497.0 0.0.1 github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/sdk",
154+
UserAgent: "speakeasy-sdk/terraform 0.15.2 2.497.0 0.0.1 github.com/epilot-dev/terraform-provider-epilot-dashboard/internal/sdk",
155155
Hooks: hooks.New(),
156156
},
157157
}

0 commit comments

Comments
 (0)