Skip to content

Tags to template #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c95fc8e
added GenerateQueryParamString templating helper function
kuba-mazurkiewicz Jul 19, 2024
b853a94
use create_query_path instead of query_param in Create and Update fun…
kuba-mazurkiewicz Jul 19, 2024
d0e2c6f
add query_param_no_body and data_source_no_id attributes
kuba-mazurkiewicz Jul 20, 2024
c1381fd
add import_no_id attribute, if import does not require and ID
kuba-mazurkiewicz Jul 20, 2024
a98ad26
add anycast_gateway
kuba-mazurkiewicz Jul 20, 2024
5545db0
update changelog
kuba-mazurkiewicz Jul 20, 2024
9c69bd5
add transitPeerNetworkId as id to transit_peer_network resource
kuba-mazurkiewicz Jul 20, 2024
c70bd2a
updated changelog
kuba-mazurkiewicz Jul 20, 2024
38d93bf
add fabric_l3_handoff_ip_transit resource and data source
kuba-mazurkiewicz Jul 21, 2024
59173f3
add fabric_device resource and data source
kuba-mazurkiewicz Jul 21, 2024
522d49c
pnp bulk import
kuba-mazurkiewicz Jul 22, 2024
30854ad
update changelog
kuba-mazurkiewicz Jul 22, 2024
9a6533c
rename pnp_device_import to pnp_import_devices
kuba-mazurkiewicz Jul 24, 2024
35565f0
add tag and assign_templates_to_tag
kuba-mazurkiewicz Jul 26, 2024
241fe0a
changed template_ids from List to Set
kuba-mazurkiewicz Jul 26, 2024
2db5bce
update changelog
kuba-mazurkiewicz Jul 26, 2024
9f31f09
Merge branch 'main' into tags_to_template
kuba-mazurkiewicz Aug 5, 2024
df90953
update changelog
kuba-mazurkiewicz Aug 5, 2024
c8291fd
modified res_description
kuba-mazurkiewicz Aug 5, 2024
6333f8e
minor modifications to tag resource
kuba-mazurkiewicz Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 0.1.10 (unreleased)

- Add `assign_templates_to_tag` resource and data source
- Add `tag` resource and data source
- Add `pnp_import_devices` resource
- Add `fabric_device` resource and data source, this resource now only works with Catalyst Center version 2.3.7.5+ `/sda/fabricDevices`
- Add `fabric_l3_handoff_ip_transit` resource and data source
Expand Down
31 changes: 31 additions & 0 deletions docs/data-sources/assign_templates_to_tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_assign_templates_to_tag Data Source - terraform-provider-catalystcenter"
subcategory: "Tags"
description: |-
This data source can read the Assign Templates to Tag.
---

# catalystcenter_assign_templates_to_tag (Data Source)

This data source can read the Assign Templates to Tag.

## Example Usage

```terraform
data "catalystcenter_assign_templates_to_tag" "example" {
tag_id = "ea505070-6bb8-493f-bff0-8058e8e03ee5"
}
```

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

### Required

- `tag_id` (String) Tag Id to be associated with the template

### Read-Only

- `id` (String) The id of the object
- `template_ids` (Set of String) Template Ids List
54 changes: 54 additions & 0 deletions docs/data-sources/tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_tag Data Source - terraform-provider-catalystcenter"
subcategory: "Tags"
description: |-
This data source can read the Tag.
---

# catalystcenter_tag (Data Source)

This data source can read the Tag.

## Example Usage

```terraform
data "catalystcenter_tag" "example" {
name = "Tag1"
}
```

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

### Required

- `name` (String)

### Read-Only

