diff --git a/docs/data-sources/equinix_fabric_cloud_router.md b/docs/data-sources/equinix_fabric_cloud_router.md index 9233e0b1f..2040a2c71 100644 --- a/docs/data-sources/equinix_fabric_cloud_router.md +++ b/docs/data-sources/equinix_fabric_cloud_router.md @@ -23,17 +23,17 @@ data "equinix_fabric_cloud_router" "cloud_router_data_name" { ## Schema -### Optional +### Required - `uuid` (String) Equinix-assigned Fabric Cloud Router identifier ### Read-Only - `account` (Set of Object) Customer account information that is associated with this Fabric Cloud Router (see [below for nested schema](#nestedatt--account)) -- `bgp_ipv4_routes_count` (Number) -- `bgp_ipv6_routes_count` (Number) +- `bgp_ipv4_routes_count` (Number) Access point used and maximum number of IPv4 BGP routes +- `bgp_ipv6_routes_count` (Number) Access point used and maximum number of IPv6 BGP routes - `change_log` (Set of Object) Captures Fabric Cloud Router lifecycle change information (see [below for nested schema](#nestedatt--change_log)) -- `connections_count` (Number) +- `connections_count` (Number) Number of connections associated with this Access point - `description` (String) Customer-provided Fabric Cloud Router description - `equinix_asn` (Number) Equinix ASN - `href` (String) Fabric Cloud Router URI information @@ -43,7 +43,7 @@ data "equinix_fabric_cloud_router" "cloud_router_data_name" { - `notifications` (List of Object) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedatt--notifications)) - `order` (Set of Object) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedatt--order)) - `package` (Set of Object) Fabric Cloud Router package information (see [below for nested schema](#nestedatt--package)) -- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project)) +- `project` (Set of Object) Project information (see [below for nested schema](#nestedatt--project)) - `state` (String) Fabric Cloud Router overall state - `type` (String) Defines the Fabric Cloud Router type like XF_GATEWAY @@ -85,7 +85,6 @@ Read-Only: Read-Only: -- `href` (String) - `ibx` (String) - `metro_code` (String) - `metro_name` (String) @@ -121,12 +120,10 @@ Read-Only: - `code` (String) - + ### Nested Schema for `project` Read-Only: -- `href` (String) Unique Resource URL -- `project_id` (String) Project Id - - +- `href` (String) +- `project_id` (String) diff --git a/docs/data-sources/equinix_fabric_connection.md b/docs/data-sources/equinix_fabric_connection.md index 1c518a789..a6deb5294 100644 --- a/docs/data-sources/equinix_fabric_connection.md +++ b/docs/data-sources/equinix_fabric_connection.md @@ -21,7 +21,7 @@ data "equinix_fabric_connection" "connection_data_name" { ## Schema -### Optional +### Required - `uuid` (String) Equinix-assigned connection identifier @@ -29,7 +29,7 @@ data "equinix_fabric_connection" "connection_data_name" { - `a_side` (Set of Object) Requester or Customer side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedatt--a_side)) - `account` (Set of Object) Customer account information that is associated with this connection (see [below for nested schema](#nestedatt--account)) -- `additional_info` (List of Object) Connection additional information (see [below for nested schema](#nestedatt--additional_info)) +- `additional_info` (List of Map of String) Connection additional information - `bandwidth` (Number) Connection bandwidth in Mbps - `change_log` (Set of Object) Captures connection lifecycle change information (see [below for nested schema](#nestedatt--change_log)) - `description` (String) Customer-provided connection description @@ -39,12 +39,12 @@ data "equinix_fabric_connection" "connection_data_name" { - `is_remote` (Boolean) Connection property derived from access point locations - `name` (String) Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `notifications` (List of Object) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedatt--notifications)) -- `operation` (Set of Object) Connection specific operational data (see [below for nested schema](#nestedatt--operation)) -- `order` (Set of Object) Order related to this connection information (see [below for nested schema](#nestedatt--order)) -- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project)) -- `redundancy` (Set of Object) Redundancy Information (see [below for nested schema](#nestedatt--redundancy)) +- `operation` (Set of Object) Connection type-specific operational data (see [below for nested schema](#nestedatt--operation)) +- `order` (Set of Object) Order details (see [below for nested schema](#nestedatt--order)) +- `project` (Set of Object) Project information (see [below for nested schema](#nestedatt--project)) +- `redundancy` (Set of Object) Connection Redundancy Configuration (see [below for nested schema](#nestedatt--redundancy)) - `state` (String) Connection overall state -- `type` (String) Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC +- `type` (String) Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, EC_VC - `z_side` (Set of Object) Destination or Provider side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedatt--z_side)) @@ -53,6 +53,7 @@ data "equinix_fabric_connection" "connection_data_name" { Read-Only: - `access_point` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point)) +- `additional_info` (List of Object) (see [below for nested schema](#nestedobjatt--a_side--additional_info)) - `service_token` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--service_token)) @@ -62,15 +63,16 @@ Read-Only: - `account` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--account)) - `authentication_key` (String) -- **Deprecated** `gateway` Use `router` instead (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--router)) -- `router` CloudRouter; Replaces `gateway` attribute (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--router)) +- `gateway` (Set of Object, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedobjatt--a_side--access_point--gateway)) - `interface` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--interface)) - `link_protocol` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--link_protocol)) - `location` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--location)) +- `network` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--network)) - `peering_type` (String) - `port` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--port)) - `profile` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--profile)) - `provider_connection_id` (String) +- `router` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--router)) - `seller_region` (String) - `type` (String) - `virtual_device` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--virtual_device)) @@ -89,13 +91,12 @@ Read-Only: - `organization_name` (String) - -### Nested Schema for `a_side.access_point.router` + +### Nested Schema for `a_side.access_point.gateway` Read-Only: - `href` (String) -- `state` (String) - `uuid` (String) @@ -104,7 +105,7 @@ Read-Only: Read-Only: -- `id` (String) +- `id` (Number) - `type` (String) - `uuid` (String) @@ -125,13 +126,21 @@ Read-Only: Read-Only: -- `href` (String) - `ibx` (String) - `metro_code` (String) - `metro_name` (String) - `region` (String) + +### Nested Schema for `a_side.access_point.network` + +Read-Only: + +- `href` (String) +- `uuid` (String) + + ### Nested Schema for `a_side.access_point.port` @@ -147,6 +156,8 @@ Read-Only: Read-Only: +- `enabled` (Boolean) +- `group` (String) - `priority` (String) @@ -168,55 +179,18 @@ Read-Only: Read-Only: -- `allow_bandwidth_auto_approval` (Boolean) -- `allow_bandwidth_upgrade` (Boolean) -- `allow_custom_bandwidth` (Boolean) -- `allow_remote_connections` (Boolean) -- `api_config` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--profile--uuid--api_config)) -- `authentication_key` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--profile--uuid--authentication_key)) -- `bandwidth_alert_threshold` (Number) -- `connection_label` (String) -- `connection_redundancy_required` (Boolean) -- `enable_auto_generate_service_key` (Boolean) -- `link_protocol_config` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--profile--uuid--link_protocol_config)) -- `supported_bandwidths` (List of Number) - `type` (String) - `uuid` (String) - -### Nested Schema for `a_side.access_point.profile.uuid.api_config` - -Read-Only: - -- `allow_over_subscription` (Boolean) -- `api_available` (Boolean) -- `bandwidth_from_api` (Boolean) -- `equinix_managed_port` (Boolean) -- `equinix_managed_vlan` (Boolean) -- `integration_id` (String) -- `over_subscription_limit` (Number) - - - -### Nested Schema for `a_side.access_point.profile.uuid.authentication_key` - -Read-Only: - -- `description` (String) -- `label` (String) -- `required` (Boolean) - -### Nested Schema for `a_side.access_point.profile.uuid.link_protocol_config` + +### Nested Schema for `a_side.access_point.router` Read-Only: -- `encapsulation` (String) -- `encapsulation_strategy` (String) -- `reuse_vlan_s_tag` (Boolean) - - +- `href` (String) +- `uuid` (String) @@ -225,11 +199,21 @@ Read-Only: Read-Only: - `href` (String) +- `name` (String) - `type` (String) - `uuid` (String) + +### Nested Schema for `a_side.additional_info` + +Read-Only: + +- `key` (String) +- `value` (String) + + ### Nested Schema for `a_side.service_token` @@ -256,15 +240,6 @@ Read-Only: - `organization_name` (String) - -### Nested Schema for `additional_info` - -Read-Only: - -- `key` (String) -- `value` (String) - - ### Nested Schema for `change_log` @@ -337,13 +312,13 @@ Read-Only: - `purchase_order_number` (String) - + ### Nested Schema for `project` Read-Only: -- `href` (String) Unique Resource URL -- `project_id` (String) Project Id +- `href` (String) +- `project_id` (String) @@ -361,6 +336,7 @@ Read-Only: Read-Only: - `access_point` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point)) +- `additional_info` (List of Object) (see [below for nested schema](#nestedobjatt--z_side--additional_info)) - `service_token` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--service_token)) @@ -370,15 +346,16 @@ Read-Only: - `account` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--account)) - `authentication_key` (String) -- **Deprecated** `gateway` Use `router` instead (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--router)) -- `router` CloudRouter; Replaces `gateway` attribute (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--router)) +- `gateway` (Set of Object, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedobjatt--z_side--access_point--gateway)) - `interface` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--interface)) - `link_protocol` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--link_protocol)) - `location` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--location)) +- `network` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--network)) - `peering_type` (String) - `port` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--port)) - `profile` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--profile)) - `provider_connection_id` (String) +- `router` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--router)) - `seller_region` (String) - `type` (String) - `virtual_device` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--virtual_device)) @@ -397,13 +374,12 @@ Read-Only: - `organization_name` (String) - -### Nested Schema for `z_side.access_point.router` + +### Nested Schema for `z_side.access_point.gateway` Read-Only: - `href` (String) -- `state` (String) - `uuid` (String) @@ -412,7 +388,7 @@ Read-Only: Read-Only: -- `id` (String) +- `id` (Number) - `type` (String) - `uuid` (String) @@ -433,13 +409,21 @@ Read-Only: Read-Only: -- `href` (String) - `ibx` (String) - `metro_code` (String) - `metro_name` (String) - `region` (String) + +### Nested Schema for `z_side.access_point.network` + +Read-Only: + +- `href` (String) +- `uuid` (String) + + ### Nested Schema for `z_side.access_point.port` @@ -455,6 +439,8 @@ Read-Only: Read-Only: +- `enabled` (Boolean) +- `group` (String) - `priority` (String) @@ -476,55 +462,18 @@ Read-Only: Read-Only: -- `allow_bandwidth_auto_approval` (Boolean) -- `allow_bandwidth_upgrade` (Boolean) -- `allow_custom_bandwidth` (Boolean) -- `allow_remote_connections` (Boolean) -- `api_config` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--profile--uuid--api_config)) -- `authentication_key` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--profile--uuid--authentication_key)) -- `bandwidth_alert_threshold` (Number) -- `connection_label` (String) -- `connection_redundancy_required` (Boolean) -- `enable_auto_generate_service_key` (Boolean) -- `link_protocol_config` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--profile--uuid--link_protocol_config)) -- `supported_bandwidths` (List of Number) - `type` (String) - `uuid` (String) - -### Nested Schema for `z_side.access_point.profile.uuid.api_config` - -Read-Only: - -- `allow_over_subscription` (Boolean) -- `api_available` (Boolean) -- `bandwidth_from_api` (Boolean) -- `equinix_managed_port` (Boolean) -- `equinix_managed_vlan` (Boolean) -- `integration_id` (String) -- `over_subscription_limit` (Number) - - -### Nested Schema for `z_side.access_point.profile.uuid.authentication_key` - -Read-Only: -- `description` (String) -- `label` (String) -- `required` (Boolean) - - - -### Nested Schema for `z_side.access_point.profile.uuid.link_protocol_config` + +### Nested Schema for `z_side.access_point.router` Read-Only: -- `encapsulation` (String) -- `encapsulation_strategy` (String) -- `reuse_vlan_s_tag` (Boolean) - - +- `href` (String) +- `uuid` (String) @@ -533,11 +482,21 @@ Read-Only: Read-Only: - `href` (String) +- `name` (String) - `type` (String) - `uuid` (String) + +### Nested Schema for `z_side.additional_info` + +Read-Only: + +- `key` (String) +- `value` (String) + + ### Nested Schema for `z_side.service_token` @@ -547,5 +506,3 @@ Read-Only: - `href` (String) - `type` (String) - `uuid` (String) - - diff --git a/docs/data-sources/equinix_fabric_port.md b/docs/data-sources/equinix_fabric_port.md index dc5409b76..5aceeb289 100644 --- a/docs/data-sources/equinix_fabric_port.md +++ b/docs/data-sources/equinix_fabric_port.md @@ -36,7 +36,7 @@ data "equinix_fabric_port" "port_data_name" { - `encapsulation` (Set of Object) Port encapsulation protocol (see [below for nested schema](#nestedatt--encapsulation)) - `href` (String) Port URI information - `id` (String) The ID of this resource. -- `lag` (Set of Object) Port Lag (see [below for nested schema](#nestedatt--lag)) +- `lag_enabled` (Boolean) Port Lag - `location` (Set of Object) Port location information (see [below for nested schema](#nestedatt--location)) - `name` (String) Port name - `operation` (Set of Object) Port specific operational data (see [below for nested schema](#nestedatt--operation)) @@ -92,6 +92,7 @@ Read-Only: Read-Only: +- `enabled` (Boolean) - `group` (String) - `priority` (String) @@ -106,23 +107,11 @@ Read-Only: - `type` (String) - -### Nested Schema for `lag` - -Read-Only: - -- `enabled` (Boolean) -- `id` (String) -- `member_status` (String) -- `name` (String) - - ### Nested Schema for `location` Read-Only: -- `href` (String) - `ibx` (String) - `metro_code` (String) - `metro_name` (String) @@ -145,7 +134,5 @@ Read-Only: Read-Only: - `enabled` (Boolean) -- `group` (Number) +- `group` (String) - `priority` (String) - - diff --git a/docs/data-sources/equinix_fabric_ports.md b/docs/data-sources/equinix_fabric_ports.md index b4342cd4c..0ae45f886 100644 --- a/docs/data-sources/equinix_fabric_ports.md +++ b/docs/data-sources/equinix_fabric_ports.md @@ -23,19 +23,19 @@ data "equinix_fabric_ports" "ports_data_name" { ## Schema -### Optional +### Required -- `filters` (Block Set) name (see [below for nested schema](#nestedblock--filters)) +- `filters` (Block Set, Min: 1, Max: 1) name (see [below for nested schema](#nestedblock--filters)) ### Read-Only -- `data` (List of Object) List of Ports (see [below for nested schema](#nestedatt--data)) +- `data` (List of Object) List of Ports (see [below for nested schema](#nestedatt--data)) - `id` (String) The ID of this resource. ### Nested Schema for `filters` -Optional: +Required: - `name` (String) Query Parameter to Get Ports By Name @@ -53,7 +53,7 @@ Read-Only: - `device` (Set of Object) (see [below for nested schema](#nestedobjatt--data--device)) - `encapsulation` (Set of Object) (see [below for nested schema](#nestedobjatt--data--encapsulation)) - `href` (String) -- `lag` (Set of Object) (see [below for nested schema](#nestedobjatt--data--lag)) +- `lag_enabled` (Boolean) - `location` (Set of Object) (see [below for nested schema](#nestedobjatt--data--location)) - `name` (String) - `operation` (Set of Object) (see [below for nested schema](#nestedobjatt--data--operation)) @@ -110,6 +110,7 @@ Read-Only: Read-Only: +- `enabled` (Boolean) - `group` (String) - `priority` (String) @@ -124,23 +125,11 @@ Read-Only: - `type` (String) - -### Nested Schema for `data.lag` - -Read-Only: - -- `enabled` (Boolean) -- `id` (String) -- `member_status` (String) -- `name` (String) - - ### Nested Schema for `data.location` Read-Only: -- `href` (String) - `ibx` (String) - `metro_code` (String) - `metro_name` (String) @@ -163,7 +152,5 @@ Read-Only: Read-Only: - `enabled` (Boolean) -- `group` (Number) +- `group` (String) - `priority` (String) - - diff --git a/docs/data-sources/equinix_fabric_routing_protocol.md b/docs/data-sources/equinix_fabric_routing_protocol.md index 0261f5375..ad11e92ca 100644 --- a/docs/data-sources/equinix_fabric_routing_protocol.md +++ b/docs/data-sources/equinix_fabric_routing_protocol.md @@ -166,5 +166,3 @@ Read-Only: - `property` (String) - `reason` (String) - - diff --git a/docs/data-sources/equinix_fabric_service_profile.md b/docs/data-sources/equinix_fabric_service_profile.md index d6fbbc6f4..2ff751a7d 100644 --- a/docs/data-sources/equinix_fabric_service_profile.md +++ b/docs/data-sources/equinix_fabric_service_profile.md @@ -226,5 +226,3 @@ Read-Only: - `href` (String) - `project_id` (String) - - diff --git a/docs/data-sources/equinix_fabric_service_profiles.md b/docs/data-sources/equinix_fabric_service_profiles.md index 2c4457b1d..e399f529e 100644 --- a/docs/data-sources/equinix_fabric_service_profiles.md +++ b/docs/data-sources/equinix_fabric_service_profiles.md @@ -27,13 +27,13 @@ data "equinix_fabric_service_profiles" "service_profiles_data_name" { ### Optional -- `filter` (Block Set) Service Profile Search Filter (see [below for nested schema](#nestedblock--filter)) +- `filter` (Block Set, Max: 1) Service Profile Search Filter (see [below for nested schema](#nestedblock--filter)) - `sort` (Block List) Service Profile Sort criteria for Search Request response payload (see [below for nested schema](#nestedblock--sort)) -- `view_point` (String) Service Profile Search Buyer/Seller Representation. Possible values are aSide and zSide. +- `view_point` (String) flips view between buyer and seller representation. Available values : aSide, zSide. Default value : aSide ### Read-Only -- `data` (List of Object) List of Service Profiles (see [below for nested schema](#nestedatt--data)) +- `data` (List of Object) List of Service Profiles (see [below for nested schema](#nestedatt--data)) - `id` (String) The ID of this resource. @@ -256,5 +256,3 @@ Read-Only: - `href` (String) - `project_id` (String) - - diff --git a/docs/resources/equinix_fabric_cloud_router.md b/docs/resources/equinix_fabric_cloud_router.md index 99283f4b4..7eda617f2 100644 --- a/docs/resources/equinix_fabric_cloud_router.md +++ b/docs/resources/equinix_fabric_cloud_router.md @@ -10,8 +10,6 @@ description: |- Fabric V4 API compatible resource allows creation and management of [Equinix Fabric Cloud Router](https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-intro.htm#HowItWorks). -~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md) - Additional Fabric Cloud Router documentation: * Getting Started: * API: @@ -52,20 +50,23 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{ - `location` (Block Set, Min: 1, Max: 1) Fabric Cloud Router location (see [below for nested schema](#nestedblock--location)) - `name` (String) Fabric Cloud Router name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `notifications` (Block List, Min: 1) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedblock--notifications)) -- `package` (Block Set, Min: 1, Max: 1) Fabric Cloud Router package (see [below for nested schema](#nestedblock--package)) -- `type` (String) Defines the FCR type like XF_GATEWAY +- `package` (Block Set, Min: 1, Max: 1) Fabric Cloud Router location (see [below for nested schema](#nestedblock--package)) +- `type` (String) Defines the FCR type like XF_ROUTER ### Optional - `account` (Block Set, Max: 1) Customer account information that is associated with this Fabric Cloud Router (see [below for nested schema](#nestedblock--account)) - `description` (String) Customer-provided Fabric Cloud Router description - `order` (Block Set, Max: 1) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedblock--order)) -- `project` (Block Set) Fabric Cloud Router project (see [below for nested schema](#nestedblock--project)) +- `project` (Block Set, Max: 1) Fabric Cloud Router project (see [below for nested schema](#nestedblock--project)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) ### Read-Only +- `bgp_ipv4_routes_count` (Number) Access point used and maximum number of IPv4 BGP routes +- `bgp_ipv6_routes_count` (Number) Access point used and maximum number of IPv6 BGP routes - `change_log` (Set of Object) Captures Fabric Cloud Router lifecycle change information (see [below for nested schema](#nestedatt--change_log)) +- `connections_count` (Number) Number of connections associated with this Access point - `equinix_asn` (Number) Equinix ASN - `href` (String) Fabric Cloud Router URI information - `id` (String) The ID of this resource. @@ -117,12 +118,9 @@ Optional: Optional: - `billing_tier` (String) Billing tier for connection bandwidth -- `purchase_order_number` (String) Purchase order number - -Read-Only: - - `order_id` (String) Order Identification - `order_number` (String) Order Reference Number +- `purchase_order_number` (String) Purchase order number @@ -162,5 +160,3 @@ Read-Only: - `updated_by_email` (String) - `updated_by_full_name` (String) - `updated_date_time` (String) - - diff --git a/docs/resources/equinix_fabric_connection.md b/docs/resources/equinix_fabric_connection.md index b60d3f5bb..fa8d4dcb3 100644 --- a/docs/resources/equinix_fabric_connection.md +++ b/docs/resources/equinix_fabric_connection.md @@ -201,7 +201,7 @@ resource "equinix_fabric_connection" "vd2port" { } interface { type = "NETWORK" - id = 45654 + id = 7 } } } @@ -245,7 +245,7 @@ resource "equinix_fabric_connection" "vd2token" { } interface { type = "NETWORK" - id = 45654 + id = 7 } } } @@ -369,6 +369,49 @@ resource "equinix_fabric_connection" "fcr2azure"{ } ``` +Virtual Device to Azure Connection: +```hcl +resource "equinix_fabric_connection" "vd2token" { + name = "ConnectionName" + type = "EVPLAN_VC" + notifications { + type = "ALL" + emails = ["example@equinix.com", "test1@equinix.com"] + } + bandwidth = 50 + order { + purchase_order_number = "1-323292" + } + a_side { + access_point { + type = "VD" + virtual_device { + type = "EDGE" + uuid = "" + } + interface { + type = "CLOUD" + id = 7 + } + } + } + z_side { + access_point { + type = "SP" + authentication_key = "" + peering_type = "PRIVATE" + profile { + type = "L2_PROFILE" + uuid = "" + } + location { + metro_code = "SV" + } + } + } +} +``` + Cloud Router to Network Connection: ```hcl resource "equinix_fabric_connection" "fcr2network"{ @@ -422,8 +465,8 @@ resource "equinix_fabric_connection" "vd2token" { uuid = "" } interface { - type = "NETWORK" - id = 45654 + type = "CLOUD" + id = 7 } } } @@ -513,20 +556,24 @@ resource "equinix_fabric_connection" "epl" { ### Required -- `a_side` (Block Set, Min: 1) Requester or Customer side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedblock--a_side)) +- `a_side` (Block Set, Min: 1, Max: 1) Requester or Customer side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedblock--a_side)) - `bandwidth` (Number) Connection bandwidth in Mbps - `name` (String) Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `notifications` (Block List, Min: 1) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedblock--notifications)) -- `type` (String) Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC -- `z_side` (Block Set, Min: 1) Destination or Provider side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedblock--z_side)) +- `order` (Block Set, Min: 1, Max: 1) Order details (see [below for nested schema](#nestedblock--order)) +- `type` (String) Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, EC_VC +- `z_side` (Block Set, Min: 1, Max: 1) Destination or Provider side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedblock--z_side)) ### Optional -- `additional_info` (Block List) Connection additional information (see [below for nested schema](#nestedblock--additional_info)) -- `order` (Block Set) Order related to this connection information (see [below for nested schema](#nestedblock--order)) -- `redundancy` (Block Set) Redundancy Information (see [below for nested schema](#nestedblock--redundancy)) +- `additional_info` (List of Map of String) Connection additional information +- `description` (String) Customer-provided connection description +- `project` (Block Set, Max: 1) Project information (see [below for nested schema](#nestedblock--project)) +- `redundancy` (Block Set, Max: 1) Connection Redundancy Configuration (see [below for nested schema](#nestedblock--redundancy)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +-~> **NOTE:** Port to IBM Connections could be modified from IBM Service Provider Side by using parameters passed to additional_info field: `{"key": "ASN", "value": "1111"}` `{"key": "Global", "value": "false"}` `{"key": "BGP_IBM_CIDR", "value": "172.16.0.18/30"}` `{"key": "BGP_CER_CIDR", "value": "172.16.0.19/30"}` + ### Read-Only - `account` (Set of Object) Customer account information that is associated with this connection (see [below for nested schema](#nestedatt--account)) @@ -536,17 +583,17 @@ resource "equinix_fabric_connection" "epl" { - `id` (String) The ID of this resource. - `is_remote` (Boolean) Connection property derived from access point locations - `operation` (Set of Object) Connection type-specific operational data (see [below for nested schema](#nestedatt--operation)) -- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project)) - `state` (String) Connection overall state +- `uuid` (String) Equinix-assigned connection identifier ### Nested Schema for `a_side` Optional: -- `access_point` (Block Set) Point of access details (see [below for nested schema](#nestedblock--a_side--access_point)) +- `access_point` (Block Set, Max: 1) Point of access details (see [below for nested schema](#nestedblock--a_side--access_point)) - `additional_info` (Block List) Connection side additional information (see [below for nested schema](#nestedblock--a_side--additional_info)) -- `service_token` (Block Set) For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets (see [below for nested schema](#nestedblock--a_side--service_token)) +- `service_token` (Block Set, Max: 1) For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets (see [below for nested schema](#nestedblock--a_side--service_token)) ### Nested Schema for `a_side.access_point` @@ -554,27 +601,26 @@ Optional: Optional: - `authentication_key` (String) Authentication key for provider based connections -- **Deprecated** `gateway` Use `router` attribute instead; (Block Set) (see [below for nested schema](#nestedblock--a_side--access_point--router)) -- `router` (Block Set) Cloud Router access point information that replaces `gateway` (refers to [below for nested schema](#nestedblock--a_side--access_point--router)) -- `interface` (Block Set) Virtual device interface (see [below for nested schema](#nestedblock--a_side--access_point--interface)) -- `network` (Block Set) Simplified Network (see [below for nested schema](#nestedblock--a_side--access_point--network)) -- `link_protocol` (Block Set) Connection link protocol (see [below for nested schema](#nestedblock--a_side--access_point--link_protocol)) -- `location` (Block Set) Access point location (see [below for nested schema](#nestedblock--a_side--access_point--location)) +- `gateway` (Block Set, Max: 1, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedblock--a_side--access_point--gateway)) +- `interface` (Block Set, Max: 1) Virtual device interface (see [below for nested schema](#nestedblock--a_side--access_point--interface)) +- `link_protocol` (Block Set, Max: 1) Connection link protocol (see [below for nested schema](#nestedblock--a_side--access_point--link_protocol)) +- `location` (Block Set, Max: 1) Access point location (see [below for nested schema](#nestedblock--a_side--access_point--location)) +- `network` (Block Set, Max: 1) network access point information (see [below for nested schema](#nestedblock--a_side--access_point--network)) - `peering_type` (String) Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL -- `port` (Block Set) Port access point information (see [below for nested schema](#nestedblock--a_side--access_point--port)) -- `profile` (Block Set) Service Profile (see [below for nested schema](#nestedblock--a_side--access_point--profile)) +- `port` (Block Set, Max: 1) Port access point information (see [below for nested schema](#nestedblock--a_side--access_point--port)) +- `profile` (Block Set, Max: 1) Service Profile (see [below for nested schema](#nestedblock--a_side--access_point--profile)) - `provider_connection_id` (String) Provider assigned Connection Id -- `routing_protocols` (Block List) Access point routing protocols configuration (see [below for nested schema](#nestedblock--a_side--access_point--routing_protocols)) +- `router` (Block Set, Max: 1) Cloud Router access point information that replaces `gateway` (see [below for nested schema](#nestedblock--a_side--access_point--router)) - `seller_region` (String) Access point seller region -- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW -- `virtual_device` (Block Set) Virtual device (see [below for nested schema](#nestedblock--a_side--access_point--virtual_device)) +- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK +- `virtual_device` (Block Set, Max: 1) Virtual device (see [below for nested schema](#nestedblock--a_side--access_point--virtual_device)) Read-Only: -- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--a_side--access_point--account)) +- `account` (Block Set) Account (see [below for nested schema](#nestedblock--a_side--access_point--account)) - -### Nested Schema for `a_side.access_point.router` + +### Nested Schema for `a_side.access_point.gateway` Optional: @@ -590,19 +636,10 @@ Read-Only: Optional: +- `id` (Number) id - `type` (String) Interface type - `uuid` (String) Equinix-assigned interface identifier -Read-Only: - -- `id` (String) id - - -### Nested Schema for `a_side.access_point.network` - -Required: -- `uuid` (String) Equinix-assigned network identifier - ### Nested Schema for `a_side.access_point.link_protocol` @@ -626,6 +663,18 @@ Optional: - `region` (String) Access point region + +### Nested Schema for `a_side.access_point.network` + +Optional: + +- `uuid` (String) Equinix-assigned Network identifier + +Read-Only: + +- `href` (String) Unique Resource Identifier + + ### Nested Schema for `a_side.access_point.port` @@ -642,10 +691,11 @@ Read-Only: ### Nested Schema for `a_side.access_point.port.redundancy` -Optional: +Read-Only: -- `priority` (String) +- `enabled` (Boolean) - `group` (String) +- `priority` (String) @@ -674,14 +724,16 @@ Read-Only: - -### Nested Schema for `a_side.access_point.routing_protocols` + +### Nested Schema for `a_side.access_point.router` Optional: -- `state` (String) Routing protocol instance state -- `type` (String) Routing Protocol type -- `uuid` (String) Equinix-assigned Routing protocol identifier +- `uuid` (String) Equinix-assigned virtual gateway identifier + +Read-Only: + +- `href` (String) Unique Resource Identifier @@ -689,28 +741,27 @@ Optional: Optional: -- `type` (String) Virtual Device type - `name` (String) Customer-assigned Virtual Device Name +- `type` (String) Virtual Device type - `uuid` (String) Equinix-assigned Virtual Device identifier - Read-Only: - `href` (String) Unique Resource Identifier - + ### Nested Schema for `a_side.access_point.account` Read-Only: -- `account_name` (String) -- `account_number` (Number) -- `global_cust_id` (String) -- `global_org_id` (String) -- `global_organization_name` (String) -- `org_id` (Number) -- `organization_name` (String) +- `account_name` (String) Account Name +- `account_number` (Number) Account Number +- `global_cust_id` (String) Global Customer organization identifier +- `global_org_id` (String) Global organization identifier +- `global_organization_name` (String) Global organization name +- `org_id` (Number) Customer organization identifier +- `organization_name` (String) Customer organization name @@ -722,7 +773,6 @@ Optional: - `key` (String) Additional information key - `value` (String) Additional information value -~> **NOTE:** Port to IBM Connections could be modified from IBM Service Provider Side by using parameters passed to additional_info field: `{"key": "ASN", "value": "1111"}` `{"key": "Global", "value": "false"}` `{"key": "BGP_IBM_CIDR", "value": "172.16.0.18/30"}` `{"key": "BGP_CER_CIDR", "value": "172.16.0.19/30"}` ### Nested Schema for `a_side.service_token` @@ -752,14 +802,25 @@ Optional: - `send_interval` (String) Send interval + +### Nested Schema for `order` + +Optional: + +- `billing_tier` (String) Billing tier for connection bandwidth +- `order_id` (String) Order Identification +- `order_number` (String) Order Reference Number +- `purchase_order_number` (String) Purchase order number + + ### Nested Schema for `z_side` Optional: -- `access_point` (Block Set) Point of access details (see [below for nested schema](#nestedblock--z_side--access_point)) +- `access_point` (Block Set, Max: 1) Point of access details (see [below for nested schema](#nestedblock--z_side--access_point)) - `additional_info` (Block List) Connection side additional information (see [below for nested schema](#nestedblock--z_side--additional_info)) -- `service_token` (Block Set) For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets (see [below for nested schema](#nestedblock--z_side--service_token)) +- `service_token` (Block Set, Max: 1) For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets (see [below for nested schema](#nestedblock--z_side--service_token)) ### Nested Schema for `z_side.access_point` @@ -767,26 +828,26 @@ Optional: Optional: - `authentication_key` (String) Authentication key for provider based connections -- **Deprecated** `gateway` Use `router` attribute instead; (Block Set) (see [below for nested schema](#nestedblock--z_side--access_point--router)) -- `router` (Block Set) Cloud Router access point information that replaces `gateway` (refers to [below for nested schema](#nestedblock--z_side--access_point--router)) -- `interface` (Block Set) Virtual device interface (see [below for nested schema](#nestedblock--z_side--access_point--interface)) -- `link_protocol` (Block Set) Connection link protocol (see [below for nested schema](#nestedblock--z_side--access_point--link_protocol)) -- `location` (Block Set) Access point location (see [below for nested schema](#nestedblock--z_side--access_point--location)) +- `gateway` (Block Set, Max: 1, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedblock--z_side--access_point--gateway)) +- `interface` (Block Set, Max: 1) Virtual device interface (see [below for nested schema](#nestedblock--z_side--access_point--interface)) +- `link_protocol` (Block Set, Max: 1) Connection link protocol (see [below for nested schema](#nestedblock--z_side--access_point--link_protocol)) +- `location` (Block Set, Max: 1) Access point location (see [below for nested schema](#nestedblock--z_side--access_point--location)) +- `network` (Block Set, Max: 1) network access point information (see [below for nested schema](#nestedblock--z_side--access_point--network)) - `peering_type` (String) Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL -- `port` (Block Set) Port access point information (see [below for nested schema](#nestedblock--z_side--access_point--port)) -- `profile` (Block Set) Service Profile (see [below for nested schema](#nestedblock--z_side--access_point--profile)) +- `port` (Block Set, Max: 1) Port access point information (see [below for nested schema](#nestedblock--z_side--access_point--port)) +- `profile` (Block Set, Max: 1) Service Profile (see [below for nested schema](#nestedblock--z_side--access_point--profile)) - `provider_connection_id` (String) Provider assigned Connection Id -- `routing_protocols` (Block List) Access point routing protocols configuration (see [below for nested schema](#nestedblock--z_side--access_point--routing_protocols)) +- `router` (Block Set, Max: 1) Cloud Router access point information that replaces `gateway` (see [below for nested schema](#nestedblock--z_side--access_point--router)) - `seller_region` (String) Access point seller region -- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW -- `virtual_device` (Block Set) Virtual device (see [below for nested schema](#nestedblock--z_side--access_point--virtual_device)) +- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK +- `virtual_device` (Block Set, Max: 1) Virtual device (see [below for nested schema](#nestedblock--z_side--access_point--virtual_device)) Read-Only: -- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--z_side--access_point--account)) +- `account` (Block Set) Account (see [below for nested schema](#nestedblock--z_side--access_point--account)) - -### Nested Schema for `z_side.access_point.router` + +### Nested Schema for `z_side.access_point.gateway` Optional: @@ -802,13 +863,10 @@ Read-Only: Optional: +- `id` (Number) id - `type` (String) Interface type - `uuid` (String) Equinix-assigned interface identifier -Read-Only: - -- `id` (String) id - ### Nested Schema for `z_side.access_point.link_protocol` @@ -832,6 +890,18 @@ Optional: - `region` (String) Access point region + +### Nested Schema for `z_side.access_point.network` + +Optional: + +- `uuid` (String) Equinix-assigned Network identifier + +Read-Only: + +- `href` (String) Unique Resource Identifier + + ### Nested Schema for `z_side.access_point.port` @@ -850,6 +920,8 @@ Read-Only: Read-Only: +- `enabled` (Boolean) +- `group` (String) - `priority` (String) @@ -879,14 +951,16 @@ Read-Only: - -### Nested Schema for `z_side.access_point.routing_protocols` + +### Nested Schema for `z_side.access_point.router` Optional: -- `state` (String) Routing protocol instance state -- `type` (String) Routing Protocol type -- `uuid` (String) Equinix-assigned Routing protocol identifier +- `uuid` (String) Equinix-assigned virtual gateway identifier + +Read-Only: + +- `href` (String) Unique Resource Identifier @@ -894,6 +968,7 @@ Optional: Optional: +- `name` (String) Customer-assigned Virtual Device Name - `type` (String) Virtual Device type - `uuid` (String) Equinix-assigned Virtual Device identifier @@ -902,18 +977,18 @@ Read-Only: - `href` (String) Unique Resource Identifier - + ### Nested Schema for `z_side.access_point.account` Read-Only: -- `account_name` (String) -- `account_number` (Number) -- `global_cust_id` (String) -- `global_org_id` (String) -- `global_organization_name` (String) -- `org_id` (Number) -- `organization_name` (String) +- `account_name` (String) Account Name +- `account_number` (Number) Account Number +- `global_cust_id` (String) Global Customer organization identifier +- `global_org_id` (String) Global organization identifier +- `global_organization_name` (String) Global organization name +- `org_id` (Number) Customer organization identifier +- `organization_name` (String) Customer organization name @@ -941,27 +1016,16 @@ Read-Only: - -### Nested Schema for `additional_info` - -Optional: - -- `key` (String) Additional information key -- `value` (String) Additional information value - - - -### Nested Schema for `order` + +### Nested Schema for `project` Optional: -- `billing_tier` (String) Billing tier for connection bandwidth -- `purchase_order_number` (String) Purchase order number +- `project_id` (String) Project Id Read-Only: -- `order_id` (String) Order Identification -- `order_number` (String) Order Reference Number +- `href` (String) Unique Resource URL @@ -969,11 +1033,8 @@ Read-Only: Optional: -- `priority` (String) Priority type- PRIMARY, SECONDARY - -Read-Only: - -- `group` (String) Redundancy group identifier +- `group` (String) Redundancy group identifier (UUID of primary connection) +- `priority` (String) Connection priority in redundancy group - PRIMARY, SECONDARY @@ -1048,16 +1109,3 @@ Read-Only: - `property` (String) - `reason` (String) - - - - - -### Nested Schema for `project` - -Read-Only: - -- `href` (String) Unique Resource URL -- `project_id` (String) Project Id - - diff --git a/docs/resources/equinix_fabric_routing_protocol.md b/docs/resources/equinix_fabric_routing_protocol.md index a796a466f..93208dc50 100644 --- a/docs/resources/equinix_fabric_routing_protocol.md +++ b/docs/resources/equinix_fabric_routing_protocol.md @@ -238,5 +238,3 @@ Read-Only: - `property` (String) - `reason` (String) - - diff --git a/docs/resources/equinix_fabric_service_profile.md b/docs/resources/equinix_fabric_service_profile.md index ea6b28b6a..58be908c0 100644 --- a/docs/resources/equinix_fabric_service_profile.md +++ b/docs/resources/equinix_fabric_service_profile.md @@ -57,13 +57,14 @@ resource "equinix_fabric_service_profile" "new_service_profile" { ### Optional - `access_point_type_configs` (Block List) Access point config information (see [below for nested schema](#nestedblock--access_point_type_configs)) -- `account` (Block Set) Account (see [below for nested schema](#nestedblock--account)) +- `account` (Block Set, Max: 1) Account (see [below for nested schema](#nestedblock--account)) - `allowed_emails` (List of String) Array of contact emails - `custom_fields` (Block List) Custom Fields (see [below for nested schema](#nestedblock--custom_fields)) -- `marketing_info` (Block Set) Marketing Info (see [below for nested schema](#nestedblock--marketing_info)) +- `marketing_info` (Block Set, Max: 1) Marketing Info (see [below for nested schema](#nestedblock--marketing_info)) - `metros` (Block List) Access point config information (see [below for nested schema](#nestedblock--metros)) - `notifications` (Block List) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedblock--notifications)) - `ports` (Block List) Ports (see [below for nested schema](#nestedblock--ports)) +- `project` (Block Set, Max: 1) Project information (see [below for nested schema](#nestedblock--project)) - `self_profile` (Boolean) Self Profile - `state` (String) Service profile state - ACTIVE, PENDING_APPROVAL, DELETED, REJECTED - `tags` (List of String) Tags attached to the connection @@ -76,7 +77,6 @@ resource "equinix_fabric_service_profile" "new_service_profile" { - `change_log` (Set of Object) Captures connection lifecycle change information (see [below for nested schema](#nestedatt--change_log)) - `href` (String) Service Profile URI response attribute - `id` (String) The ID of this resource. -- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project)) - `uuid` (String) Equinix assigned service profile identifier @@ -92,13 +92,13 @@ Optional: - `allow_bandwidth_upgrade` (Boolean) Availability of a bandwidth upgrade. The default is false - `allow_custom_bandwidth` (Boolean) Setting to enable or disable the ability of the buyer to customize the bandwidth - `allow_remote_connections` (Boolean) Setting to allow or prohibit remote connections to the service profile -- `api_config` (Block Set) Api configuration details (see [below for nested schema](#nestedblock--access_point_type_configs--api_config)) -- `authentication_key` (Block Set) Authentication key details (see [below for nested schema](#nestedblock--access_point_type_configs--authentication_key)) +- `api_config` (Block Set, Max: 1) Api configuration details (see [below for nested schema](#nestedblock--access_point_type_configs--api_config)) +- `authentication_key` (Block Set, Max: 1) Authentication key details (see [below for nested schema](#nestedblock--access_point_type_configs--authentication_key)) - `bandwidth_alert_threshold` (Number) Percentage of port bandwidth at which an allocation alert is generated - `connection_label` (String) Custom name for Connection - `connection_redundancy_required` (Boolean) Mandate redundant connections - `enable_auto_generate_service_key` (Boolean) Enable auto generate service key -- `link_protocol_config` (Block Set) Link protocol configuration details (see [below for nested schema](#nestedblock--access_point_type_configs--link_protocol_config)) +- `link_protocol_config` (Block Set, Max: 1) Link protocol configuration details (see [below for nested schema](#nestedblock--access_point_type_configs--link_protocol_config)) - `supported_bandwidths` (List of Number) Supported bandwidths Read-Only: @@ -228,7 +228,7 @@ Required: Optional: - `cross_connect_id` (String) Cross Connect Id -- `location` (Block Set) Colo/Port Location (see [below for nested schema](#nestedblock--ports--location)) +- `location` (Block Set, Max: 1) Colo/Port Location (see [below for nested schema](#nestedblock--ports--location)) - `seller_region` (String) Seller Region - `seller_region_description` (String) Seller Region details @@ -244,6 +244,18 @@ Optional: + +### Nested Schema for `project` + +Optional: + +- `project_id` (String) Project Id + +Read-Only: + +- `href` (String) Unique Resource URL + + ### Nested Schema for `timeouts` @@ -266,7 +278,7 @@ Required: Optional: - `interface_uuid` (String) Device Interface Uuid -- `location` (Block Set) Device Location (see [below for nested schema](#nestedblock--virtual_devices--location)) +- `location` (Block Set, Max: 1) Device Location (see [below for nested schema](#nestedblock--virtual_devices--location)) ### Nested Schema for `virtual_devices.location` @@ -297,14 +309,3 @@ Read-Only: - `updated_by_email` (String) - `updated_by_full_name` (String) - `updated_date_time` (String) - - - -### Nested Schema for `project` - -Read-Only: - -- `href` (String) Unique Resource URL -- `project_id` (String) Project Id - - diff --git a/equinix/data_source_fabric_cloud_router.go b/equinix/data_source_fabric_cloud_router.go index 50666b9df..bcbd2329a 100644 --- a/equinix/data_source_fabric_cloud_router.go +++ b/equinix/data_source_fabric_cloud_router.go @@ -11,7 +11,7 @@ func dataSourceCloudRouter() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceCloudRouterRead, Schema: readCloudRouterResourceSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch Fabric Cloud Router for a given UUID\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible data resource that allow user to fetch Fabric Cloud Router for a given UUID", } } diff --git a/equinix/data_source_fabric_connection.go b/equinix/data_source_fabric_connection.go index 651a4d4eb..e6914f2fc 100644 --- a/equinix/data_source_fabric_connection.go +++ b/equinix/data_source_fabric_connection.go @@ -2,16 +2,33 @@ package equinix import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +func readFabricConnectionResourceSchema() map[string]*schema.Schema { + sch := fabricConnectionResourceSchema() + for key, _ := range sch { + if key == "uuid" { + sch[key].Required = true + sch[key].Optional = false + sch[key].Computed = false + } else { + sch[key].Required = false + sch[key].Optional = false + sch[key].Computed = true + sch[key].MaxItems = 0 + sch[key].ValidateFunc = nil + } + } + return sch +} + func dataSourceFabricConnection() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceFabricConnectionRead, Schema: readFabricConnectionResourceSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch connection for a given UUID\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible data resource that allow user to fetch connection for a given UUID", } } diff --git a/equinix/data_source_fabric_port.go b/equinix/data_source_fabric_port.go index 5c8ddd052..9163a1b36 100644 --- a/equinix/data_source_fabric_port.go +++ b/equinix/data_source_fabric_port.go @@ -10,8 +10,8 @@ import ( func dataSourceFabricPort() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceFabricPortRead, - Schema: readFabricPortResourceSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch port by uuid\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Schema: FabricPortResourceSchema(), + Description: "Fabric V4 API compatible data resource that allow user to fetch port by uuid", } } @@ -25,7 +25,7 @@ func dataSourceFabricGetPortsByName() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceFabricGetPortsByNameResponseRead, Schema: readFabricPortsResponseSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch port by name\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible data resource that allow user to fetch port by name", } } diff --git a/equinix/data_source_fabric_routing_protocol.go b/equinix/data_source_fabric_routing_protocol.go index ab136a9cb..af2b68673 100644 --- a/equinix/data_source_fabric_routing_protocol.go +++ b/equinix/data_source_fabric_routing_protocol.go @@ -11,7 +11,7 @@ func dataSourceRoutingProtocol() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceRoutingProtocolRead, Schema: readFabricRoutingProtocolResourceSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch routing protocol for a given UUID\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible data resource that allow user to fetch routing protocol for a given UUID", } } diff --git a/equinix/data_source_fabric_service_profile.go b/equinix/data_source_fabric_service_profile.go index a777680d4..d31523f30 100644 --- a/equinix/data_source_fabric_service_profile.go +++ b/equinix/data_source_fabric_service_profile.go @@ -11,7 +11,7 @@ func dataSourceFabricServiceProfileReadByUuid() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceFabricServiceProfileRead, Schema: readFabricServiceProfileSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch Service Profile by UUID filter criteria\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability", + Description: "Fabric V4 API compatible data resource that allow user to fetch Service Profile by UUID filter criteria", } } @@ -25,7 +25,7 @@ func dataSourceFabricSearchServiceProfilesByName() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceFabricSearchServiceProfilesRead, Schema: readFabricServiceProfilesSearchSchema(), - Description: "Fabric V4 API compatible data resource that allow user to fetch Service Profile by name filter criteria\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible data resource that allow user to fetch Service Profile by name filter criteria", } } diff --git a/equinix/fabric_cloud_router_read_schema.go b/equinix/fabric_cloud_router_read_schema.go index 39daeec8f..31c4d7373 100644 --- a/equinix/fabric_cloud_router_read_schema.go +++ b/equinix/fabric_cloud_router_read_schema.go @@ -1,6 +1,9 @@ package equinix -import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) func readPackageSch() map[string]*schema.Schema { return map[string]*schema.Schema{ @@ -16,7 +19,7 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "uuid": { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Equinix-assigned Fabric Cloud Router identifier", }, "href": { @@ -72,7 +75,7 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Captures Fabric Cloud Router lifecycle change information", Elem: &schema.Resource{ - Schema: readChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, "type": { @@ -85,16 +88,15 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Fabric Cloud Router location", Elem: &schema.Resource{ - Schema: readLocationSch(), + Schema: equinix_schema.LocationSch(), }, }, "project": { Type: schema.TypeSet, - Optional: true, Computed: true, Description: "Project information", Elem: &schema.Resource{ - Schema: readCloudRouterProjectSch(), + Schema: equinix_schema.ProjectSch(), }, }, "account": { @@ -102,7 +104,7 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Customer account information that is associated with this Fabric Cloud Router", Elem: &schema.Resource{ - Schema: readAccountSch(), + Schema: equinix_schema.AccountSch(), }, }, "order": { @@ -110,7 +112,7 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Order information related to this Fabric Cloud Router", Elem: &schema.Resource{ - Schema: readOrderSch(), + Schema: equinix_schema.OrderSch(), }, }, "notifications": { @@ -118,7 +120,7 @@ func readCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Preferences for notifications on Fabric Cloud Router configuration or status changes", Elem: &schema.Resource{ - Schema: readNotificationSch(), + Schema: equinix_schema.NotificationSch(), }, }, } diff --git a/equinix/fabric_cloud_router_schema.go b/equinix/fabric_cloud_router_schema.go index 3ffeefc55..6c2d70921 100644 --- a/equinix/fabric_cloud_router_schema.go +++ b/equinix/fabric_cloud_router_schema.go @@ -1,6 +1,7 @@ package equinix import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) @@ -96,7 +97,7 @@ func createCloudRouterResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Captures Fabric Cloud Router lifecycle change information", Elem: &schema.Resource{ - Schema: createChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, "type": { @@ -111,7 +112,7 @@ func createCloudRouterResourceSchema() map[string]*schema.Schema { Description: "Fabric Cloud Router location", MaxItems: 1, Elem: &schema.Resource{ - Schema: createLocationSch(), + Schema: equinix_schema.LocationSch(), }, }, "project": { @@ -138,7 +139,7 @@ func createCloudRouterResourceSchema() map[string]*schema.Schema { Description: "Order information related to this Fabric Cloud Router", MaxItems: 1, Elem: &schema.Resource{ - Schema: createOrderSch(), + Schema: equinix_schema.OrderSch(), }, }, "notifications": { @@ -146,7 +147,7 @@ func createCloudRouterResourceSchema() map[string]*schema.Schema { Required: true, Description: "Preferences for notifications on Fabric Cloud Router configuration or status changes", Elem: &schema.Resource{ - Schema: createNotificationSch(), + Schema: equinix_schema.NotificationSch(), }, }, "bgp_ipv4_routes_count": { diff --git a/equinix/fabric_connection_read_schema.go b/equinix/fabric_connection_read_schema.go deleted file mode 100644 index 80b80eddb..000000000 --- a/equinix/fabric_connection_read_schema.go +++ /dev/null @@ -1,902 +0,0 @@ -package equinix - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func readServiceTokenSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: "Token type - VC_TOKEN", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "An absolute URL that is the subject of the link's context", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix-assigned service token identifier", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Service token description", - }, - } -} - -func readLocationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Computed: true, - Description: "Access point region", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "metro_name": { - Type: schema.TypeString, - Computed: true, - Description: "Access point metro name", - }, - "metro_code": { - Type: schema.TypeString, - Computed: true, - Description: "Access point metro code", - }, - "ibx": { - Type: schema.TypeString, - Computed: true, - Description: "IBX Code", - }, - } -} - -func readVirtualGatewaySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Gateway unique identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: "Virtual Gateway State", - }, - } -} - -func readServiceProfileSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Service Profile URI response attribute", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Service profile type- LAYER_2_PROFILE, LAYER_3_PROFILE", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Customer-assigned service profile name", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix assigned service profile identifier", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "User-provided service profile description", - }, - "access_point_type_configs": { - Type: schema.TypeList, - Computed: true, - Description: "Access point config information", - Elem: &schema.Resource{ - Schema: readAccessPointTypeConfigSch(), - }, - }, - } -} - -func readAccessPointTypeConfigSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Type of access point type config - VD, COLO", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix-assigned access point type config identifier", - }, - "connection_redundancy_required": { - Type: schema.TypeBool, - Computed: true, - Description: "Mandate redundant connections", - }, - "allow_bandwidth_auto_approval": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting to enable or disable the ability of the buyer to change connection bandwidth without approval of the seller", - }, - "allow_remote_connections": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting to allow or prohibit remote connections to the service profile", - }, - "allow_bandwidth_upgrade": { - Type: schema.TypeBool, - Computed: true, - Description: "Availability of a bandwidth upgrade. The default is false", - }, - "connection_label": { - Type: schema.TypeString, - Computed: true, - Description: "Custom name for Connection", - }, - "enable_auto_generate_service_key": { - Type: schema.TypeBool, - Computed: true, - Description: "Enable auto generate service key", - }, - "bandwidth_alert_threshold": { - Type: schema.TypeFloat, - Computed: true, - Description: "Percentage of port bandwidth at which an allocation alert is generated", - }, - "allow_custom_bandwidth": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting to enable or disable the ability of the buyer to customize the bandwidth", - }, - "api_config": { - Type: schema.TypeSet, - Computed: true, - Description: "Api configuration details", - Elem: &schema.Resource{ - Schema: readApiConfigSch(), - }, - }, - "authentication_key": { - Type: schema.TypeSet, - Computed: true, - Description: "Authentication key details", - Elem: &schema.Resource{ - Schema: readAuthenticationKeySch(), - }, - }, - "link_protocol_config": { - Type: schema.TypeSet, - Computed: true, - Description: "Link protocol configuration details", - Elem: &schema.Resource{ - Schema: readLinkProtocolConfigSch(), - }, - }, - "supported_bandwidths": { - Type: schema.TypeList, - Computed: true, - Description: "Supported bandwidths", - Elem: &schema.Schema{Type: schema.TypeInt}, - }, - } -} - -func readApiConfigSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "api_available": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting indicating whether the API is available (true) or not (false)", - }, - "equinix_managed_vlan": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting indicating that the VLAN is managed by Equinix (true) or not (false)", - }, - "allow_over_subscription": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting showing that oversubscription support is available (true) or not (false). The default is false", - }, - "over_subscription_limit": { - Type: schema.TypeInt, - Computed: true, - Description: "A cap on over subscription", - }, - "bandwidth_from_api": { - Type: schema.TypeBool, - Computed: true, - Description: "Bandwidth from api", - }, - "integration_id": { - Type: schema.TypeString, - Computed: true, - Description: "Integration id", - }, - "equinix_managed_port": { - Type: schema.TypeBool, - Computed: true, - Description: "Setting indicating that the port is managed by Equinix (true) or not (false)", - }, - } -} - -func readAuthenticationKeySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "required": { - Type: schema.TypeBool, - Computed: true, - Description: "Required", - }, - "label": { - Type: schema.TypeString, - Computed: true, - Description: "Label", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Description", - }, - } -} - -func readLinkProtocolConfigSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "encapsulation_strategy": { - Type: schema.TypeString, - Computed: true, - Description: "Encapsulation strategy", - }, - "reuse_vlan_s_tag": { - Type: schema.TypeBool, - Computed: true, - Description: "Reuse vlan sTag", - }, - "encapsulation": { - Type: schema.TypeString, - Computed: true, - Description: "Port Encapsulation", - }, - } -} - -func readAccessPointLinkProtocolSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Type of the link protocol - DOT1Q, QINQ, UNTAGGED", - }, - "vlan_tag": { - Type: schema.TypeInt, - Computed: true, - Description: "Vlan Tag information, vlanTag value specified for DOT1Q connections", - }, - "vlan_s_tag": { - Type: schema.TypeInt, - Computed: true, - Description: "Vlan Provider Tag information, vlanSTag value specified for QINQ connections", - }, - "vlan_c_tag": { - Type: schema.TypeInt, - Computed: true, - Description: "Vlan Customer Tag information, vlanCTag value specified for QINQ connections", - }, - } -} - -func readAccessPointVirtualDeviceSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix-assigned Virtual Device identifier", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Virtual Device type", - }, - } -} - -func readAccessPointInterface() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: "Equinix-assigned interface identifier", - }, - "id": { - Type: schema.TypeInt, - Computed: true, - Optional: true, - Description: "Access Point Interface id", - }, - "type": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Interface type- CSP", - }, - } -} - -func readPortSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix-assigned port identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port name", - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Redundancy Information", - Elem: &schema.Resource{ - Schema: readPortRedundancySch(), - }, - }, - } -} - -func readConnectionSideAccessPointSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Access point type - VD, COLO", - }, - "authentication_key": { - Type: schema.TypeString, - Computed: true, - Description: "Authentication key for provider based connections", - }, - "account": { - Type: schema.TypeSet, - Computed: true, - Description: "Account", - Elem: &schema.Resource{ - Schema: readAccountSch(), - }, - }, - "location": { - Type: schema.TypeSet, - Computed: true, - Description: "Access point location", - Elem: &schema.Resource{ - Schema: readLocationSch(), - }, - }, - "port": { - Type: schema.TypeSet, - Computed: true, - Description: "Port access point information", - Elem: &schema.Resource{ - Schema: readPortSch(), - }, - }, - "profile": { - Type: schema.TypeSet, - Computed: true, - Description: "Service Profile", - Elem: &schema.Resource{ - Schema: readServiceProfileSch(), - }, - }, - "gateway": { - Type: schema.TypeSet, - Computed: true, - Deprecated: "router attribute will be returned instead", - Description: "Cloud Router access point information", - Elem: &schema.Resource{ - Schema: readVirtualGatewaySch(), - }, - }, - "router": { - Type: schema.TypeSet, - Computed: true, - Description: "Cloud Router access point information", - Elem: &schema.Resource{ - Schema: readVirtualGatewaySch(), - }, - }, - "link_protocol": { - Type: schema.TypeSet, - Computed: true, - Description: "Connection link protocol", - Elem: &schema.Resource{ - Schema: readAccessPointLinkProtocolSch(), - }, - }, - "virtual_device": { - Type: schema.TypeSet, - Computed: true, - Description: "Virtual device", - Elem: &schema.Resource{Schema: readAccessPointVirtualDeviceSch()}, - }, - "interface": { - Type: schema.TypeSet, - Computed: true, - Description: "Virtual device interface", - Elem: &schema.Resource{ - Schema: readAccessPointInterface(), - }, - }, - "seller_region": { - Type: schema.TypeString, - Computed: true, - Description: "Access point seller region", - }, - "peering_type": { - Type: schema.TypeString, - Computed: true, - Description: "Peering Type - for Azure - Private or Public", - }, - "provider_connection_id": { - Type: schema.TypeString, - Computed: true, - Description: "Provider assigned Connection Id", - }, - } -} - -func readFabricConnectionSideSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "service_token": { - Type: schema.TypeSet, - Computed: true, - Optional: true, - Description: "For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets", - Elem: &schema.Resource{ - Schema: readServiceTokenSch(), - }, - }, - "access_point": { - Type: schema.TypeSet, - Computed: true, - Description: "Point of access details", - Elem: &schema.Resource{ - Schema: readConnectionSideAccessPointSch(), - }, - }, - } -} - -func readRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "group": { - Type: schema.TypeString, - Computed: true, - Description: "Redundancy group identifier", - }, - "priority": { - Type: schema.TypeString, - Computed: true, - Description: "Priority type - Primary or Secondary", - }, - } -} - -func readPortRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "priority": { - Type: schema.TypeString, - Computed: true, - Description: "Priority type-Primary or Secondary", - }, - } -} - -func readChangeLogSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Key", - }, - "created_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Full Name", - }, - "created_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Email Address", - }, - "created_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Created on Date and Time", - }, - "updated_by": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Key", - }, - "updated_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Full Name", - }, - "updated_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Email Address", - }, - "updated_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Updated on Date and Time", - }, - "deleted_by": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Key", - }, - "deleted_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Full Name", - }, - "deleted_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Email Address", - }, - "deleted_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted on Date and Time", - }, - } -} - -func readOrderSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "purchase_order_number": { - Type: schema.TypeString, - Computed: true, - Description: "Purchase order number", - }, - "billing_tier": { - Type: schema.TypeString, - Computed: true, - Description: "Billing tier for connection bandwidth", - }, - "order_id": { - Type: schema.TypeString, - Computed: true, - Description: "Order Identification", - }, - "order_number": { - Type: schema.TypeString, - Computed: true, - Description: "Order Reference Number", - }, - } -} - -func readAccountSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "account_number": { - Type: schema.TypeInt, - Computed: true, - Description: "Account Number", - }, - "account_name": { - Type: schema.TypeString, - Computed: true, - Description: "Account Name", - }, - "org_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Customer organization identifier", - }, - "organization_name": { - Type: schema.TypeString, - Computed: true, - Description: "Customer organization name", - }, - "global_org_id": { - Type: schema.TypeString, - Computed: true, - Description: "Global organization identifier", - }, - "global_organization_name": { - Type: schema.TypeString, - Computed: true, - Description: "Global organization name", - }, - "global_cust_id": { - Type: schema.TypeString, - Computed: true, - Description: "Global Customer organization identifier", - }, - } -} - -func readNotificationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Notification Type- ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS", - }, - "send_interval": { - Type: schema.TypeString, - Computed: true, - Description: "Send interval", - }, - "emails": { - Type: schema.TypeList, - Computed: true, - Description: "Array of contact emails", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - } -} - -func readErrorAdditionalInfoSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "property": { - Type: schema.TypeString, - Computed: true, - Description: "Property at which the error potentially occurred", - }, - "reason": { - Type: schema.TypeString, - Computed: true, - Description: "Reason for the error", - }, - } -} - -func readOperationalErrorSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "error_code": { - Type: schema.TypeString, - Computed: true, - Description: "Error code", - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - Description: "Error Message", - }, - "correlation_id": { - Type: schema.TypeString, - Computed: true, - Description: "CorrelationId", - }, - "details": { - Type: schema.TypeString, - Computed: true, - Description: "Details", - }, - "help": { - Type: schema.TypeString, - Computed: true, - Description: "Help", - }, - "additional_info": { - Type: schema.TypeList, - Computed: true, - Description: "Pricing error additional Info", - Elem: &schema.Resource{ - Schema: readErrorAdditionalInfoSch(), - }, - }, - } -} - -func readOperationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "provider_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection provider readiness status - AVAILABLE, DEPROVISIONED, DEPROVISIONING ...", - }, - "equinix_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection status - REJECTED, PENDING_DELETE, PROVISIONED ...", - }, - "errors": { - Type: schema.TypeList, - Computed: true, - Description: "Errors occurred", - Elem: &schema.Resource{ - Schema: readOperationalErrorSch(), - }, - }, - } -} - -func readAdditionalInfoSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Computed: true, - Description: "Additional information key", - }, - "value": { - Type: schema.TypeString, - Computed: true, - Description: "Additional information value", - }, - } -} - -func readFabricConnectionResourceSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned connection identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Connection URI information", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Customer-provided connection description", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, IPWAN_VC, ACCESS_EPL_VC,EVPLAN_VC,EPLAN_VC", - }, - "bandwidth": { - Type: schema.TypeInt, - Computed: true, - Description: "Connection bandwidth in Mbps", - }, - "is_remote": { - Type: schema.TypeBool, - Computed: true, - Description: "Connection property derived from access point locations", - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: "Connection overall state", - }, - "operation": { - Type: schema.TypeSet, - Computed: true, - Description: "Connection specific operational data", - Elem: &schema.Resource{ - Schema: readOperationSch(), - }, - }, - "notifications": { - Type: schema.TypeList, - Computed: true, - Description: "Preferences for notifications on connection configuration or status changes", - Elem: &schema.Resource{ - Schema: readNotificationSch(), - }, - }, - "additional_info": { - Type: schema.TypeList, - Computed: true, - Description: "Connection additional information", - Elem: &schema.Resource{ - Schema: readAdditionalInfoSch(), - }, - }, - "order": { - Type: schema.TypeSet, - Computed: true, - Description: "Order related to this connection information", - Elem: &schema.Resource{ - Schema: readOrderSch(), - }, - }, - "account": { - Type: schema.TypeSet, - Computed: true, - Description: "Customer account information that is associated with this connection", - Elem: &schema.Resource{ - Schema: readAccountSch(), - }, - }, - "change_log": { - Type: schema.TypeSet, - Computed: true, - Description: "Captures connection lifecycle change information", - Elem: &schema.Resource{ - Schema: readChangeLogSch(), - }, - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Redundancy Information", - Elem: &schema.Resource{ - Schema: readRedundancySch(), - }, - }, - "direction": { - Type: schema.TypeString, - Computed: true, - Description: "Connection directionality from the requester point of view", - }, - "a_side": { - Type: schema.TypeSet, - Computed: true, - Description: "Requester or Customer side connection configuration object of the multi-segment connection", - Elem: &schema.Resource{ - Schema: readFabricConnectionSideSch(), - }, - }, - "z_side": { - Type: schema.TypeSet, - Computed: true, - Description: "Destination or Provider side connection configuration object of the multi-segment connection", - Elem: &schema.Resource{ - Schema: readFabricConnectionSideSch(), - }, - }, - "project": { - Type: schema.TypeSet, - Optional: true, - Description: "Project information", - Elem: &schema.Resource{ - Schema: createGatewayProjectSch(), - }, - }, - } -} diff --git a/equinix/fabric_connection_schema.go b/equinix/fabric_connection_schema.go deleted file mode 100644 index 7dcdb31c6..000000000 --- a/equinix/fabric_connection_schema.go +++ /dev/null @@ -1,901 +0,0 @@ -package equinix - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" -) - -var createServiceTokenRes = &schema.Resource{ - Schema: createServiceTokenSch(), -} - -func createServiceTokenSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"VC_TOKEN"}, true), - Description: "Token type - VC_TOKEN", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "An absolute URL that is the subject of the link's context", - }, - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned service token identifier", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Service token description", - }, - } -} - -var createLocationRes = &schema.Resource{ - Schema: createLocationSch(), -} - -func createLocationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "region": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Access point region", - }, - "metro_name": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Access point metro name", - }, - "metro_code": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Access point metro code", - }, - "ibx": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "IBX Code", - }, - } -} - -func createVirtualGatewaySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned virtual gateway identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - } -} - -func createNetworkSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned Network identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - } -} - -var createGatewayProjectSchRes = &schema.Resource{ - Schema: createGatewayProjectSch(), -} - -func createGatewayProjectSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: "Project Id", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource URL", - }, - } -} - -var createServiceProfileSchRes = &schema.Resource{ - Schema: createServiceProfileSch(), -} - -func createServiceProfileSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Service Profile URI response attribute", - }, - "type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"L2_PROFILE", "L3_PROFILE", "ECIA_PROFILE", "ECMC_PROFILE"}, true), - Description: "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Customer-assigned service profile name", - }, - "uuid": { - Type: schema.TypeString, - Required: true, - Description: "Equinix assigned service profile identifier", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "User-provided service description", - }, - "access_point_type_configs": { - Type: schema.TypeList, - Computed: true, - Description: "Access point config information", - Elem: &schema.Resource{ - Schema: createAccessPointTypeConfigSch(), - }, - }, - } -} - -func createAccessPointTypeConfigSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Type of access point type config - VD, COLO", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Equinix-assigned access point type config identifier", - }, - } -} - -var createAccessPointLinkProtocolSchRes = &schema.Resource{ - Schema: createAccessPointLinkProtocolSch(), -} - -func createAccessPointLinkProtocolSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - Description: "Type of the link protocol - UNTAGGED, DOT1Q, QINQ, EVPN_VXLAN", - ValidateFunc: validation.StringInSlice([]string{"UNTAGGED", "DOT1Q", "QINQ", "EVPN_VXLAN"}, true), - }, - "vlan_tag": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Vlan Tag information, vlanTag value specified for DOT1Q connections", - }, - "vlan_s_tag": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Vlan Provider Tag information, vlanSTag value specified for QINQ connections", - }, - "vlan_c_tag": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "Vlan Customer Tag information, vlanCTag value specified for QINQ connections", - }, - } -} - -var createAccessPointVirtualDeviceRes = &schema.Resource{ - Schema: createAccessPointVirtualDeviceSch(), -} - -func createAccessPointVirtualDeviceSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned Virtual Device identifier", - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: "Virtual Device type", - }, - "name": { - Type: schema.TypeString, - Optional: true, - Description: "Customer-assigned Virtual Device Name", - }, - } -} - -func createAccessPointInterface() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned interface identifier", - }, - "id": { - Type: schema.TypeInt, - Computed: true, - Optional: true, - Description: "id", - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: "Interface type", - }, - } -} - -func createFabricConnectionRoutingProtocol() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - Description: "Routing Protocol type", - }, - "uuid": { - Type: schema.TypeString, - Optional: true, - Description: "Equinix-assigned Routing protocol identifier", - }, - "state": { - Type: schema.TypeString, - Optional: true, - Description: "Routing protocol instance state", - }, - } -} - -var createPortRes = &schema.Resource{ - Schema: createPortSch(), -} - -func createPortSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Equinix-assigned Port identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port name", - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Redundancy Information", - Elem: &schema.Resource{ - Schema: createPortRedundancySch(), - }, - }, - } -} - -func createConnectionSideAccessPointRes() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "CLOUD_ROUTER", "NETWORK"}, true), - Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK", - }, - "authentication_key": { - Type: schema.TypeString, - Optional: true, - Description: "Authentication key for provider based connections", - }, - "account": { - Type: schema.TypeSet, - Optional: true, - Computed: true, - Description: "Account", - Elem: &schema.Resource{ - Schema: createAccountSch(), - }, - }, - "location": { - Type: schema.TypeSet, - Optional: true, - Computed: true, - Description: "Access point location", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createLocationSch(), - }, - }, - "port": { - Type: schema.TypeSet, - Optional: true, - Description: "Port access point information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createPortSch(), - }, - }, - "profile": { - Type: schema.TypeSet, - Optional: true, - Description: "Service Profile", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createServiceProfileSch(), - }, - }, - "gateway": { - Type: schema.TypeSet, - Optional: true, - Deprecated: "use router attribute instead; gateway is no longer a part of the supported backend", - Description: "Cloud Router access point information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createVirtualGatewaySch(), - }, - }, - "router": { - Type: schema.TypeSet, - Optional: true, - Description: "Cloud Router access point information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createVirtualGatewaySch(), - }, - }, - "network": { - Type: schema.TypeSet, - Optional: true, - Description: "network access point information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createNetworkSch(), - }, - }, - "link_protocol": { - Type: schema.TypeSet, - Optional: true, - Description: "Connection link protocol", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createAccessPointLinkProtocolSch(), - }, - }, - "virtual_device": { - Type: schema.TypeSet, - Optional: true, - Description: "Virtual device", - MaxItems: 1, - Elem: &schema.Resource{Schema: createAccessPointVirtualDeviceSch()}, - }, - "interface": { - Type: schema.TypeSet, - Optional: true, - Description: "Virtual device interface", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createAccessPointInterface(), - }, - }, - "seller_region": { - Type: schema.TypeString, - Optional: true, - Description: "Access point seller region", - }, - "peering_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "MICROSOFT", "PUBLIC", "MANUAL"}, true), - Description: "Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL", - }, - "routing_protocols": { - Type: schema.TypeList, - Optional: true, - Description: "Access point routing protocols configuration", - Elem: &schema.Resource{ - Schema: createFabricConnectionRoutingProtocol(), - }, - }, - "provider_connection_id": { - Type: schema.TypeString, - Optional: true, - Description: "Provider assigned Connection Id", - }, - }, - } -} - -func createFabricConnectionSideRes() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "service_token": { - Type: schema.TypeSet, - Optional: true, - Description: "For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createServiceTokenSch(), - }, - }, - "access_point": { - Type: schema.TypeSet, - Optional: true, - Description: "Point of access details", - MaxItems: 1, - Elem: createConnectionSideAccessPointRes(), - }, - "additional_info": { - Type: schema.TypeList, - Optional: true, - Description: "Connection side additional information", - Elem: &schema.Resource{ - Schema: createAdditionalInfoSch(), - }, - }, - }, - } -} - -var createRedundancyRes = &schema.Resource{ - Schema: createRedundancySch(), -} - -func createRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "group": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: "Redundancy group identifier", - }, - "priority": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PRIMARY", "SECONDARY"}, true), - Description: "Priority type- PRIMARY, SECONDARY", - }, - } -} - -var createPortRedundancyRes = &schema.Resource{ - Schema: createPortRedundancySch(), -} - -func createPortRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "priority": { - Type: schema.TypeString, - Computed: true, - Description: "Priority type- PRIMARY, SECONDARY", - }, - } -} - -var createChangeLogRes = &schema.Resource{ - Schema: createChangeLogSch(), -} - -func createChangeLogSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Key", - }, - "created_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Full Name", - }, - "created_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Created by User Email Address", - }, - "created_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Created by Date and Time", - }, - "updated_by": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Key", - }, - "updated_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Full Name", - }, - "updated_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by User Email Address", - }, - "updated_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Updated by Date and Time", - }, - "deleted_by": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Key", - }, - "deleted_by_full_name": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Full Name", - }, - "deleted_by_email": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by User Email Address", - }, - "deleted_date_time": { - Type: schema.TypeString, - Computed: true, - Description: "Deleted by Date and Time", - }, - } -} - -var createOrderRes = &schema.Resource{ - Schema: createOrderSch(), -} - -func createOrderSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "purchase_order_number": { - Type: schema.TypeString, - Optional: true, - Description: "Purchase order number", - }, - "billing_tier": { - Type: schema.TypeString, - Optional: true, - Description: "Billing tier for connection bandwidth", - }, - "order_id": { - Type: schema.TypeString, - Computed: true, - Description: "Order Identification", - }, - "order_number": { - Type: schema.TypeString, - Computed: true, - Description: "Order Reference Number", - }, - } -} - -var createAccountRes = &schema.Resource{ - Schema: createAccountSch(), -} - -func createAccountSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "account_number": { - Type: schema.TypeInt, - Computed: true, - Description: "Account Number", - }, - "account_name": { - Type: schema.TypeString, - Computed: true, - Description: "Account Name", - }, - "org_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Customer organization identifier", - }, - "organization_name": { - Type: schema.TypeString, - Computed: true, - Description: "Customer organization name", - }, - "global_org_id": { - Type: schema.TypeString, - Computed: true, - Description: "Global organization identifier", - }, - "global_organization_name": { - Type: schema.TypeString, - Computed: true, - Description: "Global organization name", - }, - "global_cust_id": { - Type: schema.TypeString, - Computed: true, - Description: "Global Customer organization identifier", - }, - } -} - -func createNotificationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Required: true, - Description: "Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS", - }, - "send_interval": { - Type: schema.TypeString, - Optional: true, - Description: "Send interval", - }, - "emails": { - Type: schema.TypeList, - Required: true, - Description: "Array of contact emails", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - } -} - -func createErrorAdditionalInfoSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "property": { - Type: schema.TypeString, - Computed: true, - Description: "Property at which the error potentially occurred", - }, - "reason": { - Type: schema.TypeString, - Computed: true, - Description: "Reason for the error", - }, - } -} - -func createOperationalErrorSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "error_code": { - Type: schema.TypeString, - Computed: true, - Description: "Error code", - }, - "error_message": { - Type: schema.TypeString, - Computed: true, - Description: "Error Message", - }, - "correlation_id": { - Type: schema.TypeString, - Computed: true, - Description: "CorrelationId", - }, - "details": { - Type: schema.TypeString, - Computed: true, - Description: "Details", - }, - "help": { - Type: schema.TypeString, - Computed: true, - Description: "Help", - }, - "additional_info": { - Type: schema.TypeList, - Computed: true, - Description: "Pricing error additional Info", - Elem: &schema.Resource{ - Schema: createErrorAdditionalInfoSch(), - }, - }, - } -} - -var createOperationRes = &schema.Resource{ - Schema: createOperationSch(), -} - -func createOperationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "provider_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection provider readiness status", - }, - "equinix_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection status", - }, - "errors": { - Type: schema.TypeList, - Computed: true, - Description: "Errors occurred", - Elem: &schema.Resource{ - Schema: createOperationalErrorSch(), - }, - }, - } -} - -func createAdditionalInfoSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Optional: true, - Description: "Additional information key", - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: "Additional information value", - }, - } -} - -func createFabricConnectionResourceSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Connection URI information", - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores", - }, - // TODO v4.ConnectionPostRequest doesn't have a description field - // "description": { - // Type: schema.TypeString, - // Optional: true, - // Description: "Customer-provided connection description", - // }, - "type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"VG_VC", "EVPL_VC", "EPL_VC", "EC_VC", "IP_VC", "IPWAN_VC", "ACCESS_EPL_VC", "EVPLAN_VC", "EPLAN_VC"}, true), - Description: "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, IPWAN_VC,ACCESS_EPL_VC,EVPLAN_VC, EPLAN_VC", - }, - "bandwidth": { - Type: schema.TypeInt, - Required: true, - Description: "Connection bandwidth in Mbps", - }, - "is_remote": { - Type: schema.TypeBool, - Computed: true, - Description: "Connection property derived from access point locations", - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: "Connection overall state", - }, - "operation": { - Type: schema.TypeSet, - Computed: true, - Description: "Connection type-specific operational data", - Elem: &schema.Resource{ - Schema: createOperationSch(), - }, - }, - "notifications": { - Type: schema.TypeList, - Required: true, - Description: "Preferences for notifications on connection configuration or status changes", - Elem: &schema.Resource{ - Schema: createNotificationSch(), - }, - }, - "additional_info": { - Type: schema.TypeList, - Optional: true, - Description: "Connection additional information", - Elem: &schema.Schema{ - Type: schema.TypeMap, - }, - }, - "order": { - Type: schema.TypeSet, - Optional: true, - Description: "Order related to this connection information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createOrderSch(), - }, - }, - "project": { - Type: schema.TypeSet, - Optional: true, - Description: "Project information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createGatewayProjectSch(), - }, - }, - "account": { - Type: schema.TypeSet, - Computed: true, - Description: "Customer account information that is associated with this connection", - Elem: &schema.Resource{ - Schema: createAccountSch(), - }, - }, - "change_log": { - Type: schema.TypeSet, - Computed: true, - Description: "Captures connection lifecycle change information", - Elem: &schema.Resource{ - Schema: createChangeLogSch(), - }, - }, - "redundancy": { - Type: schema.TypeSet, - Optional: true, - Description: "Redundancy Information", - MaxItems: 1, - Elem: &schema.Resource{ - Schema: createRedundancySch(), - }, - }, - "direction": { - Type: schema.TypeString, - Computed: true, - Description: "Connection directionality from the requester point of view", - }, - "a_side": { - Type: schema.TypeSet, - Required: true, - Description: "Requester or Customer side connection configuration object of the multi-segment connection", - MaxItems: 1, - Elem: createFabricConnectionSideRes(), - Set: schema.HashResource(createConnectionSideAccessPointRes()), - }, - "z_side": { - Type: schema.TypeSet, - Required: true, - Description: "Destination or Provider side connection configuration object of the multi-segment connection", - MaxItems: 1, - Elem: createFabricConnectionSideRes(), - Set: schema.HashResource(createConnectionSideAccessPointRes()), - }, - } -} diff --git a/equinix/fabric_mapping_helper.go b/equinix/fabric_mapping_helper.go index def7ef650..0783d30e2 100644 --- a/equinix/fabric_mapping_helper.go +++ b/equinix/fabric_mapping_helper.go @@ -2,10 +2,10 @@ package equinix import ( "fmt" + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "log" v4 "github.com/equinix-labs/fabric-go/fabric/v4" - "github.com/equinix/terraform-provider-equinix/internal/converters" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -113,7 +113,7 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint { } if len(locationList) != 0 { - sl := locationToFabric(locationList) + sl := equinix_schema.LocationToFabric(locationList) accessPoint.Location = &sl } @@ -144,71 +144,6 @@ func cloudRouterToFabric(cloudRouterRequest []interface{}) v4.CloudRouter { return cloudRouterMapped } -func projectToFabric(projectRequest []interface{}) v4.Project { - if len(projectRequest) == 0 { - return v4.Project{} - } - mappedPr := v4.Project{} - for _, pr := range projectRequest { - prMap := pr.(map[string]interface{}) - projectId := prMap["project_id"].(string) - mappedPr = v4.Project{ProjectId: projectId} - } - return mappedPr -} - -func notificationToFabric(schemaNotifications []interface{}) []v4.SimplifiedNotification { - if schemaNotifications == nil { - return []v4.SimplifiedNotification{} - } - var notifications []v4.SimplifiedNotification - for _, n := range schemaNotifications { - ntype := n.(map[string]interface{})["type"].(string) - interval := n.(map[string]interface{})["send_interval"].(string) - emailsRaw := n.(map[string]interface{})["emails"].([]interface{}) - emails := converters.IfArrToStringArr(emailsRaw) - notifications = append(notifications, v4.SimplifiedNotification{ - Type_: ntype, - SendInterval: interval, - Emails: emails, - }) - } - return notifications -} - -func redundancyToFabric(schemaRedundancy []interface{}) v4.ConnectionRedundancy { - if schemaRedundancy == nil { - return v4.ConnectionRedundancy{} - } - red := v4.ConnectionRedundancy{} - for _, r := range schemaRedundancy { - redundancyMap := r.(map[string]interface{}) - connectionPriority := v4.ConnectionPriority(redundancyMap["priority"].(string)) - redundancyGroup := redundancyMap["group"].(string) - red = v4.ConnectionRedundancy{ - Priority: &connectionPriority, - Group: redundancyGroup, - } - } - return red -} - -func orderToFabric(schemaOrder []interface{}) v4.Order { - if schemaOrder == nil { - return v4.Order{} - } - order := v4.Order{} - for _, o := range schemaOrder { - orderMap := o.(map[string]interface{}) - purchaseOrderNumber := orderMap["purchase_order_number"] - billingTier := orderMap["billing_tier"] - orderId := orderMap["order_id"] - orderNumber := orderMap["order_number"] - order = v4.Order{PurchaseOrderNumber: purchaseOrderNumber.(string), BillingTier: billingTier.(string), OrderId: orderId.(string), OrderNumber: orderNumber.(string)} - } - return order -} - func linkProtocolToFabric(linkProtocolList []interface{}) v4.SimplifiedLinkProtocol { slp := v4.SimplifiedLinkProtocol{} for _, lp := range linkProtocolList { @@ -223,15 +158,6 @@ func linkProtocolToFabric(linkProtocolList []interface{}) v4.SimplifiedLinkProto return slp } -func portToFabric(portList []interface{}) v4.SimplifiedPort { - p := v4.SimplifiedPort{} - for _, pl := range portList { - plMap := pl.(map[string]interface{}) - uuid := plMap["uuid"].(string) - p = v4.SimplifiedPort{Uuid: uuid} - } - return p -} func networkToFabric(networkList []interface{}) v4.SimplifiedNetwork { p := v4.SimplifiedNetwork{} for _, pl := range networkList { @@ -255,23 +181,6 @@ func simplifiedServiceProfileToFabric(profileList []interface{}) v4.SimplifiedSe return ssp } -func locationToFabric(locationList []interface{}) v4.SimplifiedLocation { - sl := v4.SimplifiedLocation{} - for _, ll := range locationList { - llMap := ll.(map[string]interface{}) - metroName := llMap["metro_name"] - var metroNamestr string - if metroName != nil { - metroNamestr = metroName.(string) - } - region := llMap["region"].(string) - mc := llMap["metro_code"].(string) - ibx := llMap["ibx"].(string) - sl = v4.SimplifiedLocation{MetroCode: mc, Region: region, Ibx: ibx, MetroName: metroNamestr} - } - return sl -} - func virtualdeviceToFabric(virtualdeviceList []interface{}) v4.VirtualDevice { vd := v4.VirtualDevice{} for _, ll := range virtualdeviceList { @@ -307,16 +216,6 @@ func accountToCloudRouter(accountList []interface{}) v4.SimplifiedAccount { return sa } -func locationToCloudRouter(locationList []interface{}) v4.SimplifiedLocationWithoutIbx { - sl := v4.SimplifiedLocationWithoutIbx{} - for _, ll := range locationList { - llMap := ll.(map[string]interface{}) - mc := llMap["metro_code"].(string) - sl = v4.SimplifiedLocationWithoutIbx{MetroCode: mc} - } - return sl -} - func packageToCloudRouter(packageList []interface{}) v4.CloudRouterPackageType { p := v4.CloudRouterPackageType{} for _, pl := range packageList { @@ -327,19 +226,6 @@ func packageToCloudRouter(packageList []interface{}) v4.CloudRouterPackageType { return p } -func projectToCloudRouter(projectRequest []interface{}) v4.Project { - if projectRequest == nil { - return v4.Project{} - } - mappedPr := v4.Project{} - for _, pr := range projectRequest { - prMap := pr.(map[string]interface{}) - projectId := prMap["project_id"].(string) - mappedPr = v4.Project{ProjectId: projectId} - } - return mappedPr -} - func accountToTerra(account *v4.SimplifiedAccount) *schema.Set { if account == nil { return nil @@ -357,8 +243,9 @@ func accountToTerra(account *v4.SimplifiedAccount) *schema.Set { "global_cust_id": account.GlobalCustId, } } + hashAccount := &schema.Resource{Schema: equinix_schema.AccountSch()} accountSet := schema.NewSet( - schema.HashResource(createAccountRes), + schema.HashResource(hashAccount), mappedAccounts, ) @@ -384,38 +271,6 @@ func accountCloudRouterToTerra(account *v4.SimplifiedAccount) *schema.Set { return accountSet } -func errorToTerra(errors []v4.ModelError) []interface{} { - if errors == nil { - return nil - } - mappedErrors := make([]interface{}, len(errors)) - for index, mError := range errors { - mappedErrors[index] = map[string]interface{}{ - "error_code": mError.ErrorCode, - "error_message": mError.ErrorMessage, - "correlation_id": mError.CorrelationId, - "details": mError.Details, - "help": mError.Help, - "additional_info": errorAdditionalInfoToTerra(mError.AdditionalInfo), - } - } - return mappedErrors -} - -func errorAdditionalInfoToTerra(additionalInfol []v4.PriceErrorAdditionalInfo) []interface{} { - if additionalInfol == nil { - return nil - } - mappedAdditionalInfol := make([]interface{}, len(additionalInfol)) - for index, additionalInfo := range additionalInfol { - mappedAdditionalInfol[index] = map[string]interface{}{ - "property": additionalInfo.Property, - "reason": additionalInfo.Reason, - } - } - return mappedAdditionalInfol -} - func operationToTerra(operation *v4.ConnectionOperation) *schema.Set { if operation == nil { return nil @@ -427,151 +282,17 @@ func operationToTerra(operation *v4.ConnectionOperation) *schema.Set { mappedOperation["provider_status"] = string(*operation.ProviderStatus) mappedOperation["equinix_status"] = string(*operation.EquinixStatus) if operation.Errors != nil { - mappedOperation["errors"] = errorToTerra(operation.Errors) + mappedOperation["errors"] = equinix_schema.ErrorToTerra(operation.Errors) } mappedOperations = append(mappedOperations, mappedOperation) } - operationSet := schema.NewSet( - schema.HashResource(createOperationRes), + schema.HashResource(&schema.Resource{Schema: operationSch()}), mappedOperations, ) return operationSet } -func orderMappingToTerra(order *v4.Order) *schema.Set { - if order == nil { - return nil - } - orders := []*v4.Order{order} - mappedOrders := make([]interface{}, len(orders)) - for _, order := range orders { - mappedOrder := make(map[string]interface{}) - mappedOrder["purchase_order_number"] = order.PurchaseOrderNumber - mappedOrder["billing_tier"] = order.BillingTier - mappedOrder["order_id"] = order.OrderId - mappedOrder["order_number"] = order.OrderNumber - mappedOrders = append(mappedOrders, mappedOrder) - } - orderSet := schema.NewSet( - schema.HashResource(createOrderRes), - mappedOrders, - ) - return orderSet -} - -func changeLogToTerra(changeLog *v4.Changelog) *schema.Set { - if changeLog == nil { - return nil - } - changeLogs := []*v4.Changelog{changeLog} - mappedChangeLogs := make([]interface{}, len(changeLogs)) - for _, changeLog := range changeLogs { - mappedChangeLog := make(map[string]interface{}) - mappedChangeLog["created_by"] = changeLog.CreatedBy - mappedChangeLog["created_by_full_name"] = changeLog.CreatedByFullName - mappedChangeLog["created_by_email"] = changeLog.CreatedByEmail - mappedChangeLog["created_date_time"] = changeLog.CreatedDateTime.String() - mappedChangeLog["updated_by"] = changeLog.UpdatedBy - mappedChangeLog["updated_by_full_name"] = changeLog.UpdatedByFullName - mappedChangeLog["updated_date_time"] = changeLog.UpdatedDateTime.String() - mappedChangeLog["deleted_by"] = changeLog.DeletedBy - mappedChangeLog["deleted_by_full_name"] = changeLog.DeletedByFullName - mappedChangeLog["deleted_by_email"] = changeLog.DeletedByEmail - mappedChangeLog["deleted_date_time"] = changeLog.DeletedDateTime.String() - mappedChangeLogs = append(mappedChangeLogs, mappedChangeLog) - } - changeLogSet := schema.NewSet( - schema.HashResource(createChangeLogRes), - mappedChangeLogs, - ) - return changeLogSet -} - -func portRedundancyToTerra(redundancy *v4.PortRedundancy) *schema.Set { - redundancies := []*v4.PortRedundancy{redundancy} - mappedRedundancys := make([]interface{}, len(redundancies)) - for _, redundancy := range redundancies { - mappedRedundancy := make(map[string]interface{}) - mappedRedundancy["priority"] = string(*redundancy.Priority) - mappedRedundancys = append(mappedRedundancys, mappedRedundancy) - } - redundancySet := schema.NewSet( - schema.HashResource(createPortRedundancyRes), - mappedRedundancys, - ) - return redundancySet -} - -func redundancyToTerra(redundancy *v4.ConnectionRedundancy) *schema.Set { - if redundancy == nil { - return nil - } - redundancies := []*v4.ConnectionRedundancy{redundancy} - mappedRedundancys := make([]interface{}, len(redundancies)) - for _, redundancy := range redundancies { - mappedRedundancy := make(map[string]interface{}) - mappedRedundancy["group"] = redundancy.Group - mappedRedundancy["priority"] = string(*redundancy.Priority) - mappedRedundancys = append(mappedRedundancys, mappedRedundancy) - } - redundancySet := schema.NewSet( - schema.HashResource(createRedundancyRes), - mappedRedundancys, - ) - return redundancySet -} - -func notificationToTerra(notifications []v4.SimplifiedNotification) []map[string]interface{} { - if notifications == nil { - return nil - } - mappedNotifications := make([]map[string]interface{}, len(notifications)) - for index, notification := range notifications { - mappedNotifications[index] = map[string]interface{}{ - "type": notification.Type_, - "send_interval": notification.SendInterval, - "emails": notification.Emails, - } - } - return mappedNotifications -} - -func locationToTerra(location *v4.SimplifiedLocation) *schema.Set { - locations := []*v4.SimplifiedLocation{location} - mappedLocations := make([]interface{}, len(locations)) - for i, location := range locations { - mappedLocations[i] = map[string]interface{}{ - "region": location.Region, - "metro_name": location.MetroName, - "metro_code": location.MetroCode, - "ibx": location.Ibx, - } - } - locationSet := schema.NewSet( - schema.HashResource(createLocationRes), - mappedLocations, - ) - return locationSet -} - -func locationCloudRouterToTerra(location *v4.SimplifiedLocationWithoutIbx) *schema.Set { - locations := []*v4.SimplifiedLocationWithoutIbx{location} - mappedLocations := make([]interface{}, len(locations)) - for i, location := range locations { - mappedLocations[i] = map[string]interface{}{ - "region": location.Region, - "metro_name": location.MetroName, - "metro_code": location.MetroCode, - } - } - locationSet := schema.NewSet( - schema.HashResource(createLocationRes), - mappedLocations, - ) - return locationSet -} - func serviceTokenToTerra(serviceToken *v4.ServiceToken) *schema.Set { if serviceToken == nil { return nil @@ -588,7 +309,7 @@ func serviceTokenToTerra(serviceToken *v4.ServiceToken) *schema.Set { mappedServiceTokens = append(mappedServiceTokens, mappedServiceToken) } serviceTokenSet := schema.NewSet( - schema.HashResource(createServiceTokenRes), + schema.HashResource(&schema.Resource{Schema: serviceTokenSch()}), mappedServiceTokens, ) return serviceTokenSet @@ -607,7 +328,7 @@ func connectionSideToTerra(connectionSide *v4.ConnectionSide) *schema.Set { mappedConnectionSides = append(mappedConnectionSides, mappedConnectionSide) } connectionSideSet := schema.NewSet( - schema.HashResource(createFabricConnectionSideRes()), + schema.HashResource(connectionSideSch()), mappedConnectionSides, ) return connectionSideSet @@ -640,7 +361,7 @@ func cloudRouterToTerra(cloudRouter *v4.CloudRouter) *schema.Set { mappedCloudRouters = append(mappedCloudRouters, mappedCloudRouter) } linkedProtocolSet := schema.NewSet( - schema.HashResource(createGatewayProjectSchRes), + schema.HashResource(&schema.Resource{Schema: equinix_schema.ProjectSch()}), mappedCloudRouters) return linkedProtocolSet } @@ -660,43 +381,6 @@ func cloudRouterPackageToTerra(packageType *v4.CloudRouterPackageType) *schema.S return packageSet } -func orderToTerra(order *v4.Order) *schema.Set { - if order == nil { - return nil - } - orders := []*v4.Order{order} - mappedOrders := make([]interface{}, len(orders)) - for _, order := range orders { - mappedOrder := make(map[string]interface{}) - mappedOrder["purchase_order_number"] = order.PurchaseOrderNumber - mappedOrder["billing_tier"] = order.BillingTier - mappedOrder["order_id"] = order.OrderId - mappedOrder["order_number"] = order.OrderNumber - mappedOrders = append(mappedOrders, mappedOrder) - } - orderSet := schema.NewSet( - schema.HashResource(readOrderRes), - mappedOrders) - return orderSet -} - -func projectToTerra(project *v4.Project) *schema.Set { - if project == nil { - return nil - } - projects := []*v4.Project{project} - mappedProjects := make([]interface{}, len(projects)) - for _, project := range projects { - mappedProject := make(map[string]interface{}) - mappedProject["project_id"] = project.ProjectId - mappedProjects = append(mappedProjects, mappedProject) - } - projectSet := schema.NewSet( - schema.HashResource(readGatewayProjectSchRes), - mappedProjects) - return projectSet -} - func virtualDeviceToTerra(virtualDevice *v4.VirtualDevice) *schema.Set { if virtualDevice == nil { return nil @@ -712,7 +396,7 @@ func virtualDeviceToTerra(virtualDevice *v4.VirtualDevice) *schema.Set { mappedVirtualDevices = append(mappedVirtualDevices, mappedVirtualDevice) } virtualDeviceSet := schema.NewSet( - schema.HashResource(createAccessPointVirtualDeviceRes), + schema.HashResource(&schema.Resource{Schema: accessPointVirtualDeviceSch()}), mappedVirtualDevices) return virtualDeviceSet } @@ -731,7 +415,7 @@ func interfaceToTerra(mInterface *v4.ModelInterface) *schema.Set { mappedMInterfaces = append(mappedMInterfaces, mappedMInterface) } mInterfaceSet := schema.NewSet( - schema.HashResource(createAccessPointVirtualDeviceRes), + schema.HashResource(&schema.Resource{Schema: accessPointInterface()}), mappedMInterfaces) return mInterfaceSet } @@ -748,7 +432,7 @@ func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set { mappedAccessPoint["account"] = accountToTerra(accessPoint.Account) } if accessPoint.Location != nil { - mappedAccessPoint["location"] = locationToTerra(accessPoint.Location) + mappedAccessPoint["location"] = equinix_schema.LocationToTerra(accessPoint.Location) } if accessPoint.Port != nil { mappedAccessPoint["port"] = portToTerra(accessPoint.Port) @@ -758,6 +442,7 @@ func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set { } if accessPoint.Router != nil { mappedAccessPoint["router"] = cloudRouterToTerra(accessPoint.Router) + mappedAccessPoint["gateway"] = cloudRouterToTerra(accessPoint.Router) } if accessPoint.LinkProtocol != nil { mappedAccessPoint["link_protocol"] = linkedProtocolToTerra(*accessPoint.LinkProtocol) @@ -777,7 +462,7 @@ func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set { mappedAccessPoints = append(mappedAccessPoints, mappedAccessPoint) } accessPointSet := schema.NewSet( - schema.HashResource(createConnectionSideAccessPointRes()), + schema.HashResource(accessPointSch()), mappedAccessPoints, ) return accessPointSet @@ -795,7 +480,7 @@ func linkedProtocolToTerra(linkedProtocol v4.SimplifiedLinkProtocol) *schema.Set mappedLinkedProtocols = append(mappedLinkedProtocols, mappedLinkedProtocol) } linkedProtocolSet := schema.NewSet( - schema.HashResource(createAccessPointLinkProtocolSchRes), + schema.HashResource(&schema.Resource{Schema: accessPointLinkProtocolSch()}), mappedLinkedProtocols) return linkedProtocolSet } @@ -814,7 +499,7 @@ func simplifiedServiceProfileToTerra(profile *v4.SimplifiedServiceProfile) *sche } profileSet := schema.NewSet( - schema.HashResource(createServiceProfileSchRes), + schema.HashResource(&schema.Resource{Schema: serviceProfileSch()}), mappedProfiles, ) return profileSet @@ -886,26 +571,6 @@ func supportedBandwidthsToTerra(supportedBandwidths *[]int32) []interface{} { return mappedSupportedBandwidths } -func portToTerra(port *v4.SimplifiedPort) *schema.Set { - ports := []*v4.SimplifiedPort{port} - mappedPorts := make([]interface{}, len(ports)) - for _, port := range ports { - mappedPort := make(map[string]interface{}) - mappedPort["href"] = port.Href - mappedPort["name"] = port.Name - mappedPort["uuid"] = port.Uuid - if port.Redundancy != nil { - mappedPort["redundancy"] = portRedundancyToTerra(port.Redundancy) - } - mappedPorts = append(mappedPorts, mappedPort) - } - portSet := schema.NewSet( - schema.HashResource(createPortRes), - mappedPorts, - ) - return portSet -} - func routingProtocolDirectIpv4ToFabric(routingProtocolDirectIpv4Request []interface{}) v4.DirectConnectionIpv4 { mappedRpDirectIpv4 := v4.DirectConnectionIpv4{} for _, str := range routingProtocolDirectIpv4Request { @@ -1139,7 +804,7 @@ func routingProtocolOperationToTerra(routingProtocolOperation *v4.RoutingProtoco for _, routingProtocolOperation := range routingProtocolOperations { mappedRpOperation := make(map[string]interface{}) if routingProtocolOperation.Errors != nil { - mappedRpOperation["errors"] = errorToTerra(routingProtocolOperation.Errors) + mappedRpOperation["errors"] = equinix_schema.ErrorToTerra(routingProtocolOperation.Errors) } mappedRpOperations = append(mappedRpOperations, mappedRpOperation) } diff --git a/equinix/fabric_mapping_service_profile_helper.go b/equinix/fabric_mapping_service_profile_helper.go index 6a7ab792e..84fef5bdb 100644 --- a/equinix/fabric_mapping_service_profile_helper.go +++ b/equinix/fabric_mapping_service_profile_helper.go @@ -3,6 +3,7 @@ package equinix import ( v4 "github.com/equinix-labs/fabric-go/fabric/v4" "github.com/equinix/terraform-provider-equinix/internal/converters" + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -55,7 +56,7 @@ func marketingInfoMappingToTerra(mkinfo *v4.MarketingInfo) *schema.Set { mappedMkInfos = append(mappedMkInfos, mappedMkInfo) } marketingInfoSet := schema.NewSet( - schema.HashResource(readOrderRes), + schema.HashResource(&schema.Resource{Schema: equinix_schema.OrderSch()}), mappedMkInfos, ) return marketingInfoSet @@ -70,7 +71,7 @@ func accessPointColoFabricSpToTerra(accessPointColol []v4.ServiceProfileAccessPo mappedAccessPointColol[index] = map[string]interface{}{ "type": accessPointColo.Type_, "uuid": accessPointColo.Uuid, - "location": locationToTerra(accessPointColo.Location), + "location": equinix_schema.LocationToTerra(accessPointColo.Location), "seller_region": accessPointColo.SellerRegion, "seller_region_description": accessPointColo.SellerRegionDescription, "cross_connect_id": accessPointColo.CrossConnectId, @@ -338,7 +339,7 @@ func portsToFabric(schemaPorts []interface{}) []v4.ServiceProfileAccessPointColo locationList := port.(map[string]interface{})["location"].(interface{}).(*schema.Set).List() pLocation := v4.SimplifiedLocation{} if len(locationList) != 0 { - pLocation = locationToFabric(locationList) + pLocation = equinix_schema.LocationToFabric(locationList) } pSellerRegion := port.(map[string]interface{})["seller_region"].(string) pSellerRegionDescription := port.(map[string]interface{})["seller_region_description"].(string) @@ -366,7 +367,7 @@ func virtualDevicesToFabric(schemaVirtualDevices []interface{}) []v4.ServiceProf locationList := virtualDevice.(map[string]interface{})["location"].(interface{}).(*schema.Set).List() vLocation := v4.SimplifiedLocation{} if len(locationList) != 0 { - vLocation = locationToFabric(locationList) + vLocation = equinix_schema.LocationToFabric(locationList) } pInterfaceUuid := virtualDevice.(map[string]interface{})["interface_uuid"].(string) virtualDevices = append(virtualDevices, v4.ServiceProfileAccessPointVd{ @@ -417,7 +418,7 @@ func fabricServiceProfilesListToTerra(serviceProfiles v4.ServiceProfiles) []map[ "name": serviceProfile.Name, "uuid": serviceProfile.Uuid, "description": serviceProfile.Description, - "notifications": notificationToTerra(serviceProfile.Notifications), + "notifications": equinix_schema.NotificationsToTerra(serviceProfile.Notifications), "tags": tagsFabricSpToTerra(serviceProfile.Tags), "visibility": serviceProfile.Visibility, "access_point_type_configs": accessPointTypeConfigToTerra(serviceProfile.AccessPointTypeConfigs), @@ -429,7 +430,7 @@ func fabricServiceProfilesListToTerra(serviceProfiles v4.ServiceProfiles) []map[ "self_profile": serviceProfile.SelfProfile, "state": serviceProfile.State, "account": serviceProfileAccountFabricSpToTerra(serviceProfile.Account), - "project": projectToTerra(serviceProfile.Project), + "project": equinix_schema.ProjectToTerra(serviceProfile.Project), "change_log": allOfServiceProfileChangeLogToTerra(serviceProfile.ChangeLog), } } diff --git a/equinix/fabric_port_mapping_helper.go b/equinix/fabric_port_mapping_helper.go deleted file mode 100644 index 9b4325732..000000000 --- a/equinix/fabric_port_mapping_helper.go +++ /dev/null @@ -1,136 +0,0 @@ -package equinix - -import ( - v4 "github.com/equinix-labs/fabric-go/fabric/v4" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func portApiPortRedundancyToTerr(redundancy *v4.PortRedundancy) *schema.Set { - if redundancy == nil { - return nil - } - redundancies := []*v4.PortRedundancy{redundancy} - mappedRedundancies := make([]interface{}, 0) - for _, redundancy := range redundancies { - mappedRedundancy := make(map[string]interface{}) - mappedRedundancy["enabled"] = redundancy.Enabled - mappedRedundancy["group"] = redundancy.Group - mappedRedundancy["priority"] = string(*redundancy.Priority) - mappedRedundancies = append(mappedRedundancies, mappedRedundancy) - } - redundancySet := schema.NewSet( - schema.HashResource(readPortsRedundancyRes), - mappedRedundancies, - ) - return redundancySet -} - -func portOperationToTerra(operation *v4.PortOperation) *schema.Set { - if operation == nil { - return nil - } - operations := []*v4.PortOperation{operation} - mappedOperations := make([]interface{}, 0) - for _, operation := range operations { - mappedOperation := make(map[string]interface{}) - mappedOperation["operational_status"] = operation.OperationalStatus - mappedOperation["connection_count"] = operation.ConnectionCount - mappedOperation["op_status_changed_at"] = operation.OpStatusChangedAt.String() - mappedOperations = append(mappedOperations, mappedOperation) - } - operationSet := schema.NewSet( - schema.HashResource(createOperationRes), - mappedOperations, - ) - return operationSet -} - -func portDeviceRedundancyToTerra(redundancy *v4.PortDeviceRedundancy) *schema.Set { - if redundancy == nil { - return nil - } - redundancies := []*v4.PortDeviceRedundancy{redundancy} - mappedRedundancies := make([]interface{}, 0) - for _, redundancy := range redundancies { - mappedRedundancy := make(map[string]interface{}) - mappedRedundancy["group"] = redundancy.Group - mappedRedundancy["priority"] = redundancy.Priority - mappedRedundancies = append(mappedRedundancies, mappedRedundancy) - } - redundancySet := schema.NewSet( - schema.HashResource(readPortDeviceRedundancyRes), - mappedRedundancies, - ) - return redundancySet -} - -func deviceToTerra(device *v4.PortDevice) *schema.Set { - if device == nil { - return nil - } - devices := []*v4.PortDevice{device} - mappedDevices := make([]interface{}, 0) - for _, device := range devices { - mappedDevice := make(map[string]interface{}) - mappedDevice["name"] = device.Name - if device.Redundancy != nil { - mappedDevice["redundancy"] = portDeviceRedundancyToTerra(device.Redundancy) - } - mappedDevices = append(mappedDevices, mappedDevice) - } - deviceSet := schema.NewSet( - schema.HashResource(readPortDeviceRes), - mappedDevices, - ) - return deviceSet -} - -func encapsulationToTerra(portEncapsulation *v4.PortEncapsulation) *schema.Set { - if portEncapsulation == nil { - return nil - } - portEncapsulations := []*v4.PortEncapsulation{portEncapsulation} - mappedPortEncapsulations := make([]interface{}, 0) - for _, portEncapsulation := range portEncapsulations { - mappedPortEncapsulation := make(map[string]interface{}) - mappedPortEncapsulation["type"] = portEncapsulation.Type_ - mappedPortEncapsulation["tag_protocol_id"] = portEncapsulation.TagProtocolId - mappedPortEncapsulations = append(mappedPortEncapsulations, mappedPortEncapsulation) - } - portEncapsulationSet := schema.NewSet( - schema.HashResource(readPortEncapsulationRes), - mappedPortEncapsulations, - ) - return portEncapsulationSet -} - -func fabricPortsListToTerra(ports v4.AllPortsResponse) []map[string]interface{} { - portsl := ports.Data - if portsl == nil { - return nil - } - mappedPortsl := make([]map[string]interface{}, len(portsl)) - for index, port := range portsl { - mappedPortsl[index] = map[string]interface{}{ - "uuid": port.Uuid, - "name": port.Name, - "bandwidth": port.Bandwidth, - "available_bandwidth": port.AvailableBandwidth, - "used_bandwidth": port.UsedBandwidth, - "href": port.Href, - "description": port.Description, - "type": port.Type_, - "state": port.State, - "service_type": port.ServiceType, - "operation": portOperationToTerra(port.Operation), - "redundancy": portApiPortRedundancyToTerr(port.Redundancy), - "account": accountToTerra(port.Account), - "change_log": changeLogToTerra(port.Changelog), - "location": locationToTerra(port.Location), - "device": deviceToTerra(port.Device), - "encapsulation": encapsulationToTerra(port.Encapsulation), - "lag_enabled": port.LagEnabled, - } - } - return mappedPortsl -} diff --git a/equinix/fabric_port_read_schema.go b/equinix/fabric_port_read_schema.go deleted file mode 100644 index d5ad98174..000000000 --- a/equinix/fabric_port_read_schema.go +++ /dev/null @@ -1,354 +0,0 @@ -package equinix - -import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -var readPortDeviceRes = &schema.Resource{ - Schema: readPortDeviceSch(), -} - -func readPortDeviceSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port name", - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Port device redundancy", - Elem: &schema.Resource{ - Schema: readRedundancySch(), - }, - }, - } -} - -var readPortDeviceRedundancyRes = &schema.Resource{ - Schema: readRedundancySch(), -} - -var readPortInterfaceRes = &schema.Resource{ - Schema: readPortInterfaceSch(), -} - -func readPortInterfaceSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Port interface type", - }, - "if_index": { - Type: schema.TypeString, - Computed: true, - Description: "Port interface index", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port interface name", - }, - } -} - -var readPortEncapsulationRes = &schema.Resource{ - Schema: readFabricPortEncapsulation(), -} - -func readFabricPortEncapsulation() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Port encapsulation protocol type", - }, - "tag_protocol_id": { - Type: schema.TypeString, - Computed: true, - Description: "Port encapsulation Tag Protocol Identifier", - }, - } -} - -var readPortLagRes = &schema.Resource{ - Schema: readFabricPortLag(), -} - -func readFabricPortLag() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "If LAG enabled", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "Link aggregation group identifier", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Link aggregation group name", - }, - "member_status": { - Type: schema.TypeString, - Computed: true, - Description: "LAG port status", - }, - } -} - -var readPortSettingsRes = &schema.Resource{ - Schema: readFabricPortSettings(), -} - -func readFabricPortSettings() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "port_type": { - Type: schema.TypeString, - Computed: true, - Description: "Port type", - }, - } -} - -func readPortOperationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "operational_status": { - Type: schema.TypeString, - Computed: true, - Description: "Port operation status", - }, - "connection_count": { - Type: schema.TypeInt, - Computed: true, - Description: "Total number of current connections", - }, - "op_status_changed_at": { - Type: schema.TypeString, - Computed: true, - Description: "Date and time at which port availability changed", - }, - } -} - -var readPortsRedundancyRes = &schema.Resource{ - Schema: readPortsRedundancySch(), -} - -func readPortsRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "Access point redundancy", - }, - "group": { - Type: schema.TypeString, - Computed: true, - Description: "Port redundancy group", - }, - "priority": { - Type: schema.TypeString, - Computed: true, - Description: "Priority type-Primary or Secondary", - }, - } -} - -var readPortTetherRes = &schema.Resource{ - Schema: readFabricPortTether(), -} - -func readFabricPortTether() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "cross_connect_id": { - Type: schema.TypeString, - Computed: true, - Description: "Port cross connect identifier", - }, - "cabinet_number": { - Type: schema.TypeString, - Computed: true, - Description: "Port cabinet number", - }, - "system_name": { - Type: schema.TypeString, - Computed: true, - Description: "Port system name", - }, - "patch_panel": { - Type: schema.TypeString, - Computed: true, - Description: "Port patch panel", - }, - "patch_panel_port_a": { - Type: schema.TypeString, - Computed: true, - Description: "Port patch panel port A", - }, - "patch_panel_port_b": { - Type: schema.TypeString, - Computed: true, - Description: "Port patch panel port B", - }, - } -} - -func readFabricPortResourceSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Computed: true, - Description: "Port type", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Port URI information", - }, - "uuid": { - Type: schema.TypeString, - Required: true, - Description: "Equinix-assigned port identifier", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port name", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "Port description", - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: "Port state", - }, - "operation": { - Type: schema.TypeSet, - Computed: true, - Description: "Port specific operational data", - Elem: &schema.Resource{ - Schema: readPortOperationSch(), - }, - }, - "bandwidth": { - Type: schema.TypeInt, - Computed: true, - Description: "Port bandwidth in Mbps", - }, - "available_bandwidth": { - Type: schema.TypeInt, - Computed: true, - Description: "Port available bandwidth in Mbps", - }, - "used_bandwidth": { - Type: schema.TypeInt, - Computed: true, - Description: "Port used bandwidth in Mbps", - }, - "service_type": { - Type: schema.TypeString, - Computed: true, - Description: "Port service type", - }, - "account": { - Type: schema.TypeSet, - Computed: true, - Description: "Customer account information that is associated with this port", - Elem: &schema.Resource{ - Schema: readAccountSch(), - }, - }, - "change_log": { - Type: schema.TypeSet, - Computed: true, - Description: "Captures port lifecycle change information", - Elem: &schema.Resource{ - Schema: readChangeLogSch(), - }, - }, - "location": { - Type: schema.TypeSet, - Computed: true, - Description: "Port location information", - Elem: &schema.Resource{ - Schema: readLocationSch(), - }, - }, - "device": { - Type: schema.TypeSet, - Computed: true, - Description: "Port device", - Elem: &schema.Resource{ - Schema: readPortDeviceSch(), - }, - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Port redundancy information", - Elem: &schema.Resource{ - Schema: readPortsRedundancySch(), - }, - }, - "encapsulation": { - Type: schema.TypeSet, - Computed: true, - Description: "Port encapsulation protocol", - Elem: &schema.Resource{ - Schema: readFabricPortEncapsulation(), - }, - }, - "lag_enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "Port Lag", - }, - } -} - -func readGetPortsByNameQueryParamSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - Description: "Query Parameter to Get Ports By Name", - }, - } -} - -func readFabricPortResourceSchemaUpdated() map[string]*schema.Schema { - sch := readFabricPortResourceSchema() - sch["uuid"].Optional = true - sch["uuid"].Required = false - return sch -} - -func readFabricPortsResponseSchema() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "data": { - Type: schema.TypeList, - Computed: true, - Description: "List of Ports", - Elem: &schema.Resource{ - Schema: readFabricPortResourceSchemaUpdated(), - }, - }, - "filters": { - Type: schema.TypeSet, - Optional: true, - Description: "name", - Elem: &schema.Resource{ - Schema: readGetPortsByNameQueryParamSch(), - }, - }, - } -} diff --git a/equinix/fabric_routing_protocol_read_schema.go b/equinix/fabric_routing_protocol_read_schema.go index d14fc6c41..dd7e4d436 100644 --- a/equinix/fabric_routing_protocol_read_schema.go +++ b/equinix/fabric_routing_protocol_read_schema.go @@ -1,6 +1,7 @@ package equinix import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "golang.org/x/exp/maps" ) @@ -189,7 +190,7 @@ func readRoutingProtocolOperationSch() map[string]*schema.Schema { Computed: true, Description: "Errors occurred", Elem: &schema.Resource{ - Schema: readOperationalErrorSch(), + Schema: equinix_schema.ErrorSch(), }, }, } @@ -334,7 +335,7 @@ func readFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Captures Routing Protocol lifecycle change information", Elem: &schema.Resource{ - Schema: readChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, } diff --git a/equinix/fabric_routing_protocol_schema.go b/equinix/fabric_routing_protocol_schema.go index 5e500796b..585013dc2 100644 --- a/equinix/fabric_routing_protocol_schema.go +++ b/equinix/fabric_routing_protocol_schema.go @@ -1,6 +1,7 @@ package equinix import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "golang.org/x/exp/maps" @@ -227,7 +228,7 @@ func createRoutingProtocolOperationSch() map[string]*schema.Schema { Computed: true, Description: "Errors occurred", Elem: &schema.Resource{ - Schema: createOperationalErrorSch(), + Schema: equinix_schema.ErrorSch(), }, }, } @@ -378,7 +379,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Captures Routing Protocol lifecycle change information", Elem: &schema.Resource{ - Schema: createChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, } diff --git a/equinix/fabric_service_profile_read_schema.go b/equinix/fabric_service_profile_read_schema.go index 887b4dd50..e9d4b0ec7 100644 --- a/equinix/fabric_service_profile_read_schema.go +++ b/equinix/fabric_service_profile_read_schema.go @@ -1,6 +1,7 @@ package equinix import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +42,7 @@ func readFabricServiceProfileSchema() map[string]*schema.Schema { Computed: true, Description: "Preferences for notifications on connection configuration or status changes", Elem: &schema.Resource{ - Schema: readNotificationSch(), + Schema: equinix_schema.NotificationSch(), }, }, "access_point_type_configs": { @@ -49,7 +50,7 @@ func readFabricServiceProfileSchema() map[string]*schema.Schema { Computed: true, Description: "Access point config information", Elem: &schema.Resource{ - Schema: readAccessPointTypeConfigSch(), + Schema: serviceProfileAccessPointTypeConfigSch(), }, }, @@ -122,7 +123,7 @@ func readFabricServiceProfileSchema() map[string]*schema.Schema { Computed: true, Description: "Project information", Elem: &schema.Resource{ - Schema: readCloudRouterProjectSch(), + Schema: equinix_schema.ProjectSch(), }, }, "change_log": { @@ -130,7 +131,7 @@ func readFabricServiceProfileSchema() map[string]*schema.Schema { Computed: true, Description: "Captures connection lifecycle change information", Elem: &schema.Resource{ - Schema: readChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, } @@ -283,7 +284,7 @@ func readServiceProfileAccessPointColo() map[string]*schema.Schema { Computed: true, Description: "Colo/Port Location", Elem: &schema.Resource{ - Schema: createLocationSch(), + Schema: equinix_schema.LocationSch(), }, }, "seller_region": { @@ -414,21 +415,6 @@ func readAllOfServiceProfileChangeLogSch() map[string]*schema.Schema { } } -func readCloudRouterProjectSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Computed: true, - Description: "Project Id", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource URL", - }, - } -} - func readFabricServiceProfileSchemaUpdated() map[string]*schema.Schema { sch := readFabricServiceProfileSchema() sch["uuid"].Optional = true @@ -470,11 +456,3 @@ func readFabricServiceProfilesSearchSchema() map[string]*schema.Schema { }, } } - -var readOrderRes = &schema.Resource{ - Schema: readOrderSch(), -} - -var readGatewayProjectSchRes = &schema.Resource{ - Schema: readCloudRouterProjectSch(), -} diff --git a/equinix/fabric_service_profile_schema.go b/equinix/fabric_service_profile_schema.go index a2db1adbe..1a94dcac6 100644 --- a/equinix/fabric_service_profile_schema.go +++ b/equinix/fabric_service_profile_schema.go @@ -1,6 +1,7 @@ package equinix import ( + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -41,7 +42,7 @@ func createFabricServiceProfileSchema() map[string]*schema.Schema { Optional: true, Description: "Preferences for notifications on connection configuration or status changes", Elem: &schema.Resource{ - Schema: createNotificationSch(), + Schema: equinix_schema.NotificationSch(), }, }, "access_point_type_configs": { @@ -132,7 +133,7 @@ func createFabricServiceProfileSchema() map[string]*schema.Schema { Description: "Project information", MaxItems: 1, Elem: &schema.Resource{ - Schema: createGatewayProjectSch(), + Schema: equinix_schema.ProjectSch(), }, }, "change_log": { @@ -140,7 +141,7 @@ func createFabricServiceProfileSchema() map[string]*schema.Schema { Computed: true, Description: "Captures connection lifecycle change information", Elem: &schema.Resource{ - Schema: createChangeLogSch(), + Schema: equinix_schema.ChangeLogSch(), }, }, } @@ -245,7 +246,7 @@ func createServiceProfileAccessPointColo() map[string]*schema.Schema { Description: "Colo/Port Location", MaxItems: 1, Elem: &schema.Resource{ - Schema: createLocationSch(), + Schema: equinix_schema.LocationSch(), }, }, "seller_region": { @@ -284,7 +285,7 @@ func createServiceProfileAccessPointVd() map[string]*schema.Schema { Description: "Device Location", MaxItems: 1, Elem: &schema.Resource{ - Schema: createLocationSch(), + Schema: equinix_schema.LocationSch(), }, }, "interface_uuid": { diff --git a/equinix/resource_fabric_cloud_router.go b/equinix/resource_fabric_cloud_router.go index e67955ff9..96c6903a9 100644 --- a/equinix/resource_fabric_cloud_router.go +++ b/equinix/resource_fabric_cloud_router.go @@ -8,6 +8,7 @@ import ( "time" equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" + equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -35,7 +36,7 @@ func resourceCloudRouter() *schema.Resource { }, Schema: createCloudRouterResourceSchema(), - Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric Cloud Router\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric Cloud Router", } } @@ -43,15 +44,15 @@ func resourceCloudRouterCreate(ctx context.Context, d *schema.ResourceData, meta client := meta.(*config.Config).FabricClient ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) schemaNotifications := d.Get("notifications").([]interface{}) - notifications := notificationToFabric(schemaNotifications) + notifications := equinix_fabric_schema.NotificationsToFabric(schemaNotifications) schemaAccount := d.Get("account").(*schema.Set).List() account := accountToCloudRouter(schemaAccount) schemaLocation := d.Get("location").(*schema.Set).List() - location := locationToCloudRouter(schemaLocation) + location := equinix_fabric_schema.LocationWithoutIBXToFabric(schemaLocation) project := v4.Project{} schemaProject := d.Get("project").(*schema.Set).List() if len(schemaProject) != 0 { - project = projectToCloudRouter(schemaProject) + project = equinix_fabric_schema.ProjectToFabric(schemaProject) } schemaPackage := d.Get("package").(*schema.Set).List() packages := packageToCloudRouter(schemaPackage) @@ -67,7 +68,7 @@ func resourceCloudRouterCreate(ctx context.Context, d *schema.ResourceData, meta } if v, ok := d.GetOk("order"); ok { - order := orderToFabric(v.(*schema.Set).List()) + order := equinix_fabric_schema.OrderToFabric(v.(*schema.Set).List()) createRequest.Order = &order } @@ -107,16 +108,16 @@ func setCloudRouterMap(d *schema.ResourceData, fcr v4.CloudRouter) diag.Diagnost "type": fcr.Type_, "state": fcr.State, "package": cloudRouterPackageToTerra(fcr.Package_), - "location": locationCloudRouterToTerra(fcr.Location), - "change_log": changeLogToTerra(fcr.ChangeLog), + "location": equinix_fabric_schema.LocationWithoutIBXToTerra(fcr.Location), + "change_log": equinix_fabric_schema.ChangeLogToTerra(fcr.ChangeLog), "account": accountCloudRouterToTerra(fcr.Account), - "notifications": notificationToTerra(fcr.Notifications), - "project": projectToTerra(fcr.Project), + "notifications": equinix_fabric_schema.NotificationsToTerra(fcr.Notifications), + "project": equinix_fabric_schema.ProjectToTerra(fcr.Project), "equinix_asn": fcr.EquinixAsn, "bgp_ipv4_routes_count": fcr.BgpIpv4RoutesCount, "bgp_ipv6_routes_count": fcr.BgpIpv6RoutesCount, "connections_count": fcr.ConnectionsCount, - "order": orderToTerra(fcr.Order), + "order": equinix_fabric_schema.OrderToTerra(fcr.Order), }) if err != nil { return diag.FromErr(err) diff --git a/equinix/resource_fabric_connection.go b/equinix/resource_fabric_connection.go index 64d882cf1..ac97ce470 100644 --- a/equinix/resource_fabric_connection.go +++ b/equinix/resource_fabric_connection.go @@ -3,11 +3,13 @@ package equinix import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "log" "strings" "time" equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" + equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -18,6 +20,574 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +func fabricConnectionResourceSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"EVPL_VC", "EPL_VC", "IP_VC", "IPWAN_VC", "ACCESS_EPL_VC", "EVPLAN_VC", "EPLAN_VC", "EIA_VC", "EC_VC"}, false), + Description: "Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, EC_VC", + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 24), + Description: "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores", + }, + "order": { + Type: schema.TypeSet, + Required: true, + Description: "Order details", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.OrderSch(), + }, + }, + "notifications": { + Type: schema.TypeList, + Required: true, + Description: "Preferences for notifications on connection configuration or status changes", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.NotificationSch(), + }, + }, + "bandwidth": { + Type: schema.TypeInt, + Required: true, + Description: "Connection bandwidth in Mbps", + }, + //"geo_scope": { + // Type: schema.TypeString, + // Optional: true, + // ValidateFunc: validation.StringInSlice([]string{"CANADA", "CONUS"}, false), + // Description: "Geographic boundary types", + //}, + "redundancy": { + Type: schema.TypeSet, + Optional: true, + Description: "Connection Redundancy Configuration", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: connectionRedundancySch(), + }, + }, + "a_side": { + Type: schema.TypeSet, + Required: true, + Description: "Requester or Customer side connection configuration object of the multi-segment connection", + MaxItems: 1, + Elem: connectionSideSch(), + Set: schema.HashResource(accessPointSch()), + }, + "z_side": { + Type: schema.TypeSet, + Required: true, + Description: "Destination or Provider side connection configuration object of the multi-segment connection", + MaxItems: 1, + Elem: connectionSideSch(), + Set: schema.HashResource(accessPointSch()), + }, + "project": { + Type: schema.TypeSet, + Optional: true, + Description: "Project information", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.ProjectSch(), + }, + }, + "additional_info": { + Type: schema.TypeList, + Optional: true, + Description: "Connection additional information", + Elem: &schema.Schema{ + Type: schema.TypeMap, + }, + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Connection URI information", + }, + "uuid": { + Type: schema.TypeString, + Computed: true, + Description: "Equinix-assigned connection identifier", + }, + "description": { + Type: schema.TypeString, + Optional: true, + Description: "Customer-provided connection description", + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: "Connection overall state", + }, + "operation": { + Type: schema.TypeSet, + Computed: true, + Description: "Connection type-specific operational data", + Elem: &schema.Resource{ + Schema: operationSch(), + }, + }, + "account": { + Type: schema.TypeSet, + Computed: true, + Description: "Customer account information that is associated with this connection", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.AccountSch(), + }, + }, + "change_log": { + Type: schema.TypeSet, + Computed: true, + Description: "Captures connection lifecycle change information", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.ChangeLogSch(), + }, + }, + "is_remote": { + Type: schema.TypeBool, + Computed: true, + Description: "Connection property derived from access point locations", + }, + "direction": { + Type: schema.TypeString, + Computed: true, + Description: "Connection directionality from the requester point of view", + }, + } +} + +func connectionSideSch() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "service_token": { + Type: schema.TypeSet, + Optional: true, + Description: "For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: serviceTokenSch(), + }, + }, + "access_point": { + Type: schema.TypeSet, + Optional: true, + Description: "Point of access details", + MaxItems: 1, + Elem: accessPointSch(), + }, + "additional_info": { + Type: schema.TypeList, + Optional: true, + Description: "Connection side additional information", + Elem: &schema.Resource{ + Schema: additionalInfoSch(), + }, + }, + }, + } +} + +func serviceTokenSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"VC_TOKEN"}, true), + Description: "Token type - VC_TOKEN", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "An absolute URL that is the subject of the link's context", + }, + "uuid": { + Type: schema.TypeString, + Optional: true, + Description: "Equinix-assigned service token identifier", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Service token description", + }, + } +} + +func accessPointSch() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "CLOUD_ROUTER", "NETWORK"}, true), + Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK", + }, + "account": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Description: "Account", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.AccountSch(), + }, + }, + "location": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Description: "Access point location", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.LocationSch(), + }, + }, + "port": { + Type: schema.TypeSet, + Optional: true, + Description: "Port access point information", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: portSch(), + }, + }, + "profile": { + Type: schema.TypeSet, + Optional: true, + Description: "Service Profile", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: serviceProfileSch(), + }, + }, + "gateway": { + Type: schema.TypeSet, + Optional: true, + Deprecated: "use router attribute instead; gateway is no longer a part of the supported backend", + Description: "**Deprecated** `gateway` Use `router` attribute instead", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: cloudRouterSch(), + }, + }, + "router": { + Type: schema.TypeSet, + Optional: true, + Description: "Cloud Router access point information that replaces `gateway`", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: cloudRouterSch(), + }, + }, + "link_protocol": { + Type: schema.TypeSet, + Optional: true, + Description: "Connection link protocol", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: accessPointLinkProtocolSch(), + }, + }, + "virtual_device": { + Type: schema.TypeSet, + Optional: true, + Description: "Virtual device", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: accessPointVirtualDeviceSch(), + }, + }, + "interface": { + Type: schema.TypeSet, + Optional: true, + Description: "Virtual device interface", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: accessPointInterface(), + }, + }, + "network": { + Type: schema.TypeSet, + Optional: true, + Description: "network access point information", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: networkSch(), + }, + }, + "seller_region": { + Type: schema.TypeString, + Optional: true, + Description: "Access point seller region", + }, + "peering_type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "MICROSOFT", "PUBLIC", "MANUAL"}, true), + Description: "Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL", + }, + "authentication_key": { + Type: schema.TypeString, + Optional: true, + Description: "Authentication key for provider based connections", + }, + "provider_connection_id": { + Type: schema.TypeString, + Optional: true, + Description: "Provider assigned Connection Id", + }, + }, + } +} + +func serviceProfileSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Service Profile URI response attribute", + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"L2_PROFILE", "L3_PROFILE", "ECIA_PROFILE", "ECMC_PROFILE"}, true), + Description: "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Customer-assigned service profile name", + }, + "uuid": { + Type: schema.TypeString, + Required: true, + Description: "Equinix assigned service profile identifier", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "User-provided service description", + }, + "access_point_type_configs": { + Type: schema.TypeList, + Computed: true, + Description: "Access point config information", + Elem: &schema.Resource{ + Schema: connectionAccessPointTypeConfigSch(), + }, + }, + } +} + +func cloudRouterSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "uuid": { + Type: schema.TypeString, + Optional: true, + Description: "Equinix-assigned virtual gateway identifier", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource Identifier", + }, + } +} + +func accessPointLinkProtocolSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Type of the link protocol - UNTAGGED, DOT1Q, QINQ, EVPN_VXLAN", + ValidateFunc: validation.StringInSlice([]string{"UNTAGGED", "DOT1Q", "QINQ", "EVPN_VXLAN"}, true), + }, + "vlan_tag": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Vlan Tag information, vlanTag value specified for DOT1Q connections", + }, + "vlan_s_tag": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Vlan Provider Tag information, vlanSTag value specified for QINQ connections", + }, + "vlan_c_tag": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Vlan Customer Tag information, vlanCTag value specified for QINQ connections", + }, + } +} + +func accessPointVirtualDeviceSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource Identifier", + }, + "uuid": { + Type: schema.TypeString, + Optional: true, + Description: "Equinix-assigned Virtual Device identifier", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Virtual Device type", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "Customer-assigned Virtual Device Name", + }, + } +} + +func accessPointInterface() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "uuid": { + Type: schema.TypeString, + Optional: true, + Description: "Equinix-assigned interface identifier", + }, + "id": { + Type: schema.TypeInt, + Computed: true, + Optional: true, + Description: "id", + }, + "type": { + Type: schema.TypeString, + Optional: true, + Description: "Interface type", + }, + } +} + +func networkSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "uuid": { + Type: schema.TypeString, + Optional: true, + Description: "Equinix-assigned Network identifier", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource Identifier", + }, + } +} + +func portSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "uuid": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Equinix-assigned Port identifier", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource Identifier", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Port name", + }, + "redundancy": { + Type: schema.TypeSet, + Computed: true, + Description: "Redundancy Information", + Elem: &schema.Resource{ + Schema: PortRedundancySch(), + }, + }, + } +} + +func connectionAccessPointTypeConfigSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Type of access point type config - VD, COLO", + }, + "uuid": { + Type: schema.TypeString, + Computed: true, + Description: "Equinix-assigned access point type config identifier", + }, + } +} + +func additionalInfoSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Optional: true, + Description: "Additional information key", + }, + "value": { + Type: schema.TypeString, + Optional: true, + Description: "Additional information value", + }, + } +} + +func operationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "provider_status": { + Type: schema.TypeString, + Computed: true, + Description: "Connection provider readiness status", + }, + "equinix_status": { + Type: schema.TypeString, + Computed: true, + Description: "Connection status", + }, + "errors": { + Type: schema.TypeList, + Computed: true, + Description: "Errors occurred", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.ErrorSch(), + }, + }, + } +} + +func connectionRedundancySch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "group": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Redundancy group identifier (UUID of primary connection)", + }, + "priority": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"PRIMARY", "SECONDARY"}, true), + Description: "Connection priority in redundancy group - PRIMARY, SECONDARY", + }, + } +} + func resourceFabricConnection() *schema.Resource { return &schema.Resource{ Timeouts: &schema.ResourceTimeout{ @@ -33,9 +603,9 @@ func resourceFabricConnection() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, - Schema: createFabricConnectionResourceSchema(), + Schema: fabricConnectionResourceSchema(), - Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric connection\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric connection", } } @@ -44,14 +614,14 @@ func resourceFabricConnectionCreate(ctx context.Context, d *schema.ResourceData, ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) conType := v4.ConnectionType(d.Get("type").(string)) schemaNotifications := d.Get("notifications").([]interface{}) - notifications := notificationToFabric(schemaNotifications) + notifications := equinix_fabric_schema.NotificationsToFabric(schemaNotifications) schemaRedundancy := d.Get("redundancy").(*schema.Set).List() - red := redundancyToFabric(schemaRedundancy) + red := connectionRedundancyToFabric(schemaRedundancy) schemaOrder := d.Get("order").(*schema.Set).List() - order := orderToFabric(schemaOrder) + order := equinix_fabric_schema.OrderToFabric(schemaOrder) aside := d.Get("a_side").(*schema.Set).List() projectReq := d.Get("project").(*schema.Set).List() - project := projectToFabric(projectReq) + project := equinix_fabric_schema.ProjectToFabric(projectReq) additionalInfoTerraConfig := d.Get("additional_info").([]interface{}) additionalInfo := additionalInfoTerraToGo(additionalInfoTerraConfig) connectionASide := v4.ConnectionSide{} @@ -193,15 +763,15 @@ func setFabricMap(d *schema.ResourceData, conn v4.Connection) diag.Diagnostics { "state": conn.State, "direction": conn.Direction, "operation": operationToTerra(conn.Operation), - "order": orderMappingToTerra(conn.Order), - "change_log": changeLogToTerra(conn.ChangeLog), - "redundancy": redundancyToTerra(conn.Redundancy), - "notifications": notificationToTerra(conn.Notifications), + "order": equinix_fabric_schema.OrderToTerra(conn.Order), + "change_log": equinix_fabric_schema.ChangeLogToTerra(conn.ChangeLog), + "redundancy": connectionRedundancyToTerra(conn.Redundancy), + "notifications": equinix_fabric_schema.NotificationsToTerra(conn.Notifications), "account": accountToTerra(conn.Account), "a_side": connectionSideToTerra(conn.ASide), "z_side": connectionSideToTerra(conn.ZSide), "additional_info": additionalInfoToTerra(conn.AdditionalInfo), - "project": projectToTerra(conn.Project), + "project": equinix_fabric_schema.ProjectToTerra(conn.Project), }) if err != nil { return diag.FromErr(err) @@ -426,3 +996,39 @@ func WaitUntilConnectionDeprovisioned(uuid string, meta interface{}, ctx context _, err := stateConf.WaitForStateContext(ctx) return err } + +func connectionRedundancyToFabric(schemaRedundancy []interface{}) v4.ConnectionRedundancy { + if schemaRedundancy == nil { + return v4.ConnectionRedundancy{} + } + red := v4.ConnectionRedundancy{} + for _, r := range schemaRedundancy { + redundancyMap := r.(map[string]interface{}) + connectionPriority := v4.ConnectionPriority(redundancyMap["priority"].(string)) + redundancyGroup := redundancyMap["group"].(string) + red = v4.ConnectionRedundancy{ + Priority: &connectionPriority, + Group: redundancyGroup, + } + } + return red +} + +func connectionRedundancyToTerra(redundancy *v4.ConnectionRedundancy) *schema.Set { + if redundancy == nil { + return nil + } + redundancies := []*v4.ConnectionRedundancy{redundancy} + mappedRedundancys := make([]interface{}, len(redundancies)) + for _, redundancy := range redundancies { + mappedRedundancy := make(map[string]interface{}) + mappedRedundancy["group"] = redundancy.Group + mappedRedundancy["priority"] = string(*redundancy.Priority) + mappedRedundancys = append(mappedRedundancys, mappedRedundancy) + } + redundancySet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: connectionRedundancySch()}), + mappedRedundancys, + ) + return redundancySet +} diff --git a/equinix/resource_fabric_connection_acc_test.go b/equinix/resource_fabric_connection_acc_test.go index 299b79743..23739f134 100644 --- a/equinix/resource_fabric_connection_acc_test.go +++ b/equinix/resource_fabric_connection_acc_test.go @@ -292,7 +292,6 @@ func TestAccFabricCreateCloudRouter2PortConnection_PFCR(t *testing.T) { resource.TestCheckResourceAttr( "equinix_fabric_connection.test", "z_side.0.access_point.0.link_protocol.0.vlan_tag", "2325"), ), - ExpectNonEmptyPlan: true, }, }, }) diff --git a/equinix/resource_fabric_port.go b/equinix/resource_fabric_port.go index 5130630d8..1cd4c8268 100644 --- a/equinix/resource_fabric_port.go +++ b/equinix/resource_fabric_port.go @@ -9,6 +9,7 @@ import ( "strings" equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" + equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -19,6 +20,395 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +func portDeviceSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Port name", + }, + "redundancy": { + Type: schema.TypeSet, + Computed: true, + Description: "Port device redundancy", + Elem: &schema.Resource{ + Schema: PortRedundancySch(), + }, + }, + } +} + +func portEncapsulationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Port encapsulation protocol type", + }, + "tag_protocol_id": { + Type: schema.TypeString, + Computed: true, + Description: "Port encapsulation Tag Protocol Identifier", + }, + } +} + +func portOperationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "operational_status": { + Type: schema.TypeString, + Computed: true, + Description: "Port operation status", + }, + "connection_count": { + Type: schema.TypeInt, + Computed: true, + Description: "Total number of current connections", + }, + "op_status_changed_at": { + Type: schema.TypeString, + Computed: true, + Description: "Date and time at which port availability changed", + }, + } +} + +func PortRedundancySch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Access point redundancy", + }, + "group": { + Type: schema.TypeString, + Computed: true, + Description: "Port redundancy group", + }, + "priority": { + Type: schema.TypeString, + Computed: true, + Description: "Priority type-Primary or Secondary", + }, + } +} + +func FabricPortResourceSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Port type", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Port URI information", + }, + "uuid": { + Type: schema.TypeString, + Required: true, + Description: "Equinix-assigned port identifier", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Port name", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Port description", + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: "Port state", + }, + "operation": { + Type: schema.TypeSet, + Computed: true, + Description: "Port specific operational data", + Elem: &schema.Resource{ + Schema: portOperationSch(), + }, + }, + "account": { + Type: schema.TypeSet, + Computed: true, + Description: "Customer account information that is associated with this port", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.AccountSch(), + }, + }, + "change_log": { + Type: schema.TypeSet, + Computed: true, + Description: "Captures port lifecycle change information", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.ChangeLogSch(), + }, + }, + "service_type": { + Type: schema.TypeString, + Computed: true, + Description: "Port service type", + }, + "bandwidth": { + Type: schema.TypeInt, + Computed: true, + Description: "Port bandwidth in Mbps", + }, + "available_bandwidth": { + Type: schema.TypeInt, + Computed: true, + Description: "Port available bandwidth in Mbps", + }, + "used_bandwidth": { + Type: schema.TypeInt, + Computed: true, + Description: "Port used bandwidth in Mbps", + }, + "location": { + Type: schema.TypeSet, + Computed: true, + Description: "Port location information", + Elem: &schema.Resource{ + Schema: equinix_fabric_schema.LocationSch(), + }, + }, + "device": { + Type: schema.TypeSet, + Computed: true, + Description: "Port device", + Elem: &schema.Resource{ + Schema: portDeviceSch(), + }, + }, + "redundancy": { + Type: schema.TypeSet, + Computed: true, + Description: "Port redundancy information", + Elem: &schema.Resource{ + Schema: PortRedundancySch(), + }, + }, + "encapsulation": { + Type: schema.TypeSet, + Computed: true, + Description: "Port encapsulation protocol", + Elem: &schema.Resource{ + Schema: portEncapsulationSch(), + }, + }, + "lag_enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Port Lag", + }, + } +} + +func readFabricPortResourceSchemaUpdated() map[string]*schema.Schema { + sch := FabricPortResourceSchema() + sch["uuid"].Computed = true + sch["uuid"].Optional = false + sch["uuid"].Required = false + return sch +} + +func readFabricPortsResponseSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "data": { + Type: schema.TypeList, + Computed: true, + Description: "List of Ports", + Elem: &schema.Resource{ + Schema: readFabricPortResourceSchemaUpdated(), + }, + }, + "filters": { + Type: schema.TypeSet, + Required: true, + Description: "name", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: readGetPortsByNameQueryParamSch(), + }, + }, + } +} + +func readGetPortsByNameQueryParamSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + Description: "Query Parameter to Get Ports By Name", + }, + } +} + +func portToFabric(portList []interface{}) v4.SimplifiedPort { + p := v4.SimplifiedPort{} + for _, pl := range portList { + plMap := pl.(map[string]interface{}) + uuid := plMap["uuid"].(string) + p = v4.SimplifiedPort{Uuid: uuid} + } + return p +} + +func portToTerra(port *v4.SimplifiedPort) *schema.Set { + ports := []*v4.SimplifiedPort{port} + mappedPorts := make([]interface{}, len(ports)) + for _, port := range ports { + mappedPort := make(map[string]interface{}) + mappedPort["href"] = port.Href + mappedPort["name"] = port.Name + mappedPort["uuid"] = port.Uuid + if port.Redundancy != nil { + mappedPort["redundancy"] = PortRedundancyToTerra(port.Redundancy) + } + mappedPorts = append(mappedPorts, mappedPort) + } + portSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: portSch()}), + mappedPorts, + ) + return portSet +} + +func PortRedundancyToTerra(redundancy *v4.PortRedundancy) *schema.Set { + if redundancy == nil { + return nil + } + redundancies := []*v4.PortRedundancy{redundancy} + mappedRedundancies := make([]interface{}, 0) + for _, redundancy := range redundancies { + mappedRedundancy := make(map[string]interface{}) + mappedRedundancy["enabled"] = redundancy.Enabled + mappedRedundancy["group"] = redundancy.Group + mappedRedundancy["priority"] = string(*redundancy.Priority) + mappedRedundancies = append(mappedRedundancies, mappedRedundancy) + } + redundancySet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: PortRedundancySch()}), + mappedRedundancies, + ) + return redundancySet +} + +func portOperationToTerra(operation *v4.PortOperation) *schema.Set { + if operation == nil { + return nil + } + operations := []*v4.PortOperation{operation} + mappedOperations := make([]interface{}, 0) + for _, operation := range operations { + mappedOperation := make(map[string]interface{}) + mappedOperation["operational_status"] = operation.OperationalStatus + mappedOperation["connection_count"] = operation.ConnectionCount + mappedOperation["op_status_changed_at"] = operation.OpStatusChangedAt.String() + mappedOperations = append(mappedOperations, mappedOperation) + } + operationSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: operationSch()}), + mappedOperations, + ) + return operationSet +} + +func portDeviceRedundancyToTerra(redundancy *v4.PortDeviceRedundancy) *schema.Set { + if redundancy == nil { + return nil + } + redundancies := []*v4.PortDeviceRedundancy{redundancy} + mappedRedundancies := make([]interface{}, 0) + for _, redundancy := range redundancies { + mappedRedundancy := make(map[string]interface{}) + mappedRedundancy["group"] = redundancy.Group + mappedRedundancy["priority"] = redundancy.Priority + mappedRedundancies = append(mappedRedundancies, mappedRedundancy) + } + redundancySet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: PortRedundancySch()}), + mappedRedundancies, + ) + return redundancySet +} + +func portDeviceToTerra(device *v4.PortDevice) *schema.Set { + if device == nil { + return nil + } + devices := []*v4.PortDevice{device} + mappedDevices := make([]interface{}, 0) + for _, device := range devices { + mappedDevice := make(map[string]interface{}) + mappedDevice["name"] = device.Name + if device.Redundancy != nil { + mappedDevice["redundancy"] = portDeviceRedundancyToTerra(device.Redundancy) + } + mappedDevices = append(mappedDevices, mappedDevice) + } + deviceSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: portDeviceSch()}), + mappedDevices, + ) + return deviceSet +} + +func portEncapsulationToTerra(portEncapsulation *v4.PortEncapsulation) *schema.Set { + if portEncapsulation == nil { + return nil + } + portEncapsulations := []*v4.PortEncapsulation{portEncapsulation} + mappedPortEncapsulations := make([]interface{}, 0) + for _, portEncapsulation := range portEncapsulations { + mappedPortEncapsulation := make(map[string]interface{}) + mappedPortEncapsulation["type"] = portEncapsulation.Type_ + mappedPortEncapsulation["tag_protocol_id"] = portEncapsulation.TagProtocolId + mappedPortEncapsulations = append(mappedPortEncapsulations, mappedPortEncapsulation) + } + portEncapsulationSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: portEncapsulationSch()}), + mappedPortEncapsulations, + ) + return portEncapsulationSet +} + +func fabricPortsListToTerra(ports v4.AllPortsResponse) []map[string]interface{} { + portsl := ports.Data + if portsl == nil { + return nil + } + mappedPortsl := make([]map[string]interface{}, len(portsl)) + for index, port := range portsl { + mappedPortsl[index] = map[string]interface{}{ + "uuid": port.Uuid, + "name": port.Name, + "bandwidth": port.Bandwidth, + "available_bandwidth": port.AvailableBandwidth, + "used_bandwidth": port.UsedBandwidth, + "href": port.Href, + "description": port.Description, + "type": port.Type_, + "state": port.State, + "service_type": port.ServiceType, + "operation": portOperationToTerra(port.Operation), + "redundancy": PortRedundancyToTerra(port.Redundancy), + "account": accountToTerra(port.Account), + "change_log": equinix_fabric_schema.ChangeLogToTerra(port.Changelog), + "location": equinix_fabric_schema.LocationToTerra(port.Location), + "device": portDeviceToTerra(port.Device), + "encapsulation": portEncapsulationToTerra(port.Encapsulation), + "lag_enabled": port.LagEnabled, + } + } + return mappedPortsl +} + func resourceFabricPortRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*config.Config).FabricClient ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) @@ -47,12 +437,12 @@ func setFabricPortMap(d *schema.ResourceData, port v4.Port) diag.Diagnostics { "state": port.State, "service_type": port.ServiceType, "operation": portOperationToTerra(port.Operation), - "redundancy": portApiPortRedundancyToTerr(port.Redundancy), + "redundancy": PortRedundancyToTerra(port.Redundancy), "account": accountToTerra(port.Account), - "change_log": changeLogToTerra(port.Changelog), - "location": locationToTerra(port.Location), - "device": deviceToTerra(port.Device), - "encapsulation": encapsulationToTerra(port.Encapsulation), + "change_log": equinix_fabric_schema.ChangeLogToTerra(port.Changelog), + "location": equinix_fabric_schema.LocationToTerra(port.Location), + "device": portDeviceToTerra(port.Device), + "encapsulation": portEncapsulationToTerra(port.Encapsulation), "lag_enabled": port.LagEnabled, }) if err != nil { diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index 5be4bfb7f..20957f595 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -9,6 +9,7 @@ import ( "time" equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" + equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -47,7 +48,7 @@ func resourceFabricRoutingProtocol() *schema.Resource { }, Schema: createFabricRoutingProtocolResourceSchema(), - Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric connection\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric connection", } } @@ -290,7 +291,7 @@ func setFabricRoutingProtocolMap(d *schema.ResourceData, rp v4.RoutingProtocolDa "bfd": routingProtocolBfdToTerra(rp.Bfd), "bgp_auth_key": rp.BgpAuthKey, "change": routingProtocolChangeToTerra(rp.RoutingProtocolBgpData.Change), - "change_log": changeLogToTerra(rp.RoutingProtocolBgpData.Changelog), + "change_log": equinix_fabric_schema.ChangeLogToTerra(rp.RoutingProtocolBgpData.Changelog), }) } else if rp.Type_ == "DIRECT" { err = equinix_schema.SetMap(d, map[string]interface{}{ @@ -302,7 +303,7 @@ func setFabricRoutingProtocolMap(d *schema.ResourceData, rp v4.RoutingProtocolDa "direct_ipv4": routingProtocolDirectConnectionIpv4ToTerra(rp.DirectIpv4), "direct_ipv6": routingProtocolDirectConnectionIpv6ToTerra(rp.DirectIpv6), "change": routingProtocolChangeToTerra(rp.RoutingProtocolDirectData.Change), - "change_log": changeLogToTerra(rp.RoutingProtocolDirectData.Changelog), + "change_log": equinix_fabric_schema.ChangeLogToTerra(rp.RoutingProtocolDirectData.Changelog), }) } if err != nil { diff --git a/equinix/resource_fabric_service_profile.go b/equinix/resource_fabric_service_profile.go index 9af7d5af9..55644f79e 100644 --- a/equinix/resource_fabric_service_profile.go +++ b/equinix/resource_fabric_service_profile.go @@ -11,6 +11,7 @@ import ( "github.com/equinix/terraform-provider-equinix/internal/converters" equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" + equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" "github.com/antihax/optional" @@ -22,6 +23,171 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +func serviceProfileAccessPointTypeConfigSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Computed: true, + Description: "Type of access point type config - VD, COLO", + }, + "uuid": { + Type: schema.TypeString, + Computed: true, + Description: "Equinix-assigned access point type config identifier", + }, + "connection_redundancy_required": { + Type: schema.TypeBool, + Computed: true, + Description: "Mandate redundant connections", + }, + "allow_bandwidth_auto_approval": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting to enable or disable the ability of the buyer to change connection bandwidth without approval of the seller", + }, + "allow_remote_connections": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting to allow or prohibit remote connections to the service profile", + }, + "allow_bandwidth_upgrade": { + Type: schema.TypeBool, + Computed: true, + Description: "Availability of a bandwidth upgrade. The default is false", + }, + "connection_label": { + Type: schema.TypeString, + Computed: true, + Description: "An alternative term for connection in case it's different in your organization.", + }, + "enable_auto_generate_service_key": { + Type: schema.TypeBool, + Computed: true, + Description: "Applicable to Verizon Software Defined Interconnect service profile.", + }, + "bandwidth_alert_threshold": { + Type: schema.TypeFloat, + Computed: true, + Description: "Percentage of port bandwidth at which an allocation alert is generated", + }, + "allow_custom_bandwidth": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting to enable or disable the ability of the buyer to customize the bandwidth", + }, + "api_config": { + Type: schema.TypeSet, + Computed: true, + Description: "API configuration settings and preferences.", + Elem: &schema.Resource{ + Schema: apiConfigSch(), + }, + }, + "authentication_key": { + Type: schema.TypeSet, + Computed: true, + Description: "Authentication key configuration", + Elem: &schema.Resource{ + Schema: authenticationKeySch(), + }, + }, + "link_protocol_config": { + Type: schema.TypeSet, + Computed: true, + Description: "Settings and preferences for the link protocol used at the access point.", + Elem: &schema.Resource{ + Schema: linkProtocolConfigSch(), + }, + }, + "supported_bandwidths": { + Type: schema.TypeList, + Computed: true, + Description: "Allowed connection bandwidths (Mbps).", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + } +} + +func apiConfigSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "api_available": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates if it's possible to establish connections based on the given service profile using the Equinix Fabric API.", + }, + "equinix_managed_vlan": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting indicating that the VLAN is managed by Equinix (true) or not (false)", + }, + "allow_over_subscription": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting showing that oversubscription support is available (true) or not (false). The default is false", + }, + "over_subscription_limit": { + Type: schema.TypeInt, + Computed: true, + Description: "Port bandwidth multiplier that determines the total bandwidth that can be allocated to users creating connections to your services.", + }, + "bandwidth_from_api": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates if the connection bandwidth can be obtained directly from the cloud service provider.", + }, + "integration_id": { + Type: schema.TypeString, + Computed: true, + Description: "A unique identifier issued during onboarding and used to integrate the customer's service profile with the Equinix Fabric API.", + }, + "equinix_managed_port": { + Type: schema.TypeBool, + Computed: true, + Description: "Setting indicating that the port is managed by Equinix (true) or not (false)", + }, + } +} + +func authenticationKeySch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "required": { + Type: schema.TypeBool, + Computed: true, + Description: "Requirement to configure an authentication key.", + }, + "label": { + Type: schema.TypeString, + Computed: true, + Description: "Name of the parameter that must be provided to authorize the connection.", + }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "Description of authorization key", + }, + } +} + +func linkProtocolConfigSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "encapsulation_strategy": { + Type: schema.TypeString, + Computed: true, + Description: "Additional tagging information required by the seller profile.", + }, + "reuse_vlan_s_tag": { + Type: schema.TypeBool, + Computed: true, + Description: "Automatically accept subsequent DOT1Q to QINQ connections that use the same authentication key. These connections will have the same VLAN S-tag assigned as the initial connection.", + }, + "encapsulation": { + Type: schema.TypeString, + Computed: true, + Description: "Data frames encapsulation standard.UNTAGGED - Untagged encapsulation for EPL connections. DOT1Q - DOT1Q encapsulation standard. QINQ - QINQ encapsulation standard.", + }, + } +} + func resourceFabricServiceProfile() *schema.Resource { return &schema.Resource{ Timeouts: &schema.ResourceTimeout{ @@ -38,7 +204,7 @@ func resourceFabricServiceProfile() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, Schema: createFabricServiceProfileSchema(), - Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric Service Profile\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric Service Profile", } } @@ -73,7 +239,7 @@ func getServiceProfileRequestPayload(d *schema.ResourceData) v4.ServiceProfileRe spType := v4.ServiceProfileTypeEnum(d.Get("type").(string)) schemaNotifications := d.Get("notifications").([]interface{}) - notifications := notificationToFabric(schemaNotifications) + notifications := equinix_fabric_schema.NotificationsToFabric(schemaNotifications) var tags []string if d.Get("tags") != nil { @@ -244,7 +410,7 @@ func setFabricServiceProfileMap(d *schema.ResourceData, sp v4.ServiceProfile) di "name": sp.Name, "uuid": sp.Uuid, "description": sp.Description, - "notifications": notificationToTerra(sp.Notifications), + "notifications": equinix_fabric_schema.NotificationsToTerra(sp.Notifications), "tags": tagsFabricSpToTerra(sp.Tags), "visibility": sp.Visibility, "access_point_type_configs": accessPointTypeConfigToTerra(sp.AccessPointTypeConfigs), @@ -256,7 +422,7 @@ func setFabricServiceProfileMap(d *schema.ResourceData, sp v4.ServiceProfile) di "self_profile": sp.SelfProfile, "state": sp.State, "account": serviceProfileAccountFabricSpToTerra(sp.Account), - "project": projectToTerra(sp.Project), + "project": equinix_fabric_schema.ProjectToTerra(sp.Project), "change_log": allOfServiceProfileChangeLogToTerra(sp.ChangeLog), }) if err != nil { diff --git a/internal/fabric/schema/fabric_common_mapping_helpers.go b/internal/fabric/schema/fabric_common_mapping_helpers.go new file mode 100644 index 000000000..0bd331041 --- /dev/null +++ b/internal/fabric/schema/fabric_common_mapping_helpers.go @@ -0,0 +1,230 @@ +package schema + +import ( + v4 "github.com/equinix-labs/fabric-go/fabric/v4" + "github.com/equinix/terraform-provider-equinix/internal/converters" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func OrderToFabric(schemaOrder []interface{}) v4.Order { + if schemaOrder == nil { + return v4.Order{} + } + order := v4.Order{} + for _, o := range schemaOrder { + orderMap := o.(map[string]interface{}) + purchaseOrderNumber := orderMap["purchase_order_number"] + billingTier := orderMap["billing_tier"] + orderId := orderMap["order_id"] + orderNumber := orderMap["order_number"] + order = v4.Order{PurchaseOrderNumber: purchaseOrderNumber.(string), BillingTier: billingTier.(string), OrderId: orderId.(string), OrderNumber: orderNumber.(string)} + } + return order +} + +func OrderToTerra(order *v4.Order) *schema.Set { + if order == nil { + return nil + } + orders := []*v4.Order{order} + mappedOrders := make([]interface{}, len(orders)) + for _, order := range orders { + mappedOrder := make(map[string]interface{}) + mappedOrder["purchase_order_number"] = order.PurchaseOrderNumber + mappedOrder["billing_tier"] = order.BillingTier + mappedOrder["order_id"] = order.OrderId + mappedOrder["order_number"] = order.OrderNumber + mappedOrders = append(mappedOrders, mappedOrder) + } + orderSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: OrderSch()}), + mappedOrders, + ) + return orderSet +} + +func NotificationsToFabric(schemaNotifications []interface{}) []v4.SimplifiedNotification { + if schemaNotifications == nil { + return []v4.SimplifiedNotification{} + } + var notifications []v4.SimplifiedNotification + for _, n := range schemaNotifications { + ntype := n.(map[string]interface{})["type"].(string) + interval := n.(map[string]interface{})["send_interval"].(string) + emailsRaw := n.(map[string]interface{})["emails"].([]interface{}) + emails := converters.IfArrToStringArr(emailsRaw) + notifications = append(notifications, v4.SimplifiedNotification{ + Type_: ntype, + SendInterval: interval, + Emails: emails, + }) + } + return notifications +} + +func NotificationsToTerra(notifications []v4.SimplifiedNotification) []map[string]interface{} { + if notifications == nil { + return nil + } + mappedNotifications := make([]map[string]interface{}, len(notifications)) + for index, notification := range notifications { + mappedNotifications[index] = map[string]interface{}{ + "type": notification.Type_, + "send_interval": notification.SendInterval, + "emails": notification.Emails, + } + } + return mappedNotifications +} + +func LocationToFabric(locationList []interface{}) v4.SimplifiedLocation { + sl := v4.SimplifiedLocation{} + for _, ll := range locationList { + llMap := ll.(map[string]interface{}) + metroName := llMap["metro_name"] + var metroNamestr string + if metroName != nil { + metroNamestr = metroName.(string) + } + region := llMap["region"].(string) + mc := llMap["metro_code"].(string) + ibx := llMap["ibx"].(string) + sl = v4.SimplifiedLocation{MetroCode: mc, Region: region, Ibx: ibx, MetroName: metroNamestr} + } + return sl +} + +func LocationToTerra(location *v4.SimplifiedLocation) *schema.Set { + locations := []*v4.SimplifiedLocation{location} + mappedLocations := make([]interface{}, len(locations)) + for i, location := range locations { + mappedLocations[i] = map[string]interface{}{ + "region": location.Region, + "metro_name": location.MetroName, + "metro_code": location.MetroCode, + "ibx": location.Ibx, + } + } + locationSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: LocationSch()}), + mappedLocations, + ) + return locationSet +} + +func LocationWithoutIBXToFabric(locationList []interface{}) v4.SimplifiedLocationWithoutIbx { + sl := v4.SimplifiedLocationWithoutIbx{} + for _, ll := range locationList { + llMap := ll.(map[string]interface{}) + mc := llMap["metro_code"].(string) + sl = v4.SimplifiedLocationWithoutIbx{MetroCode: mc} + } + return sl +} + +func LocationWithoutIBXToTerra(location *v4.SimplifiedLocationWithoutIbx) *schema.Set { + locations := []*v4.SimplifiedLocationWithoutIbx{location} + mappedLocations := make([]interface{}, len(locations)) + for i, location := range locations { + mappedLocations[i] = map[string]interface{}{ + "region": location.Region, + "metro_name": location.MetroName, + "metro_code": location.MetroCode, + } + } + locationSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: LocationSch()}), + mappedLocations, + ) + return locationSet +} + +func ProjectToFabric(projectRequest []interface{}) v4.Project { + if len(projectRequest) == 0 { + return v4.Project{} + } + mappedPr := v4.Project{} + for _, pr := range projectRequest { + prMap := pr.(map[string]interface{}) + projectId := prMap["project_id"].(string) + mappedPr = v4.Project{ProjectId: projectId} + } + return mappedPr +} + +func ProjectToTerra(project *v4.Project) *schema.Set { + if project == nil { + return nil + } + projects := []*v4.Project{project} + mappedProjects := make([]interface{}, len(projects)) + for _, project := range projects { + mappedProject := make(map[string]interface{}) + mappedProject["project_id"] = project.ProjectId + mappedProjects = append(mappedProjects, mappedProject) + } + projectSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: ProjectSch()}), + mappedProjects) + return projectSet +} + +func ChangeLogToTerra(changeLog *v4.Changelog) *schema.Set { + if changeLog == nil { + return nil + } + changeLogs := []*v4.Changelog{changeLog} + mappedChangeLogs := make([]interface{}, len(changeLogs)) + for _, changeLog := range changeLogs { + mappedChangeLog := make(map[string]interface{}) + mappedChangeLog["created_by"] = changeLog.CreatedBy + mappedChangeLog["created_by_full_name"] = changeLog.CreatedByFullName + mappedChangeLog["created_by_email"] = changeLog.CreatedByEmail + mappedChangeLog["created_date_time"] = changeLog.CreatedDateTime.String() + mappedChangeLog["updated_by"] = changeLog.UpdatedBy + mappedChangeLog["updated_by_full_name"] = changeLog.UpdatedByFullName + mappedChangeLog["updated_date_time"] = changeLog.UpdatedDateTime.String() + mappedChangeLog["deleted_by"] = changeLog.DeletedBy + mappedChangeLog["deleted_by_full_name"] = changeLog.DeletedByFullName + mappedChangeLog["deleted_by_email"] = changeLog.DeletedByEmail + mappedChangeLog["deleted_date_time"] = changeLog.DeletedDateTime.String() + mappedChangeLogs = append(mappedChangeLogs, mappedChangeLog) + } + changeLogSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: ChangeLogSch()}), + mappedChangeLogs, + ) + return changeLogSet +} + +func ErrorToTerra(errors []v4.ModelError) []interface{} { + if errors == nil { + return nil + } + mappedErrors := make([]interface{}, len(errors)) + for index, mError := range errors { + mappedErrors[index] = map[string]interface{}{ + "error_code": mError.ErrorCode, + "error_message": mError.ErrorMessage, + "correlation_id": mError.CorrelationId, + "details": mError.Details, + "help": mError.Help, + "additional_info": ErrorAdditionalInfoToTerra(mError.AdditionalInfo), + } + } + return mappedErrors +} + +func ErrorAdditionalInfoToTerra(additionalInfol []v4.PriceErrorAdditionalInfo) []interface{} { + if additionalInfol == nil { + return nil + } + mappedAdditionalInfol := make([]interface{}, len(additionalInfol)) + for index, additionalInfo := range additionalInfol { + mappedAdditionalInfol[index] = map[string]interface{}{ + "property": additionalInfo.Property, + "reason": additionalInfo.Reason, + } + } + return mappedAdditionalInfol +} diff --git a/internal/fabric/schema/fabric_common_schemas.go b/internal/fabric/schema/fabric_common_schemas.go new file mode 100644 index 000000000..9178c46ef --- /dev/null +++ b/internal/fabric/schema/fabric_common_schemas.go @@ -0,0 +1,285 @@ +package schema + +import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func OrderSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "purchase_order_number": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Purchase order number", + }, + "billing_tier": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Billing tier for connection bandwidth", + }, + "order_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Order Identification", + }, + "order_number": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Order Reference Number", + }, + } +} + +func NotificationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "type": { + Type: schema.TypeString, + Required: true, + Description: "Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS", + }, + "send_interval": { + Type: schema.TypeString, + Optional: true, + Description: "Send interval", + }, + "emails": { + Type: schema.TypeList, + Required: true, + Description: "Array of contact emails", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + } +} + +func AccountSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "account_number": { + Type: schema.TypeInt, + Computed: true, + Description: "Account Number", + }, + "account_name": { + Type: schema.TypeString, + Computed: true, + Description: "Account Name", + }, + "org_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Customer organization identifier", + }, + "organization_name": { + Type: schema.TypeString, + Computed: true, + Description: "Customer organization name", + }, + "global_org_id": { + Type: schema.TypeString, + Computed: true, + Description: "Global organization identifier", + }, + "global_organization_name": { + Type: schema.TypeString, + Computed: true, + Description: "Global organization name", + }, + //"ucm_id": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Account ucmId", + //}, + "global_cust_id": { + Type: schema.TypeString, + Computed: true, + Description: "Global Customer organization identifier", + }, + //"reseller_account_number": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Reseller account number", + //}, + //"reseller_account_name": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Reseller account name", + //}, + //"reseller_ucm_id": { + // Type: schema.TypeString, + // Computed: true, + // Description: "Reseller account ucmId", + //}, + //"reseller_org_id": { + // Type: schema.TypeInt, + // Computed: true, + // Description: "Reseller customer organization identifier", + //}, + } +} + +func LocationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "region": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Access point region", + }, + "metro_name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Access point metro name", + }, + "metro_code": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Access point metro code", + }, + "ibx": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "IBX Code", + }, + } +} + +func ProjectSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Project Id", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource URL", + }, + } +} + +func ChangeLogSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "created_by": { + Type: schema.TypeString, + Computed: true, + Description: "Created by User Key", + }, + "created_by_full_name": { + Type: schema.TypeString, + Computed: true, + Description: "Created by User Full Name", + }, + "created_by_email": { + Type: schema.TypeString, + Computed: true, + Description: "Created by User Email Address", + }, + "created_date_time": { + Type: schema.TypeString, + Computed: true, + Description: "Created by Date and Time", + }, + "updated_by": { + Type: schema.TypeString, + Computed: true, + Description: "Updated by User Key", + }, + "updated_by_full_name": { + Type: schema.TypeString, + Computed: true, + Description: "Updated by User Full Name", + }, + "updated_by_email": { + Type: schema.TypeString, + Computed: true, + Description: "Updated by User Email Address", + }, + "updated_date_time": { + Type: schema.TypeString, + Computed: true, + Description: "Updated by Date and Time", + }, + "deleted_by": { + Type: schema.TypeString, + Computed: true, + Description: "Deleted by User Key", + }, + "deleted_by_full_name": { + Type: schema.TypeString, + Computed: true, + Description: "Deleted by User Full Name", + }, + "deleted_by_email": { + Type: schema.TypeString, + Computed: true, + Description: "Deleted by User Email Address", + }, + "deleted_date_time": { + Type: schema.TypeString, + Computed: true, + Description: "Deleted by Date and Time", + }, + } +} + +func ErrorSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "error_code": { + Type: schema.TypeString, + Computed: true, + Description: "Error code", + }, + "error_message": { + Type: schema.TypeString, + Computed: true, + Description: "Error Message", + }, + "correlation_id": { + Type: schema.TypeString, + Computed: true, + Description: "CorrelationId", + }, + "details": { + Type: schema.TypeString, + Computed: true, + Description: "Details", + }, + "help": { + Type: schema.TypeString, + Computed: true, + Description: "Help", + }, + "additional_info": { + Type: schema.TypeList, + Computed: true, + Description: "Pricing error additional Info", + Elem: &schema.Resource{ + Schema: ErrorAdditionalInfoSch(), + }, + }, + } +} + +func ErrorAdditionalInfoSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "property": { + Type: schema.TypeString, + Computed: true, + Description: "Property at which the error potentially occurred", + }, + "reason": { + Type: schema.TypeString, + Computed: true, + Description: "Reason for the error", + }, + } +} diff --git a/internal/schema/resourcedata.go b/internal/schema/resourcedata.go index e4490bb63..551721746 100644 --- a/internal/schema/resourcedata.go +++ b/internal/schema/resourcedata.go @@ -2,7 +2,7 @@ package schema import "reflect" -// resourceDataProvider provies interface to schema.ResourceData +// resourceDataProvider proxies interface to schema.ResourceData // for convenient mocking purposes type resourceDataProvider interface { Get(key string) interface{} diff --git a/internal/schema/set_map.go b/internal/schema/set_map.go index 7a9ef1bf3..1e7420034 100644 --- a/internal/schema/set_map.go +++ b/internal/schema/set_map.go @@ -20,9 +20,6 @@ func SetMap(d *schema.ResourceData, m map[string]interface{}) error { if f, ok := v.(setFn); ok { err = f(d, key) } else { - if key == "router" { - d.Set("gateway", v) - } err = d.Set(key, v) }