Skip to content

Commit 1ecbbbd

Browse files
committed
docs: generate docs for datasource filter feature
1 parent 0deb9d8 commit 1ecbbbd

File tree

27 files changed

+298
-84
lines changed

27 files changed

+298
-84
lines changed

docs/data-sources/backupstorages.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@ List all backup storages, or query backup storages by exact name match, or query
1717
data "zstack_backupstorages" "example" {
1818
# name = "backupstorage name"
1919
# name_pattern = "image%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
Status = "Connected"
22-
State = "Enabled"
20+
# optional support schema filter
21+
filter {
22+
name = "status"
23+
values = ["Connected"]
24+
}
25+
filter {
26+
name = "state"
27+
values = ["Enabled"]
28+
}
29+
filter {
30+
name = "total_capacity"
31+
values = ["7999424823296"]
2332
}
2433
}
2534
@@ -33,14 +42,23 @@ output "zstack_imagestorages" {
3342

3443
### Optional
3544

36-
- `filter` (Map of String) Key-value pairs to filter image Storages. For example, to filter by status, use `Status = "Connected"`.
45+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3746
- `name` (String) Exact name for searching backup storage.
3847
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
3948

4049
### Read-Only
4150

4251
- `backup_storages` (Attributes List) List of backup storage entries (see [below for nested schema](#nestedatt--backup_storages))
4352

53+
<a id="nestedblock--filter"></a>
54+
### Nested Schema for `filter`
55+
56+
Required:
57+
58+
- `name` (String) Name of the field to filter by (e.g., status, state).
59+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
60+
61+
4462
<a id="nestedatt--backup_storages"></a>
4563
### Nested Schema for `backup_storages`
4664

docs/data-sources/clusters.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ Fetches a list of clusters and their associated attributes.
1717
data "zstack_clusters" "example" {
1818
#name = "cluster1"
1919
#name_pattern = "clu%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
State = "Enabled"
22-
HypervisorType = "KVM"
23-
Architecture = "x86_64"
20+
filter {
21+
name = "architecture"
22+
values = ["aarch64", "x86_64"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Enabled"]
27+
}
28+
filter {
29+
name = "hypervisor_type"
30+
values = ["KVM"]
2431
}
2532
}
2633
@@ -34,20 +41,30 @@ output "zstack_clusters" {
3441

3542
### Optional
3643

37-
- `filter` (Map of String) Key-value pairs to filter Clusters. For example, to filter by CPU Architecture, use `Architecture = "x86_64"`.
44+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3845
- `name` (String) Exact name for searching Cluster
3946
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
4047

4148
### Read-Only
4249

4350
- `clusters` (Attributes List) List of clusters matching the specified filters (see [below for nested schema](#nestedatt--clusters))
4451

52+
<a id="nestedblock--filter"></a>
53+
### Nested Schema for `filter`
54+
55+
Required:
56+
57+
- `name` (String) Name of the field to filter by (e.g., status, state).
58+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
59+
60+
4561
<a id="nestedatt--clusters"></a>
4662
### Nested Schema for `clusters`
4763

4864
Read-Only:
4965

50-
- `hypervisortype` (String) Type of hypervisor used by the cluster (e.g., KVM, ESXi)
66+
- `architecture` (String) Architecture of the cluster
67+
- `hypervisor_type` (String) Type of hypervisor used by the cluster (e.g., KVM, ESXi)
5168
- `name` (String) Name of the cluster
5269
- `state` (String) State of the cluster (e.g., Enabled, Disabled)
5370
- `type` (String) ype of the cluster

docs/data-sources/disk_offers.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ Fetches a list of disk offers and their associated attributes from the ZStack en
1717
data "zstack_disk_offers" "example" {
1818
name = "smallDiskOffering"
1919
# name_pattern = "sm%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
State = "Enabled"
20+
filter {
21+
name = "name"
22+
values = ["name1", "name2"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Enabled"]
2227
}
2328
}
2429
@@ -32,14 +37,23 @@ output "zstack_disk_offers" {
3237

3338
### Optional
3439

35-
- `filter` (Map of String) Key-value pairs to filter disk offering. For example, to filter by State, use `State = "Enabled"`.
40+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3641
- `name` (String) Exact name for searching disk offer
3742
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
3843

3944
### Read-Only
4045

4146
- `disk_offers` (Attributes List) (see [below for nested schema](#nestedatt--disk_offers))
4247

48+
<a id="nestedblock--filter"></a>
49+
### Nested Schema for `filter`
50+
51+
Required:
52+
53+
- `name` (String) Name of the field to filter by (e.g., status, state).
54+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
55+
56+
4357
<a id="nestedatt--disk_offers"></a>
4458
### Nested Schema for `disk_offers`
4559

docs/data-sources/hosts.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ Fetches a list of hosts and their associated attributes from the ZStack environm
1717
data "zstack_images" "example" {
1818
# name = "imageName"
1919
# name_pattern = "hostname%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = {
21-
Status = "Ready"
22-
State = "Enabled"
23-
Platform = "Linux"
24-
Architecture = "x86_64"
20+
filter {
21+
name = "architecture"
22+
values = ["aarch64", "x86_64"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Enabled"]
27+
}
28+
filter {
29+
name = "status"
30+
values = ["Ready", "Deleted"]
31+
}
32+
filter {
33+
name = "guest_os_type"
34+
values = ["Linux"]
2535
}
2636
}
2737
@@ -35,14 +45,23 @@ output "zstack_images" {
3545

3646
### Optional
3747

38-
- `filter` (Map of String) Key-value pairs to filter hosts. For example, to filter by State, use `State = "Enabled"`.
48+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3949
- `name` (String) Exact name for searching hosts
4050
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
4151

4252
### Read-Only
4353

4454
- `hosts` (Attributes List) List of host entries matching the specified filters (see [below for nested schema](#nestedatt--hosts))
4555

56+
<a id="nestedblock--filter"></a>
57+
### Nested Schema for `filter`
58+
59+
Required:
60+
61+
- `name` (String) Name of the field to filter by (e.g., status, state).
62+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
63+
64+
4665
<a id="nestedatt--hosts"></a>
4766
### Nested Schema for `hosts`
4867

docs/data-sources/images.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@ Fetches a list of images and their associated attributes from the ZStack environ
1717
data "zstack_hosts" "example" {
1818
# name = "hostname"
1919
# name_pattern = "hostname%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
State = "Enabled"
22-
Status = "Connected"
23-
HypervisorType = "KVM"
24-
Architecture = "x86_64"
25-
TotalCpuCapacity = "480"
26-
ManagementIp = "172.30.3.4"
20+
filter {
21+
name = "architecture"
22+
values = ["aarch64", "x86_64"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Enabled"]
27+
}
28+
filter {
29+
name = "status"
30+
values = ["Disconnected"]
31+
}
32+
filter {
33+
name = "cluster_uuid"
34+
values = ["37c25209578c495ca176f60ad0cd97fa"]
2735
}
2836
}
2937
@@ -37,14 +45,23 @@ output "zstack_hosts" {
3745

3846
### Optional
3947

40-
- `filter` (Map of String) Key-value pairs to filter images. For example, to filter by status, use `Status = "Ready"`.
48+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
4149
- `name` (String) Exact name for searching images
4250
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
4351

4452
### Read-Only
4553

4654
- `images` (Attributes List) List of Images (see [below for nested schema](#nestedatt--images))
4755

56+
<a id="nestedblock--filter"></a>
57+
### Nested Schema for `filter`
58+
59+
Required:
60+
61+
- `name` (String) Name of the field to filter by (e.g., status, state).
62+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
63+
64+
4865
<a id="nestedatt--images"></a>
4966
### Nested Schema for `images`
5067

docs/data-sources/instance_offers.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@ Fetches a list of instance offers and their associated attributes from the ZStac
1717
data "zstack_instance_offers" "example" {
1818
# name = "InstanceOffering-1"
1919
# name_pattern = "clu%" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
State = "Enabled"
20+
filter {
21+
name = "allocator_strategy"
22+
values = ["LeastVmPreferredHostAllocatorStrategy"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Enabled"]
27+
}
28+
filter {
29+
name = "memory_size"
30+
values = ["1073741824"]
31+
}
32+
filter {
33+
name = "cpu_num"
34+
values = [1]
2235
}
2336
}
2437
@@ -32,14 +45,23 @@ output "zstack_instance_offers" {
3245

3346
### Optional
3447

35-
- `filter` (Map of String) Key-value pairs to filter instance offering. For example, to filter by State, use `State = "Enabled"`.
48+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3649
- `name` (String) Exact name for searching instance offer
3750
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
3851

3952
### Read-Only
4053

4154
- `instance_offers` (Attributes List) (see [below for nested schema](#nestedatt--instance_offers))
4255

56+
<a id="nestedblock--filter"></a>
57+
### Nested Schema for `filter`
58+
59+
Required:
60+
61+
- `name` (String) Name of the field to filter by (e.g., status, state).
62+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
63+
64+
4365
<a id="nestedatt--instance_offers"></a>
4466
### Nested Schema for `instance_offers`
4567

docs/data-sources/instances.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ Fetches a list of VM instances and their associated attributes from the ZStack e
1717
data "zstack_instances" "vminstances" {
1818
# name = "name of vm instance"
1919
# name_pattern = "virtual machine instances name% Pattern" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = { # option
21-
State = "Running"
22-
CPUNum = "3"
20+
filter {
21+
name = "architecture"
22+
values = ["aarch64", "x86_64"]
23+
}
24+
filter {
25+
name = "state"
26+
values = ["Running", "Stopped"]
27+
}
28+
filter {
29+
name = "hypervisor_type"
30+
values = ["KVM"]
2331
}
2432
}
2533
@@ -34,14 +42,23 @@ output "zstack_vminstances" {
3442

3543
### Optional
3644

37-
- `filter` (Map of String) Key-value pairs to filter instance . For example, to filter by State, use `State = "Running"`.
45+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3846
- `name` (String) Exact name for searching VM instance
3947
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
4048

4149
### Read-Only
4250

4351
- `vminstances` (Attributes List) (see [below for nested schema](#nestedatt--vminstances))
4452

53+
<a id="nestedblock--filter"></a>
54+
### Nested Schema for `filter`
55+
56+
Required:
57+
58+
- `name` (String) Name of the field to filter by (e.g., status, state).
59+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
60+
61+
4562
<a id="nestedatt--vminstances"></a>
4663
### Nested Schema for `vminstances`
4764

docs/data-sources/l2networks.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ Fetches a list of L2 networks and their associated attributes from the ZStack en
1717
data "zstack_l2networks" "networks" {
1818
# name = "L2 networks name"
1919
# name_pattern = "L2 networks name% Pattern" # Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
20-
filter = {
21-
Vlan = 36
22-
Type = "L2VlanNetwork"
20+
filter {
21+
name = "vlan"
22+
values = [36]
23+
}
24+
filter {
25+
name = "physical_interface"
26+
values = ["ens29f1"]
2327
}
2428
}
2529
@@ -33,14 +37,23 @@ output "zstack_l2networks" {
3337

3438
### Optional
3539

36-
- `filter` (Map of String) Key-value pairs to filter L2 networks . For example, to filter by Vlan, use `Vlan = "2"`.
40+
- `filter` (Block List) Filter resources based on any field in the schema. For example, to filter by status, use `name = "status"` and `values = ["Ready"]`. (see [below for nested schema](#nestedblock--filter))
3741
- `name` (String) Exact name for searching L2 Network.
3842
- `name_pattern` (String) Pattern for fuzzy name search, similar to MySQL LIKE. Use % for multiple characters and _ for exactly one character.
3943

4044
### Read-Only
4145

4246
- `l2networks` (Attributes List) List of L2 networks matching the specified filters. (see [below for nested schema](#nestedatt--l2networks))
4347

48+
<a id="nestedblock--filter"></a>
49+
### Nested Schema for `filter`
50+
51+
Required:
52+
53+
- `name` (String) Name of the field to filter by (e.g., status, state).
54+
- `values` (Set of String) Values to filter by. Multiple values will be treated as an OR condition.
55+
56+
4457
<a id="nestedatt--l2networks"></a>
4558
### Nested Schema for `l2networks`
4659

0 commit comments

Comments
 (0)