- `description` (String) Description of the tag
- `dynamic_rules` (Attributes List) Dynamic rules details (see [below for nested schema](#nestedatt--dynamic_rules))
- `id` (String) The id of the object
- `system_tag` (Boolean) true for system created tags, false for user defined tag

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

Read-Only:

- `member_type` (String) memberType of the tag (e.g. networkdevice, interface)
- `rule_items` (Attributes List) items details, multiple rules can be defined by items (see [below for nested schema](#nestedatt--dynamic_rules--rule_items))
- `rule_name` (String) Name of the parameter (e.g. for interface:portName,adminStatus,speed,status,description. for networkdevice:family,series,hostname,managementIpAddress,groupNameHierarchy,softwareVersion)
- `rule_operation` (String) Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- `rule_value` (String) Value of the parameter (e.g. for portName:1/0/1,for adminStatus,status:up/down, for speed: any integer value, for description: any valid string, for family:switches, for series:C3650, for managementIpAddress:10.197.124.90, groupNameHierarchy:Global, softwareVersion: 16.9.1)
- `rule_values` (List of String) values of the parameter,Only one of the value or values can be used for the given parameter. (for managementIpAddress e.g. ["10.197.124.90","10.197.124.91"])

<a id="nestedatt--dynamic_rules--rule_items"></a>
### Nested Schema for `dynamic_rules.rule_items`

Read-Only:

- `name` (String) Name of the parameter (e.g. managementIpAddress,hostname)
- `operation` (String) Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- `value` (String) Value of the parameter (e.g. %10%,%NA%)
2 changes: 2 additions & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: |-

## 0.1.10 (unreleased)

- Add `assign_templates_to_tag` resource and data source
- Add `tag` resource and data source
- Add `pnp_import_devices` resource
- Add `fabric_device` resource and data source, this resource now only works with Catalyst Center version 2.3.7.5+ `/sda/fabricDevices`
- Add `fabric_l3_handoff_ip_transit` resource and data source
Expand Down
35 changes: 35 additions & 0 deletions docs/resources/assign_templates_to_tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_assign_templates_to_tag Resource - terraform-provider-catalystcenter"
subcategory: "Tags"
description: |-
This resource is responsible for assigning templates to a specified tag during creation and removing the template from the tag during destroy operation.
---

# catalystcenter_assign_templates_to_tag (Resource)

This resource is responsible for assigning templates to a specified tag during creation and removing the template from the tag during destroy operation.

## Example Usage

```terraform
resource "catalystcenter_assign_templates_to_tag" "example" {
tag_id = "ea505070-6bb8-493f-bff0-8058e8e03ee5"
template_ids = ["75b0f85a-8157-4db3-ae2d-9807c893319a"]
}
```

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

### Required

- `tag_id` (String) Tag Id to be associated with the template

### Optional

- `template_ids` (Set of String) Template Ids List

### Read-Only

- `id` (String) The id of the object
67 changes: 67 additions & 0 deletions docs/resources/tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_tag Resource - terraform-provider-catalystcenter"
subcategory: "Tags"
description: |-
This resource can manage a Tag.
---

# catalystcenter_tag (Resource)

This resource can manage a Tag.

## Example Usage

```terraform
resource "catalystcenter_tag" "example" {
name = "Tag1"
description = "Tag1 Description"
system_tag = false
}
```

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

### Required

- `name` (String)

### Optional

- `description` (String) Description of the tag
- `dynamic_rules` (Attributes List) Dynamic rules details (see [below for nested schema](#nestedatt--dynamic_rules))
- `system_tag` (Boolean) true for system created tags, false for user defined tag

### Read-Only

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

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

Optional:

- `member_type` (String) memberType of the tag (e.g. networkdevice, interface)
- `rule_items` (Attributes List) items details, multiple rules can be defined by items (see [below for nested schema](#nestedatt--dynamic_rules--rule_items))
- `rule_name` (String) Name of the parameter (e.g. for interface:portName,adminStatus,speed,status,description. for networkdevice:family,series,hostname,managementIpAddress,groupNameHierarchy,softwareVersion)
- `rule_operation` (String) Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- `rule_value` (String) Value of the parameter (e.g. for portName:1/0/1,for adminStatus,status:up/down, for speed: any integer value, for description: any valid string, for family:switches, for series:C3650, for managementIpAddress:10.197.124.90, groupNameHierarchy:Global, softwareVersion: 16.9.1)
- `rule_values` (List of String) values of the parameter,Only one of the value or values can be used for the given parameter. (for managementIpAddress e.g. ["10.197.124.90","10.197.124.91"])

<a id="nestedatt--dynamic_rules--rule_items"></a>
### Nested Schema for `dynamic_rules.rule_items`

Optional:

- `name` (String) Name of the parameter (e.g. managementIpAddress,hostname)
- `operation` (String) Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- `value` (String) Value of the parameter (e.g. %10%,%NA%)

## Import

Import is supported using the following syntax:

```shell
terraform import catalystcenter_tag.example "<name>"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "catalystcenter_assign_templates_to_tag" "example" {
tag_id = "ea505070-6bb8-493f-bff0-8058e8e03ee5"
}
3 changes: 3 additions & 0 deletions examples/data-sources/catalystcenter_tag/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "catalystcenter_tag" "example" {
name = "Tag1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "catalystcenter_assign_templates_to_tag" "example" {
tag_id = "ea505070-6bb8-493f-bff0-8058e8e03ee5"
template_ids = ["75b0f85a-8157-4db3-ae2d-9807c893319a"]
}
1 change: 1 addition & 0 deletions examples/resources/catalystcenter_tag/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import catalystcenter_tag.example "<name>"
5 changes: 5 additions & 0 deletions examples/resources/catalystcenter_tag/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "catalystcenter_tag" "example" {
name = "Tag1"
description = "Tag1 Description"
system_tag = false
}
56 changes: 56 additions & 0 deletions gen/definitions/assign_templates_to_tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: Assign Templates to Tag
rest_endpoint: /dna/intent/api/v1/tag/%v/member
get_extra_query_params: '?memberType=template'
get_no_id: true
# Manual updates in Delete function to handle removal of templates from tag in resource file, and fromBody, updateFromBody functions in model file
res_description: 'This resource is responsible for assigning templates to a specified tag during creation
and removing the template from the tag during destroy operation.'
post_update: true
no_import: true
data_source_no_id: true
skip_minimum_test: true
doc_category: Tags
attributes:
- model_name: tagId
type: String
reference: true
id: true
description: Tag Id to be associated with the template
example: ea505070-6bb8-493f-bff0-8058e8e03ee5
test_value: catalystcenter_tag.test.id
- model_name: template
tf_name: template_ids
type: Set
element_type: String
description: Template Ids List
example: 75b0f85a-8157-4db3-ae2d-9807c893319a
test_value: '[catalystcenter_template.test.id]'
test_prerequisites: |
resource "catalystcenter_tag" "test" {
name = "Tag1"
description = "Tag1 Description"
system_tag = false
}

resource "catalystcenter_project" "test" {
name = "Project1"
}

resource "catalystcenter_template" "test" {
project_id = catalystcenter_project.test.id
name = "Template1"
description = "My description"
device_types = [
{
product_family = "Switches and Hubs"
product_series = "Cisco Catalyst 9300 Series Switches"
product_type = "Cisco Catalyst 9300 Switch"
}
]
language = "JINJA"
software_type = "IOS-XE"
software_variant = "XE"
software_version = "16.12.1a"
template_content = "hostname SW1"
}
71 changes: 71 additions & 0 deletions gen/definitions/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Tag
rest_endpoint: /dna/intent/api/v1/tag
id_from_query_path: response.0
id_from_query_path_attribute: id
put_id_include_path: id
import_no_id: true
data_source_no_id: true
doc_category: Tags
attributes:
- model_name: name
response_data_path: response.0.name
type: String
mandatory: true
query_param: true
example: Tag1
- model_name: description
response_data_path: response.0.description
type: String
description: Description of the tag
example: Tag1 Description
- model_name: systemTag
response_data_path: response.0.systemTag
type: Bool
description: true for system created tags, false for user defined tag
example: false
- model_name: dynamicRules
response_data_path: response.0.dynamicRules
type: List
description: Dynamic rules details
exclude_test: true
attributes:
- model_name: memberType
type: String
description: memberType of the tag (e.g. networkdevice, interface)
- model_name: values
tf_name: rule_values
data_path: rules
type: List
element_type: String
description: 'values of the parameter,Only one of the value or values can be used for the given parameter. (for managementIpAddress e.g. [\"10.197.124.90\",\"10.197.124.91\"])'
- model_name: items
tf_name: rule_items
data_path: rules
type: List
description: 'items details, multiple rules can be defined by items'
attributes:
- model_name: operation
type: String
description: Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- model_name: name
type: String
description: Name of the parameter (e.g. managementIpAddress,hostname)
- model_name: value
type: String
description: Value of the parameter (e.g. %10%,%NA%)
- model_name: operation
tf_name: rule_operation
data_path: rules
type: String
description: Operation of the rule (e.g. OR,IN,EQ,LIKE,ILIKE,AND)
- model_name: name
tf_name: rule_name
data_path: rules
type: String
description: 'Name of the parameter (e.g. for interface:portName,adminStatus,speed,status,description. for networkdevice:family,series,hostname,managementIpAddress,groupNameHierarchy,softwareVersion)'
- model_name: value
tf_name: rule_value
data_path: rules
type: String
description: 'Value of the parameter (e.g. for portName:1/0/1,for adminStatus,status:up/down, for speed: any integer value, for description: any valid string, for family:switches, for series:C3650, for managementIpAddress:10.197.124.90, groupNameHierarchy:Global, softwareVersion: 16.9.1)'
Loading