Skip to content
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

fix markdown and example to reflect map #797

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apstra/data_source_freeform_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (o *dataSourceFreeformLink) Schema(_ context.Context, _ datasource.SchemaRe
resp.Schema = schema.Schema{
MarkdownDescription: docCategoryFreeform + "This data source provides details of a specific Freeform Link.\n\n" +
"At least one optional attribute is required.",
Attributes: freeform.FreeformLink{}.DataSourceAttributes(),
Attributes: freeform.Link{}.DataSourceAttributes(),
}
}

func (o *dataSourceFreeformLink) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config freeform.FreeformLink
var config freeform.Link
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...)
if resp.Diagnostics.HasError() {
return
Expand Down
14 changes: 7 additions & 7 deletions apstra/freeform/freeform_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

type FreeformLink struct {
type Link struct {
BlueprintId types.String `tfsdk:"blueprint_id"`
Id types.String `tfsdk:"id"`
Speed types.String `tfsdk:"speed"`
Expand All @@ -32,7 +32,7 @@ type FreeformLink struct {
Tags types.Set `tfsdk:"tags"`
}

func (o FreeformLink) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
func (o Link) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
return map[string]dataSourceSchema.Attribute{
"blueprint_id": dataSourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID. Used to identify " +
Expand Down Expand Up @@ -79,7 +79,7 @@ func (o FreeformLink) DataSourceAttributes() map[string]dataSourceSchema.Attribu
Computed: true,
},
"endpoints": dataSourceSchema.MapNestedAttribute{
MarkdownDescription: "Endpoints assigned to the Link",
MarkdownDescription: "Endpoints of the Link, a Map keyed by System ID.",
Computed: true,
NestedObject: dataSourceSchema.NestedAttributeObject{
Attributes: FreeformEndpoint{}.DatasourceAttributes(),
Expand All @@ -93,7 +93,7 @@ func (o FreeformLink) DataSourceAttributes() map[string]dataSourceSchema.Attribu
}
}

func (o FreeformLink) ResourceAttributes() map[string]resourceSchema.Attribute {
func (o Link) ResourceAttributes() map[string]resourceSchema.Attribute {
return map[string]resourceSchema.Attribute{
"blueprint_id": resourceSchema.StringAttribute{
MarkdownDescription: "Apstra Blueprint ID.",
Expand Down Expand Up @@ -131,7 +131,7 @@ func (o FreeformLink) ResourceAttributes() map[string]resourceSchema.Attribute {
Attributes: FreeformEndpoint{}.ResourceAttributes(),
},
PlanModifiers: []planmodifier.Map{mapplanmodifier.RequiresReplace()},
MarkdownDescription: "Endpoints of the Link",
MarkdownDescription: "Endpoints of the Link, a Map keyed by System ID.",
Required: true,
Validators: []validator.Map{mapvalidator.SizeBetween(2, 2)},
},
Expand All @@ -147,7 +147,7 @@ func (o FreeformLink) ResourceAttributes() map[string]resourceSchema.Attribute {
}
}

func (o *FreeformLink) Request(ctx context.Context, diags *diag.Diagnostics) *apstra.FreeformLinkRequest {
func (o *Link) Request(ctx context.Context, diags *diag.Diagnostics) *apstra.FreeformLinkRequest {
var tags []string
diags.Append(o.Tags.ElementsAs(ctx, &tags, false)...)
if diags.HasError() {
Expand All @@ -174,7 +174,7 @@ func (o *FreeformLink) Request(ctx context.Context, diags *diag.Diagnostics) *ap
}
}

func (o *FreeformLink) LoadApiData(ctx context.Context, in *apstra.FreeformLinkData, diags *diag.Diagnostics) {
func (o *Link) LoadApiData(ctx context.Context, in *apstra.FreeformLinkData, diags *diag.Diagnostics) {
interfaceIds := make([]string, len(in.Endpoints))
for i, endpoint := range in.Endpoints {
if endpoint.Interface.Id == nil {
Expand Down
10 changes: 5 additions & 5 deletions apstra/resource_freeform_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ func (o *resourceFreeformLink) Configure(ctx context.Context, req resource.Confi
func (o *resourceFreeformLink) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: docCategoryFreeform + "This resource creates a Link in a Freeform Blueprint.",
Attributes: freeform.FreeformLink{}.ResourceAttributes(),
Attributes: freeform.Link{}.ResourceAttributes(),
}
}

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

func (o *resourceFreeformLink) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var state freeform.FreeformLink
var state freeform.Link
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -131,7 +131,7 @@ func (o *resourceFreeformLink) Read(ctx context.Context, req resource.ReadReques

func (o *resourceFreeformLink) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
// Get plan values
var plan freeform.FreeformLink
var plan freeform.Link
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
if resp.Diagnostics.HasError() {
return
Expand Down Expand Up @@ -174,7 +174,7 @@ func (o *resourceFreeformLink) Update(ctx context.Context, req resource.UpdateRe
}

func (o *resourceFreeformLink) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var state freeform.FreeformLink
var state freeform.Link
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
if resp.Diagnostics.HasError() {
return
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/freeform_link.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ output "test_Link_out" { value = data.apstra_freeform_link.test }
### Read-Only

- `aggregate_link_id` (String) ID of aggregate link node that the current link belongs to
- `endpoints` (Attributes Map) Endpoints assigned to the Link (see [below for nested schema](#nestedatt--endpoints))
- `endpoints` (Attributes Map) Endpoints of the Link, a Map keyed by System ID. (see [below for nested schema](#nestedatt--endpoints))
- `speed` (String) Speed of the Link 200G | 5G | 1G | 100G | 150g | 40g | 2500M | 25G | 25g | 10G | 50G | 800G | 10M | 100m | 2500m | 50g | 400g | 400G | 200g | 5g | 800g | 100M | 10g | 150G | 10m | 100g | 1g | 40G
- `tags` (Set of String) Set of unique case-insensitive tag labels
- `type` (String) aggregate_link | ethernet
Expand Down
16 changes: 7 additions & 9 deletions docs/resources/freeform_link.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,25 @@ This resource creates a Link in a Freeform Blueprint.
## Example Usage

```terraform
# This example creates a link between systems "-CEYpa9xZ5chndvu0OY" and
# "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint
# This example creates a link between systems with IDs "CEYpa9xZ5chndvu0OYa"
# and "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint

resource "apstra_freeform_link" "test" {
blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32"
name = "link_a_b"
tags = ["a", "b"]
endpoints = [
{
system_id = "-CEYpa9xZ5chndvu0OY"
endpoints = {
CEYpa9xZ5chndvu0OYa = {
interface_name = "ge-0/0/3"
transformation_id = 1
tags = ["prod", "native_1000BASE-T"]
},
{
system_id = "ySBRdHvl2KZmWKLhkIk"
ySBRdHvl2KZmWKLhkIk = {
interface_name = "ge-0/0/3"
transformation_id = 1
tags = ["prod", "requires_transceiver"]
}
]
}
}
```

Expand All @@ -43,7 +41,7 @@ resource "apstra_freeform_link" "test" {
### Required

- `blueprint_id` (String) Apstra Blueprint ID.
- `endpoints` (Attributes Map) Endpoints of the Link (see [below for nested schema](#nestedatt--endpoints))
- `endpoints` (Attributes Map) Endpoints of the Link, a Map keyed by System ID. (see [below for nested schema](#nestedatt--endpoints))
- `name` (String) Freeform Link name as shown in the Web UI.

### Optional
Expand Down
14 changes: 6 additions & 8 deletions examples/resources/apstra_freeform_link/example.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# This example creates a link between systems "-CEYpa9xZ5chndvu0OY" and
# "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint
# This example creates a link between systems with IDs "CEYpa9xZ5chndvu0OYa"
# and "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint

resource "apstra_freeform_link" "test" {
blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32"
name = "link_a_b"
tags = ["a", "b"]
endpoints = [
{
system_id = "-CEYpa9xZ5chndvu0OY"
endpoints = {
CEYpa9xZ5chndvu0OYa = {
interface_name = "ge-0/0/3"
transformation_id = 1
tags = ["prod", "native_1000BASE-T"]
},
{
system_id = "ySBRdHvl2KZmWKLhkIk"
ySBRdHvl2KZmWKLhkIk = {
interface_name = "ge-0/0/3"
transformation_id = 1
tags = ["prod", "requires_transceiver"]
}
]
}
}
Loading