Skip to content

Commit

Permalink
Refactor cli 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 c5f12fd commit 7ccfae2
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 84 deletions.
9 changes: 5 additions & 4 deletions docs/data-sources/cli_device_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "sdwan_cli_device_template Data Source - terraform-provider-sdwan"
subcategory: "Device Templates"
description: |-
This data source can read a CLI device template.
This data source can read the CLI Device Template .
---

# sdwan_cli_device_template (Data Source)

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

## Example Usage

Expand All @@ -23,12 +23,13 @@ data "sdwan_cli_device_template" "example" {

### Required

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

### Read-Only

- `cli_configuration` (String) CLI configuration
- `cli_type` (String) CLI type
- `description` (String) The description of the feature template
- `description` (String) The description of the device template
- `device_type` (String) The device type (e.g., `vedge-ISR-4331`)
- `name` (String) The name of the device template
- `version` (Number) The version of the object
18 changes: 8 additions & 10 deletions docs/resources/cli_device_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
page_title: "sdwan_cli_device_template Resource - terraform-provider-sdwan"
subcategory: "Device Templates"
description: |-
This resource can manage a CLI device template.
This resource can manage a CLI Device Template .
---

# sdwan_cli_device_template (Resource)

This resource can manage a CLI device template.
This resource can manage a CLI Device Template .

## Example Usage

```terraform
resource "sdwan_cli_device_template" "test" {
name = "cli_template_1"
description = "Terraform integration test"
resource "sdwan_cli_device_template" "example" {
name = "Example"
description = "My description"
device_type = "vedge-ISR-4331"
cli_type = "device"
cli_configuration = <<-EOT
system
host-name {{test}}-ISR4331-1200-1
EOT
cli_configuration = " system\n host-name R1-ISR4331-1200-1"
}
```

Expand All @@ -39,7 +36,8 @@ resource "sdwan_cli_device_template" "test" {

### Read-Only

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

## Import

Expand Down
11 changes: 4 additions & 7 deletions examples/resources/sdwan_cli_device_template/resource.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
resource "sdwan_cli_device_template" "test" {
name = "cli_template_1"
description = "Terraform integration test"
resource "sdwan_cli_device_template" "example" {
name = "Example"
description = "My description"
device_type = "vedge-ISR-4331"
cli_type = "device"
cli_configuration = <<-EOT
system
host-name {{test}}-ISR4331-1200-1
EOT
cli_configuration = " system\n host-name R1-ISR4331-1200-1"
}
46 changes: 46 additions & 0 deletions gen/definitions/generic/cli_device_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: CLI Device Template
rest_endpoint: /template/device/
get_rest_endpoint: /template/device/object/
post_rest_endpoint: /template/device/cli/
has_version: true
id_attribute: templateId
doc_category: Device Templates
attributes:
- model_name: configType
type: String
value: file
- model_name: factoryDefault
Type: Bool
value: false
- 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: cliType
tf_name: cli_type
type: String
mandatory: true
enum_values: [device, intend]
description: CLI type
example: device
- model_name: templateConfiguration
tf_name: cli_configuration
type: String
mandatory: true
description: CLI configuration
example: " system\\n host-name R1-ISR4331-1200-1"
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{
"cli_device_template": "Device Templates",
"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 @@ -143,6 +143,7 @@ type YamlConfig struct {
Model string `yaml:"model"`
RestEndpoint string `yaml:"rest_endpoint"`
GetRestEndpoint string `yaml:"get_rest_endpoint"`
PostRestEndpoint string `yaml:"post_rest_endpoint"`
Type string `yaml:"type"`
MinimumVersion string `yaml:"minimum_version"`
DsDescription string `yaml:"ds_description"`
Expand Down
1 change: 1 addition & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: str()
model: str(required=False)
rest_endpoint: str(required=False)
get_rest_endpoint: str(required=False)
post_rest_endpoint: str(required=False)
type: str(required=False)
minimum_version: str()
ds_description: str(required=False)
Expand Down
2 changes: 1 addition & 1 deletion gen/templates/generic/resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions gen/templates/provider.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions internal/provider/data_source_sdwan_cli_device_template.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions internal/provider/data_source_sdwan_cli_device_template_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 48 additions & 15 deletions internal/provider/model_sdwan_cli_device_template.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7ccfae2

Please sign in to comment.