-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding fabric_network_schema_resource (#553)
Includes: fabric_network_data_source fabric_network_resource fabric_network_data_source_acc_test fabric_network_resource_acc_test
- Loading branch information
Showing
8 changed files
with
885 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "equinix_fabric_network Data Source - terraform-provider-equinix" | ||
subcategory: "Fabric" | ||
description: |- | ||
Fabric V4 API compatible data resource that allow user to fetch Fabric Network for a given UUID | ||
--- | ||
|
||
# equinix_fabric_network (Data Source) | ||
|
||
Fabric V4 API compatible data resource that allow user to fetch Fabric Network for a given UUID | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `uuid` (String) Equinix-assigned network identifier | ||
|
||
### Read-Only | ||
|
||
- `change` (Set of Object) Information on asset change operation (see [below for nested schema](#nestedatt--change)) | ||
- `change_log` (Set of Object) A permanent record of asset creation, modification, or deletion (see [below for nested schema](#nestedatt--change_log)) | ||
- `connections_count` (Number) Number of connections associated with this network | ||
- `href` (String) Fabric Network URI information | ||
- `id` (String) The ID of this resource. | ||
- `location` (Set of Object) Fabric Network location (see [below for nested schema](#nestedatt--location)) | ||
- `name` (String) Fabric Network name. An alpha-numeric 24 characters string which can include only hyphens and underscores | ||
- `notifications` (List of Object) Preferences for notifications on Fabric Network configuration or status changes (see [below for nested schema](#nestedatt--notifications)) | ||
- `operation` (Set of Object) Network operation information that is associated with this Fabric Network (see [below for nested schema](#nestedatt--operation)) | ||
- `project` (Set of Object) Fabric Network project (see [below for nested schema](#nestedatt--project)) | ||
- `scope` (String) Fabric Network scope | ||
- `state` (String) Fabric Network overall state | ||
- `type` (String) Supported Network types - EVPLAN, EPLAN, IPWAN | ||
|
||
<a id="nestedatt--change"></a> | ||
### Nested Schema for `change` | ||
|
||
Read-Only: | ||
|
||
- `href` (String) | ||
- `type` (String) | ||
- `uuid` (String) | ||
|
||
|
||
<a id="nestedatt--change_log"></a> | ||
### Nested Schema for `change_log` | ||
|
||
Read-Only: | ||
|
||
- `created_by` (String) | ||
- `created_by_email` (String) | ||
- `created_by_full_name` (String) | ||
- `created_date_time` (String) | ||
- `deleted_by` (String) | ||
- `deleted_by_email` (String) | ||
- `deleted_by_full_name` (String) | ||
- `deleted_date_time` (String) | ||
- `updated_by` (String) | ||
- `updated_by_email` (String) | ||
- `updated_by_full_name` (String) | ||
- `updated_date_time` (String) | ||
|
||
|
||
<a id="nestedatt--location"></a> | ||
### Nested Schema for `location` | ||
|
||
Read-Only: | ||
|
||
- `ibx` (String) | ||
- `metro_code` (String) | ||
- `metro_name` (String) | ||
- `region` (String) | ||
|
||
|
||
<a id="nestedatt--notifications"></a> | ||
### Nested Schema for `notifications` | ||
|
||
Read-Only: | ||
|
||
- `emails` (List of String) | ||
- `send_interval` (String) | ||
- `type` (String) | ||
|
||
|
||
<a id="nestedatt--operation"></a> | ||
### Nested Schema for `operation` | ||
|
||
Read-Only: | ||
|
||
- `equinix_status` (String) | ||
|
||
|
||
<a id="nestedatt--project"></a> | ||
### Nested Schema for `project` | ||
|
||
Read-Only: | ||
|
||
- `project_id` (String) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "equinix_fabric_network Resource - terraform-provider-equinix" | ||
subcategory: "Fabric" | ||
description: |- | ||
Fabric V4 API compatible resource allows creation and management of Equinix Fabric Network | ||
--- | ||
|
||
# equinix_fabric_network (Resource) | ||
|
||
Fabric V4 API compatible resource allows creation and management of Equinix Fabric Network | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Fabric Network name. An alpha-numeric 24 characters string which can include only hyphens and underscores | ||
- `notifications` (Block List, Min: 1) Preferences for notifications on Fabric Network configuration or status changes (see [below for nested schema](#nestedblock--notifications)) | ||
- `project` (Block Set, Min: 1) Fabric Network project (see [below for nested schema](#nestedblock--project)) | ||
- `scope` (String) Fabric Network scope | ||
- `type` (String) Supported Network types - EVPLAN, EPLAN, IPWAN | ||
|
||
### Optional | ||
|
||
- `location` (Block Set, Max: 1) Fabric Network location (see [below for nested schema](#nestedblock--location)) | ||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) | ||
|
||
### Read-Only | ||
|
||
- `change` (Set of Object) Information on asset change operation (see [below for nested schema](#nestedatt--change)) | ||
- `change_log` (Set of Object) A permanent record of asset creation, modification, or deletion (see [below for nested schema](#nestedatt--change_log)) | ||
- `connections_count` (Number) Number of connections associated with this network | ||
- `href` (String) Fabric Network URI information | ||
- `id` (String) The ID of this resource. | ||
- `operation` (Set of Object) Network operation information that is associated with this Fabric Network (see [below for nested schema](#nestedatt--operation)) | ||
- `state` (String) Fabric Network overall state | ||
- `uuid` (String) Equinix-assigned network identifier | ||
|
||
<a id="nestedblock--notifications"></a> | ||
### Nested Schema for `notifications` | ||
|
||
Required: | ||
|
||
- `emails` (List of String) Array of contact emails | ||
- `type` (String) Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS | ||
|
||
Optional: | ||
|
||
- `send_interval` (String) Send interval | ||
|
||
|
||
<a id="nestedblock--project"></a> | ||
### Nested Schema for `project` | ||
|
||
Required: | ||
|
||
- `project_id` (String) Customer project identifier | ||
|
||
|
||
<a id="nestedblock--location"></a> | ||
### Nested Schema for `location` | ||
|
||
Optional: | ||
|
||
- `ibx` (String) IBX Code | ||
- `metro_code` (String) Access point metro code | ||
- `metro_name` (String) Access point metro name | ||
- `region` (String) Access point region | ||
|
||
|
||
<a id="nestedblock--timeouts"></a> | ||
### Nested Schema for `timeouts` | ||
|
||
Optional: | ||
|
||
- `create` (String) | ||
- `delete` (String) | ||
- `read` (String) | ||
- `update` (String) | ||
|
||
|
||
<a id="nestedatt--change"></a> | ||
### Nested Schema for `change` | ||
|
||
Read-Only: | ||
|
||
- `href` (String) | ||
- `type` (String) | ||
- `uuid` (String) | ||
|
||
|
||
<a id="nestedatt--change_log"></a> | ||
### Nested Schema for `change_log` | ||
|
||
Read-Only: | ||
|
||
- `created_by` (String) | ||
- `created_by_email` (String) | ||
- `created_by_full_name` (String) | ||
- `created_date_time` (String) | ||
- `deleted_by` (String) | ||
- `deleted_by_email` (String) | ||
- `deleted_by_full_name` (String) | ||
- `deleted_date_time` (String) | ||
- `updated_by` (String) | ||
- `updated_by_email` (String) | ||
- `updated_by_full_name` (String) | ||
- `updated_date_time` (String) | ||
|
||
|
||
<a id="nestedatt--operation"></a> | ||
### Nested Schema for `operation` | ||
|
||
Read-Only: | ||
|
||
- `equinix_status` (String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package equinix | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func readFabricNetworkResourceSchema() map[string]*schema.Schema { | ||
sch := fabricNetworkResourceSchema() | ||
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 dataSourceFabricNetwork() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceFabricNetworkRead, | ||
Schema: readFabricNetworkResourceSchema(), | ||
Description: "Fabric V4 API compatible data resource that allow user to fetch Fabric Network for a given UUID", | ||
} | ||
} | ||
|
||
func dataSourceFabricNetworkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { | ||
uuid, _ := d.Get("uuid").(string) | ||
d.SetId(uuid) | ||
return resourceFabricNetworkRead(ctx, d, meta) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package equinix_test | ||
|
||
import ( | ||
"fmt" | ||
"github.com/equinix/terraform-provider-equinix/internal/acceptance" | ||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
_ "github.com/hashicorp/terraform-plugin-testing/terraform" | ||
"testing" | ||
) | ||
|
||
func TestAccDataSourceFabricNetwork_PFCR(t *testing.T) { | ||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.TestAccPreCheck(t) }, | ||
ExternalProviders: acceptance.TestExternalProviders, | ||
Providers: acceptance.TestAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: configCreateNetworkResource_PFCR(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "href"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "uuid"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "name", "Test_Network_PFCR"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "state"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "connections_count", "0"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "type", "EVPLAN"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "notifications.0.type", "ALL"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "notifications.0.emails.0", "[email protected]"), | ||
resource.TestCheckResourceAttr("data.equinix_fabric_network.example", "scope", "GLOBAL"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "change_log.0.created_by"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "change_log.0.created_by_full_name"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "change_log.0.created_by_email"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "change_log.0.created_date_time"), | ||
resource.TestCheckResourceAttrSet("data.equinix_fabric_network.example", "operation.0.equinix_status"), | ||
), | ||
ExpectNonEmptyPlan: false, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func configCreateNetworkResource_PFCR() string { | ||
return fmt.Sprintf(` | ||
resource "equinix_fabric_network" "example" { | ||
type = "EVPLAN" | ||
name = "Test_Network_PFCR" | ||
scope = "GLOBAL" | ||
notifications { | ||
type = "ALL" | ||
emails = ["[email protected]","[email protected]"] | ||
} | ||
project{ | ||
project_id = "291639000636552" | ||
} | ||
} | ||
data "equinix_fabric_network" "example"{ | ||
uuid = equinix_fabric_network.example.id | ||
} | ||
`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.