Skip to content

Commit

Permalink
remove the predefined_probes datasource and rename ibaX to just X sin…
Browse files Browse the repository at this point in the history
…ce it's already in the iba package
  • Loading branch information
rajagopalans committed Oct 17, 2023
1 parent b2248d3 commit 1d100f3
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 235 deletions.
8 changes: 4 additions & 4 deletions apstra/data_source_iba_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (o *dataSourceIbaDashboard) Schema(_ context.Context, _ datasource.SchemaRe
MarkdownDescription: "This data source provides details of a specific IBA Dashboard in a Blueprint." +
"\n\n" +
"At least one optional attribute is required.",
Attributes: iba.IbaDashboard{}.DataSourceAttributes(),
Attributes: iba.Dashboard{}.DataSourceAttributes(),
}
}

func (o *dataSourceIbaDashboard) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config iba.IbaDashboard
var config iba.Dashboard
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -75,8 +75,8 @@ func (o *dataSourceIbaDashboard) Read(ctx context.Context, req datasource.ReadRe
if utils.IsApstra404(err) {
resp.Diagnostics.AddAttributeError(
path.Root("id"),
"IbaDashboard not found",
fmt.Sprintf("IbaDashboard with ID %s not found", config.Id))
"Dashboard not found",
fmt.Sprintf("Dashboard with ID %s not found", config.Id))
return
}
resp.Diagnostics.AddAttributeError(
Expand Down
4 changes: 2 additions & 2 deletions apstra/data_source_iba_predefined_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func (o *dataSourceIbaPredefinedProbe) Configure(ctx context.Context, req dataso
func (o *dataSourceIbaPredefinedProbe) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "This data source provides details of a specific IBA Predefined Probe in a Blueprint.",
Attributes: iba.IbaPredefinedProbe{}.DataSourceAttributes(),
Attributes: iba.PredefinedProbe{}.DataSourceAttributes(),
}
}

func (o *dataSourceIbaPredefinedProbe) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config iba.IbaPredefinedProbe
var config iba.PredefinedProbe
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
Expand Down
93 changes: 0 additions & 93 deletions apstra/data_source_iba_predefined_probes.go

This file was deleted.

8 changes: 4 additions & 4 deletions apstra/data_source_iba_widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (o *dataSourceIbaWidget) Schema(_ context.Context, _ datasource.SchemaReque
MarkdownDescription: "This data source provides details of a specific IBA Widget in a Blueprint." +
"\n\n" +
"At least one optional attribute is required.",
Attributes: iba.IbaWidget{}.DataSourceAttributes(),
Attributes: iba.Widget{}.DataSourceAttributes(),
}
}

