From e12724a837446e9361542f58445fb63a621329d2 Mon Sep 17 00:00:00 2001 From: Kuba Mazurkiewicz <132581633+kuba-mazurkiewicz@users.noreply.github.com> Date: Fri, 26 Jan 2024 09:07:23 +0100 Subject: [PATCH] Add active directory add groups and join domain with all nodes resources (#36) --- docs/resources/active_directory_add_groups.md | 64 +++++ ...ve_directory_join_domain_with_all_nodes.md | 45 ++++ .../resource.tf | 15 ++ .../resource.tf | 9 + .../active_directory_add_groups.yaml | 69 +++++ ..._directory_join_domain_with_all_nodes.yaml | 35 +++ .../active_directory_join_point.yaml | 3 +- gen/doc_category.go | 10 +- gen/generator.go | 38 ++- gen/schema/schema.yaml | 11 + gen/templates/model.go | 12 + gen/templates/provider.go | 8 +- gen/templates/resource.go | 38 ++- .../model_ise_active_directory_add_groups.go | 237 +++++++++++++++++ ...ve_directory_join_domain_with_all_nodes.go | 155 ++++++++++++ internal/provider/provider.go | 2 + internal/provider/provider_test.go | 49 ---- ...esource_ise_active_directory_add_groups.go | 238 ++++++++++++++++++ ...ce_ise_active_directory_add_groups_test.go | 95 +++++++ ...ve_directory_join_domain_with_all_nodes.go | 218 ++++++++++++++++ ...rectory_join_domain_with_all_nodes_test.go | 86 +++++++ ...esource_ise_active_directory_join_point.go | 9 - .../resource_ise_allowed_protocols.go | 2 - .../resource_ise_allowed_protocols_tacacs.go | 2 - .../resource_ise_authorization_profile.go | 2 - ..._ise_certificate_authentication_profile.go | 2 - ...ce_ise_device_admin_authentication_rule.go | 2 - ...vice_admin_authorization_exception_rule.go | 2 - ...min_authorization_global_exception_rule.go | 2 - ...rce_ise_device_admin_authorization_rule.go | 2 - .../resource_ise_device_admin_condition.go | 2 - .../resource_ise_device_admin_policy_set.go | 2 - ...se_device_admin_time_and_date_condition.go | 2 - .../provider/resource_ise_downloadable_acl.go | 2 - .../resource_ise_endpoint_identity_group.go | 2 - .../resource_ise_identity_source_sequence.go | 2 - .../provider/resource_ise_internal_user.go | 2 - .../resource_ise_license_tier_state.go | 2 - ..._ise_network_access_authentication_rule.go | 2 - ...ork_access_authorization_exception_rule.go | 2 - ...ess_authorization_global_exception_rule.go | 2 - ...e_ise_network_access_authorization_rule.go | 2 - .../resource_ise_network_access_condition.go | 2 - .../resource_ise_network_access_dictionary.go | 2 - .../resource_ise_network_access_policy_set.go | 2 - ..._network_access_time_and_date_condition.go | 2 - .../provider/resource_ise_network_device.go | 2 - .../resource_ise_network_device_group.go | 2 - internal/provider/resource_ise_repository.go | 2 - .../resource_ise_tacacs_command_set.go | 2 - .../provider/resource_ise_tacacs_profile.go | 2 - ...esource_ise_trustsec_egress_matrix_cell.go | 2 - ...resource_ise_trustsec_ip_to_sgt_mapping.go | 2 - ...ce_ise_trustsec_ip_to_sgt_mapping_group.go | 2 - .../resource_ise_trustsec_security_group.go | 2 - ...esource_ise_trustsec_security_group_acl.go | 2 - .../resource_ise_user_identity_group.go | 2 - 57 files changed, 1375 insertions(+), 141 deletions(-) create mode 100644 docs/resources/active_directory_add_groups.md create mode 100644 docs/resources/active_directory_join_domain_with_all_nodes.md create mode 100644 examples/resources/ise_active_directory_add_groups/resource.tf create mode 100644 examples/resources/ise_active_directory_join_domain_with_all_nodes/resource.tf create mode 100644 gen/definitions/active_directory_add_groups.yaml create mode 100644 gen/definitions/active_directory_join_domain_with_all_nodes.yaml create mode 100644 internal/provider/model_ise_active_directory_add_groups.go create mode 100644 internal/provider/model_ise_active_directory_join_domain_with_all_nodes.go delete mode 100644 internal/provider/provider_test.go create mode 100644 internal/provider/resource_ise_active_directory_add_groups.go create mode 100644 internal/provider/resource_ise_active_directory_add_groups_test.go create mode 100644 internal/provider/resource_ise_active_directory_join_domain_with_all_nodes.go create mode 100644 internal/provider/resource_ise_active_directory_join_domain_with_all_nodes_test.go diff --git a/docs/resources/active_directory_add_groups.md b/docs/resources/active_directory_add_groups.md new file mode 100644 index 0000000..821a622 --- /dev/null +++ b/docs/resources/active_directory_add_groups.md @@ -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 + +### 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 + + +### 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) diff --git a/docs/resources/active_directory_join_domain_with_all_nodes.md b/docs/resources/active_directory_join_domain_with_all_nodes.md new file mode 100644 index 0000000..bba07dc --- /dev/null +++ b/docs/resources/active_directory_join_domain_with_all_nodes.md @@ -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 + +### 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 + + +### Nested Schema for `additional_data` + +Required: + +- `name` (String) Additional attribute name +- `value` (String) Additional attribute value diff --git a/examples/resources/ise_active_directory_add_groups/resource.tf b/examples/resources/ise_active_directory_add_groups/resource.tf new file mode 100644 index 0000000..e504d14 --- /dev/null +++ b/examples/resources/ise_active_directory_add_groups/resource.tf @@ -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" + } + ] +} diff --git a/examples/resources/ise_active_directory_join_domain_with_all_nodes/resource.tf b/examples/resources/ise_active_directory_join_domain_with_all_nodes/resource.tf new file mode 100644 index 0000000..0d55288 --- /dev/null +++ b/examples/resources/ise_active_directory_join_domain_with_all_nodes/resource.tf @@ -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" + } + ] +} diff --git a/gen/definitions/active_directory_add_groups.yaml b/gen/definitions/active_directory_add_groups.yaml new file mode 100644 index 0000000..6889cf3 --- /dev/null +++ b/gen/definitions/active_directory_add_groups.yaml @@ -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 + \ No newline at end of file diff --git a/gen/definitions/active_directory_join_domain_with_all_nodes.yaml b/gen/definitions/active_directory_join_domain_with_all_nodes.yaml new file mode 100644 index 0000000..11c3dd6 --- /dev/null +++ b/gen/definitions/active_directory_join_domain_with_all_nodes.yaml @@ -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 diff --git a/gen/definitions/active_directory_join_point.yaml b/gen/definitions/active_directory_join_point.yaml index b28e2e0..f9ab882 100644 --- a/gen/definitions/active_directory_join_point.yaml +++ b/gen/definitions/active_directory_join_point.yaml @@ -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 @@ -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 \ No newline at end of file diff --git a/gen/doc_category.go b/gen/doc_category.go index 22d0cb8..ea010ec 100644 --- a/gen/doc_category.go +++ b/gen/doc_category.go @@ -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/"} @@ -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 { diff --git a/gen/generator.go b/gen/generator.go index 77dccab..98f46e2 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -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"` @@ -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"` @@ -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"` @@ -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 { @@ -263,6 +283,7 @@ var functions = template.FuncMap{ "toLower": strings.ToLower, "path": BuildPath, "hasId": HasId, + "getId": GetId, "hasReference": HasReference, "importParts": ImportParts, "subtract": Subtract, @@ -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)) @@ -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 { diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 76d2cb7..2d14736 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -1,9 +1,19 @@ --- name: str() # Name of the resource rest_endpoint: str(required=False) # REST endpoint path +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 no_delete: bool(required=False) # Set to true if the DELETE request is not supported +no_import: bool(required=False) # Set to true if the resource does not support importing +no_update: bool(required=False) # Set to true if the PUT request is not supported +no_data_source: bool(required=False) # Set to true if no data source should be created +no_resource: bool(required=False) # Set to true if no resource should be created post_update: bool(required=False) # Set to true if the POST request is used for update +put_create: bool(required=False) # Set to true if the PUT request is used to create +put_delete: bool(required=False) # Set to true if the PUT request is used to delete +put_read: bool(required=False) # Set to true if the PUT request is used to read +no_read: bool(required=False) # Set to true if the GET request is not supported +id_from_attribute: bool(required=False) # Set to true if the ID is derived from an attribute 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) @@ -21,6 +31,7 @@ test_prerequisites: str(required=False) # HCL code that is included in the accep --- attribute: model_name: str(required=False) # Name of the attribute in the model (payload) + requires_replace: bool(required=False) # Set to true if the attribute requires a replace operation tf_name: str(required=False) # Name of the attribute in the Terraform resource, by default derived from model_name type: enum('String', 'Int64', 'Float', 'Bool', 'List', 'Set', 'StringList', required=False) # Type of the attribute data_path: list(str(), required=False) # Path to the attribute in the model structure diff --git a/gen/templates/model.go b/gen/templates/model.go index 8396512..56ef3ee 100644 --- a/gen/templates/model.go +++ b/gen/templates/model.go @@ -145,6 +145,18 @@ func (data {{camelCase .Name}}) getPath() string { } //template:end getPath +{{if .DeleteRestEndpoint}} +//template:begin getPathPut +func (data {{camelCase .Name}}) getPathPut() string { + {{- if hasReference .Attributes}} + return fmt.Sprintf("{{.DeleteRestEndpoint}}"{{range .Attributes}}{{if .Reference}}, data.{{toGoName .TfName}}.Value{{.Type}}(){{end}}{{end}}) + {{- else}} + return "{{.DeleteRestEndpoint}}" + {{- end}} +} +//template:end getPathPut +{{end}} + //template:begin toBody func (data {{camelCase .Name}}) toBody(ctx context.Context, state {{camelCase .Name}}) string { {{- if .RootList}} diff --git a/gen/templates/provider.go b/gen/templates/provider.go index ff4760f..a35340c 100644 --- a/gen/templates/provider.go +++ b/gen/templates/provider.go @@ -244,7 +244,9 @@ func (p *IseProvider) Configure(ctx context.Context, req provider.ConfigureReque func (p *IseProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ {{- range .}} - New{{camelCase .}}Resource, + {{- if not .NoResource}} + New{{camelCase .Name}}Resource, + {{- end}} {{- end}} } } @@ -252,7 +254,9 @@ func (p *IseProvider) Resources(ctx context.Context) []func() resource.Resource func (p *IseProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ {{- range .}} - New{{camelCase .}}DataSource, + {{- if not .NoDataSource}} + New{{camelCase .Name}}DataSource, + {{- end}} {{- end}} } } diff --git a/gen/templates/resource.go b/gen/templates/resource.go index 2c71969..db4c3c2 100644 --- a/gen/templates/resource.go +++ b/gen/templates/resource.go @@ -54,7 +54,9 @@ import ( // Ensure provider defined types fully satisfy framework interfaces var _ resource.Resource = &{{camelCase .Name}}Resource{} +{{- if not .NoImport}} var _ resource.ResourceWithImportState = &{{camelCase .Name}}Resource{} +{{- end}} func New{{camelCase .Name}}Resource() resource.Resource { return &{{camelCase .Name}}Resource{} @@ -449,14 +451,30 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C {{- end}} {{- end}} {{- else}} + {{- if .PutCreate}} + res, err := r.client.Put(plan.getPath(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + {{- else}} res, location, err := r.client.Post(plan.getPath(), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String())) return } + {{- end}} + {{- if hasId .Attributes}} + {{- range .Attributes}} + {{- if .Id}} + plan.Id = types.StringValue(fmt.Sprint(plan.{{toGoName .TfName}}.Value{{.Type}}())) + {{- end}} + {{- end}} + {{- else}} locationElements := strings.Split(location, "/") plan.Id = types.StringValue(locationElements[len(locationElements)-1]) {{- end}} + {{- end}} tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Id.ValueString())) @@ -478,6 +496,7 @@ func (r *{{camelCase .Name}}Resource) Read(ctx context.Context, req resource.Rea tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) + {{- if not .NoRead}} res, err := r.client.Get(state.getPath(){{if not .GetNoId}} + "/" + state.Id.ValueString(){{end}}) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -493,6 +512,7 @@ func (r *{{camelCase .Name}}Resource) Read(ctx context.Context, req resource.Rea } else { state.updateFromBody(ctx, res) } + {{- end}} tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Id.ValueString())) @@ -520,6 +540,8 @@ func (r *{{camelCase .Name}}Resource) Update(ctx context.Context, req resource.U tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) + + {{- if not .NoUpdate}} body := plan.toBody(ctx, state) {{if .PostUpdate}} res, _, err := r.client.Post(plan.getPath(), body) @@ -530,6 +552,7 @@ func (r *{{camelCase .Name}}Resource) Update(ctx context.Context, req resource.U resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) return } + {{- end}} tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Id.ValueString())) @@ -551,8 +574,15 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) - {{- if not .NoDelete}} - res, err := r.client.Delete(state.getPath() + "/" + state.Id.ValueString()) + {{- if .PutDelete}} + body := state.toBody(ctx, state) + res, err := r.client.Put(state.getPathPut(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (DELETE), got error: %s, %s", err, res.String())) + return + } + {{- else if not .NoDelete}} + res, err := r.client.Delete({{if .DeleteRestEndpoint}}"{{.DeleteRestEndpoint}}"{{else}}state.getPath(){{end}} + "/" + state.Id.ValueString()) if err != nil{{if .IgnoreDeleteError}} && !strings.Contains(res.String(), "{{.IgnoreDeleteError}}"){{end}} { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (DELETE), got error: %s, %s", err, res.String())) return @@ -566,6 +596,7 @@ func (r *{{camelCase .Name}}Resource) Delete(ctx context.Context, req resource.D //template:end delete //template:begin import +{{- if not .NoImport}} func (r *{{camelCase .Name}}Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { {{- if hasReference .Attributes}} idParts := strings.Split(req.ID, ",") @@ -588,4 +619,5 @@ func (r *{{camelCase .Name}}Resource) ImportState(ctx context.Context, req resou resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) {{- end}} } -//template:end import +{{- end}} +//template:end import \ No newline at end of file diff --git a/internal/provider/model_ise_active_directory_add_groups.go b/internal/provider/model_ise_active_directory_add_groups.go new file mode 100644 index 0000000..fa21737 --- /dev/null +++ b/internal/provider/model_ise_active_directory_add_groups.go @@ -0,0 +1,237 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +//template:end imports + +//template:begin types +type ActiveDirectoryAddGroups struct { + Id types.String `tfsdk:"id"` + JoinPointId types.String `tfsdk:"join_point_id"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + Domain types.String `tfsdk:"domain"` + AdScopesNames types.String `tfsdk:"ad_scopes_names"` + EnableDomainAllowedList types.Bool `tfsdk:"enable_domain_allowed_list"` + Groups []ActiveDirectoryAddGroupsGroups `tfsdk:"groups"` +} + +type ActiveDirectoryAddGroupsGroups struct { + Name types.String `tfsdk:"name"` + Sid types.String `tfsdk:"sid"` + Type types.String `tfsdk:"type"` +} + +//template:end types + +//template:begin getPath +func (data ActiveDirectoryAddGroups) getPath() string { + return fmt.Sprintf("/ers/config/activedirectory/%v/addGroups", data.JoinPointId.ValueString()) +} + +//template:end getPath + +//template:begin toBody +func (data ActiveDirectoryAddGroups) toBody(ctx context.Context, state ActiveDirectoryAddGroups) string { + body := "" + if !data.Name.IsNull() { + body, _ = sjson.Set(body, "ERSActiveDirectory.name", data.Name.ValueString()) + } + if !data.Description.IsNull() { + body, _ = sjson.Set(body, "ERSActiveDirectory.description", data.Description.ValueString()) + } + if !data.Domain.IsNull() { + body, _ = sjson.Set(body, "ERSActiveDirectory.domain", data.Domain.ValueString()) + } + if !data.AdScopesNames.IsNull() { + body, _ = sjson.Set(body, "ERSActiveDirectory.adScopesNames", data.AdScopesNames.ValueString()) + } + if !data.EnableDomainAllowedList.IsNull() { + body, _ = sjson.Set(body, "ERSActiveDirectory.enableDomainAllowedList", data.EnableDomainAllowedList.ValueBool()) + } + if len(data.Groups) > 0 { + body, _ = sjson.Set(body, "ERSActiveDirectory.adgroups.groups", []interface{}{}) + for _, item := range data.Groups { + itemBody := "" + if !item.Name.IsNull() { + itemBody, _ = sjson.Set(itemBody, "name", item.Name.ValueString()) + } + if !item.Sid.IsNull() { + itemBody, _ = sjson.Set(itemBody, "sid", item.Sid.ValueString()) + } + if !item.Type.IsNull() { + itemBody, _ = sjson.Set(itemBody, "type", item.Type.ValueString()) + } + body, _ = sjson.SetRaw(body, "ERSActiveDirectory.adgroups.groups.-1", itemBody) + } + } + return body +} + +//template:end toBody + +//template:begin fromBody +func (data *ActiveDirectoryAddGroups) fromBody(ctx context.Context, res gjson.Result) { + if value := res.Get("ERSActiveDirectory.name"); value.Exists() { + data.Name = types.StringValue(value.String()) + } else { + data.Name = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.description"); value.Exists() { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.domain"); value.Exists() { + data.Domain = types.StringValue(value.String()) + } else { + data.Domain = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.adScopesNames"); value.Exists() { + data.AdScopesNames = types.StringValue(value.String()) + } else { + data.AdScopesNames = types.StringValue("Default_Scope") + } + if value := res.Get("ERSActiveDirectory.enableDomainAllowedList"); value.Exists() { + data.EnableDomainAllowedList = types.BoolValue(value.Bool()) + } else { + data.EnableDomainAllowedList = types.BoolValue(true) + } + if value := res.Get("ERSActiveDirectory.adgroups.groups"); value.Exists() { + data.Groups = make([]ActiveDirectoryAddGroupsGroups, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := ActiveDirectoryAddGroupsGroups{} + if cValue := v.Get("name"); cValue.Exists() { + item.Name = types.StringValue(cValue.String()) + } else { + item.Name = types.StringNull() + } + if cValue := v.Get("sid"); cValue.Exists() { + item.Sid = types.StringValue(cValue.String()) + } else { + item.Sid = types.StringNull() + } + data.Groups = append(data.Groups, item) + return true + }) + } +} + +//template:end fromBody + +//template:begin updateFromBody +func (data *ActiveDirectoryAddGroups) updateFromBody(ctx context.Context, res gjson.Result) { + if value := res.Get("ERSActiveDirectory.name"); value.Exists() && !data.Name.IsNull() { + data.Name = types.StringValue(value.String()) + } else { + data.Name = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.description"); value.Exists() && !data.Description.IsNull() { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.domain"); value.Exists() && !data.Domain.IsNull() { + data.Domain = types.StringValue(value.String()) + } else { + data.Domain = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.adScopesNames"); value.Exists() && !data.AdScopesNames.IsNull() { + data.AdScopesNames = types.StringValue(value.String()) + } else if data.AdScopesNames.ValueString() != "Default_Scope" { + data.AdScopesNames = types.StringNull() + } + if value := res.Get("ERSActiveDirectory.enableDomainAllowedList"); value.Exists() && !data.EnableDomainAllowedList.IsNull() { + data.EnableDomainAllowedList = types.BoolValue(value.Bool()) + } else if data.EnableDomainAllowedList.ValueBool() != true { + data.EnableDomainAllowedList = types.BoolNull() + } + for i := range data.Groups { + keys := [...]string{"sid"} + keyValues := [...]string{data.Groups[i].Sid.ValueString()} + + var r gjson.Result + res.Get("ERSActiveDirectory.adgroups.groups").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + if v.Get(keys[ik]).String() == keyValues[ik] { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + if value := r.Get("name"); value.Exists() && !data.Groups[i].Name.IsNull() { + data.Groups[i].Name = types.StringValue(value.String()) + } else { + data.Groups[i].Name = types.StringNull() + } + if value := r.Get("sid"); value.Exists() && !data.Groups[i].Sid.IsNull() { + data.Groups[i].Sid = types.StringValue(value.String()) + } else { + data.Groups[i].Sid = types.StringNull() + } + } +} + +//template:end updateFromBody + +//template:begin isNull +func (data *ActiveDirectoryAddGroups) isNull(ctx context.Context, res gjson.Result) bool { + if !data.Name.IsNull() { + return false + } + if !data.Description.IsNull() { + return false + } + if !data.Domain.IsNull() { + return false + } + if !data.AdScopesNames.IsNull() { + return false + } + if !data.EnableDomainAllowedList.IsNull() { + return false + } + if len(data.Groups) > 0 { + return false + } + return true +} + +//template:end isNull diff --git a/internal/provider/model_ise_active_directory_join_domain_with_all_nodes.go b/internal/provider/model_ise_active_directory_join_domain_with_all_nodes.go new file mode 100644 index 0000000..2c2253c --- /dev/null +++ b/internal/provider/model_ise_active_directory_join_domain_with_all_nodes.go @@ -0,0 +1,155 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +//template:end imports + +//template:begin types +type ActiveDirectoryJoinDomainWithAllNodes struct { + Id types.String `tfsdk:"id"` + JoinPointId types.String `tfsdk:"join_point_id"` + AdditionalData []ActiveDirectoryJoinDomainWithAllNodesAdditionalData `tfsdk:"additional_data"` +} + +type ActiveDirectoryJoinDomainWithAllNodesAdditionalData struct { + Name types.String `tfsdk:"name"` + Value types.String `tfsdk:"value"` +} + +//template:end types + +//template:begin getPath +func (data ActiveDirectoryJoinDomainWithAllNodes) getPath() string { + return fmt.Sprintf("/ers/config/activedirectory/%v/joinAllNodes", data.JoinPointId.ValueString()) +} + +//template:end getPath + +//template:begin getPathPut +func (data ActiveDirectoryJoinDomainWithAllNodes) getPathPut() string { + return fmt.Sprintf("/ers/config/activedirectory/%v/leaveAllNodes", data.JoinPointId.ValueString()) +} + +//template:end getPathPut + +//template:begin toBody +func (data ActiveDirectoryJoinDomainWithAllNodes) toBody(ctx context.Context, state ActiveDirectoryJoinDomainWithAllNodes) string { + body := "" + if len(data.AdditionalData) > 0 { + body, _ = sjson.Set(body, "OperationAdditionalData.additionalData", []interface{}{}) + for _, item := range data.AdditionalData { + itemBody := "" + if !item.Name.IsNull() { + itemBody, _ = sjson.Set(itemBody, "name", item.Name.ValueString()) + } + if !item.Value.IsNull() { + itemBody, _ = sjson.Set(itemBody, "value", item.Value.ValueString()) + } + body, _ = sjson.SetRaw(body, "OperationAdditionalData.additionalData.-1", itemBody) + } + } + return body +} + +//template:end toBody + +//template:begin fromBody +func (data *ActiveDirectoryJoinDomainWithAllNodes) fromBody(ctx context.Context, res gjson.Result) { + if value := res.Get("OperationAdditionalData.additionalData"); value.Exists() { + data.AdditionalData = make([]ActiveDirectoryJoinDomainWithAllNodesAdditionalData, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := ActiveDirectoryJoinDomainWithAllNodesAdditionalData{} + if cValue := v.Get("name"); cValue.Exists() { + item.Name = types.StringValue(cValue.String()) + } else { + item.Name = types.StringNull() + } + if cValue := v.Get("value"); cValue.Exists() { + item.Value = types.StringValue(cValue.String()) + } else { + item.Value = types.StringNull() + } + data.AdditionalData = append(data.AdditionalData, item) + return true + }) + } +} + +//template:end fromBody + +//template:begin updateFromBody +func (data *ActiveDirectoryJoinDomainWithAllNodes) updateFromBody(ctx context.Context, res gjson.Result) { + for i := range data.AdditionalData { + keys := [...]string{"name"} + keyValues := [...]string{data.AdditionalData[i].Name.ValueString()} + + var r gjson.Result + res.Get("OperationAdditionalData.additionalData").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + if v.Get(keys[ik]).String() == keyValues[ik] { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + if value := r.Get("name"); value.Exists() && !data.AdditionalData[i].Name.IsNull() { + data.AdditionalData[i].Name = types.StringValue(value.String()) + } else { + data.AdditionalData[i].Name = types.StringNull() + } + if value := r.Get("value"); value.Exists() && !data.AdditionalData[i].Value.IsNull() { + data.AdditionalData[i].Value = types.StringValue(value.String()) + } else { + data.AdditionalData[i].Value = types.StringNull() + } + } +} + +//template:end updateFromBody + +//template:begin isNull +func (data *ActiveDirectoryJoinDomainWithAllNodes) isNull(ctx context.Context, res gjson.Result) bool { + if len(data.AdditionalData) > 0 { + return false + } + return true +} + +//template:end isNull diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e8b02fd..1ecce03 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -242,6 +242,8 @@ func (p *IseProvider) Configure(ctx context.Context, req provider.ConfigureReque func (p *IseProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{ + NewActiveDirectoryAddGroupsResource, + NewActiveDirectoryJoinDomainWithAllNodesResource, NewActiveDirectoryJoinPointResource, NewAllowedProtocolsResource, NewAllowedProtocolsTACACSResource, diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go deleted file mode 100644 index 938117a..0000000 --- a/internal/provider/provider_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright © 2023 Cisco Systems, Inc. and its affiliates. -// All rights reserved. -// -// Licensed under the Mozilla Public License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://mozilla.org/MPL/2.0/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// SPDX-License-Identifier: MPL-2.0 - -package provider - -import ( - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-go/tfprotov6" -) - -// testAccProtoV6ProviderFactories are used to instantiate a provider during -// acceptance testing. The factory function will be invoked for every Terraform -// CLI command executed to create a provider server to which the CLI can -// reattach. -var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ - "ise": providerserver.NewProtocol6WithError(New("test")()), -} - -func testAccPreCheck(t *testing.T) { - // You can add code here to run prior to any test case execution, for example assertions - // about the appropriate environment variables being set are common to see in a pre-check - // function. - if v := os.Getenv("ISE_USERNAME"); v == "" { - t.Fatal("ISE_USERNAME env variable must be set for acceptance tests") - } - if v := os.Getenv("ISE_PASSWORD"); v == "" { - t.Fatal("ISE_PASSWORD env variable must be set for acceptance tests") - } - if v := os.Getenv("ISE_URL"); v == "" { - t.Fatal("ISE_URL env variable must be set for acceptance tests") - } -} diff --git a/internal/provider/resource_ise_active_directory_add_groups.go b/internal/provider/resource_ise_active_directory_add_groups.go new file mode 100644 index 0000000..6be453e --- /dev/null +++ b/internal/provider/resource_ise_active_directory_add_groups.go @@ -0,0 +1,238 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "context" + "fmt" + + "github.com/CiscoDevNet/terraform-provider-ise/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/netascode/go-ise" +) + +//template:end imports + +//template:begin model + +// Ensure provider defined types fully satisfy framework interfaces +var _ resource.Resource = &ActiveDirectoryAddGroupsResource{} + +func NewActiveDirectoryAddGroupsResource() resource.Resource { + return &ActiveDirectoryAddGroupsResource{} +} + +type ActiveDirectoryAddGroupsResource struct { + client *ise.Client +} + +func (r *ActiveDirectoryAddGroupsResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_active_directory_add_groups" +} + +func (r *ActiveDirectoryAddGroupsResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: helpers.NewAttributeDescription("This resource can manage an Active Directory Add Groups.").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the object", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "join_point_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Active Directory Join Point ID").String, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("The name of the active directory join point").String, + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Join point Description").String, + Optional: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "domain": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("AD domain associated with the join point").String, + Required: true, + }, + "ad_scopes_names": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("String that contains the names of the scopes that the active directory belongs to. Names are separated by comm").AddDefaultValueDescription("Default_Scope").String, + Optional: true, + Computed: true, + Default: stringdefault.StaticString("Default_Scope"), + }, + "enable_domain_allowed_list": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddDefaultValueDescription("true").String, + Optional: true, + Computed: true, + Default: booldefault.StaticBool(true), + }, + "groups": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("List of AD Groups").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Required for each group in the group list with no duplication between groups").String, + Required: true, + }, + "sid": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Required for each group in the group list with no duplication between groups").String, + Required: true, + }, + "type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Optional: true, + }, + }, + }, + }, + }, + } +} + +func (r *ActiveDirectoryAddGroupsResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*IseProviderData).Client +} + +//template:end model + +//template:begin create +func (r *ActiveDirectoryAddGroupsResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ActiveDirectoryAddGroups + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + + // Create object + body := plan.toBody(ctx, ActiveDirectoryAddGroups{}) + res, err := r.client.Put(plan.getPath(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + plan.Id = types.StringValue(fmt.Sprint(plan.JoinPointId.ValueString())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Id.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +//template:end create + +//template:begin read +func (r *ActiveDirectoryAddGroupsResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ActiveDirectoryAddGroups + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Id.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +//template:end read + +//template:begin update +func (r *ActiveDirectoryAddGroupsResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ActiveDirectoryAddGroups + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Id.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +//template:end update + +//template:begin delete +func (r *ActiveDirectoryAddGroupsResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ActiveDirectoryAddGroups + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) + + resp.State.RemoveResource(ctx) +} + +//template:end delete + +//template:begin import +//template:end import diff --git a/internal/provider/resource_ise_active_directory_add_groups_test.go b/internal/provider/resource_ise_active_directory_add_groups_test.go new file mode 100644 index 0000000..ea011de --- /dev/null +++ b/internal/provider/resource_ise_active_directory_add_groups_test.go @@ -0,0 +1,95 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +//template:end imports + +//template:begin testAcc +func TestAccIseActiveDirectoryAddGroups(t *testing.T) { + if os.Getenv("AD") == "" { + t.Skip("skipping test, set environment variable AD") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "join_point_id", "73808580-b6e6-11ee-8960-de6d7692bc40")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "name", "cisco.local")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "description", "My AD join point")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "domain", "cisco.local")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "ad_scopes_names", "Default_Scope")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "enable_domain_allowed_list", "true")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "groups.0.name", "cisco.local/operators")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_add_groups.test", "groups.0.sid", "S-1-5-32-548")) + + var steps []resource.TestStep + steps = append(steps, resource.TestStep{ + Config: testAccIseActiveDirectoryAddGroupsConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: steps, + }) +} + +//template:end testAcc + +//template:begin testPrerequisites +//template:end testPrerequisites + +//template:begin testAccConfigMinimal +func testAccIseActiveDirectoryAddGroupsConfig_minimum() string { + config := `resource "ise_active_directory_add_groups" "test" {` + "\n" + config += ` join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"` + "\n" + config += ` name = "cisco.local"` + "\n" + config += ` domain = "cisco.local"` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigMinimal + +//template:begin testAccConfigAll +func testAccIseActiveDirectoryAddGroupsConfig_all() string { + config := `resource "ise_active_directory_add_groups" "test" {` + "\n" + config += ` join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"` + "\n" + config += ` name = "cisco.local"` + "\n" + config += ` description = "My AD join point"` + "\n" + config += ` domain = "cisco.local"` + "\n" + config += ` ad_scopes_names = "Default_Scope"` + "\n" + config += ` enable_domain_allowed_list = true` + "\n" + config += ` groups = [{` + "\n" + config += ` name = "cisco.local/operators"` + "\n" + config += ` sid = "S-1-5-32-548"` + "\n" + config += ` type = "GLOBAL"` + "\n" + config += ` }]` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigAll diff --git a/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes.go b/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes.go new file mode 100644 index 0000000..824abf5 --- /dev/null +++ b/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes.go @@ -0,0 +1,218 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "context" + "fmt" + + "github.com/CiscoDevNet/terraform-provider-ise/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/netascode/go-ise" +) + +//template:end imports + +//template:begin model + +// Ensure provider defined types fully satisfy framework interfaces +var _ resource.Resource = &ActiveDirectoryJoinDomainWithAllNodesResource{} + +func NewActiveDirectoryJoinDomainWithAllNodesResource() resource.Resource { + return &ActiveDirectoryJoinDomainWithAllNodesResource{} +} + +type ActiveDirectoryJoinDomainWithAllNodesResource struct { + client *ise.Client +} + +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_active_directory_join_domain_with_all_nodes" +} + +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: helpers.NewAttributeDescription("This resource can manage an Active Directory Join Domain with All Nodes.").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the object", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "join_point_id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Active Directory Join Point ID").String, + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + }, + "additional_data": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Additional attribute name").String, + Required: true, + }, + "value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Additional attribute value").String, + Required: true, + }, + }, + }, + }, + }, + } +} + +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + r.client = req.ProviderData.(*IseProviderData).Client +} + +//template:end model + +//template:begin create +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan ActiveDirectoryJoinDomainWithAllNodes + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Create", plan.Id.ValueString())) + + // Create object + body := plan.toBody(ctx, ActiveDirectoryJoinDomainWithAllNodes{}) + res, err := r.client.Put(plan.getPath(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + plan.Id = types.StringValue(fmt.Sprint(plan.JoinPointId.ValueString())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Create finished successfully", plan.Id.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +//template:end create + +//template:begin read +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state ActiveDirectoryJoinDomainWithAllNodes + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", state.Id.ValueString())) + + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) +} + +//template:end read + +//template:begin update +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state ActiveDirectoryJoinDomainWithAllNodes + + // Read plan + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + // Read state + diags = req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) + body := plan.toBody(ctx, state) + + res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Id.ValueString())) + + diags = resp.State.Set(ctx, &plan) + resp.Diagnostics.Append(diags...) +} + +//template:end update + +//template:begin delete +func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state ActiveDirectoryJoinDomainWithAllNodes + + // Read state + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) + body := state.toBody(ctx, state) + res, err := r.client.Put(state.getPathPut(), body) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (DELETE), got error: %s, %s", err, res.String())) + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Delete finished successfully", state.Id.ValueString())) + + resp.State.RemoveResource(ctx) +} + +//template:end delete + +//template:begin import +//template:end import diff --git a/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes_test.go b/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes_test.go new file mode 100644 index 0000000..290ebf5 --- /dev/null +++ b/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes_test.go @@ -0,0 +1,86 @@ +// Copyright © 2023 Cisco Systems, Inc. and its affiliates. +// All rights reserved. +// +// Licensed under the Mozilla Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://mozilla.org/MPL/2.0/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by "gen/generator.go"; DO NOT EDIT. + +package provider + +//template:begin imports +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +//template:end imports + +//template:begin testAcc +func TestAccIseActiveDirectoryJoinDomainWithAllNodes(t *testing.T) { + if os.Getenv("AD") == "" { + t.Skip("skipping test, set environment variable AD") + } + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_join_domain_with_all_nodes.test", "join_point_id", "73808580-b6e6-11ee-8960-de6d7692bc40")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_join_domain_with_all_nodes.test", "additional_data.0.name", "username")) + checks = append(checks, resource.TestCheckResourceAttr("ise_active_directory_join_domain_with_all_nodes.test", "additional_data.0.value", "administrator")) + + var steps []resource.TestStep + steps = append(steps, resource.TestStep{ + Config: testAccIseActiveDirectoryJoinDomainWithAllNodesConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: steps, + }) +} + +//template:end testAcc + +//template:begin testPrerequisites +//template:end testPrerequisites + +//template:begin testAccConfigMinimal +func testAccIseActiveDirectoryJoinDomainWithAllNodesConfig_minimum() string { + config := `resource "ise_active_directory_join_domain_with_all_nodes" "test" {` + "\n" + config += ` join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"` + "\n" + config += ` additional_data = [{` + "\n" + config += ` name = "username"` + "\n" + config += ` value = "administrator"` + "\n" + config += ` }]` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigMinimal + +//template:begin testAccConfigAll +func testAccIseActiveDirectoryJoinDomainWithAllNodesConfig_all() string { + config := `resource "ise_active_directory_join_domain_with_all_nodes" "test" {` + "\n" + config += ` join_point_id = "73808580-b6e6-11ee-8960-de6d7692bc40"` + "\n" + config += ` additional_data = [{` + "\n" + config += ` name = "username"` + "\n" + config += ` value = "administrator"` + "\n" + config += ` }]` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigAll diff --git a/internal/provider/resource_ise_active_directory_join_point.go b/internal/provider/resource_ise_active_directory_join_point.go index d66df49..df314fd 100644 --- a/internal/provider/resource_ise_active_directory_join_point.go +++ b/internal/provider/resource_ise_active_directory_join_point.go @@ -473,7 +473,6 @@ func (r *ActiveDirectoryJoinPointResource) Read(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -517,14 +516,6 @@ func (r *ActiveDirectoryJoinPointResource) Update(ctx context.Context, req resou tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) - - res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) - if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (PUT), got error: %s, %s", err, res.String())) - return - } - tflog.Debug(ctx, fmt.Sprintf("%s: Update finished successfully", plan.Id.ValueString())) diags = resp.State.Set(ctx, &plan) diff --git a/internal/provider/resource_ise_allowed_protocols.go b/internal/provider/resource_ise_allowed_protocols.go index 8ca6d60..2cd9b09 100644 --- a/internal/provider/resource_ise_allowed_protocols.go +++ b/internal/provider/resource_ise_allowed_protocols.go @@ -476,7 +476,6 @@ func (r *AllowedProtocolsResource) Read(ctx context.Context, req resource.ReadRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -519,7 +518,6 @@ func (r *AllowedProtocolsResource) Update(ctx context.Context, req resource.Upda } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_allowed_protocols_tacacs.go b/internal/provider/resource_ise_allowed_protocols_tacacs.go index c2eafe5..560c350 100644 --- a/internal/provider/resource_ise_allowed_protocols_tacacs.go +++ b/internal/provider/resource_ise_allowed_protocols_tacacs.go @@ -146,7 +146,6 @@ func (r *AllowedProtocolsTACACSResource) Read(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -189,7 +188,6 @@ func (r *AllowedProtocolsTACACSResource) Update(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_authorization_profile.go b/internal/provider/resource_ise_authorization_profile.go index 199ac0f..f4b2357 100644 --- a/internal/provider/resource_ise_authorization_profile.go +++ b/internal/provider/resource_ise_authorization_profile.go @@ -328,7 +328,6 @@ func (r *AuthorizationProfileResource) Read(ctx context.Context, req resource.Re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -371,7 +370,6 @@ func (r *AuthorizationProfileResource) Update(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_certificate_authentication_profile.go b/internal/provider/resource_ise_certificate_authentication_profile.go index 54fcd1e..3870384 100644 --- a/internal/provider/resource_ise_certificate_authentication_profile.go +++ b/internal/provider/resource_ise_certificate_authentication_profile.go @@ -177,7 +177,6 @@ func (r *CertificateAuthenticationProfileResource) Read(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -220,7 +219,6 @@ func (r *CertificateAuthenticationProfileResource) Update(ctx context.Context, r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_authentication_rule.go b/internal/provider/resource_ise_device_admin_authentication_rule.go index 84eae69..8f10d55 100644 --- a/internal/provider/resource_ise_device_admin_authentication_rule.go +++ b/internal/provider/resource_ise_device_admin_authentication_rule.go @@ -308,7 +308,6 @@ func (r *DeviceAdminAuthenticationRuleResource) Read(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -351,7 +350,6 @@ func (r *DeviceAdminAuthenticationRuleResource) Update(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_authorization_exception_rule.go b/internal/provider/resource_ise_device_admin_authorization_exception_rule.go index 734c685..8e490f3 100644 --- a/internal/provider/resource_ise_device_admin_authorization_exception_rule.go +++ b/internal/provider/resource_ise_device_admin_authorization_exception_rule.go @@ -292,7 +292,6 @@ func (r *DeviceAdminAuthorizationExceptionRuleResource) Read(ctx context.Context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -335,7 +334,6 @@ func (r *DeviceAdminAuthorizationExceptionRuleResource) Update(ctx context.Conte } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_authorization_global_exception_rule.go b/internal/provider/resource_ise_device_admin_authorization_global_exception_rule.go index 3cf2df8..1f41ace 100644 --- a/internal/provider/resource_ise_device_admin_authorization_global_exception_rule.go +++ b/internal/provider/resource_ise_device_admin_authorization_global_exception_rule.go @@ -285,7 +285,6 @@ func (r *DeviceAdminAuthorizationGlobalExceptionRuleResource) Read(ctx context.C } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -328,7 +327,6 @@ func (r *DeviceAdminAuthorizationGlobalExceptionRuleResource) Update(ctx context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_authorization_rule.go b/internal/provider/resource_ise_device_admin_authorization_rule.go index 0e98529..10a7f43 100644 --- a/internal/provider/resource_ise_device_admin_authorization_rule.go +++ b/internal/provider/resource_ise_device_admin_authorization_rule.go @@ -292,7 +292,6 @@ func (r *DeviceAdminAuthorizationRuleResource) Read(ctx context.Context, req res } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -335,7 +334,6 @@ func (r *DeviceAdminAuthorizationRuleResource) Update(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_condition.go b/internal/provider/resource_ise_device_admin_condition.go index 3b86e0d..59d56e2 100644 --- a/internal/provider/resource_ise_device_admin_condition.go +++ b/internal/provider/resource_ise_device_admin_condition.go @@ -277,7 +277,6 @@ func (r *DeviceAdminConditionResource) Read(ctx context.Context, req resource.Re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -320,7 +319,6 @@ func (r *DeviceAdminConditionResource) Update(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_policy_set.go b/internal/provider/resource_ise_device_admin_policy_set.go index f6b9082..36270f3 100644 --- a/internal/provider/resource_ise_device_admin_policy_set.go +++ b/internal/provider/resource_ise_device_admin_policy_set.go @@ -284,7 +284,6 @@ func (r *DeviceAdminPolicySetResource) Read(ctx context.Context, req resource.Re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -327,7 +326,6 @@ func (r *DeviceAdminPolicySetResource) Update(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_device_admin_time_and_date_condition.go b/internal/provider/resource_ise_device_admin_time_and_date_condition.go index 9d99f52..ac7b5a9 100644 --- a/internal/provider/resource_ise_device_admin_time_and_date_condition.go +++ b/internal/provider/resource_ise_device_admin_time_and_date_condition.go @@ -179,7 +179,6 @@ func (r *DeviceAdminTimeAndDateConditionResource) Read(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -222,7 +221,6 @@ func (r *DeviceAdminTimeAndDateConditionResource) Update(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_downloadable_acl.go b/internal/provider/resource_ise_downloadable_acl.go index 99c6ff2..3590e05 100644 --- a/internal/provider/resource_ise_downloadable_acl.go +++ b/internal/provider/resource_ise_downloadable_acl.go @@ -150,7 +150,6 @@ func (r *DownloadableACLResource) Read(ctx context.Context, req resource.ReadReq } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -193,7 +192,6 @@ func (r *DownloadableACLResource) Update(ctx context.Context, req resource.Updat } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_endpoint_identity_group.go b/internal/provider/resource_ise_endpoint_identity_group.go index 5d01107..5931435 100644 --- a/internal/provider/resource_ise_endpoint_identity_group.go +++ b/internal/provider/resource_ise_endpoint_identity_group.go @@ -145,7 +145,6 @@ func (r *EndpointIdentityGroupResource) Read(ctx context.Context, req resource.R } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -188,7 +187,6 @@ func (r *EndpointIdentityGroupResource) Update(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_identity_source_sequence.go b/internal/provider/resource_ise_identity_source_sequence.go index 2f5cdfd..0252133 100644 --- a/internal/provider/resource_ise_identity_source_sequence.go +++ b/internal/provider/resource_ise_identity_source_sequence.go @@ -158,7 +158,6 @@ func (r *IdentitySourceSequenceResource) Read(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -201,7 +200,6 @@ func (r *IdentitySourceSequenceResource) Update(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_internal_user.go b/internal/provider/resource_ise_internal_user.go index ca2474c..2708f68 100644 --- a/internal/provider/resource_ise_internal_user.go +++ b/internal/provider/resource_ise_internal_user.go @@ -190,7 +190,6 @@ func (r *InternalUserResource) Read(ctx context.Context, req resource.ReadReques } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -233,7 +232,6 @@ func (r *InternalUserResource) Update(ctx context.Context, req resource.UpdateRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_license_tier_state.go b/internal/provider/resource_ise_license_tier_state.go index 4000ea5..8ac8777 100644 --- a/internal/provider/resource_ise_license_tier_state.go +++ b/internal/provider/resource_ise_license_tier_state.go @@ -149,7 +149,6 @@ func (r *LicenseTierStateResource) Read(ctx context.Context, req resource.ReadRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -192,7 +191,6 @@ func (r *LicenseTierStateResource) Update(ctx context.Context, req resource.Upda } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, _, err := r.client.Post(plan.getPath(), body) diff --git a/internal/provider/resource_ise_network_access_authentication_rule.go b/internal/provider/resource_ise_network_access_authentication_rule.go index 0c371a0..4ea060a 100644 --- a/internal/provider/resource_ise_network_access_authentication_rule.go +++ b/internal/provider/resource_ise_network_access_authentication_rule.go @@ -308,7 +308,6 @@ func (r *NetworkAccessAuthenticationRuleResource) Read(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -351,7 +350,6 @@ func (r *NetworkAccessAuthenticationRuleResource) Update(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_authorization_exception_rule.go b/internal/provider/resource_ise_network_access_authorization_exception_rule.go index dcef907..6518dd7 100644 --- a/internal/provider/resource_ise_network_access_authorization_exception_rule.go +++ b/internal/provider/resource_ise_network_access_authorization_exception_rule.go @@ -292,7 +292,6 @@ func (r *NetworkAccessAuthorizationExceptionRuleResource) Read(ctx context.Conte } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -335,7 +334,6 @@ func (r *NetworkAccessAuthorizationExceptionRuleResource) Update(ctx context.Con } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_authorization_global_exception_rule.go b/internal/provider/resource_ise_network_access_authorization_global_exception_rule.go index 651b8e8..ecdc8c6 100644 --- a/internal/provider/resource_ise_network_access_authorization_global_exception_rule.go +++ b/internal/provider/resource_ise_network_access_authorization_global_exception_rule.go @@ -285,7 +285,6 @@ func (r *NetworkAccessAuthorizationGlobalExceptionRuleResource) Read(ctx context } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -328,7 +327,6 @@ func (r *NetworkAccessAuthorizationGlobalExceptionRuleResource) Update(ctx conte } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_authorization_rule.go b/internal/provider/resource_ise_network_access_authorization_rule.go index 0767e44..7b5201c 100644 --- a/internal/provider/resource_ise_network_access_authorization_rule.go +++ b/internal/provider/resource_ise_network_access_authorization_rule.go @@ -292,7 +292,6 @@ func (r *NetworkAccessAuthorizationRuleResource) Read(ctx context.Context, req r } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -335,7 +334,6 @@ func (r *NetworkAccessAuthorizationRuleResource) Update(ctx context.Context, req } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_condition.go b/internal/provider/resource_ise_network_access_condition.go index edad9ef..97416b3 100644 --- a/internal/provider/resource_ise_network_access_condition.go +++ b/internal/provider/resource_ise_network_access_condition.go @@ -277,7 +277,6 @@ func (r *NetworkAccessConditionResource) Read(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -320,7 +319,6 @@ func (r *NetworkAccessConditionResource) Update(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_dictionary.go b/internal/provider/resource_ise_network_access_dictionary.go index 2930349..d534620 100644 --- a/internal/provider/resource_ise_network_access_dictionary.go +++ b/internal/provider/resource_ise_network_access_dictionary.go @@ -149,7 +149,6 @@ func (r *NetworkAccessDictionaryResource) Read(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -192,7 +191,6 @@ func (r *NetworkAccessDictionaryResource) Update(ctx context.Context, req resour } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_policy_set.go b/internal/provider/resource_ise_network_access_policy_set.go index 43bbb9a..bd4426d 100644 --- a/internal/provider/resource_ise_network_access_policy_set.go +++ b/internal/provider/resource_ise_network_access_policy_set.go @@ -284,7 +284,6 @@ func (r *NetworkAccessPolicySetResource) Read(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -327,7 +326,6 @@ func (r *NetworkAccessPolicySetResource) Update(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_access_time_and_date_condition.go b/internal/provider/resource_ise_network_access_time_and_date_condition.go index 26a16c0..ea999ba 100644 --- a/internal/provider/resource_ise_network_access_time_and_date_condition.go +++ b/internal/provider/resource_ise_network_access_time_and_date_condition.go @@ -179,7 +179,6 @@ func (r *NetworkAccessTimeAndDateConditionResource) Read(ctx context.Context, re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -222,7 +221,6 @@ func (r *NetworkAccessTimeAndDateConditionResource) Update(ctx context.Context, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_device.go b/internal/provider/resource_ise_network_device.go index c83fc25..0315a28 100644 --- a/internal/provider/resource_ise_network_device.go +++ b/internal/provider/resource_ise_network_device.go @@ -338,7 +338,6 @@ func (r *NetworkDeviceResource) Read(ctx context.Context, req resource.ReadReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -381,7 +380,6 @@ func (r *NetworkDeviceResource) Update(ctx context.Context, req resource.UpdateR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_network_device_group.go b/internal/provider/resource_ise_network_device_group.go index 1dcd0cb..919898e 100644 --- a/internal/provider/resource_ise_network_device_group.go +++ b/internal/provider/resource_ise_network_device_group.go @@ -138,7 +138,6 @@ func (r *NetworkDeviceGroupResource) Read(ctx context.Context, req resource.Read } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -181,7 +180,6 @@ func (r *NetworkDeviceGroupResource) Update(ctx context.Context, req resource.Up } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_repository.go b/internal/provider/resource_ise_repository.go index 130c2ff..464c93d 100644 --- a/internal/provider/resource_ise_repository.go +++ b/internal/provider/resource_ise_repository.go @@ -161,7 +161,6 @@ func (r *RepositoryResource) Read(ctx context.Context, req resource.ReadRequest, } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -204,7 +203,6 @@ func (r *RepositoryResource) Update(ctx context.Context, req resource.UpdateRequ } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_tacacs_command_set.go b/internal/provider/resource_ise_tacacs_command_set.go index 55e5b61..a81fc1f 100644 --- a/internal/provider/resource_ise_tacacs_command_set.go +++ b/internal/provider/resource_ise_tacacs_command_set.go @@ -166,7 +166,6 @@ func (r *TACACSCommandSetResource) Read(ctx context.Context, req resource.ReadRe } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -209,7 +208,6 @@ func (r *TACACSCommandSetResource) Update(ctx context.Context, req resource.Upda } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_tacacs_profile.go b/internal/provider/resource_ise_tacacs_profile.go index 30e4880..85e9c83 100644 --- a/internal/provider/resource_ise_tacacs_profile.go +++ b/internal/provider/resource_ise_tacacs_profile.go @@ -159,7 +159,6 @@ func (r *TACACSProfileResource) Read(ctx context.Context, req resource.ReadReque } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -202,7 +201,6 @@ func (r *TACACSProfileResource) Update(ctx context.Context, req resource.UpdateR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_trustsec_egress_matrix_cell.go b/internal/provider/resource_ise_trustsec_egress_matrix_cell.go index 541a314..16af4af 100644 --- a/internal/provider/resource_ise_trustsec_egress_matrix_cell.go +++ b/internal/provider/resource_ise_trustsec_egress_matrix_cell.go @@ -164,7 +164,6 @@ func (r *TrustSecEgressMatrixCellResource) Read(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -207,7 +206,6 @@ func (r *TrustSecEgressMatrixCellResource) Update(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping.go b/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping.go index 31d56f3..bc6e05b 100644 --- a/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping.go +++ b/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping.go @@ -163,7 +163,6 @@ func (r *TrustSecIPToSGTMappingResource) Read(ctx context.Context, req resource. } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -206,7 +205,6 @@ func (r *TrustSecIPToSGTMappingResource) Update(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping_group.go b/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping_group.go index 3bcf540..44d329d 100644 --- a/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping_group.go +++ b/internal/provider/resource_ise_trustsec_ip_to_sgt_mapping_group.go @@ -151,7 +151,6 @@ func (r *TrustSecIPToSGTMappingGroupResource) Read(ctx context.Context, req reso } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -194,7 +193,6 @@ func (r *TrustSecIPToSGTMappingGroupResource) Update(ctx context.Context, req re } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_trustsec_security_group.go b/internal/provider/resource_ise_trustsec_security_group.go index 9d5e417..5c2a9a6 100644 --- a/internal/provider/resource_ise_trustsec_security_group.go +++ b/internal/provider/resource_ise_trustsec_security_group.go @@ -154,7 +154,6 @@ func (r *TrustSecSecurityGroupResource) Read(ctx context.Context, req resource.R } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -197,7 +196,6 @@ func (r *TrustSecSecurityGroupResource) Update(ctx context.Context, req resource } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_trustsec_security_group_acl.go b/internal/provider/resource_ise_trustsec_security_group_acl.go index a68166f..28d00b4 100644 --- a/internal/provider/resource_ise_trustsec_security_group_acl.go +++ b/internal/provider/resource_ise_trustsec_security_group_acl.go @@ -157,7 +157,6 @@ func (r *TrustSecSecurityGroupACLResource) Read(ctx context.Context, req resourc } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -200,7 +199,6 @@ func (r *TrustSecSecurityGroupACLResource) Update(ctx context.Context, req resou } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body) diff --git a/internal/provider/resource_ise_user_identity_group.go b/internal/provider/resource_ise_user_identity_group.go index 4c1cf82..aadbd27 100644 --- a/internal/provider/resource_ise_user_identity_group.go +++ b/internal/provider/resource_ise_user_identity_group.go @@ -138,7 +138,6 @@ func (r *UserIdentityGroupResource) Read(ctx context.Context, req resource.ReadR } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", state.Id.String())) - res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) if err != nil && strings.Contains(err.Error(), "StatusCode 404") { resp.State.RemoveResource(ctx) @@ -181,7 +180,6 @@ func (r *UserIdentityGroupResource) Update(ctx context.Context, req resource.Upd } tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Update", plan.Id.ValueString())) - body := plan.toBody(ctx, state) res, err := r.client.Put(plan.getPath()+"/"+plan.Id.ValueString(), body)