Skip to content

Commit

Permalink
Refactor feature device template resource and data source
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Jul 25, 2023
1 parent 7ccfae2 commit a960db5
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 271 deletions.
23 changes: 12 additions & 11 deletions docs/data-sources/feature_device_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "sdwan_feature_device_template Data Source - terraform-provider-sdwan"
subcategory: "Device Templates"
description: |-
This data source can read a feature device template.
This data source can read the Feature Device Template .
---

# sdwan_feature_device_template (Data Source)

This data source can read a feature device template.
This data source can read the Feature Device Template .

## Example Usage

Expand All @@ -23,39 +23,40 @@ data "sdwan_feature_device_template" "example" {

### Required

- `id` (String) The id of the device template
- `id` (String) The id of the object

### Read-Only

- `description` (String) The description of the feature template
- `description` (String) The description of the device template
- `device_role` (String) The device role
- `device_type` (String) The device type (e.g., `vedge-ISR-4331`)
- `general_templates` (Attributes Set) General templates (see [below for nested schema](#nestedatt--general_templates))
- `general_templates` (Attributes Set) List of general templates (see [below for nested schema](#nestedatt--general_templates))
- `name` (String) The name of the device template
- `policy_id` (String) The policy ID
- `policy_version` (Number) The policy version
- `security_policy_id` (String) The security policy ID
- `version` (Number) The version of the device template
- `security_policy_version` (Number) The security policy version
- `version` (Number) The version of the object

<a id="nestedatt--general_templates"></a>
### Nested Schema for `general_templates`

Read-Only:

- `id` (String) Feature template ID
- `sub_templates` (Attributes Set) Sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates))
- `sub_templates` (Attributes Set) List of sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates))
- `type` (String) Feature template type
- `version` (Number) The version of the feature template
- `version` (Number) Feature template version

<a id="nestedatt--general_templates--sub_templates"></a>
### Nested Schema for `general_templates.sub_templates`

Read-Only:

- `id` (String) Feature template ID
- `sub_templates` (Attributes Set) Sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates--sub_templates))
- `sub_templates` (Attributes Set) List of sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates--sub_templates))
- `type` (String) Feature template type
- `version` (Number) The version of the feature template
- `version` (Number) Feature template version

<a id="nestedatt--general_templates--sub_templates--sub_templates"></a>
### Nested Schema for `general_templates.sub_templates.sub_templates`
Expand All @@ -64,4 +65,4 @@ Read-Only:

- `id` (String) Feature template ID
- `type` (String) Feature template type
- `version` (Number) The version of the feature template
- `version` (Number) Feature template version
31 changes: 17 additions & 14 deletions docs/resources/feature_device_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
page_title: "sdwan_feature_device_template Resource - terraform-provider-sdwan"
subcategory: "Device Templates"
description: |-
This resource can manage a feature device template.
This resource can manage a Feature Device Template .
---

# sdwan_feature_device_template (Resource)

This resource can manage a feature device template.
This resource can manage a Feature Device Template .

## Example Usage

```terraform
resource "sdwan_feature_device_template" "test" {
name = "device_group_1"
description = "My device template"
resource "sdwan_feature_device_template" "example" {
name = "Example"
description = "My description"
device_type = "vedge-ISR-4331"
general_templates = [{
id = sdwan_cisco_system_feature_template.system.id
type = sdwan_cisco_system_feature_template.system.template_type
}]
general_templates = [
{
id = "2081c2f4-3f9f-4fee-8078-dcc8904e368d"
type = "cisco_system"
}
]
}
```