func (o *dataSourceIbaWidget) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config iba.IbaWidget
var config iba.Widget
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -75,8 +75,8 @@ func (o *dataSourceIbaWidget) Read(ctx context.Context, req datasource.ReadReque
if utils.IsApstra404(err) {
resp.Diagnostics.AddAttributeError(
path.Root("id"),
"IbaWidget not found",
fmt.Sprintf("IbaWidget with ID %s not found", config.Id))
"Widget not found",
fmt.Sprintf("Widget with ID %s not found", config.Id))
return
}
resp.Diagnostics.AddAttributeError(
Expand Down
10 changes: 5 additions & 5 deletions apstra/iba/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type IbaDashboard struct {
type Dashboard struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Expand All @@ -27,7 +27,7 @@ type IbaDashboard struct {
UpdatedBy types.String `tfsdk:"updated_by"`
}

func (o IbaDashboard) ResourceAttributes() map[string]resourceSchema.Attribute {
func (o Dashboard) ResourceAttributes() map[string]resourceSchema.Attribute {
return map[string]resourceSchema.Attribute{
"blueprint_id": resourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify the Blueprint that the IBA Widget belongs to.",
Expand Down Expand Up @@ -75,7 +75,7 @@ func (o IbaDashboard) ResourceAttributes() map[string]resourceSchema.Attribute {
}
}

func (o IbaDashboard) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
func (o Dashboard) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
return map[string]dataSourceSchema.Attribute{
"blueprint_id": dataSourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify the Blueprint that the IBA Widget belongs to.",
Expand Down Expand Up @@ -131,7 +131,7 @@ func (o IbaDashboard) DataSourceAttributes() map[string]dataSourceSchema.Attribu
}
}

func (o *IbaDashboard) LoadApiData(ctx context.Context, in *apstra.IbaDashboard, diag *diag.Diagnostics) {
func (o *Dashboard) LoadApiData(ctx context.Context, in *apstra.IbaDashboard, diag *diag.Diagnostics) {
o.Id = types.StringValue(in.Id.String())
o.Name = types.StringValue(in.Data.Label)
o.Description = types.StringValue(in.Data.Description)
Expand All @@ -141,7 +141,7 @@ func (o *IbaDashboard) LoadApiData(ctx context.Context, in *apstra.IbaDashboard,
o.WidgetGrid = utils.ListValueOrNull(ctx, types.ListType{ElemType: types.StringType}, in.Data.IbaWidgetGrid, diag)
}

func (o *IbaDashboard) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaDashboardData {
func (o *Dashboard) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaDashboardData {
var grid [][]apstra.ObjectId
d.Append(o.WidgetGrid.ElementsAs(ctx, &grid, false)...)
if d.HasError() {
Expand Down
6 changes: 3 additions & 3 deletions apstra/iba/predefined_probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type IbaPredefinedProbe struct {
type PredefinedProbe struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Name types.String `tfsdk:"name"`
Description types.String `tfsdk:"description"`
Schema types.String `tfsdk:"schema"`
}

func (o IbaPredefinedProbe) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
func (o PredefinedProbe) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
return map[string]dataSourceSchema.Attribute{
"blueprint_id": dataSourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify the Blueprint that the IBA Predefined Probe belongs to.",
Expand All @@ -42,7 +42,7 @@ func (o IbaPredefinedProbe) DataSourceAttributes() map[string]dataSourceSchema.A
}
}

func (o *IbaPredefinedProbe) LoadApiData(_ context.Context, in *apstra.IbaPredefinedProbe, d *diag.Diagnostics) {
func (o *PredefinedProbe) LoadApiData(_ context.Context, in *apstra.IbaPredefinedProbe, d *diag.Diagnostics) {
o.Name = types.StringValue(in.Name)
o.Description = types.StringValue(in.Description)
o.Schema = types.StringValue(string(in.Schema))
Expand Down
8 changes: 4 additions & 4 deletions apstra/iba/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type IbaProbe struct {
type Probe struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Expand All @@ -23,7 +23,7 @@ type IbaProbe struct {
Stages types.Set `tfsdk:"stages"`
}

func (o IbaProbe) ResourceAttributes() map[string]resourceSchema.Attribute {
func (o Probe) ResourceAttributes() map[string]resourceSchema.Attribute {
return map[string]resourceSchema.Attribute{
"blueprint_id": resourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify the Blueprint that the IBA Probe belongs to.",
Expand Down Expand Up @@ -60,7 +60,7 @@ func (o IbaProbe) ResourceAttributes() map[string]resourceSchema.Attribute {
}
}

func (o *IbaProbe) LoadApiData(ctx context.Context, in *apstra.IbaProbe, diag *diag.Diagnostics) {
func (o *Probe) LoadApiData(ctx context.Context, in *apstra.IbaProbe, diag *diag.Diagnostics) {
o.Id = types.StringValue(in.Id.String())
o.Name = types.StringValue(in.Label)
o.Description = types.StringValue(in.Description)
Expand All @@ -71,7 +71,7 @@ func (o *IbaProbe) LoadApiData(ctx context.Context, in *apstra.IbaProbe, diag *d
o.Stages = utils.SetValueOrNull(ctx, types.StringType, s, diag)
}

func (o *IbaProbe) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaPredefinedProbeRequest {
func (o *Probe) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaPredefinedProbeRequest {
return &apstra.IbaPredefinedProbeRequest{
Name: o.PredefinedIbaProbeId.ValueString(),
Data: []byte(o.IbaProbeConfig.ValueString()),
Expand Down
10 changes: 5 additions & 5 deletions apstra/iba/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type IbaWidget struct {
type Widget struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Expand All @@ -23,7 +23,7 @@ type IbaWidget struct {
ProbeId types.String `tfsdk:"probe_id"`
}

func (o IbaWidget) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
func (o Widget) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
return map[string]dataSourceSchema.Attribute{
"blueprint_id": dataSourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify the Blueprint that the IBA Widget belongs to.",
Expand Down Expand Up @@ -65,7 +65,7 @@ func (o IbaWidget) DataSourceAttributes() map[string]dataSourceSchema.Attribute
}
}

func (o IbaWidget) ResourceAttributes() map[string]resourceSchema.Attribute {
func (o Widget) ResourceAttributes() map[string]resourceSchema.Attribute {
return map[string]resourceSchema.Attribute{
"blueprint_id": resourceSchema.StringAttribute{
MarkdownDescription: "ID of the Apstra Blueprint where the IBA Widget will be created",
Expand Down Expand Up @@ -105,15 +105,15 @@ func (o IbaWidget) ResourceAttributes() map[string]resourceSchema.Attribute {
}
}

func (o *IbaWidget) LoadApiData(_ context.Context, in *apstra.IbaWidget, _ *diag.Diagnostics) {
func (o *Widget) LoadApiData(_ context.Context, in *apstra.IbaWidget, _ *diag.Diagnostics) {
o.Id = types.StringValue(in.Id.String())
o.Name = types.StringValue(in.Data.Label)
o.Description = types.StringValue(in.Data.Description)
o.Stage = types.StringValue(in.Data.StageName)
o.ProbeId = types.StringValue(in.Data.ProbeId.String())
}

func (o *IbaWidget) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaWidgetData {
func (o *Widget) Request(ctx context.Context, d *diag.Diagnostics) *apstra.IbaWidgetData {

return &apstra.IbaWidgetData{
StageName: o.Stage.ValueString(),
Expand Down
1 change: 0 additions & 1 deletion apstra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource
func() datasource.DataSource { return &dataSourceDatacenterSvis{} },
func() datasource.DataSource { return &dataSourceDatacenterVirtualNetworks{} },
func() datasource.DataSource { return &dataSourceIbaPredefinedProbe{} },
func() datasource.DataSource { return &dataSourceIbaPredefinedProbes{} },
func() datasource.DataSource { return &dataSourceIbaWidget{} },
func() datasource.DataSource { return &dataSourceIbaWidgets{} },
func() datasource.DataSource { return &dataSourceIbaDashboard{} },
Expand Down
10 changes: 5 additions & 5 deletions apstra/resource_iba_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func (o *resourceIbaDashboard) Configure(ctx context.Context, req resource.Confi
func (o *resourceIbaDashboard) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "This resource creates a IBA Dashboard.",
Attributes: iba.IbaDashboard{}.ResourceAttributes(),
Attributes: iba.Dashboard{}.ResourceAttributes(),
}
}

func (o *resourceIbaDashboard) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
// Retrieve values from plan
var plan iba.IbaDashboard
var plan iba.Dashboard
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -76,7 +76,7 @@ func (o *resourceIbaDashboard) Create(ctx context.Context, req resource.CreateRe
}

func (o *resourceIbaDashboard) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var state iba.IbaDashboard
var state iba.Dashboard
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -115,7 +115,7 @@ func (o *resourceIbaDashboard) Read(ctx context.Context, req resource.ReadReques
// Update resource
func (o *resourceIbaDashboard) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
// Get plan values
var plan iba.IbaDashboard
var plan iba.Dashboard
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -156,7 +156,7 @@ func (o *resourceIbaDashboard) Update(ctx context.Context, req resource.UpdateRe

// Delete resource
func (o *resourceIbaDashboard) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var state iba.IbaDashboard
var state iba.Dashboard
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down
8 changes: 4 additions & 4 deletions apstra/resource_iba_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func (o *resourceIbaProbe) Configure(ctx context.Context, req resource.Configure
func (o *resourceIbaProbe) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "This resource creates a IBA Probe.",
Attributes: iba.IbaProbe{}.ResourceAttributes(),
Attributes: iba.Probe{}.ResourceAttributes(),
}
}

func (o *resourceIbaProbe) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
// Retrieve values from plan
var plan iba.IbaProbe
var plan iba.Probe
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -75,7 +75,7 @@ func (o *resourceIbaProbe) Create(ctx context.Context, req resource.CreateReques
}

func (o *resourceIbaProbe) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var state iba.IbaProbe
var state iba.Probe
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -119,7 +119,7 @@ func (o *resourceIbaProbe) Update(_ context.Context, _ resource.UpdateRequest, r

// Delete resource
func (o *resourceIbaProbe) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var state iba.IbaProbe
var state iba.Probe
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down
Loading

0 comments on commit 1d100f3

Please sign in to comment.