Skip to content

Commit

Permalink
update attribute descriptions and make docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bwJuniper committed Aug 9, 2024
1 parent 67f3705 commit 84a252f
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apstra/blueprint/freeform_resource_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (o FreeformResourceGenerator) DataSourceAttributes() map[string]dataSourceS
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
},
"id": dataSourceSchema.StringAttribute{
MarkdownDescription: "Populate this field to look up the Freeform Resource by ID. Required when `name` is omitted.",
MarkdownDescription: "Populate this field to look up the Freeform Resource Generator by ID. Required when `name` is omitted.",
Optional: true,
Computed: true,
Validators: []validator.String{
Expand All @@ -53,11 +53,11 @@ func (o FreeformResourceGenerator) DataSourceAttributes() map[string]dataSourceS
},
},
"type": dataSourceSchema.StringAttribute{
MarkdownDescription: "Type of the Resource",
MarkdownDescription: "Type of the Resource Generator",
Computed: true,
},
"name": dataSourceSchema.StringAttribute{
MarkdownDescription: "Populate this field to look up Resource by Name. Required when `id` is omitted.",
MarkdownDescription: "Populate this field to look up Resource Generator by Name. Required when `id` is omitted.",
Optional: true,
Computed: true,
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
Expand All @@ -73,7 +73,7 @@ func (o FreeformResourceGenerator) DataSourceAttributes() map[string]dataSourceS
Computed: true,
},
"container_id": dataSourceSchema.StringAttribute{
MarkdownDescription: "ID of the group generator that created the group, if any.",
MarkdownDescription: "ID of the group used to organize the generated resources",
Computed: true,
},
"subnet_prefix_len": dataSourceSchema.Int64Attribute{
Expand Down Expand Up @@ -104,7 +104,7 @@ func (o FreeformResourceGenerator) ResourceAttributes() map[string]resourceSchem
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
},
"name": resourceSchema.StringAttribute{
MarkdownDescription: "Freeform Resource name as shown in the Web UI.",
MarkdownDescription: "Freeform Resource Generator name as shown in the Web UI.",
Required: true,
Validators: []validator.String{
stringvalidator.RegexMatches(regexp.MustCompile("^[a-zA-Z0-9.-_]+$"), "name may consist only of the following characters : a-zA-Z0-9.-_"),
Expand Down
92 changes: 92 additions & 0 deletions docs/data-sources/freeform_resource_generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
page_title: "apstra_freeform_resource_generator Data Source - terraform-provider-apstra"
subcategory: "Reference Design: Freeform"
description: |-
This data source provides details of a specific Freeform Resource.
At least one optional attribute is required.
---

# apstra_freeform_resource_generator (Data Source)

This data source provides details of a specific Freeform Resource.

At least one optional attribute is required.


## Example Usage

```terraform
# This example creates an ASN resource Generator within a
# preexisting resource group in a Freeform Blueprint.
#
# After creating the Resource Generator, the data source is invoked to look up
# the details.
resource "apstra_freeform_resource_group" "fizz_grp" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "fizz_grp"
}
resource "apstra_asn_pool" "rfc5398" {
name = "RFC5398 ASN"
ranges = [
{
first = 64496
last = 64511
},
{
first = 65536
last = 65551
},
]
}
resource "apstra_freeform_alloc_group" "test" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "test_alloc_group2"
type = "asn"
pool_ids = [apstra_asn_pool.rfc5398.id]
}
resource "apstra_freeform_resource_generator" "test_res_gen" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "test_res_gen"
type = "asn"
scope = "node('system', name='target')"
allocated_from = apstra_freeform_alloc_group.test.id
container_id = apstra_freeform_resource_group.fizz_grp.id
}
# The output looks like:
#test_resource_generator_out = {
# "allocated_from" = "rag_asn_test_alloc_group2"
# "blueprint_id" = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
# "container_id" = "gPJtXP7_SM31CYWDJ0g"
# "id" = "EkrP9avh6pgqRqRCm44"
# "name" = "test_res_gen"
# "scope" = "node('system', name='target')"
# "subnet_prefix_len" = tonumber(null)
# "type" = "asn"
#}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `blueprint_id` (String) Apstra Blueprint ID. Used to identify the Blueprint where the Resource lives.

### Optional

- `id` (String) Populate this field to look up the Freeform Resource Generator by ID. Required when `name` is omitted.
- `name` (String) Populate this field to look up Resource Generator by Name. Required when `id` is omitted.

### Read-Only

- `allocated_from` (String) ID of the node from which this resource generator has been sourced. This could be an ID of resource generator or another resource (in case of IP or Host IP allocations). This also can be empty. In that case it is required that value for this resource is provided by the user.
- `container_id` (String) ID of the group used to organize the generated resources
- `scope` (String) Scope the Resource Generator uses for resource generation
- `subnet_prefix_len` (Number) Length of the subnet for the generated resources, if any.
- `type` (String) Type of the Resource Generator
100 changes: 100 additions & 0 deletions docs/resources/freeform_resource_generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
page_title: "apstra_freeform_resource_generator Resource - terraform-provider-apstra"
subcategory: "Reference Design: Freeform"
description: |-
This resource creates a Resource in a Freeform Blueprint.
---

# apstra_freeform_resource_generator (Resource)

This resource creates a Resource in a Freeform Blueprint.


## Example Usage

```terraform
# This example creates an ASN resource Generator within a
# preexisting resource group in a Freeform Blueprint.
#
# After creating the Resource Generator, the data source is invoked to look up
# the details.
resource "apstra_freeform_resource_group" "fizz_grp" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "fizz_grp"
}
resource "apstra_asn_pool" "rfc5398" {
name = "RFC5398 ASN"
ranges = [
{
first = 64496
last = 64511
},
{
first = 65536
last = 65551
},
]
}
resource "apstra_freeform_alloc_group" "test" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "test_alloc_group2"
type = "asn"
pool_ids = [apstra_asn_pool.rfc5398.id]
}
resource "apstra_freeform_resource_generator" "test_res_gen" {
blueprint_id = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
name = "test_res_gen"
type = "asn"
scope = "node('system', name='target')"
allocated_from = apstra_freeform_alloc_group.test.id
container_id = apstra_freeform_resource_group.fizz_grp.id
}
# The output looks like:
#test_resource_generator_out = {
# "allocated_from" = "rag_asn_test_alloc_group2"
# "blueprint_id" = "631f8832-ae59-40ca-b4f6-9c19b411aeaf"
# "container_id" = "gPJtXP7_SM31CYWDJ0g"
# "id" = "EkrP9avh6pgqRqRCm44"
# "name" = "test_res_gen"
# "scope" = "node('system', name='target')"
# "subnet_prefix_len" = tonumber(null)
# "type" = "asn"
#}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `allocated_from` (String) ID of the node to be used as a source for this resource. This could be an ID of resource group or another resource (in case of IP or Host IP allocations). This also can be empty. In that case it is required that value for this resource is provided by the user.
- `blueprint_id` (String) Apstra Blueprint ID.
- `container_id` (String) ID of the group where resources are generated.
- `name` (String) Freeform Resource Generator name as shown in the Web UI.
- `scope` (String) Scope the Resource Generator uses for resource generation.
- `type` (String) type of the Resource Generator, must be one of :
- `asn`
- `host_ipv4`
- `host_ipv6`
- `integer`
- `ipv4`
- `ipv6`
- `vlan`
- `vni`

### Optional

- `subnet_prefix_len` (Number) Length of the subnet for the generated resources, if any.

### Read-Only

- `id` (String) ID of the Resource Generator within the Freeform Blueprint.



0 comments on commit 84a252f

Please sign in to comment.