Expand All @@ -37,15 +39,16 @@ resource "sdwan_feature_device_template" "test" {

- `device_role` (String) The device role
- Choices: `sdwan-edge`, `service-node`
- `general_templates` (Attributes Set) General templates (see [below for nested schema](#nestedatt--general_templates))
- `general_templates` (Attributes Set) List of general templates (see [below for nested schema](#nestedatt--general_templates))
- `policy_id` (String) The policy ID
- `policy_version` (Number) The policy version
- `security_policy_id` (String) The security policy ID
- `security_policy_version` (Number) The security policy version

### Read-Only

- `id` (String) The id of the device template
- `version` (Number) The version of the device template
- `id` (String) The id of the object
- `version` (Number) The version of the object

<a id="nestedatt--general_templates"></a>
### Nested Schema for `general_templates`
Expand All @@ -57,7 +60,7 @@ Required:

Optional:

- `sub_templates` (Attributes Set) Sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates))
- `sub_templates` (Attributes Set) List of sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates))
- `version` (Number) Feature template version

<a id="nestedatt--general_templates--sub_templates"></a>
Expand All @@ -70,7 +73,7 @@ Required:

Optional:

- `sub_templates` (Attributes Set) Sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates--sub_templates))
- `sub_templates` (Attributes Set) List of sub templates (see [below for nested schema](#nestedatt--general_templates--sub_templates--sub_templates))
- `version` (Number) Feature template version

<a id="nestedatt--general_templates--sub_templates--sub_templates"></a>
Expand Down
16 changes: 9 additions & 7 deletions examples/resources/sdwan_feature_device_template/resource.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
resource "sdwan_feature_device_template" "test" {
name = "device_group_1"
description = "My device template"
resource "sdwan_feature_device_template" "example" {
name = "Example"
description = "My description"
device_type = "vedge-ISR-4331"
general_templates = [{
id = sdwan_cisco_system_feature_template.system.id
type = sdwan_cisco_system_feature_template.system.template_type
}]
general_templates = [
{
id = "2081c2f4-3f9f-4fee-8078-dcc8904e368d"
type = "cisco_system"
}
]
}
151 changes: 151 additions & 0 deletions gen/definitions/generic/feature_device_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
name: Feature Device Template
rest_endpoint: /template/device/
post_rest_endpoint: /template/device/feature/
get_rest_endpoint: /template/device/object/
has_version: true
id_attribute: templateId
doc_category: Device Templates
attributes:
- model_name: configType
type: String
value: template
- model_name: factoryDefault
type: Bool
value: false
- model_name: featureTemplateUidRange
type: List
value: "[]interface{}{}"
- model_name: templateName
tf_name: name
type: String
mandatory: true
description: The name of the device template
example: Example
- model_name: templateDescription
tf_name: description
type: String
mandatory: true
description: The description of the device template
example: My description
- model_name: deviceType
tf_name: device_type
type: String
mandatory: true
description: The device type (e.g., `vedge-ISR-4331`)
example: vedge-ISR-4331
- model_name: deviceRole
tf_name: device_role
type: String
enum_values: [sdwan-edge, service-node]
description: The device role
example: sdwan-edge
always_include: true
exclude_test: true
- model_name: policyId
tf_name: policy_id
type: String
description: The policy ID
example: 2081c2f4-3f9f-4fee-8078-dcc8904e368d
always_include: true
exclude_test: true
- tf_name: policy_version
tf_only: true
type: Version
description: The policy version
exclude_test: true
- model_name: securityPolicyId
tf_name: security_policy_id
type: String
description: The security policy ID
example: 2081c2f4-3f9f-4fee-8078-dcc8904e368d
exclude_test: true
- tf_name: security_policy_version
tf_only: true
type: Version
description: The security policy version
exclude_test: true
- model_name: generalTemplates
tf_name: general_templates
type: Set
description: List of general templates
attributes:
- model_name: templateId
tf_name: id
type: String
id: true
mandatory: true
description: Feature template ID
example: 2081c2f4-3f9f-4fee-8078-dcc8904e368d
test_value: sdwan_cisco_system_feature_template.system.id
- tf_name: version
tf_only: true
type: Version
description: Feature template version
exclude_test: true
- model_name: templateType
tf_name: type
type: String
mandatory: true
description: Feature template type
example: cisco_system
- model_name: subTemplates
tf_name: sub_templates
type: Set
description: List of sub templates
exclude_test: true
attributes:
- model_name: templateId
tf_name: id
type: String
id: true
mandatory: true
description: Feature template ID
example: 2081c2f4-3f9f-4fee-8078-dcc8904e368d
- tf_name: version
tf_only: true
type: Version
description: Feature template version
exclude_test: true
- model_name: templateType
tf_name: type
type: String
mandatory: true
description: Feature template type
example: cisco_vpn_interface
- model_name: subTemplates
tf_name: sub_templates
type: Set
description: List of sub templates
exclude_test: true
attributes:
- model_name: templateId
tf_name: id
type: String
id: true
mandatory: true
description: Feature template ID
example: 2081c2f4-3f9f-4fee-8078-dcc8904e368d
- tf_name: version
tf_only: true
type: Version
description: Feature template version
exclude_test: true
- model_name: templateType
tf_name: type
type: String
mandatory: true
description: Feature template type
example: cisco_vpn_interface

test_prerequisites: |
resource "sdwan_cisco_system_feature_template" "system" {
name = "TF_SYSTEM_1"
description = "Terraform integration test"
device_types = ["vedge-C8000V"]
hostname = "Router1"
system_ip = "5.5.5.5"
site_id = 1
console_baud_rate = "115200"
multi_tenant = true
}
1 change: 0 additions & 1 deletion gen/doc_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type YamlConfig struct {
var docPaths = []string{"./docs/data-sources/", "./docs/resources/"}

var extraDocs = map[string]string{
"feature_device_template": "Device Templates",
"attach_feature_device_template": "Device Templates",
}

Expand Down
1 change: 1 addition & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ type YamlConfigAttribute struct {
DefaultValue string `yaml:"default_value"`
Value string `yaml:"value"`
TestValue string `yaml:"test_value"`
AlwaysInclude bool `yaml:"always_include"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
ConditionalAttribute YamlConfigConditionalAttribute `yaml:"conditional_attribute"`
}
Expand Down
1 change: 1 addition & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ attribute:
default_value: any(str(), int(), bool(), required=False)
value: any(str(), int(), bool(), required=False)
test_value: str(required=False)
always_include: bool(required=False)
attributes: list(include('attribute'), required=False)
conditional_attribute: include('conditional_attribute', required=False)

Expand Down
Loading

0 comments on commit a960db5

Please sign in to comment.