Skip to content

Commit

Permalink
return LOAAccessURI when physical port is created (#38)
Browse files Browse the repository at this point in the history
* return LOAAccessURI when physical port is created

* change URI to URL

* update docs

* add markdown linter

* add MD012 linter rule

* modify line_length limitation

---------

Co-authored-by: Pauline ESPALIEU <[email protected]>
  • Loading branch information
Pauline Espalieu and Pauline ESPALIEU authored Oct 7, 2024
1 parent 588f3ca commit 23f6715
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
# default state for all rules
default: true

# MD012 - Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md012.md
MD012:
maximum: 2

# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md013.md
MD013:
line_length: 180
line_length: 300

# MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
MD022:
Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/access_product.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Optional:
- `operator` (String) Comparison operator
- `values` (List of String) Values of the filter


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -68,6 +69,7 @@ Read-Only:
- `provider` (Map of Number)
- `type` (Map of Number)


<a id="nestedatt--hit"></a>
### Nested Schema for `hit`

Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/access_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--sort"></a>
### Nested Schema for `sort`

Expand All @@ -72,6 +73,7 @@ Optional:
- `name` (String)
- `value` (String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -82,6 +84,7 @@ Read-Only:
- `provider` (Map of Number)
- `type` (Map of Number)


<a id="nestedatt--hits"></a>
### Nested Schema for `hits`

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/cloud_product.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -83,6 +84,7 @@ Read-Only:
- `location` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hit"></a>
### Nested Schema for `hit`

Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/cloud_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--sort"></a>
### Nested Schema for `sort`

Expand All @@ -86,6 +87,7 @@ Optional:
- `name` (String)
- `value` (String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -98,6 +100,7 @@ Read-Only:
- `location` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hits"></a>
### Nested Schema for `hits`

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/physical_port.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--port"></a>
### Nested Schema for `port`

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/physical_port_product.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -71,6 +72,7 @@ Read-Only:
- `location` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hit"></a>
### Nested Schema for `hit`

Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/physical_port_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--sort"></a>
### Nested Schema for `sort`

Expand All @@ -80,6 +81,7 @@ Optional:
- `name` (String)
- `value` (String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -90,6 +92,7 @@ Read-Only:
- `location` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hits"></a>
### Nested Schema for `hits`

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/physical_ports.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--ports"></a>
### Nested Schema for `ports`

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/transport_product.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -77,6 +78,7 @@ Read-Only:
- `location_to` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hit"></a>
### Nested Schema for `hit`

Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/transport_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--sort"></a>
### Nested Schema for `sort`

Expand All @@ -83,6 +84,7 @@ Optional:
- `name` (String)
- `value` (String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -93,6 +95,7 @@ Read-Only:
- `location_to` (Map of Number)
- `provider` (Map of Number)


<a id="nestedatt--hits"></a>
### Nested Schema for `hits`

Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/virtual_access_product.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Optional:
- `operator` (String) Comparison operator
- `values` (List of String) Values of the filter


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -73,6 +74,7 @@ Read-Only:
- `provider` (Map of Number)
- `type` (Map of Number)


<a id="nestedatt--hit"></a>
### Nested Schema for `hit`

Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/virtual_access_products.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Optional:
- `operator` (String)
- `values` (List of String)


<a id="nestedatt--sort"></a>
### Nested Schema for `sort`

Expand All @@ -77,6 +78,7 @@ Optional:
- `name` (String)
- `value` (String)


<a id="nestedatt--facet_distribution"></a>
### Nested Schema for `facet_distribution`

Expand All @@ -87,6 +89,7 @@ Read-Only:
- `provider` (Map of Number)
- `type` (Map of Number)


<a id="nestedatt--hits"></a>
### Nested Schema for `hits`

Expand Down
4 changes: 1 addition & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@ provider "autonomi" {

### Optional

- `personal_access_token` (String, Sensitive) Personal Access Token (PAT) to authenticate through Autonomi API.
This token can be obtained from the Autonomi service and is required to access and manage resources via the API.
Can be set as variable or in environment as AUTONOMI_PAT
- `personal_access_token` (String, Sensitive) Personal Access Token (PAT) to authenticate through Autonomi API. This token can be obtained from the Autonomi service and is required to access and manage resources via the API. Can be set as variable or in environment as AUTONOMI_PAT
1 change: 1 addition & 0 deletions docs/resources/cloud_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Required:

- `sku` (String) ID of the product


<a id="nestedatt--provider_config"></a>
### Nested Schema for `provider_config`

Expand Down
1 change: 1 addition & 0 deletions docs/resources/physical_port.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ resource "autonomi_physical_port" "physical_port" {
- `available_bandwidth` (Number) Available bandwidth on the physical port
- `created_at` (String) Creation date of the physical port
- `id` (String) ID of the physical port, set after creation
- `loa_access_url` (String) URL to the physical port page where the LOA is downloadable
- `updated_at` (String) Update date of the physical port
- `used_vlans` (List of Number) Vlan already attributed on the physical port

Expand Down
1 change: 1 addition & 0 deletions docs/resources/transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Required:

- `sku` (String) ID of the product


<a id="nestedatt--vlans"></a>
### Nested Schema for `vlans`

Expand Down
1 change: 1 addition & 0 deletions docs/resources/virtual_access_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Required:

- `sku` (String) ID of the product


<a id="nestedatt--service_key"></a>
### Nested Schema for `service_key`

Expand Down
13 changes: 11 additions & 2 deletions internal/resources/physical_port_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/intercloud/autonomi-sdk/models"
)

const (
AUTONOMI_FRONT_URL = "https://autonomi-platform.com/#"
)

// physicalPortResource is the resource implementation.
type physicalPortResource struct {
client *autonomisdk.Client
Expand All @@ -31,6 +35,7 @@ type physicalPortResourceModel struct {
Product product `tfsdk:"product"`
AvailableBandwidth types.Int64 `tfsdk:"available_bandwidth"`
UsedVLANs types.List `tfsdk:"used_vlans"`
LOAAccessURL types.String `tfsdk:"loa_access_url"`
}

// Ensure the implementation satisfies the expected interfaces.
Expand Down Expand Up @@ -127,6 +132,10 @@ They allow you to connect InterCloud back bone through access node.`,
Computed: true,
ElementType: types.NumberType,
},
"loa_access_url": schema.StringAttribute{
MarkdownDescription: `URL to the physical port page where the LOA is downloadable`,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -167,7 +176,7 @@ func (r *physicalPortResource) Create(ctx context.Context, req resource.CreateRe
plan.UpdatedAt = types.StringValue(physicalPort.UpdatedAt.String())
plan.AvailableBandwidth = types.Int64Value(int64(physicalPort.AvailableBandwidth))
plan.UsedVLANs = types.ListValueMust(types.NumberType, convertInt64ArrayToNumberValues(physicalPort.UsedVLANs))

plan.LOAAccessURL = types.StringValue(fmt.Sprintf("%s/ports/details/port/%s", AUTONOMI_FRONT_URL, physicalPort.ID))
// Set state to fully populated data
diags = resp.State.Set(ctx, plan)
resp.Diagnostics.Append(diags...)
Expand Down Expand Up @@ -207,7 +216,7 @@ func (r *physicalPortResource) Read(ctx context.Context, req resource.ReadReques
state.AccountID = types.StringValue(physicalPort.AccountID)
state.AvailableBandwidth = types.Int64Value(int64(physicalPort.AvailableBandwidth))
state.UsedVLANs = types.ListValueMust(types.NumberType, convertInt64ArrayToNumberValues(physicalPort.UsedVLANs))

state.LOAAccessURL = types.StringValue(fmt.Sprintf("%s/ports/details/port/%s", AUTONOMI_FRONT_URL, physicalPort.ID))
// Set refreshed state
diags = resp.State.Set(ctx, &state)
resp.Diagnostics.Append(diags...)
Expand Down

0 comments on commit 23f6715

Please sign in to comment.