Skip to content

Commit

Permalink
Add network profile resource and data source
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Nov 17, 2023
1 parent 08a8f8e commit 96c2a95
Show file tree
Hide file tree
Showing 15 changed files with 920 additions and 30 deletions.
40 changes: 40 additions & 0 deletions docs/data-sources/network_profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_network_profile Data Source - terraform-provider-catalystcenter"
subcategory: "Network Settings"
description: |-
This data source can read the Network Profile.
---

# catalystcenter_network_profile (Data Source)

This data source can read the Network Profile.

## Example Usage

```terraform
data "catalystcenter_network_profile" "example" {
id = "Profile1"
}
```

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

### Required

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

### Read-Only

- `name` (String) The name of the network profile
- `templates` (Attributes List) (see [below for nested schema](#nestedatt--templates))
- `type` (String) Profile type

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

Read-Only:

- `template_id` (String) Template ID
- `type` (String) Template type
60 changes: 60 additions & 0 deletions docs/resources/network_profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_network_profile Resource - terraform-provider-catalystcenter"
subcategory: "Network Settings"
description: |-
This resource can manage a Network Profile.
---

# catalystcenter_network_profile (Resource)

This resource can manage a Network Profile.

## Example Usage

```terraform
resource "catalystcenter_network_profile" "example" {
name = "Profile1"
type = "switching"
templates = [
{
type = "cli.templates"
template_id = "f8297e86-35b0-486c-8752-6169aa5eb43c"
}
]
}
```

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

### Required

- `name` (String) The name of the network profile
- `type` (String) Profile type
- Choices: `switching`

### Optional

- `templates` (Attributes List) (see [below for nested schema](#nestedatt--templates))

### Read-Only

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

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

Required:

- `template_id` (String) Template ID
- `type` (String) Template type
- Choices: `cli.templates`, `day0.templates`

## Import

Import is supported using the following syntax:

```shell
terraform import catalystcenter_network_profile.example "Profile1"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "catalystcenter_network_profile" "example" {
id = "Profile1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import catalystcenter_network_profile.example "Profile1"
10 changes: 10 additions & 0 deletions examples/resources/catalystcenter_network_profile/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "catalystcenter_network_profile" "example" {
name = "Profile1"
type = "switching"
templates = [
{
type = "cli.templates"
template_id = "f8297e86-35b0-486c-8752-6169aa5eb43c"
}
]
}
45 changes: 45 additions & 0 deletions gen/definitions/network_profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: Network Profile
rest_endpoint: /api/v1/siteprofile
get_extra_query_params: "?populated=true"
id_from_query_path: response
id_from_query_path_attribute: siteProfileUuid
doc_category: Network Settings
attributes:
- model_name: name
response_data_path: response.name
type: String
id: true
description: The name of the network profile
example: Profile1
- model_name: namespace
tf_name: type
response_data_path: response.namespace
type: String
enum_values: [switching]
mandatory: true
description: Profile type
example: switching
- model_name: profileAttributes
tf_name: templates
response_data_path: response.profileAttributes
type: List
attributes:
- model_name: key
tf_name: type
id: true
type: String
enum_values: [cli.templates, day0.templates]
description: Template type
example: cli.templates
- model_name: key
data_path: attribs.0
type: String
value: template.id
- model_name: value
tf_name: template_id
data_path: attribs.0
type: String
id: true
description: Template ID
example: f8297e86-35b0-486c-8752-6169aa5eb43c
60 changes: 31 additions & 29 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,35 +94,37 @@ var templates = []t{
}

type YamlConfig struct {
Name string `yaml:"name"`
RestEndpoint string `yaml:"rest_endpoint"`
GetRestEndpoint string `yaml:"get_rest_endpoint"`
PutRestEndpoint string `yaml:"put_rest_endpoint"`
DeleteRestEndpoint string `yaml:"delete_rest_endpoint"`
GetNoId bool `yaml:"get_no_id"`
GetFromAll bool `yaml:"get_from_all"`
GetRequiresId bool `yaml:"get_requires_id"`
NoDelete bool `yaml:"no_delete"`
PostUpdate bool `yaml:"post_update"`
RootList bool `yaml:"root_list"`
NoReadPrefix bool `yaml:"no_read_prefix"`
IdPath string `yaml:"id_path"`
IdFromQueryPath string `yaml:"id_from_query_path"`
IdQueryParam string `yaml:"id_query_param"`
IdFromAttribute string `yaml:"id_from_attribute"`
PutIdIncludePath string `yaml:"put_id_include_path"`
PutIdQueryParam string `yaml:"put_id_query_param"`
PutNoId bool `yaml:"put_no_id"`
DataSourceNameQuery bool `yaml:"data_source_name_query"`
MinimumVersion string `yaml:"minimum_version"`
DsDescription string `yaml:"ds_description"`
ResDescription string `yaml:"res_description"`
DocCategory string `yaml:"doc_category"`
ExcludeTest bool `yaml:"exclude_test"`
SkipMinimumTest bool `yaml:"skip_minimum_test"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
TestTags []string `yaml:"test_tags"`
TestPrerequisites string `yaml:"test_prerequisites"`
Name string `yaml:"name"`
RestEndpoint string `yaml:"rest_endpoint"`
GetRestEndpoint string `yaml:"get_rest_endpoint"`
PutRestEndpoint string `yaml:"put_rest_endpoint"`
DeleteRestEndpoint string `yaml:"delete_rest_endpoint"`
GetNoId bool `yaml:"get_no_id"`
GetFromAll bool `yaml:"get_from_all"`
GetRequiresId bool `yaml:"get_requires_id"`
GetExtraQueryParams string `yaml:"get_extra_query_params"`
NoDelete bool `yaml:"no_delete"`
PostUpdate bool `yaml:"post_update"`
RootList bool `yaml:"root_list"`
NoReadPrefix bool `yaml:"no_read_prefix"`
IdPath string `yaml:"id_path"`
IdFromQueryPath string `yaml:"id_from_query_path"`
IdFromQueryPathAttribute string `yaml:"id_from_query_path_attribute"`
IdQueryParam string `yaml:"id_query_param"`
IdFromAttribute string `yaml:"id_from_attribute"`
PutIdIncludePath string `yaml:"put_id_include_path"`
PutIdQueryParam string `yaml:"put_id_query_param"`
PutNoId bool `yaml:"put_no_id"`
DataSourceNameQuery bool `yaml:"data_source_name_query"`
MinimumVersion string `yaml:"minimum_version"`
DsDescription string `yaml:"ds_description"`
ResDescription string `yaml:"res_description"`
DocCategory string `yaml:"doc_category"`
ExcludeTest bool `yaml:"exclude_test"`
SkipMinimumTest bool `yaml:"skip_minimum_test"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
TestTags []string `yaml:"test_tags"`
TestPrerequisites string `yaml:"test_prerequisites"`
}

type YamlConfigAttribute struct {
Expand Down
2 changes: 2 additions & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ delete_rest_endpoint: str(required=False) # Override DELETE REST endpoint path
get_no_id: bool(required=False) # Set to true if the GET request does not require an ID
get_from_all: bool(required=False) # Set to true if GET does not support querying individual objects
get_requires_id: bool(required=False) # Set to true if the GET request requires an ID in the URL path
get_extra_query_params: str(required=False) # Additional query parameters for GET request
no_delete: bool(required=False) # Set to true if the DELETE request is not supported
post_update: bool(required=False) # Set to true if the POST request is used for update
root_list: bool(required=False) # Set to true if the root element of the data structure is a list
no_read_prefix: bool(required=False) # Set to true if it is an Open API endpoint put the response is not embeeded into a "response" element
id_path: str(required=False) # Path to the ID in the response (use "." to access nested elements)
id_from_query_path: str(required=False) # Specify path to ID container if ID is not included in POST response and needs to be resolved via separate GET request
id_from_query_path_attribute: str(required=False) # Specify attribute name of ID, only relevant if "id_from_query_path" option used, default is "id"
id_query_param: str(required=False) # Query parameter used to specify the ID
id_from_attribute: bool(required=False) # Set to true if the ID is derived from an attribute
put_id_include_path: str(required=False) # If PUT needs to have specific JSON path where ID should be inserted
Expand Down
5 changes: 4 additions & 1 deletion gen/templates/resource.go

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

132 changes: 132 additions & 0 deletions internal/provider/data_source_catalystcenter_network_profile.go

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

Loading

0 comments on commit 96c2a95

Please sign in to comment.