Skip to content

Commit 81a1b36

Browse files
committed
Fix region data source documentation
Signed-off-by: Ferran Rodenas <[email protected]>
1 parent 9fe1b31 commit 81a1b36

File tree

3 files changed

+54
-95
lines changed

3 files changed

+54
-95
lines changed

vra/data_source_region.go

+21-15
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ func dataSourceRegion() *schema.Resource {
1818

1919
Schema: map[string]*schema.Schema{
2020
"cloud_account_id": {
21-
Type: schema.TypeString,
22-
Optional: true,
23-
Computed: true,
24-
Description: "The id of the cloud account the region belongs to.",
21+
Type: schema.TypeString,
22+
Optional: true,
23+
Computed: true,
24+
ConflictsWith: []string{"id", "filter"},
25+
Description: "The id of the cloud account the region belongs to.",
26+
RequiredWith: []string{"region"},
2527
},
2628
"created_at": {
2729
Type: schema.TypeString,
@@ -34,15 +36,17 @@ func dataSourceRegion() *schema.Resource {
3436
Description: "Unique identifier of region on the provider side.",
3537
},
3638
"filter": {
37-
Type: schema.TypeString,
38-
Optional: true,
39-
Description: "Search criteria to narrow down Regions.",
39+
Type: schema.TypeString,
40+
ConflictsWith: []string{"cloud_account_id", "id", "region"},
41+
Optional: true,
42+
Description: "Search criteria to narrow down Regions.",
4043
},
4144
"id": {
42-
Type: schema.TypeString,
43-
Optional: true,
44-
Computed: true,
45-
Description: "The id of the region instance.",
45+
Type: schema.TypeString,
46+
Optional: true,
47+
Computed: true,
48+
ConflictsWith: []string{"cloud_account_id", "filter", "region"},
49+
Description: "The id of the region instance.",
4650
},
4751
"name": {
4852
Type: schema.TypeString,
@@ -60,9 +64,11 @@ func dataSourceRegion() *schema.Resource {
6064
Description: "Email of the user that owns the entity.",
6165
},
6266
"region": {
63-
Type: schema.TypeString,
64-
Optional: true,
65-
Description: "The specific region associated with the cloud account. On vSphere, this is the external ID.",
67+
Type: schema.TypeString,
68+
Optional: true,
69+
ConflictsWith: []string{"id", "filter"},
70+
Description: "The specific region associated with the cloud account. On vSphere, this is the external ID.",
71+
RequiredWith: []string{"cloud_account_id"},
6672
},
6773
"updated_at": {
6874
Type: schema.TypeString,
@@ -82,7 +88,7 @@ func dataSourceRegionRead(d *schema.ResourceData, meta interface{}) error {
8288
id, idOk := d.GetOk("id")
8389

8490
if !idOk && !cloudAccountIDOk && !regionOk && !filterOk {
85-
return fmt.Errorf("one of the following are required: (id, filter, region and cloudAccountId)")
91+
return fmt.Errorf("one of the following are required: (`id`, `filter`, or `region` and `cloud_account_id`)")
8692
}
8793

8894
setFields := func(region *models.Region) {

website/docs/d/region.html.markdown

+33-19
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,59 @@ description: |-
88

99
# Data Source: vra\_region
1010

11-
This is an example of how to lookup a region data source.
11+
This is an example of how to lookup a region data source:
12+
13+
**Region data source by id:**
1214

13-
**Region data source**
1415
```hcl
15-
data "vra_region" "region_1" {
16-
cloud_account_id = "cloud_account_id"
17-
region = "us-east-1"
16+
data "vra_region" "this" {
17+
id = var.vra_region_id
1818
}
1919
```
2020

21+
**Region data source by filter:**
22+
2123
```hcl
22-
data "vra_region" "eastus" {
23-
cloud_account_id = "cloud_account_id"
24-
region = "eastus"
24+
data "vra_region" "this" {
25+
filter = "name eq '${var.vra_region_name}'"
2526
}
2627
```
2728

28-
The region data source supports the following arguments:
29+
**Region data source by cloud account id and region:**
30+
31+
```hcl
32+
data "vra_region" "this" {
33+
cloud_account_id = var.vra_cloud_account_id
34+
region = var.vra_region_external_id
35+
}
36+
```
2937

3038
## Argument Reference
31-
* `cloud_account_id` - (Optional) The id of the cloud account this region belongs to. Example: 9e49
3239

33-
* `filter` - (Optional) The id of this resource instance.
40+
The following arguments are supported:
41+
42+
* `cloud_account_id` - (Optional) The id of the cloud account the region belongs to.
3443

35-
* `id` - (Optional) The id of this resource instance. Example: 9e49
44+
* `filter` - (Optional) Search criteria to narrow down Regions.
3645

37-
* `region` - (Optional) Name of region on the provider side. In vSphere, the name of the region is different from its id. Example: us-west
46+
* `id` - (Optional) The id of the region instance.
3847

48+
* `region` - (Optional) The specific region associated with the cloud account. On vSphere, this is the external ID.
49+
50+
-> **Note:** One of `id`, `filter` or` cloud_account_id` and `region` must be specified.
3951

4052
## Attribute Reference
41-
* `created_at` - Date when the entity was created. The date is in ISO 8601 and UTC. Example: 2012-09-27
4253

43-
* `external_region_id` - Unique identifier of region on the provider side. Example: us-west
54+
In addition to all arguments above, the following attributes are exported:
55+
56+
* `created_at` - Date when the entity was created. The date is in ISO 8601 and UTC.
4457

45-
* `name` - Name of region on the provider side. In vSphere, the name of the region is different from its id. Example: us-west
58+
* `external_region_id` - Unique identifier of region on the provider side.
4659

47-
* `org_id` - The id of the organization this entity belongs to. Example: 9e49
60+
* `name` - Name of region on the provider side. In vSphere, the name of the region is different from its id.
4861

49-
* `owner` - Email of the user that owns the entity. Example: [email protected]
62+
* `org_id` - The id of the organization this entity belongs to.
5063

51-
* `updated_at` - Date when the entity was last updated. The date is ISO 8601 and UTC. Example: 2012-09-27
64+
* `owner` - Email of the user that owns the entity.
5265

66+
* `updated_at` - Date when the entity was last updated. The date is ISO 8601 and UTC.

website/docs/d/vra_region.html.markdown

-61
This file was deleted.

0 commit comments

Comments
 (0)