From 5bd82afba7e3414d4a0d4e50c625c82205d49dc1 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Wed, 17 Jan 2024 17:14:34 +0000 Subject: [PATCH 01/11] CRUD operations for OA --- internal/provider/client_open_access.go | 85 ++++++++ internal/provider/models.go | 13 ++ internal/provider/provider.go | 1 + internal/provider/resource_open_acess.go | 259 +++++++++++++++++++++++ 4 files changed, 358 insertions(+) create mode 100644 internal/provider/client_open_access.go create mode 100644 internal/provider/resource_open_acess.go diff --git a/internal/provider/client_open_access.go b/internal/provider/client_open_access.go new file mode 100644 index 0000000..01a1fd4 --- /dev/null +++ b/internal/provider/client_open_access.go @@ -0,0 +1,85 @@ +package provider + +import ( + "encoding/json" + "net/http" + "strings" +) + +func (c *SquaredUpClient) CreateOpenAccess(openAccess OpenAccess) (*OpenAccess, error) { + rb, err := json.Marshal(openAccess) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", c.baseURL+"/api/openaccess/shares", strings.NewReader(string(rb))) + if err != nil { + return nil, err + } + + body, err := c.doRequest(req) + if err != nil { + return nil, err + } + + newOpenAccess := OpenAccess{} + err = json.Unmarshal(body, &newOpenAccess) + if err != nil { + return nil, err + } + + return &newOpenAccess, nil +} + +func (c *SquaredUpClient) GetOpenAccess(openAcessId string) (*OpenAccess, error) { + req, err := http.NewRequest("GET", c.baseURL+"/api/openaccess/shares/"+openAcessId, nil) + if err != nil { + return nil, err + } + + body, err := c.doRequest(req) + if err != nil { + return nil, err + } + + openAccess := OpenAccess{} + err = json.Unmarshal(body, &openAccess) + if err != nil { + return nil, err + } + + return &openAccess, nil +} + +func (c *SquaredUpClient) UpdateOpenAccess(openAcessId string, openAccess OpenAccess) error { + rb, err := json.Marshal(openAccess) + if err != nil { + return err + } + + req, err := http.NewRequest("PUT", c.baseURL+"/api/openaccess/shares/"+openAcessId, strings.NewReader(string(rb))) + if err != nil { + return err + } + + _, err = c.doRequest(req) + if err != nil { + return err + } + + return nil +} + +func (c *SquaredUpClient) DeleteOpenAccess(openAcessId string) error { + req, err := http.NewRequest("DELETE", c.baseURL+"/api/openaccess/shares/"+openAcessId, nil) + if err != nil { + return err + } + + _, err = c.doRequest(req) + if err != nil { + return err + } + + return nil +} diff --git a/internal/provider/models.go b/internal/provider/models.go index d4bc178..66227d6 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -107,3 +107,16 @@ type GremlinQueryResult struct { TenantId []string `json:"__tenantId"` ConfigId []string `json:"__configId"` } + +type OpenAccess struct { + LastUpdated string `json:"lastUpdated,omitempty"` + ID string `json:"id,omitempty"` + TargetID string `json:"targetId"` + WorkspaceID string `json:"workspaceId"` + Properties OpenAccessProperties `json:"properties"` +} + +type OpenAccessProperties struct { + Enabled bool `json:"enabled"` + RequireAuthentication bool `json:"requireAuthentication"` +} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index b32af95..0e831fb 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -160,5 +160,6 @@ func (p *squaredupProvider) Resources(_ context.Context) []func() resource.Resou SquaredupDataSourceResource, SquaredupWorkspaceResource, SquaredUpDashboardResource, + SquaredUpOpenAccessResource, } } diff --git a/internal/provider/resource_open_acess.go b/internal/provider/resource_open_acess.go new file mode 100644 index 0000000..73641e3 --- /dev/null +++ b/internal/provider/resource_open_acess.go @@ -0,0 +1,259 @@ +package provider + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var ( + _ resource.Resource = &OpenAccessResource{} + _ resource.ResourceWithConfigure = &OpenAccessResource{} + _ resource.ResourceWithImportState = &OpenAccessResource{} +) + +func SquaredUpOpenAccessResource() resource.Resource { + return &OpenAccessResource{} +} + +type OpenAccessResource struct { + client *SquaredUpClient +} + +type DashboardSharing struct { + OpenAccessID types.String `tfsdk:"id"` + DashboardID types.String `tfsdk:"dashboard_id"` + WorkspaceID types.String `tfsdk:"workspace_id"` + RequireAuthentication types.Bool `tfsdk:"require_authentication"` + EnableLink types.Bool `tfsdk:"enable_link"` + OpenAccessLink types.String `tfsdk:"open_access_link"` + LastUpdated types.String `tfsdk:"last_updated"` +} + +func (r *OpenAccessResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_dashboard_sharing" +} + +func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Enable Open Access for a dashboard", + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Description: "The ID of the Open Access", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "dashboard_id": schema.StringAttribute{ + Description: "The ID of the dashboard", + Required: true, + }, + "workspace_id": schema.StringAttribute{ + Description: "The ID of the workspace where the dashboard is located", + Required: true, + }, + "require_authentication": schema.BoolAttribute{ + Description: "If false, the dashboard will be accessible to anyone with the link", + Required: true, + }, + "enable_link": schema.BoolAttribute{ + Description: "If false, the dashboard will not be accessible via Open Access Link", + Optional: true, + Computed: true, + Default: booldefault.StaticBool(true), + }, + "open_access_link": schema.StringAttribute{ + Description: "The Open Access Link for the dashboard", + Computed: true, + }, + "last_updated": schema.StringAttribute{ + Description: "The last time the Open Access was updated", + Computed: true, + }, + }, + } +} + +func (r *OpenAccessResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*SquaredUpClient) + if !ok { + resp.Diagnostics.AddError( + "Unexpected type for provider data", + fmt.Sprintf("Expected *SquaredUpClient, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *OpenAccessResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan DashboardSharing + diags := req.Plan.Get(ctx, &plan) + if diags.HasError() { + return + } + + OpenAccessPayload := OpenAccess{ + TargetID: plan.DashboardID.ValueString(), + WorkspaceID: plan.WorkspaceID.ValueString(), + Properties: OpenAccessProperties{ + Enabled: plan.EnableLink.ValueBool(), + RequireAuthentication: plan.RequireAuthentication.ValueBool(), + }, + } + + openAccess, err := r.client.CreateOpenAccess(OpenAccessPayload) + if err != nil { + resp.Diagnostics.AddError( + "Unable to enable Open Access", + fmt.Sprintf("Unable to enable Open Access: %s", err.Error()), + ) + + return + } + + state := DashboardSharing{ + OpenAccessID: types.StringValue(openAccess.ID), + DashboardID: types.StringValue(openAccess.TargetID), + WorkspaceID: types.StringValue(openAccess.WorkspaceID), + RequireAuthentication: types.BoolValue(openAccess.Properties.RequireAuthentication), + EnableLink: types.BoolValue(openAccess.Properties.Enabled), + OpenAccessLink: types.StringValue(generateOpenAccessURL(openAccess.ID)), + LastUpdated: types.StringValue(time.Now().Format(time.RFC850)), + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *OpenAccessResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state DashboardSharing + diags := req.State.Get(ctx, &state) + if diags.HasError() { + return + } + + openAccess, err := r.client.GetOpenAccess(state.OpenAccessID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read Open Access", + fmt.Sprintf("Unable to read Open Access: %s", err.Error()), + ) + + return + } + + state = DashboardSharing{ + OpenAccessID: types.StringValue(openAccess.ID), + DashboardID: types.StringValue(openAccess.TargetID), + WorkspaceID: types.StringValue(openAccess.WorkspaceID), + RequireAuthentication: types.BoolValue(openAccess.Properties.RequireAuthentication), + EnableLink: types.BoolValue(openAccess.Properties.Enabled), + OpenAccessLink: types.StringValue(generateOpenAccessURL(openAccess.ID)), + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan DashboardSharing + diags := req.Plan.Get(ctx, &plan) + if diags.HasError() { + return + } + + OpenAccessPayload := OpenAccess{ + TargetID: plan.DashboardID.ValueString(), + WorkspaceID: plan.WorkspaceID.ValueString(), + Properties: OpenAccessProperties{ + Enabled: plan.EnableLink.ValueBool(), + RequireAuthentication: plan.RequireAuthentication.ValueBool(), + }, + } + + err := r.client.UpdateOpenAccess(plan.OpenAccessID.ValueString(), OpenAccessPayload) + if err != nil { + resp.Diagnostics.AddError( + "Unable to update Open Access", + fmt.Sprintf("Unable to update Open Access: %s", err.Error()), + ) + + return + } + + readOpenAccess, err := r.client.GetOpenAccess(plan.OpenAccessID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Unable to read Open Access", + fmt.Sprintf("Unable to read Open Access: %s", err.Error()), + ) + + return + } + + state := DashboardSharing{ + OpenAccessID: types.StringValue(readOpenAccess.ID), + DashboardID: types.StringValue(readOpenAccess.TargetID), + WorkspaceID: types.StringValue(readOpenAccess.WorkspaceID), + RequireAuthentication: types.BoolValue(readOpenAccess.Properties.RequireAuthentication), + EnableLink: types.BoolValue(readOpenAccess.Properties.Enabled), + OpenAccessLink: types.StringValue(generateOpenAccessURL(readOpenAccess.ID)), + LastUpdated: types.StringValue(time.Now().Format(time.RFC850)), + } + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *OpenAccessResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state DashboardSharing + diags := req.State.Get(ctx, &state) + if diags.HasError() { + resp.Diagnostics = diags + return + } + + err := r.client.DeleteOpenAccess(state.OpenAccessID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Unable to delete Open Access", + fmt.Sprintf("Unable to delete Open Access: %s", err.Error()), + ) + + return + } +} + +func (r *OpenAccessResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +func generateOpenAccessURL(id string) string { + return "https://app.squaredup.com/openaccess/" + strings.Split(id, "-")[1] +} From 74e9593fd5807b553d8c2e88a8e375b94d4bfea1 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Wed, 17 Jan 2024 17:14:49 +0000 Subject: [PATCH 02/11] example for OA --- .../squaredup_dashboard_share/import.sh | 2 + .../squaredup_dashboard_share/resource.tf | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 examples/resources/squaredup_dashboard_share/import.sh create mode 100644 examples/resources/squaredup_dashboard_share/resource.tf diff --git a/examples/resources/squaredup_dashboard_share/import.sh b/examples/resources/squaredup_dashboard_share/import.sh new file mode 100644 index 0000000..481de76 --- /dev/null +++ b/examples/resources/squaredup_dashboard_share/import.sh @@ -0,0 +1,2 @@ +# Shared Dashboard can be imported using the OA ID. +terraform import squaredup_dashboard.example openacc-123 diff --git a/examples/resources/squaredup_dashboard_share/resource.tf b/examples/resources/squaredup_dashboard_share/resource.tf new file mode 100644 index 0000000..c3b2958 --- /dev/null +++ b/examples/resources/squaredup_dashboard_share/resource.tf @@ -0,0 +1,46 @@ +resource "squaredup_workspace" "application_workspace" { + display_name = "Application Team" + description = "Workspace with Dashboards for Application Team" + open_access_enabled = true +} + +resource "squaredup_dashboard" "sample_dashboard" { + dashboard_template = < Date: Wed, 17 Jan 2024 17:20:18 +0000 Subject: [PATCH 03/11] generated docs --- docs/resources/dashboard_share.md | 90 +++++++++++++++++++ .../squaredup_dashboard_share/resource.tf | 6 +- internal/provider/resource_open_acess.go | 2 +- 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 docs/resources/dashboard_share.md diff --git a/docs/resources/dashboard_share.md b/docs/resources/dashboard_share.md new file mode 100644 index 0000000..1e73bc4 --- /dev/null +++ b/docs/resources/dashboard_share.md @@ -0,0 +1,90 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "squaredup_dashboard_share Resource - terraform-provider-squaredup" +subcategory: "" +description: |- + Enable Open Access for a dashboard +--- + +# squaredup_dashboard_share (Resource) + +Enable Open Access for a dashboard + +## Example Usage + +```terraform +resource "squaredup_workspace" "application_workspace" { + display_name = "Application Team" + description = "Workspace with Dashboards for Application Team" + open_access_enabled = true +} + +resource "squaredup_dashboard" "sample_dashboard" { + dashboard_template = < +## Schema + +### Required + +- `dashboard_id` (String) The ID of the dashboard +- `require_authentication` (Boolean) If false, the dashboard will be accessible to anyone with the link +- `workspace_id` (String) The ID of the workspace where the dashboard is located + +### Optional + +- `enable_link` (Boolean) If false, the dashboard will not be accessible via Open Access Link + +### Read-Only + +- `id` (String) The ID of the Open Access +- `last_updated` (String) The last time the Open Access was updated +- `open_access_link` (String) The Open Access Link for the dashboard + +## Import + +Import is supported using the following syntax: + +```shell +# Shared Dashboard can be imported using the OA ID. +terraform import squaredup_dashboard.example openacc-123 +``` diff --git a/examples/resources/squaredup_dashboard_share/resource.tf b/examples/resources/squaredup_dashboard_share/resource.tf index c3b2958..c0c844d 100644 --- a/examples/resources/squaredup_dashboard_share/resource.tf +++ b/examples/resources/squaredup_dashboard_share/resource.tf @@ -34,11 +34,11 @@ resource "squaredup_dashboard" "sample_dashboard" { "version": 1 } EOT - workspace_id = squaredup_workspace.application_workspace.id - display_name = "Sample Dashboard" + workspace_id = squaredup_workspace.application_workspace.id + display_name = "Sample Dashboard" } -resource "squaredup_dashboard_sharing" "sample_dashboard_sharing" { +resource "squaredup_dashboard_share" "sample_dashboard_share" { dashboard_id = squaredup_dashboard.sample_dashboard.id workspace_id = squaredup_workspace.application_workspace.id require_authentication = true diff --git a/internal/provider/resource_open_acess.go b/internal/provider/resource_open_acess.go index 73641e3..81ff707 100644 --- a/internal/provider/resource_open_acess.go +++ b/internal/provider/resource_open_acess.go @@ -40,7 +40,7 @@ type DashboardSharing struct { } func (r *OpenAccessResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_dashboard_sharing" + resp.TypeName = req.ProviderTypeName + "_dashboard_share" } func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { From bba9dfbfdd35563e7031dfa5f690a7ac7afc9d35 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Wed, 17 Jan 2024 17:48:49 +0000 Subject: [PATCH 04/11] tests for OA --- internal/provider/resource_open_acess_test.go | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 internal/provider/resource_open_acess_test.go diff --git a/internal/provider/resource_open_acess_test.go b/internal/provider/resource_open_acess_test.go new file mode 100644 index 0000000..26ee097 --- /dev/null +++ b/internal/provider/resource_open_acess_test.go @@ -0,0 +1,135 @@ +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceOpenAccess(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: providerConfig + + ` +resource "squaredup_workspace" "application_workspace" { + display_name = "OA Test Workspace" + description = "Workspace with Dashboards for Application Team" + open_access_enabled = true +} + +resource "squaredup_dashboard" "sample_dashboard" { + dashboard_template = < Date: Fri, 19 Jan 2024 10:56:41 +0000 Subject: [PATCH 05/11] pr comments --- docs/resources/dashboard_share.md | 8 ++--- .../squaredup_dashboard_share/resource.tf | 2 +- internal/provider/resource_open_acess.go | 32 +++++++++---------- internal/provider/resource_open_acess_test.go | 10 +++--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/resources/dashboard_share.md b/docs/resources/dashboard_share.md index 1e73bc4..9300cab 100644 --- a/docs/resources/dashboard_share.md +++ b/docs/resources/dashboard_share.md @@ -57,7 +57,7 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { dashboard_id = squaredup_dashboard.sample_dashboard.id workspace_id = squaredup_workspace.application_workspace.id require_authentication = true - enable_link = true + enabled = true } ``` @@ -72,13 +72,13 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { ### Optional -- `enable_link` (Boolean) If false, the dashboard will not be accessible via Open Access Link +- `enabled` (Boolean) If false, sharing of the dashboard is disabled ### Read-Only -- `id` (String) The ID of the Open Access +- `dashboard_share_link` (String) The Open Access Link for the dashboard +- `id` (String) The ID of the Shared dashboard - `last_updated` (String) The last time the Open Access was updated -- `open_access_link` (String) The Open Access Link for the dashboard ## Import diff --git a/examples/resources/squaredup_dashboard_share/resource.tf b/examples/resources/squaredup_dashboard_share/resource.tf index c0c844d..7b1ece6 100644 --- a/examples/resources/squaredup_dashboard_share/resource.tf +++ b/examples/resources/squaredup_dashboard_share/resource.tf @@ -42,5 +42,5 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { dashboard_id = squaredup_dashboard.sample_dashboard.id workspace_id = squaredup_workspace.application_workspace.id require_authentication = true - enable_link = true + enabled = true } diff --git a/internal/provider/resource_open_acess.go b/internal/provider/resource_open_acess.go index 81ff707..a57ccb8 100644 --- a/internal/provider/resource_open_acess.go +++ b/internal/provider/resource_open_acess.go @@ -34,8 +34,8 @@ type DashboardSharing struct { DashboardID types.String `tfsdk:"dashboard_id"` WorkspaceID types.String `tfsdk:"workspace_id"` RequireAuthentication types.Bool `tfsdk:"require_authentication"` - EnableLink types.Bool `tfsdk:"enable_link"` - OpenAccessLink types.String `tfsdk:"open_access_link"` + EnableLink types.Bool `tfsdk:"enabled"` + OpenAccessLink types.String `tfsdk:"dashboard_share_link"` LastUpdated types.String `tfsdk:"last_updated"` } @@ -48,7 +48,7 @@ func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, Description: "Enable Open Access for a dashboard", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "The ID of the Open Access", + Description: "The ID of the Shared dashboard", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), @@ -66,13 +66,13 @@ func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, Description: "If false, the dashboard will be accessible to anyone with the link", Required: true, }, - "enable_link": schema.BoolAttribute{ - Description: "If false, the dashboard will not be accessible via Open Access Link", + "enabled": schema.BoolAttribute{ + Description: "If false, sharing of the dashboard is disabled", Optional: true, Computed: true, Default: booldefault.StaticBool(true), }, - "open_access_link": schema.StringAttribute{ + "dashboard_share_link": schema.StringAttribute{ Description: "The Open Access Link for the dashboard", Computed: true, }, @@ -121,8 +121,8 @@ func (r *OpenAccessResource) Create(ctx context.Context, req resource.CreateRequ openAccess, err := r.client.CreateOpenAccess(OpenAccessPayload) if err != nil { resp.Diagnostics.AddError( - "Unable to enable Open Access", - fmt.Sprintf("Unable to enable Open Access: %s", err.Error()), + "Unable to share dashboard", + fmt.Sprintf("Unable to share dashboard: %s", err.Error()), ) return @@ -155,8 +155,8 @@ func (r *OpenAccessResource) Read(ctx context.Context, req resource.ReadRequest, openAccess, err := r.client.GetOpenAccess(state.OpenAccessID.ValueString()) if err != nil { resp.Diagnostics.AddError( - "Unable to read Open Access", - fmt.Sprintf("Unable to read Open Access: %s", err.Error()), + "Unable to read shared dashboard", + fmt.Sprintf("Unable to read shared dashboard: %s", err.Error()), ) return @@ -197,8 +197,8 @@ func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequ err := r.client.UpdateOpenAccess(plan.OpenAccessID.ValueString(), OpenAccessPayload) if err != nil { resp.Diagnostics.AddError( - "Unable to update Open Access", - fmt.Sprintf("Unable to update Open Access: %s", err.Error()), + "Unable to update shared dashboard", + fmt.Sprintf("Unable to update shared dashboard: %s", err.Error()), ) return @@ -207,8 +207,8 @@ func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequ readOpenAccess, err := r.client.GetOpenAccess(plan.OpenAccessID.ValueString()) if err != nil { resp.Diagnostics.AddError( - "Unable to read Open Access", - fmt.Sprintf("Unable to read Open Access: %s", err.Error()), + "Unable to read shared dashboard", + fmt.Sprintf("Unable to read shared dashboard: %s", err.Error()), ) return @@ -242,8 +242,8 @@ func (r *OpenAccessResource) Delete(ctx context.Context, req resource.DeleteRequ err := r.client.DeleteOpenAccess(state.OpenAccessID.ValueString()) if err != nil { resp.Diagnostics.AddError( - "Unable to delete Open Access", - fmt.Sprintf("Unable to delete Open Access: %s", err.Error()), + "Unable to delete shared dashboard", + fmt.Sprintf("Unable to delete shared dashboard: %s", err.Error()), ) return diff --git a/internal/provider/resource_open_acess_test.go b/internal/provider/resource_open_acess_test.go index 26ee097..a8747bb 100644 --- a/internal/provider/resource_open_acess_test.go +++ b/internal/provider/resource_open_acess_test.go @@ -57,14 +57,14 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { dashboard_id = squaredup_dashboard.sample_dashboard.id workspace_id = squaredup_workspace.application_workspace.id require_authentication = true - enable_link = true + enabled = true } `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "require_authentication", "true"), - resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "enable_link", "true"), + resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "enabled", "true"), resource.TestCheckResourceAttrSet("squaredup_dashboard_share.sample_dashboard_share", "id"), - resource.TestCheckResourceAttrSet("squaredup_dashboard_share.sample_dashboard_share", "open_access_link"), + resource.TestCheckResourceAttrSet("squaredup_dashboard_share.sample_dashboard_share", "dashboard_share_link"), ), }, // Import Test @@ -122,12 +122,12 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { dashboard_id = squaredup_dashboard.sample_dashboard.id workspace_id = squaredup_workspace.application_workspace.id require_authentication = false -enable_link = false +enabled = false } `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "require_authentication", "false"), - resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "enable_link", "false"), + resource.TestCheckResourceAttr("squaredup_dashboard_share.sample_dashboard_share", "enabled", "false"), ), }, }, From 705d674f579d3d0c1a3d766b598da4eea8157441 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 11:05:47 +0000 Subject: [PATCH 06/11] rename of files from open access to dashboard share --- .../provider/{client_open_access.go => client_dashboard_share.go} | 0 .../{resource_open_acess.go => resource_dashboard_share.go} | 0 ...source_open_acess_test.go => resource_dashboard_share_test.go} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename internal/provider/{client_open_access.go => client_dashboard_share.go} (100%) rename internal/provider/{resource_open_acess.go => resource_dashboard_share.go} (100%) rename internal/provider/{resource_open_acess_test.go => resource_dashboard_share_test.go} (100%) diff --git a/internal/provider/client_open_access.go b/internal/provider/client_dashboard_share.go similarity index 100% rename from internal/provider/client_open_access.go rename to internal/provider/client_dashboard_share.go diff --git a/internal/provider/resource_open_acess.go b/internal/provider/resource_dashboard_share.go similarity index 100% rename from internal/provider/resource_open_acess.go rename to internal/provider/resource_dashboard_share.go diff --git a/internal/provider/resource_open_acess_test.go b/internal/provider/resource_dashboard_share_test.go similarity index 100% rename from internal/provider/resource_open_acess_test.go rename to internal/provider/resource_dashboard_share_test.go From 0db153eee8bea25db3ef5f289287aeb2a5026109 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 11:08:32 +0000 Subject: [PATCH 07/11] update descriptions --- docs/resources/dashboard_share.md | 8 ++++---- internal/provider/resource_dashboard_share.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/resources/dashboard_share.md b/docs/resources/dashboard_share.md index 9300cab..6aa8868 100644 --- a/docs/resources/dashboard_share.md +++ b/docs/resources/dashboard_share.md @@ -3,12 +3,12 @@ page_title: "squaredup_dashboard_share Resource - terraform-provider-squaredup" subcategory: "" description: |- - Enable Open Access for a dashboard + Enable Sharing for a dashboard --- # squaredup_dashboard_share (Resource) -Enable Open Access for a dashboard +Enable Sharing for a dashboard ## Example Usage @@ -76,9 +76,9 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { ### Read-Only -- `dashboard_share_link` (String) The Open Access Link for the dashboard +- `dashboard_share_link` (String) Shareable link for the dashboard - `id` (String) The ID of the Shared dashboard -- `last_updated` (String) The last time the Open Access was updated +- `last_updated` (String) The last time the Dashboard Share was updated ## Import diff --git a/internal/provider/resource_dashboard_share.go b/internal/provider/resource_dashboard_share.go index a57ccb8..1790226 100644 --- a/internal/provider/resource_dashboard_share.go +++ b/internal/provider/resource_dashboard_share.go @@ -45,7 +45,7 @@ func (r *OpenAccessResource) Metadata(_ context.Context, req resource.MetadataRe func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Enable Open Access for a dashboard", + Description: "Enable Sharing for a dashboard", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Description: "The ID of the Shared dashboard", @@ -73,11 +73,11 @@ func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, Default: booldefault.StaticBool(true), }, "dashboard_share_link": schema.StringAttribute{ - Description: "The Open Access Link for the dashboard", + Description: "Shareable link for the dashboard", Computed: true, }, "last_updated": schema.StringAttribute{ - Description: "The last time the Open Access was updated", + Description: "The last time the Dashboard Share was updated", Computed: true, }, }, From 435357cf96c264112415a2bb4b4ee0f9227ae552 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 11:09:49 +0000 Subject: [PATCH 08/11] Update description --- docs/resources/dashboard_share.md | 2 +- internal/provider/resource_dashboard_share.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/dashboard_share.md b/docs/resources/dashboard_share.md index 6aa8868..52e1406 100644 --- a/docs/resources/dashboard_share.md +++ b/docs/resources/dashboard_share.md @@ -66,7 +66,7 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { ### Required -- `dashboard_id` (String) The ID of the dashboard +- `dashboard_id` (String) The ID of the dashboard to share - `require_authentication` (Boolean) If false, the dashboard will be accessible to anyone with the link - `workspace_id` (String) The ID of the workspace where the dashboard is located diff --git a/internal/provider/resource_dashboard_share.go b/internal/provider/resource_dashboard_share.go index 1790226..00731e1 100644 --- a/internal/provider/resource_dashboard_share.go +++ b/internal/provider/resource_dashboard_share.go @@ -55,7 +55,7 @@ func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, }, }, "dashboard_id": schema.StringAttribute{ - Description: "The ID of the dashboard", + Description: "The ID of the dashboard to share", Required: true, }, "workspace_id": schema.StringAttribute{ From c0bbdf5509146b64b8abe38df950658dba713de9 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 11:26:24 +0000 Subject: [PATCH 09/11] rename OA to dashboard share --- internal/provider/client_dashboard_share.go | 30 +++---- internal/provider/models.go | 14 +-- internal/provider/provider.go | 2 +- internal/provider/resource_dashboard_share.go | 88 +++++++++---------- .../provider/resource_dashboard_share_test.go | 2 +- 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/internal/provider/client_dashboard_share.go b/internal/provider/client_dashboard_share.go index 01a1fd4..ccebcd9 100644 --- a/internal/provider/client_dashboard_share.go +++ b/internal/provider/client_dashboard_share.go @@ -6,8 +6,8 @@ import ( "strings" ) -func (c *SquaredUpClient) CreateOpenAccess(openAccess OpenAccess) (*OpenAccess, error) { - rb, err := json.Marshal(openAccess) +func (c *SquaredUpClient) CreateSharedDashboard(dashboardShare DashboardShare) (*DashboardShare, error) { + rb, err := json.Marshal(dashboardShare) if err != nil { return nil, err } @@ -22,17 +22,17 @@ func (c *SquaredUpClient) CreateOpenAccess(openAccess OpenAccess) (*OpenAccess, return nil, err } - newOpenAccess := OpenAccess{} - err = json.Unmarshal(body, &newOpenAccess) + sharedDashboard := DashboardShare{} + err = json.Unmarshal(body, &sharedDashboard) if err != nil { return nil, err } - return &newOpenAccess, nil + return &sharedDashboard, nil } -func (c *SquaredUpClient) GetOpenAccess(openAcessId string) (*OpenAccess, error) { - req, err := http.NewRequest("GET", c.baseURL+"/api/openaccess/shares/"+openAcessId, nil) +func (c *SquaredUpClient) GetSharedDashboard(sharedDashboardId string) (*DashboardShare, error) { + req, err := http.NewRequest("GET", c.baseURL+"/api/openaccess/shares/"+sharedDashboardId, nil) if err != nil { return nil, err } @@ -42,22 +42,22 @@ func (c *SquaredUpClient) GetOpenAccess(openAcessId string) (*OpenAccess, error) return nil, err } - openAccess := OpenAccess{} - err = json.Unmarshal(body, &openAccess) + sharedDashboard := DashboardShare{} + err = json.Unmarshal(body, &sharedDashboard) if err != nil { return nil, err } - return &openAccess, nil + return &sharedDashboard, nil } -func (c *SquaredUpClient) UpdateOpenAccess(openAcessId string, openAccess OpenAccess) error { - rb, err := json.Marshal(openAccess) +func (c *SquaredUpClient) UpdateSharedDashboard(sharedDashboardId string, dashboardShare DashboardShare) error { + rb, err := json.Marshal(dashboardShare) if err != nil { return err } - req, err := http.NewRequest("PUT", c.baseURL+"/api/openaccess/shares/"+openAcessId, strings.NewReader(string(rb))) + req, err := http.NewRequest("PUT", c.baseURL+"/api/openaccess/shares/"+sharedDashboardId, strings.NewReader(string(rb))) if err != nil { return err } @@ -70,8 +70,8 @@ func (c *SquaredUpClient) UpdateOpenAccess(openAcessId string, openAccess OpenAc return nil } -func (c *SquaredUpClient) DeleteOpenAccess(openAcessId string) error { - req, err := http.NewRequest("DELETE", c.baseURL+"/api/openaccess/shares/"+openAcessId, nil) +func (c *SquaredUpClient) DeleteSharedDashboard(sharedDashboardId string) error { + req, err := http.NewRequest("DELETE", c.baseURL+"/api/openaccess/shares/"+sharedDashboardId, nil) if err != nil { return err } diff --git a/internal/provider/models.go b/internal/provider/models.go index 66227d6..3c5f717 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -108,15 +108,15 @@ type GremlinQueryResult struct { ConfigId []string `json:"__configId"` } -type OpenAccess struct { - LastUpdated string `json:"lastUpdated,omitempty"` - ID string `json:"id,omitempty"` - TargetID string `json:"targetId"` - WorkspaceID string `json:"workspaceId"` - Properties OpenAccessProperties `json:"properties"` +type DashboardShare struct { + LastUpdated string `json:"lastUpdated,omitempty"` + ID string `json:"id,omitempty"` + TargetID string `json:"targetId"` + WorkspaceID string `json:"workspaceId"` + Properties DashboardShareProperties `json:"properties"` } -type OpenAccessProperties struct { +type DashboardShareProperties struct { Enabled bool `json:"enabled"` RequireAuthentication bool `json:"requireAuthentication"` } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 0e831fb..b87e205 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -160,6 +160,6 @@ func (p *squaredupProvider) Resources(_ context.Context) []func() resource.Resou SquaredupDataSourceResource, SquaredupWorkspaceResource, SquaredUpDashboardResource, - SquaredUpOpenAccessResource, + SquaredUpDashboardShareResource, } } diff --git a/internal/provider/resource_dashboard_share.go b/internal/provider/resource_dashboard_share.go index 00731e1..58125b1 100644 --- a/internal/provider/resource_dashboard_share.go +++ b/internal/provider/resource_dashboard_share.go @@ -16,34 +16,34 @@ import ( ) var ( - _ resource.Resource = &OpenAccessResource{} - _ resource.ResourceWithConfigure = &OpenAccessResource{} - _ resource.ResourceWithImportState = &OpenAccessResource{} + _ resource.Resource = &DashboardShareResource{} + _ resource.ResourceWithConfigure = &DashboardShareResource{} + _ resource.ResourceWithImportState = &DashboardShareResource{} ) -func SquaredUpOpenAccessResource() resource.Resource { - return &OpenAccessResource{} +func SquaredUpDashboardShareResource() resource.Resource { + return &DashboardShareResource{} } -type OpenAccessResource struct { +type DashboardShareResource struct { client *SquaredUpClient } type DashboardSharing struct { - OpenAccessID types.String `tfsdk:"id"` + DashboardShareID types.String `tfsdk:"id"` DashboardID types.String `tfsdk:"dashboard_id"` WorkspaceID types.String `tfsdk:"workspace_id"` RequireAuthentication types.Bool `tfsdk:"require_authentication"` EnableLink types.Bool `tfsdk:"enabled"` - OpenAccessLink types.String `tfsdk:"dashboard_share_link"` + SharedDashboardLink types.String `tfsdk:"dashboard_share_link"` LastUpdated types.String `tfsdk:"last_updated"` } -func (r *OpenAccessResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *DashboardShareResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_dashboard_share" } -func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *DashboardShareResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Enable Sharing for a dashboard", Attributes: map[string]schema.Attribute{ @@ -84,7 +84,7 @@ func (r *OpenAccessResource) Schema(_ context.Context, _ resource.SchemaRequest, } } -func (r *OpenAccessResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *DashboardShareResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -102,23 +102,23 @@ func (r *OpenAccessResource) Configure(_ context.Context, req resource.Configure r.client = client } -func (r *OpenAccessResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *DashboardShareResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var plan DashboardSharing diags := req.Plan.Get(ctx, &plan) if diags.HasError() { return } - OpenAccessPayload := OpenAccess{ + dashboardSharePayload := DashboardShare{ TargetID: plan.DashboardID.ValueString(), WorkspaceID: plan.WorkspaceID.ValueString(), - Properties: OpenAccessProperties{ + Properties: DashboardShareProperties{ Enabled: plan.EnableLink.ValueBool(), RequireAuthentication: plan.RequireAuthentication.ValueBool(), }, } - openAccess, err := r.client.CreateOpenAccess(OpenAccessPayload) + sharedDashboard, err := r.client.CreateSharedDashboard(dashboardSharePayload) if err != nil { resp.Diagnostics.AddError( "Unable to share dashboard", @@ -129,12 +129,12 @@ func (r *OpenAccessResource) Create(ctx context.Context, req resource.CreateRequ } state := DashboardSharing{ - OpenAccessID: types.StringValue(openAccess.ID), - DashboardID: types.StringValue(openAccess.TargetID), - WorkspaceID: types.StringValue(openAccess.WorkspaceID), - RequireAuthentication: types.BoolValue(openAccess.Properties.RequireAuthentication), - EnableLink: types.BoolValue(openAccess.Properties.Enabled), - OpenAccessLink: types.StringValue(generateOpenAccessURL(openAccess.ID)), + DashboardShareID: types.StringValue(sharedDashboard.ID), + DashboardID: types.StringValue(sharedDashboard.TargetID), + WorkspaceID: types.StringValue(sharedDashboard.WorkspaceID), + RequireAuthentication: types.BoolValue(sharedDashboard.Properties.RequireAuthentication), + EnableLink: types.BoolValue(sharedDashboard.Properties.Enabled), + SharedDashboardLink: types.StringValue(generateSharedDashboardURL(sharedDashboard.ID)), LastUpdated: types.StringValue(time.Now().Format(time.RFC850)), } @@ -145,14 +145,14 @@ func (r *OpenAccessResource) Create(ctx context.Context, req resource.CreateRequ } } -func (r *OpenAccessResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *DashboardShareResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var state DashboardSharing diags := req.State.Get(ctx, &state) if diags.HasError() { return } - openAccess, err := r.client.GetOpenAccess(state.OpenAccessID.ValueString()) + sharedDashboard, err := r.client.GetSharedDashboard(state.DashboardShareID.ValueString()) if err != nil { resp.Diagnostics.AddError( "Unable to read shared dashboard", @@ -163,12 +163,12 @@ func (r *OpenAccessResource) Read(ctx context.Context, req resource.ReadRequest, } state = DashboardSharing{ - OpenAccessID: types.StringValue(openAccess.ID), - DashboardID: types.StringValue(openAccess.TargetID), - WorkspaceID: types.StringValue(openAccess.WorkspaceID), - RequireAuthentication: types.BoolValue(openAccess.Properties.RequireAuthentication), - EnableLink: types.BoolValue(openAccess.Properties.Enabled), - OpenAccessLink: types.StringValue(generateOpenAccessURL(openAccess.ID)), + DashboardShareID: types.StringValue(sharedDashboard.ID), + DashboardID: types.StringValue(sharedDashboard.TargetID), + WorkspaceID: types.StringValue(sharedDashboard.WorkspaceID), + RequireAuthentication: types.BoolValue(sharedDashboard.Properties.RequireAuthentication), + EnableLink: types.BoolValue(sharedDashboard.Properties.Enabled), + SharedDashboardLink: types.StringValue(generateSharedDashboardURL(sharedDashboard.ID)), } diags = resp.State.Set(ctx, &state) @@ -178,23 +178,23 @@ func (r *OpenAccessResource) Read(ctx context.Context, req resource.ReadRequest, } } -func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *DashboardShareResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var plan DashboardSharing diags := req.Plan.Get(ctx, &plan) if diags.HasError() { return } - OpenAccessPayload := OpenAccess{ + dashboardSharePayload := DashboardShare{ TargetID: plan.DashboardID.ValueString(), WorkspaceID: plan.WorkspaceID.ValueString(), - Properties: OpenAccessProperties{ + Properties: DashboardShareProperties{ Enabled: plan.EnableLink.ValueBool(), RequireAuthentication: plan.RequireAuthentication.ValueBool(), }, } - err := r.client.UpdateOpenAccess(plan.OpenAccessID.ValueString(), OpenAccessPayload) + err := r.client.UpdateSharedDashboard(plan.DashboardShareID.ValueString(), dashboardSharePayload) if err != nil { resp.Diagnostics.AddError( "Unable to update shared dashboard", @@ -204,7 +204,7 @@ func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequ return } - readOpenAccess, err := r.client.GetOpenAccess(plan.OpenAccessID.ValueString()) + sharedDashboard, err := r.client.GetSharedDashboard(plan.DashboardShareID.ValueString()) if err != nil { resp.Diagnostics.AddError( "Unable to read shared dashboard", @@ -215,12 +215,12 @@ func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequ } state := DashboardSharing{ - OpenAccessID: types.StringValue(readOpenAccess.ID), - DashboardID: types.StringValue(readOpenAccess.TargetID), - WorkspaceID: types.StringValue(readOpenAccess.WorkspaceID), - RequireAuthentication: types.BoolValue(readOpenAccess.Properties.RequireAuthentication), - EnableLink: types.BoolValue(readOpenAccess.Properties.Enabled), - OpenAccessLink: types.StringValue(generateOpenAccessURL(readOpenAccess.ID)), + DashboardShareID: types.StringValue(sharedDashboard.ID), + DashboardID: types.StringValue(sharedDashboard.TargetID), + WorkspaceID: types.StringValue(sharedDashboard.WorkspaceID), + RequireAuthentication: types.BoolValue(sharedDashboard.Properties.RequireAuthentication), + EnableLink: types.BoolValue(sharedDashboard.Properties.Enabled), + SharedDashboardLink: types.StringValue(generateSharedDashboardURL(sharedDashboard.ID)), LastUpdated: types.StringValue(time.Now().Format(time.RFC850)), } @@ -231,7 +231,7 @@ func (r *OpenAccessResource) Update(ctx context.Context, req resource.UpdateRequ } } -func (r *OpenAccessResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r *DashboardShareResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var state DashboardSharing diags := req.State.Get(ctx, &state) if diags.HasError() { @@ -239,7 +239,7 @@ func (r *OpenAccessResource) Delete(ctx context.Context, req resource.DeleteRequ return } - err := r.client.DeleteOpenAccess(state.OpenAccessID.ValueString()) + err := r.client.DeleteSharedDashboard(state.DashboardShareID.ValueString()) if err != nil { resp.Diagnostics.AddError( "Unable to delete shared dashboard", @@ -250,10 +250,10 @@ func (r *OpenAccessResource) Delete(ctx context.Context, req resource.DeleteRequ } } -func (r *OpenAccessResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *DashboardShareResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } -func generateOpenAccessURL(id string) string { +func generateSharedDashboardURL(id string) string { return "https://app.squaredup.com/openaccess/" + strings.Split(id, "-")[1] } diff --git a/internal/provider/resource_dashboard_share_test.go b/internal/provider/resource_dashboard_share_test.go index a8747bb..4ec14cb 100644 --- a/internal/provider/resource_dashboard_share_test.go +++ b/internal/provider/resource_dashboard_share_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccResourceOpenAccess(t *testing.T) { +func TestAccResourceDashboardSharing(t *testing.T) { resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ From ad6be7959d0bf5517d4f6a340b20aab71b9518e2 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 13:44:34 +0000 Subject: [PATCH 10/11] pr comments --- examples/resources/squaredup_dashboard_share/import.sh | 2 +- internal/provider/resource_dashboard_share.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/resources/squaredup_dashboard_share/import.sh b/examples/resources/squaredup_dashboard_share/import.sh index 481de76..14cf271 100644 --- a/examples/resources/squaredup_dashboard_share/import.sh +++ b/examples/resources/squaredup_dashboard_share/import.sh @@ -1,2 +1,2 @@ -# Shared Dashboard can be imported using the OA ID. +# Dashboard share can be imported using the OA ID. terraform import squaredup_dashboard.example openacc-123 diff --git a/internal/provider/resource_dashboard_share.go b/internal/provider/resource_dashboard_share.go index 58125b1..c2b9828 100644 --- a/internal/provider/resource_dashboard_share.go +++ b/internal/provider/resource_dashboard_share.go @@ -45,10 +45,10 @@ func (r *DashboardShareResource) Metadata(_ context.Context, req resource.Metada func (r *DashboardShareResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - Description: "Enable Sharing for a dashboard", + Description: "Enable sharing for a dashboard", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Description: "The ID of the Shared dashboard", + Description: "The ID of the dashboard share", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), From 2dcced4851212f7c52c050c8a3bb6c2ff80f3057 Mon Sep 17 00:00:00 2001 From: Shaswot Subedi Date: Fri, 19 Jan 2024 13:45:29 +0000 Subject: [PATCH 11/11] update docs --- docs/resources/dashboard_share.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/resources/dashboard_share.md b/docs/resources/dashboard_share.md index 52e1406..a39170a 100644 --- a/docs/resources/dashboard_share.md +++ b/docs/resources/dashboard_share.md @@ -3,12 +3,12 @@ page_title: "squaredup_dashboard_share Resource - terraform-provider-squaredup" subcategory: "" description: |- - Enable Sharing for a dashboard + Enable sharing for a dashboard --- # squaredup_dashboard_share (Resource) -Enable Sharing for a dashboard +Enable sharing for a dashboard ## Example Usage @@ -77,7 +77,7 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { ### Read-Only - `dashboard_share_link` (String) Shareable link for the dashboard -- `id` (String) The ID of the Shared dashboard +- `id` (String) The ID of the dashboard share - `last_updated` (String) The last time the Dashboard Share was updated ## Import @@ -85,6 +85,6 @@ resource "squaredup_dashboard_share" "sample_dashboard_share" { Import is supported using the following syntax: ```shell -# Shared Dashboard can be imported using the OA ID. +# Dashboard share can be imported using the OA ID. terraform import squaredup_dashboard.example openacc-123 ```