Skip to content

Commit

Permalink
feat: Updating Service Token Resource for Aside Port Service Token
Browse files Browse the repository at this point in the history
  • Loading branch information
srushti-patl committed Nov 5, 2024
1 parent dcc2cbd commit 48c65ac
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 45 deletions.
94 changes: 67 additions & 27 deletions docs/resources/fabric_service_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,40 @@ Additional documentation:

## Example Usage

Aside Port Service Token
```terraform
resource "equinix_fabric_service_token" "test" {
type = "VC_TOKEN"
description = "Aside COLO Service Token"
expiration_date_time = "2025-01-18T06:43:49.981Z"
service_token_connection {
type = "EVPL_VC"
bandwidth_limit = 1000
a_side {
access_point_selectors{
type = "COLO"
port {
uuid = "<port_uuid>"
}
link_protocol {
type = "DOT1Q"
vlan_tag = "2987"
}
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]", "[email protected]"]
}
}
```

Zside Virtual Device Service Token
```terraform
resource "equinix_fabric_service_token" "test" {
type = "VC_TOKEN"
description = "Zside VD Service Token"
expiration_date_time = "2025-01-18T06:43:49.986Z"
service_token_connection {
type = "EVPL_VC"
Expand All @@ -33,6 +63,10 @@ resource "equinix_fabric_service_token" "test" {
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]"]
}
}
```

Expand Down Expand Up @@ -82,7 +116,6 @@ Optional:

Required:

- `supported_bandwidths` (List of Number) List of permitted bandwidths'; For Port-based Service Tokens, the maximum allowable bandwidth is 50 Gbps, while for Virtual Device-based Service Tokens, it is limited to 10 Gbps
- `type` (String) Type of Connection supported by Service Token you will create; EVPL_VC, EVPLAN_VC, EPLAN_VC, IPWAN_VC

