Skip to content

Commit

Permalink
Add active directory add groups and join domain with all nodes resour…
Browse files Browse the repository at this point in the history
…ces (#36)
  • Loading branch information
kuba-mazurkiewicz authored Jan 26, 2024
1 parent 7a1df44 commit e12724a
Show file tree
Hide file tree
Showing 57 changed files with 1,375 additions and 141 deletions.
64 changes: 64 additions & 0 deletions docs/resources/active_directory_add_groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ise_active_directory_add_groups Resource - terraform-provider-ise"
subcategory: "Identity Management"
description: |-
This resource can manage an Active Directory Add Groups.
---

# ise_active_directory_add_groups (Resource)

This resource can manage an Active Directory Add Groups.

## Example Usage

```terraform
resource "ise_active_directory_add_groups" "example" {
join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"
name = "cisco.local"
description = "My AD join point"
domain = "cisco.local"
ad_scopes_names = "Default_Scope"
enable_domain_allowed_list = true
groups = [
{
name = "cisco.local/operators"
sid = "S-1-5-32-548"
type = "GLOBAL"
}
]
}
```

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

### Required

- `domain` (String) AD domain associated with the join point
- `join_point_id` (String) Active Directory Join Point ID
- `name` (String) The name of the active directory join point

### Optional

- `ad_scopes_names` (String) String that contains the names of the scopes that the active directory belongs to. Names are separated by comm
- Default value: `Default_Scope`
- `description` (String) Join point Description
- `enable_domain_allowed_list` (Boolean) - Default value: `true`
- `groups` (Attributes List) List of AD Groups (see [below for nested schema](#nestedatt--groups))

### Read-Only

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

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

Required:

- `name` (String) Required for each group in the group list with no duplication between groups
- `sid` (String) Required for each group in the group list with no duplication between groups

Optional:

- `type` (String)
45 changes: 45 additions & 0 deletions docs/resources/active_directory_join_domain_with_all_nodes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "ise_active_directory_join_domain_with_all_nodes Resource - terraform-provider-ise"
subcategory: "Identity Management"
description: |-
This resource can manage an Active Directory Join Domain with All Nodes.
---

# ise_active_directory_join_domain_with_all_nodes (Resource)

This resource can manage an Active Directory Join Domain with All Nodes.

## Example Usage

```terraform
resource "ise_active_directory_join_domain_with_all_nodes" "example" {
join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"
additional_data = [
{
name = "username"
value = "administrator"
}
]
}
```

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

### Required

- `additional_data` (Attributes List) (see [below for nested schema](#nestedatt--additional_data))
- `join_point_id` (String) Active Directory Join Point ID

### Read-Only

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

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

Required:

- `name` (String) Additional attribute name
- `value` (String) Additional attribute value
15 changes: 15 additions & 0 deletions examples/resources/ise_active_directory_add_groups/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "ise_active_directory_add_groups" "example" {
join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"
name = "cisco.local"
description = "My AD join point"
domain = "cisco.local"
ad_scopes_names = "Default_Scope"
enable_domain_allowed_list = true
groups = [
{
name = "cisco.local/operators"
sid = "S-1-5-32-548"
type = "GLOBAL"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "ise_active_directory_join_domain_with_all_nodes" "example" {
join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"
additional_data = [
{
name = "username"
value = "administrator"
}
]
}
69 changes: 69 additions & 0 deletions gen/definitions/active_directory_add_groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: Active Directory Add Groups
rest_endpoint: /ers/config/activedirectory/%v/addGroups
doc_category: Identity Management
no_delete: true
put_create: true
no_update: true
no_read: true
no_import: true
no_data_source: true
skip_minimum_test: true
test_tags: [AD]
attributes:
- tf_name: join_point_id
type: String
reference: true
id: true
description: Active Directory Join Point ID
example: 73808580-b6e6-11ee-8960-de6d7692bc40
- model_name: name
data_path: [ERSActiveDirectory]
type: String
mandatory: true
description: The name of the active directory join point
example: cisco.local
- model_name: description
data_path: [ERSActiveDirectory]
type: String
requires_replace: true
description: Join point Description
example: My AD join point
- model_name: domain
data_path: [ERSActiveDirectory]
type: String
mandatory: true
description: AD domain associated with the join point
example: cisco.local
- model_name: adScopesNames
data_path: [ERSActiveDirectory]
type: String
description: String that contains the names of the scopes that the active directory belongs to. Names are separated by comm
default_value: Default_Scope
example: Default_Scope
- model_name: enableDomainAllowedList
data_path: [ERSActiveDirectory]
type: Bool
default_value: true
example: true
- model_name: groups
description: List of AD Groups
data_path: [ERSActiveDirectory,adgroups]
type: List
attributes:
- model_name: name
type: String
mandatory: true
description: Required for each group in the group list with no duplication between groups
example: cisco.local/operators
- model_name: sid
type: String
mandatory: true
id: true
description: Required for each group in the group list with no duplication between groups
example: S-1-5-32-548
- model_name: type
type: String
write_only: true
example: GLOBAL

35 changes: 35 additions & 0 deletions gen/definitions/active_directory_join_domain_with_all_nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Active Directory Join Domain with All Nodes
rest_endpoint: /ers/config/activedirectory/%v/joinAllNodes
delete_rest_endpoint: /ers/config/activedirectory/%v/leaveAllNodes
doc_category: Identity Management
put_delete: true
no_read: true
put_create: true
no_import: true
no_data_source: true
skip_minimum_test: true
test_tags: [AD]
attributes:
- tf_name: join_point_id
type: String
reference: true
id: true
description: Active Directory Join Point ID
example: 73808580-b6e6-11ee-8960-de6d7692bc40
- model_name: additionalData
data_path: [OperationAdditionalData]
type: List
mandatory: true
attributes:
- model_name: name
type: String
id: true
mandatory: true
description: Additional attribute name
example: username
- model_name: value
type: String
mandatory: true
description: Additional attribute value
example: administrator
3 changes: 2 additions & 1 deletion gen/definitions/active_directory_join_point.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: Active Directory Join Point
rest_endpoint: /ers/config/activedirectory
doc_category: Identity Management
no_update: true
skip_minimum_test: true
attributes:
- model_name: name
Expand Down Expand Up @@ -275,4 +276,4 @@ attributes:
requires_replace: true
enum_values: [WIRELESS, WIRED, BOTH]
description: Enable prevent AD account lockout for WIRELESS/WIRED/BOTH
example: WIRELESS
example: WIRELESS
10 changes: 8 additions & 2 deletions gen/doc_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ const (
)

type YamlConfig struct {
Name string `yaml:"name"`
DocCategory string `yaml:"doc_category"`
Name string `yaml:"name"`
DocCategory string `yaml:"doc_category"`
NoResource bool `yaml:"no_resource"`
NoDataSource bool `yaml:"no_data_source"`
}

var docPaths = []string{"./docs/data-sources/", "./docs/resources/"}
Expand Down Expand Up @@ -74,6 +76,10 @@ func main() {
// Update doc category
for i := range configs {
for _, path := range docPaths {
if (configs[i].NoDataSource && path == "./docs/data-sources/") ||
(configs[i].NoResource && path == "./docs/resources/") {
continue
}
filename := path + SnakeCase(configs[i].Name) + ".md"
content, err := os.ReadFile(filename)
if err != nil {
Expand Down
38 changes: 33 additions & 5 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,19 @@ var templates = []t{
type YamlConfig struct {
Name string `yaml:"name"`
RestEndpoint string `yaml:"rest_endpoint"`
DeleteRestEndpoint string `yaml:"delete_rest_endpoint"`
GetNoId bool `yaml:"get_no_id"`
NoDataSource bool `yaml:"no_data_source"`
NoResource bool `yaml:"no_resource"`
NoDelete bool `yaml:"no_delete"`
NoImport bool `yaml:"no_import"`
PostUpdate bool `yaml:"post_update"`
PutCreate bool `yaml:"put_create"`
PutDelete bool `yaml:"put_delete"`
PutRead bool `yaml:"put_read"`
NoRead bool `yaml:"no_read"`
NoUpdate bool `yaml:"no_update"`
IdFromAttribute bool `yaml:"id_from_attribute"`
RootList bool `yaml:"root_list"`
NoReadPrefix bool `yaml:"no_read_prefix"`
IdPath string `yaml:"id_path"`
Expand Down Expand Up @@ -127,6 +137,7 @@ type YamlConfigAttribute struct {
WriteOnly bool `yaml:"write_only"`
WriteChangesOnly bool `yaml:"write_changes_only"`
ExcludeTest bool `yaml:"exclude_test"`
RequiresReplace bool `yaml:"requires_replace"`
ExcludeExample bool `yaml:"exclude_example"`
Description string `yaml:"description"`
Example string `yaml:"example"`
Expand All @@ -140,7 +151,6 @@ type YamlConfigAttribute struct {
StringPatterns []string `yaml:"string_patterns"`
StringMinLength int64 `yaml:"string_min_length"`
StringMaxLength int64 `yaml:"string_max_length"`
RequiresReplace bool `yaml:"requires_replace"`
DefaultValue string `yaml:"default_value"`
Value string `yaml:"value"`
TestValue string `yaml:"test_value"`
Expand Down Expand Up @@ -202,6 +212,16 @@ func contains(s []string, str string) bool {
return false
}

// Templating helper function to return the ID attribute
func GetId(attributes []YamlConfigAttribute) YamlConfigAttribute {
for _, attr := range attributes {
if attr.Id {
return attr
}
}
return YamlConfigAttribute{}
}

// Templating helper function to return true if id included in attributes
func HasId(attributes []YamlConfigAttribute) bool {
for _, attr := range attributes {
Expand Down Expand Up @@ -263,6 +283,7 @@ var functions = template.FuncMap{
"toLower": strings.ToLower,
"path": BuildPath,
"hasId": HasId,
"getId": GetId,
"hasReference": HasReference,
"importParts": ImportParts,
"subtract": Subtract,
Expand Down Expand Up @@ -399,8 +420,6 @@ func renderTemplate(templatePath, outputPath string, config interface{}) {
}

func main() {
providerConfig := make([]string, 0)

files, _ := os.ReadDir(definitionsPath)
configs := make([]YamlConfig, len(files))

Expand All @@ -425,13 +444,22 @@ func main() {

// Iterate over templates and render files
for _, t := range templates {
if (configs[i].NoImport && t.path == "./gen/templates/import.sh") ||
(configs[i].NoDataSource && t.path == "./gen/templates/data_source.go") ||
(configs[i].NoDataSource && t.path == "./gen/templates/data_source_test.go") ||
(configs[i].NoDataSource && t.path == "./gen/templates/data-source.tf") ||
(configs[i].NoResource && t.path == "./gen/templates/resource.go") ||
(configs[i].NoResource && t.path == "./gen/templates/resource_test.go") ||
(configs[i].NoResource && t.path == "./gen/templates/resource.tf") ||
(configs[i].NoResource && t.path == "./gen/templates/import.sh") {
continue
}
renderTemplate(t.path, t.prefix+SnakeCase(configs[i].Name)+t.suffix, configs[i])
}
providerConfig = append(providerConfig, configs[i].Name)
}

// render provider.go
renderTemplate(providerTemplate, providerLocation, providerConfig)
renderTemplate(providerTemplate, providerLocation, configs)

changelog, err := os.ReadFile(changelogOriginal)
if err != nil {
Expand Down
Loading

0 comments on commit e12724a

Please sign in to comment.