Optional:
Expand All @@ -91,6 +124,7 @@ Optional:
- `allow_custom_bandwidth` (Boolean) Allow custom bandwidth value
- `allow_remote_connection` (Boolean) Authorization to connect remotely
- `bandwidth_limit` (Number) Connection bandwidth limit in Mbps
- `supported_bandwidths` (List of Number) List of permitted bandwidths'; For Port-based Service Tokens, the maximum allowable bandwidth is 50 Gbps, while for Virtual Device-based Service Tokens, it is limited to 10 Gbps
- `z_side` (Block Set) Z-Side Connection link protocol,virtual device or network configuration (see [below for nested schema](#nestedblock--service_token_connection--z_side))

Read-Only:
Expand Down Expand Up @@ -170,31 +204,34 @@ Optional:
<a id="nestedblock--service_token_connection--a_side--access_point_selectors--port"></a>
### Nested Schema for `service_token_connection.a_side.access_point_selectors.port`

Required:

- `uuid` (String) Equinix-assigned Port identifier

Optional:

- `type` (String) Type of Port

Read-Only:

- `account_name` (String) Account Name
- `bandwidth` (Number) Port Bandwidth
- `cvp_id` (Number) Customer virtual port Id
- `encapsulation_protocol_type` (String) Port Encapsulation
- `location` (Block Set) Port Location (see [below for nested schema](#nestedblock--service_token_connection--a_side--access_point_selectors--port--location))
- `href` (String) Unique Resource Identifier
- `location` (Set of Object) Port Location (see [below for nested schema](#nestedatt--service_token_connection--a_side--access_point_selectors--port--location))
- `port_name` (String) Port Name
- `priority` (String) Port Priority
- `type` (String) Type of Port
- `uuid` (String) Equinix-assigned Port identifier

Read-Only:

- `href` (String) Unique Resource Identifier

<a id="nestedblock--service_token_connection--a_side--access_point_selectors--port--location"></a>
<a id="nestedatt--service_token_connection--a_side--access_point_selectors--port--location"></a>
### Nested Schema for `service_token_connection.a_side.access_point_selectors.port.location`

Optional:
Read-Only:

- `ibx` (String) IBX Code
- `metro_code` (String) Access point metro code
- `metro_name` (String) Access point metro name
- `region` (String) Access point region
- `ibx` (String)
- `metro_code` (String)
- `metro_name` (String)
- `region` (String)



Expand Down Expand Up @@ -291,31 +328,34 @@ Optional:
<a id="nestedblock--service_token_connection--z_side--access_point_selectors--port"></a>
### Nested Schema for `service_token_connection.z_side.access_point_selectors.port`

Required:

- `uuid` (String) Equinix-assigned Port identifier

Optional:

- `type` (String) Type of Port

Read-Only:

- `account_name` (String) Account Name
- `bandwidth` (Number) Port Bandwidth
- `cvp_id` (Number) Customer virtual port Id
- `encapsulation_protocol_type` (String) Port Encapsulation
- `location` (Block Set) Port Location (see [below for nested schema](#nestedblock--service_token_connection--z_side--access_point_selectors--port--location))
- `href` (String) Unique Resource Identifier
- `location` (Set of Object) Port Location (see [below for nested schema](#nestedatt--service_token_connection--z_side--access_point_selectors--port--location))
- `port_name` (String) Port Name
- `priority` (String) Port Priority
- `type` (String) Type of Port
- `uuid` (String) Equinix-assigned Port identifier

Read-Only:

- `href` (String) Unique Resource Identifier

<a id="nestedblock--service_token_connection--z_side--access_point_selectors--port--location"></a>
<a id="nestedatt--service_token_connection--z_side--access_point_selectors--port--location"></a>
### Nested Schema for `service_token_connection.z_side.access_point_selectors.port.location`

Optional:
Read-Only:

- `ibx` (String) IBX Code
- `metro_code` (String) Access point metro code
- `metro_name` (String) Access point metro name
- `region` (String) Access point region
- `ibx` (String)
- `metro_code` (String)
- `metro_name` (String)
- `region` (String)



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "equinix_fabric_service_token" "test" {
type = "VC_TOKEN"
description = "Aside COLO Service Token"
expiration_date_time = "2025-01-18T06:43:49.981Z"
service_token_connection {
type = "EVPL_VC"
bandwidth_limit = 1000
a_side {
access_point_selectors{
type = "COLO"
port {
uuid = "<port_uuid>"
}
link_protocol {
type = "DOT1Q"
vlan_tag = "2987"
}
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]", "[email protected]"]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resource "equinix_fabric_service_token" "test" {
type = "VC_TOKEN"
description = "Zside VD Service Token"
expiration_date_time = "2025-01-18T06:43:49.986Z"
service_token_connection {
type = "EVPL_VC"
Expand All @@ -17,4 +18,8 @@ resource "equinix_fabric_service_token" "test" {
}
}
}
notifications {
type = "ALL"
emails = ["[email protected]"]
}
}
79 changes: 75 additions & 4 deletions internal/resources/fabric/service_token/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,47 @@ func portTerraformToGo(portList []interface{}) fabricv4.SimplifiedMetadataEntity
var port fabricv4.SimplifiedMetadataEntity
portListMap := portList[0].(map[string]interface{})
uuid := portListMap["uuid"].(string)
port.SetUuid(uuid)
href := portListMap["href"].(string)
type_ := portListMap["type"].(string)
cvpId := portListMap["cvp_id"].(int)
bandwidth := portListMap["bandwidth"].(int)
portName := portListMap["port_name"].(string)
encapsulationProtocolType := portListMap["encapsulation_protocol_type"].(string)
accountName := portListMap["account_name"].(string)
priority := portListMap["priority"].(string)
locationList := portListMap["location"].(*schema.Set).List()

if uuid != "" {
port.SetUuid(uuid)
}
if href != "" {
port.SetHref(href)
}
if type_ != "" {
port.SetType(type_)
}
if cvpId != 0 {
port.SetCvpId(int32(cvpId))
}
if bandwidth != 0 {
port.SetBandwidth(float32(bandwidth))
}
if portName != "" {
port.SetPortName(portName)
}
if encapsulationProtocolType != "" {
port.SetEncapsulationProtocolType(encapsulationProtocolType)
}
if accountName != "" {
port.SetAccountName(accountName)
}
if priority != "" {
port.SetPriority(priority)
}
if len(locationList) != 0 {
location := equinix_fabric_schema.LocationTerraformToGo(locationList)
port.SetLocation(location)
}

return port
}
Expand Down Expand Up @@ -601,10 +641,41 @@ func accessPointSelectorsGoToTerraform(apSelectors []fabricv4.AccessPointSelecto
}

func portGoToTerraform(port *fabricv4.SimplifiedMetadataEntity) *schema.Set {
if port == nil {
return nil
}
mappedPort := make(map[string]interface{})
mappedPort["href"] = port.GetHref()
mappedPort["type"] = port.GetType()
mappedPort["uuid"] = port.GetUuid()
if href := port.GetHref(); href != "" {
mappedPort["href"] = href
}
if uuid := port.GetUuid(); uuid != "" {
mappedPort["uuid"] = uuid
}
if port.GetType() != "" {
mappedPort["type"] = port.GetType()
}
if cvpId := port.GetCvpId(); cvpId != 0 {
mappedPort["cvp_id"] = port.GetCvpId()
}
if bandwidth := port.GetBandwidth(); bandwidth != 0 {
mappedPort["bandwidth"] = port.GetBandwidth()
}
if portName := port.GetPortName(); portName != "" {
mappedPort["port_name"] = port.GetPortName()
}
if encapsulationProtocolType := port.GetEncapsulationProtocolType(); encapsulationProtocolType != "" {
mappedPort["encapsulation_protocol_type"] = port.GetEncapsulationProtocolType()
}
if accountName := port.GetAccountName(); accountName != "" {
mappedPort["account_name"] = port.GetAccountName()
}
if priority := port.GetPriority(); priority != "" {
mappedPort["priority"] = port.GetPriority()
}
if port.Location != nil {
location := port.GetLocation()
mappedPort["location"] = equinix_fabric_schema.LocationGoToTerraform(&location)
}

portSet := schema.NewSet(
schema.HashResource(portSch()),
Expand Down
13 changes: 3 additions & 10 deletions internal/resources/fabric/service_token/resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func serviceTokenConnectionSch() *schema.Resource {
},
"supported_bandwidths": {
Type: schema.TypeList,
Required: true,
Optional: true,
Computed: true,
Description: "List of permitted bandwidths'; For Port-based Service Tokens, the maximum allowable bandwidth is 50 Gbps, while for Virtual Device-based Service Tokens, it is limited to 10 Gbps",
Elem: &schema.Schema{
Type: schema.TypeInt,
Expand Down Expand Up @@ -230,8 +231,7 @@ func portSch() *schema.Resource {
},
"uuid": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
Description: "Equinix-assigned Port identifier",
},
"type": {
Expand All @@ -243,43 +243,36 @@ func portSch() *schema.Resource {
"cvp_id": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: "Customer virtual port Id",
},
"bandwidth": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
Description: "Port Bandwidth",
},
"port_name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Port Name",
},
"encapsulation_protocol_type": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Port Encapsulation",
},
"account_name": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Account Name",
},
"priority": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Port Priority",
},
"location": {
Type: schema.TypeSet,
Computed: true,
Optional: true,
Description: "Port Location",
Elem: &schema.Resource{
Schema: equinix_fabric_schema.LocationSch(),
Expand Down
Loading

0 comments on commit 48c65ac

Please sign in to comment.