diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abd076..8607c7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.1.12 (unreleased) - Ignore error messages when attempting to delete default policy sets or rules +- Add `ise_active_directory_add_groups` resource +- Add `ise_active_directory_join_domain_with_all_nodes` resource ## 0.1.11 diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 5859add..213d0dc 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -10,6 +10,8 @@ description: |- ## 0.1.12 (unreleased) - Ignore error messages when attempting to delete default policy sets or rules +- Add `ise_active_directory_add_groups` resource +- Add `ise_active_directory_join_domain_with_all_nodes` resource ## 0.1.11 diff --git a/gen/definitions/trustsec_egress_matrix_cell.yaml b/gen/definitions/trustsec_egress_matrix_cell.yaml index 2f6680b..2478c7c 100644 --- a/gen/definitions/trustsec_egress_matrix_cell.yaml +++ b/gen/definitions/trustsec_egress_matrix_cell.yaml @@ -2,7 +2,6 @@ name: TrustSec Egress Matrix Cell rest_endpoint: /ers/config/egressmatrixcell doc_category: TrustSec -id_path: response.id put_id_include_path: EgressMatrixCell attributes: - model_name: description diff --git a/gen/definitions/trustsec_ip_to_sgt_mapping.yaml b/gen/definitions/trustsec_ip_to_sgt_mapping.yaml index b7d4095..dc95472 100644 --- a/gen/definitions/trustsec_ip_to_sgt_mapping.yaml +++ b/gen/definitions/trustsec_ip_to_sgt_mapping.yaml @@ -3,7 +3,6 @@ name: TrustSec IP to SGT Mapping rest_endpoint: /ers/config/sgmapping doc_category: TrustSec data_source_name_query: true -id_path: response.id attributes: - model_name: name data_path: [SGMapping] diff --git a/gen/definitions/trustsec_ip_to_sgt_mapping_group.yaml b/gen/definitions/trustsec_ip_to_sgt_mapping_group.yaml index 0ba25e3..2bb8b2f 100644 --- a/gen/definitions/trustsec_ip_to_sgt_mapping_group.yaml +++ b/gen/definitions/trustsec_ip_to_sgt_mapping_group.yaml @@ -3,7 +3,6 @@ name: TrustSec IP to SGT Mapping Group rest_endpoint: /ers/config/sgmappinggroup doc_category: TrustSec data_source_name_query: true -id_path: response.id attributes: - model_name: name data_path: [SGMappingGroup] diff --git a/gen/doc_category.go b/gen/doc_category.go index ea010ec..db955b9 100644 --- a/gen/doc_category.go +++ b/gen/doc_category.go @@ -35,7 +35,7 @@ const ( type YamlConfig struct { Name string `yaml:"name"` DocCategory string `yaml:"doc_category"` - NoResource bool `yaml:"no_resource"` + NoResource bool `yaml:"no_resource"` NoDataSource bool `yaml:"no_data_source"` } diff --git a/gen/generator.go b/gen/generator.go index 98f46e2..e5744f0 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -108,7 +108,6 @@ type YamlConfig struct { 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"` diff --git a/gen/schema/schema.yaml b/gen/schema/schema.yaml index 2d14736..2e6f0ff 100644 --- a/gen/schema/schema.yaml +++ b/gen/schema/schema.yaml @@ -13,7 +13,6 @@ put_create: bool(required=False) # Set to true if the PUT request is used to cre 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) diff --git a/gen/templates/model.go b/gen/templates/model.go index 56ef3ee..1d88882 100644 --- a/gen/templates/model.go +++ b/gen/templates/model.go @@ -145,17 +145,17 @@ func (data {{camelCase .Name}}) getPath() string { } //template:end getPath +//template:begin getPathDelete {{if .DeleteRestEndpoint}} -//template:begin getPathPut -func (data {{camelCase .Name}}) getPathPut() string { +func (data {{camelCase .Name}}) getPathDelete() 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:end getPathDelete //template:begin toBody func (data {{camelCase .Name}}) toBody(ctx context.Context, state {{camelCase .Name}}) string { diff --git a/gen/templates/resource.go b/gen/templates/resource.go index db4c3c2..73a3cc4 100644 --- a/gen/templates/resource.go +++ b/gen/templates/resource.go @@ -435,46 +435,26 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C // Create object body := plan.toBody(ctx, {{camelCase .Name}}{}) - {{- if not (isErs .RestEndpoint)}} - res, _, 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 - } - {{- if .IdPath}} - plan.Id = types.StringValue(res.Get("{{.IdPath}}").String()) - {{- else}} - {{- range .Attributes}} - {{- if .Id}} - plan.Id = types.StringValue(fmt.Sprint(plan.{{toGoName .TfName}}.Value{{.Type}}())) - {{- end}} - {{- 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}} + {{- else if and (isErs .RestEndpoint) (not .IdPath) (not (hasId .Attributes))}} res, location, err := r.client.Post(plan.getPath(), body) + {{- else}} + res, _, err := r.client.Post(plan.getPath(), body) + {{- end}} if err != nil { - resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object (POST), got error: %s, %s", err, res.String())) + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to configure object ({{- if .PutCreate}}PUT{{else}}POST{{end}}), 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}} + {{- if .IdPath}} + plan.Id = types.StringValue(res.Get("{{.IdPath}}").String()) + {{- else if hasId .Attributes}} + {{- $id := getId .Attributes}} + plan.Id = types.StringValue(fmt.Sprint(plan.{{toGoName $id.TfName}}.Value{{$id.Type}}())) {{- 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())) @@ -540,7 +520,6 @@ 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}} @@ -574,15 +553,13 @@ 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}} {{- 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()) + res, err := r.client.Put(state.getPathDelete(), body) + {{- else}} + res, err := r.client.Delete({{if .DeleteRestEndpoint}}state.getPathDelete(){{else}}state.getPath(){{end}} + "/" + state.Id.ValueString()) + {{- end}} 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 diff --git a/internal/provider/model_ise_active_directory_add_groups.go b/internal/provider/model_ise_active_directory_add_groups.go index fa21737..24e3e6a 100644 --- a/internal/provider/model_ise_active_directory_add_groups.go +++ b/internal/provider/model_ise_active_directory_add_groups.go @@ -58,6 +58,10 @@ func (data ActiveDirectoryAddGroups) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data ActiveDirectoryAddGroups) toBody(ctx context.Context, state ActiveDirectoryAddGroups) string { body := "" 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 index 2c2253c..11751b3 100644 --- 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 @@ -52,12 +52,13 @@ func (data ActiveDirectoryJoinDomainWithAllNodes) getPath() string { //template:end getPath -//template:begin getPathPut -func (data ActiveDirectoryJoinDomainWithAllNodes) getPathPut() string { +//template:begin getPathDelete + +func (data ActiveDirectoryJoinDomainWithAllNodes) getPathDelete() string { return fmt.Sprintf("/ers/config/activedirectory/%v/leaveAllNodes", data.JoinPointId.ValueString()) } -//template:end getPathPut +//template:end getPathDelete //template:begin toBody func (data ActiveDirectoryJoinDomainWithAllNodes) toBody(ctx context.Context, state ActiveDirectoryJoinDomainWithAllNodes) string { diff --git a/internal/provider/model_ise_active_directory_join_point.go b/internal/provider/model_ise_active_directory_join_point.go index 6943c65..cfd3978 100644 --- a/internal/provider/model_ise_active_directory_join_point.go +++ b/internal/provider/model_ise_active_directory_join_point.go @@ -96,6 +96,10 @@ func (data ActiveDirectoryJoinPoint) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data ActiveDirectoryJoinPoint) toBody(ctx context.Context, state ActiveDirectoryJoinPoint) string { body := "" diff --git a/internal/provider/model_ise_allowed_protocols.go b/internal/provider/model_ise_allowed_protocols.go index 20d702c..52e5234 100644 --- a/internal/provider/model_ise_allowed_protocols.go +++ b/internal/provider/model_ise_allowed_protocols.go @@ -121,6 +121,10 @@ func (data AllowedProtocols) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data AllowedProtocols) toBody(ctx context.Context, state AllowedProtocols) string { body := "" diff --git a/internal/provider/model_ise_allowed_protocols_tacacs.go b/internal/provider/model_ise_allowed_protocols_tacacs.go index 96df26c..587e3f0 100644 --- a/internal/provider/model_ise_allowed_protocols_tacacs.go +++ b/internal/provider/model_ise_allowed_protocols_tacacs.go @@ -49,6 +49,10 @@ func (data AllowedProtocolsTACACS) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data AllowedProtocolsTACACS) toBody(ctx context.Context, state AllowedProtocolsTACACS) string { body := "" diff --git a/internal/provider/model_ise_authorization_profile.go b/internal/provider/model_ise_authorization_profile.go index 36c83d0..998c752 100644 --- a/internal/provider/model_ise_authorization_profile.go +++ b/internal/provider/model_ise_authorization_profile.go @@ -86,6 +86,10 @@ func (data AuthorizationProfile) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data AuthorizationProfile) toBody(ctx context.Context, state AuthorizationProfile) string { body := "" diff --git a/internal/provider/model_ise_certificate_authentication_profile.go b/internal/provider/model_ise_certificate_authentication_profile.go index 8269d79..0349d19 100644 --- a/internal/provider/model_ise_certificate_authentication_profile.go +++ b/internal/provider/model_ise_certificate_authentication_profile.go @@ -51,6 +51,10 @@ func (data CertificateAuthenticationProfile) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data CertificateAuthenticationProfile) toBody(ctx context.Context, state CertificateAuthenticationProfile) string { body := "" diff --git a/internal/provider/model_ise_device_admin_authentication_rule.go b/internal/provider/model_ise_device_admin_authentication_rule.go index eb39687..3c649fd 100644 --- a/internal/provider/model_ise_device_admin_authentication_rule.go +++ b/internal/provider/model_ise_device_admin_authentication_rule.go @@ -87,6 +87,10 @@ func (data DeviceAdminAuthenticationRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminAuthenticationRule) toBody(ctx context.Context, state DeviceAdminAuthenticationRule) string { body := "" diff --git a/internal/provider/model_ise_device_admin_authorization_exception_rule.go b/internal/provider/model_ise_device_admin_authorization_exception_rule.go index 3a1b642..88580b9 100644 --- a/internal/provider/model_ise_device_admin_authorization_exception_rule.go +++ b/internal/provider/model_ise_device_admin_authorization_exception_rule.go @@ -86,6 +86,10 @@ func (data DeviceAdminAuthorizationExceptionRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminAuthorizationExceptionRule) toBody(ctx context.Context, state DeviceAdminAuthorizationExceptionRule) string { body := "" diff --git a/internal/provider/model_ise_device_admin_authorization_global_exception_rule.go b/internal/provider/model_ise_device_admin_authorization_global_exception_rule.go index 1681fcb..f236bce 100644 --- a/internal/provider/model_ise_device_admin_authorization_global_exception_rule.go +++ b/internal/provider/model_ise_device_admin_authorization_global_exception_rule.go @@ -84,6 +84,10 @@ func (data DeviceAdminAuthorizationGlobalExceptionRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminAuthorizationGlobalExceptionRule) toBody(ctx context.Context, state DeviceAdminAuthorizationGlobalExceptionRule) string { body := "" diff --git a/internal/provider/model_ise_device_admin_authorization_rule.go b/internal/provider/model_ise_device_admin_authorization_rule.go index 840c8ef..81ae638 100644 --- a/internal/provider/model_ise_device_admin_authorization_rule.go +++ b/internal/provider/model_ise_device_admin_authorization_rule.go @@ -86,6 +86,10 @@ func (data DeviceAdminAuthorizationRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminAuthorizationRule) toBody(ctx context.Context, state DeviceAdminAuthorizationRule) string { body := "" diff --git a/internal/provider/model_ise_device_admin_condition.go b/internal/provider/model_ise_device_admin_condition.go index 9cb11c1..5dd2180 100644 --- a/internal/provider/model_ise_device_admin_condition.go +++ b/internal/provider/model_ise_device_admin_condition.go @@ -81,6 +81,10 @@ func (data DeviceAdminCondition) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminCondition) toBody(ctx context.Context, state DeviceAdminCondition) string { body := "" diff --git a/internal/provider/model_ise_device_admin_policy_set.go b/internal/provider/model_ise_device_admin_policy_set.go index 153438c..88447e8 100644 --- a/internal/provider/model_ise_device_admin_policy_set.go +++ b/internal/provider/model_ise_device_admin_policy_set.go @@ -83,6 +83,10 @@ func (data DeviceAdminPolicySet) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminPolicySet) toBody(ctx context.Context, state DeviceAdminPolicySet) string { body := "" diff --git a/internal/provider/model_ise_device_admin_time_and_date_condition.go b/internal/provider/model_ise_device_admin_time_and_date_condition.go index 1a22329..a05fe90 100644 --- a/internal/provider/model_ise_device_admin_time_and_date_condition.go +++ b/internal/provider/model_ise_device_admin_time_and_date_condition.go @@ -58,6 +58,10 @@ func (data DeviceAdminTimeAndDateCondition) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DeviceAdminTimeAndDateCondition) toBody(ctx context.Context, state DeviceAdminTimeAndDateCondition) string { body := "" diff --git a/internal/provider/model_ise_downloadable_acl.go b/internal/provider/model_ise_downloadable_acl.go index a80428f..3a7ebcc 100644 --- a/internal/provider/model_ise_downloadable_acl.go +++ b/internal/provider/model_ise_downloadable_acl.go @@ -48,6 +48,10 @@ func (data DownloadableACL) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data DownloadableACL) toBody(ctx context.Context, state DownloadableACL) string { body := "" diff --git a/internal/provider/model_ise_endpoint_identity_group.go b/internal/provider/model_ise_endpoint_identity_group.go index fcfd9c5..0087e63 100644 --- a/internal/provider/model_ise_endpoint_identity_group.go +++ b/internal/provider/model_ise_endpoint_identity_group.go @@ -48,6 +48,10 @@ func (data EndpointIdentityGroup) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data EndpointIdentityGroup) toBody(ctx context.Context, state EndpointIdentityGroup) string { body := "" diff --git a/internal/provider/model_ise_identity_source_sequence.go b/internal/provider/model_ise_identity_source_sequence.go index 848f2dc..d569357 100644 --- a/internal/provider/model_ise_identity_source_sequence.go +++ b/internal/provider/model_ise_identity_source_sequence.go @@ -55,6 +55,10 @@ func (data IdentitySourceSequence) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data IdentitySourceSequence) toBody(ctx context.Context, state IdentitySourceSequence) string { body := "" diff --git a/internal/provider/model_ise_internal_user.go b/internal/provider/model_ise_internal_user.go index def096c..2a0f087 100644 --- a/internal/provider/model_ise_internal_user.go +++ b/internal/provider/model_ise_internal_user.go @@ -58,6 +58,10 @@ func (data InternalUser) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data InternalUser) toBody(ctx context.Context, state InternalUser) string { body := "" diff --git a/internal/provider/model_ise_license_tier_state.go b/internal/provider/model_ise_license_tier_state.go index aae20cb..47d0033 100644 --- a/internal/provider/model_ise_license_tier_state.go +++ b/internal/provider/model_ise_license_tier_state.go @@ -50,6 +50,10 @@ func (data LicenseTierState) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data LicenseTierState) toBody(ctx context.Context, state LicenseTierState) string { body := "[]" diff --git a/internal/provider/model_ise_network_access_authentication_rule.go b/internal/provider/model_ise_network_access_authentication_rule.go index 039436f..917f985 100644 --- a/internal/provider/model_ise_network_access_authentication_rule.go +++ b/internal/provider/model_ise_network_access_authentication_rule.go @@ -87,6 +87,10 @@ func (data NetworkAccessAuthenticationRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessAuthenticationRule) toBody(ctx context.Context, state NetworkAccessAuthenticationRule) string { body := "" diff --git a/internal/provider/model_ise_network_access_authorization_exception_rule.go b/internal/provider/model_ise_network_access_authorization_exception_rule.go index 1e4a244..fd599ea 100644 --- a/internal/provider/model_ise_network_access_authorization_exception_rule.go +++ b/internal/provider/model_ise_network_access_authorization_exception_rule.go @@ -86,6 +86,10 @@ func (data NetworkAccessAuthorizationExceptionRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessAuthorizationExceptionRule) toBody(ctx context.Context, state NetworkAccessAuthorizationExceptionRule) string { body := "" diff --git a/internal/provider/model_ise_network_access_authorization_global_exception_rule.go b/internal/provider/model_ise_network_access_authorization_global_exception_rule.go index df7ef81..96311d0 100644 --- a/internal/provider/model_ise_network_access_authorization_global_exception_rule.go +++ b/internal/provider/model_ise_network_access_authorization_global_exception_rule.go @@ -84,6 +84,10 @@ func (data NetworkAccessAuthorizationGlobalExceptionRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessAuthorizationGlobalExceptionRule) toBody(ctx context.Context, state NetworkAccessAuthorizationGlobalExceptionRule) string { body := "" diff --git a/internal/provider/model_ise_network_access_authorization_rule.go b/internal/provider/model_ise_network_access_authorization_rule.go index ede4c09..2d73f74 100644 --- a/internal/provider/model_ise_network_access_authorization_rule.go +++ b/internal/provider/model_ise_network_access_authorization_rule.go @@ -86,6 +86,10 @@ func (data NetworkAccessAuthorizationRule) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessAuthorizationRule) toBody(ctx context.Context, state NetworkAccessAuthorizationRule) string { body := "" diff --git a/internal/provider/model_ise_network_access_condition.go b/internal/provider/model_ise_network_access_condition.go index a3c53ce..c1729f6 100644 --- a/internal/provider/model_ise_network_access_condition.go +++ b/internal/provider/model_ise_network_access_condition.go @@ -81,6 +81,10 @@ func (data NetworkAccessCondition) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessCondition) toBody(ctx context.Context, state NetworkAccessCondition) string { body := "" diff --git a/internal/provider/model_ise_network_access_dictionary.go b/internal/provider/model_ise_network_access_dictionary.go index fb2a336..48f3bf1 100644 --- a/internal/provider/model_ise_network_access_dictionary.go +++ b/internal/provider/model_ise_network_access_dictionary.go @@ -48,6 +48,10 @@ func (data NetworkAccessDictionary) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessDictionary) toBody(ctx context.Context, state NetworkAccessDictionary) string { body := "" diff --git a/internal/provider/model_ise_network_access_policy_set.go b/internal/provider/model_ise_network_access_policy_set.go index dd20487..3679a1a 100644 --- a/internal/provider/model_ise_network_access_policy_set.go +++ b/internal/provider/model_ise_network_access_policy_set.go @@ -83,6 +83,10 @@ func (data NetworkAccessPolicySet) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessPolicySet) toBody(ctx context.Context, state NetworkAccessPolicySet) string { body := "" diff --git a/internal/provider/model_ise_network_access_time_and_date_condition.go b/internal/provider/model_ise_network_access_time_and_date_condition.go index 8fdc961..85c528b 100644 --- a/internal/provider/model_ise_network_access_time_and_date_condition.go +++ b/internal/provider/model_ise_network_access_time_and_date_condition.go @@ -58,6 +58,10 @@ func (data NetworkAccessTimeAndDateCondition) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkAccessTimeAndDateCondition) toBody(ctx context.Context, state NetworkAccessTimeAndDateCondition) string { body := "" diff --git a/internal/provider/model_ise_network_device.go b/internal/provider/model_ise_network_device.go index 1d8397f..a83c1cd 100644 --- a/internal/provider/model_ise_network_device.go +++ b/internal/provider/model_ise_network_device.go @@ -93,6 +93,10 @@ func (data NetworkDevice) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkDevice) toBody(ctx context.Context, state NetworkDevice) string { body := "" diff --git a/internal/provider/model_ise_network_device_group.go b/internal/provider/model_ise_network_device_group.go index 23256ef..54ff97a 100644 --- a/internal/provider/model_ise_network_device_group.go +++ b/internal/provider/model_ise_network_device_group.go @@ -47,6 +47,10 @@ func (data NetworkDeviceGroup) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data NetworkDeviceGroup) toBody(ctx context.Context, state NetworkDeviceGroup) string { body := "" diff --git a/internal/provider/model_ise_repository.go b/internal/provider/model_ise_repository.go index 23a63f0..eb89130 100644 --- a/internal/provider/model_ise_repository.go +++ b/internal/provider/model_ise_repository.go @@ -51,6 +51,10 @@ func (data Repository) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data Repository) toBody(ctx context.Context, state Repository) string { body := "" diff --git a/internal/provider/model_ise_tacacs_command_set.go b/internal/provider/model_ise_tacacs_command_set.go index 6a622e4..0d7d552 100644 --- a/internal/provider/model_ise_tacacs_command_set.go +++ b/internal/provider/model_ise_tacacs_command_set.go @@ -54,6 +54,10 @@ func (data TACACSCommandSet) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TACACSCommandSet) toBody(ctx context.Context, state TACACSCommandSet) string { body := "" diff --git a/internal/provider/model_ise_tacacs_profile.go b/internal/provider/model_ise_tacacs_profile.go index 44238e7..679fb4d 100644 --- a/internal/provider/model_ise_tacacs_profile.go +++ b/internal/provider/model_ise_tacacs_profile.go @@ -53,6 +53,10 @@ func (data TACACSProfile) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TACACSProfile) toBody(ctx context.Context, state TACACSProfile) string { body := "" diff --git a/internal/provider/model_ise_trustsec_egress_matrix_cell.go b/internal/provider/model_ise_trustsec_egress_matrix_cell.go index e205e33..007f28f 100644 --- a/internal/provider/model_ise_trustsec_egress_matrix_cell.go +++ b/internal/provider/model_ise_trustsec_egress_matrix_cell.go @@ -51,6 +51,10 @@ func (data TrustSecEgressMatrixCell) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TrustSecEgressMatrixCell) toBody(ctx context.Context, state TrustSecEgressMatrixCell) string { body := "" diff --git a/internal/provider/model_ise_trustsec_ip_to_sgt_mapping.go b/internal/provider/model_ise_trustsec_ip_to_sgt_mapping.go index 73f43f8..176a268 100644 --- a/internal/provider/model_ise_trustsec_ip_to_sgt_mapping.go +++ b/internal/provider/model_ise_trustsec_ip_to_sgt_mapping.go @@ -52,6 +52,10 @@ func (data TrustSecIPToSGTMapping) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TrustSecIPToSGTMapping) toBody(ctx context.Context, state TrustSecIPToSGTMapping) string { body := "" diff --git a/internal/provider/model_ise_trustsec_ip_to_sgt_mapping_group.go b/internal/provider/model_ise_trustsec_ip_to_sgt_mapping_group.go index 9ce1292..954dc67 100644 --- a/internal/provider/model_ise_trustsec_ip_to_sgt_mapping_group.go +++ b/internal/provider/model_ise_trustsec_ip_to_sgt_mapping_group.go @@ -49,6 +49,10 @@ func (data TrustSecIPToSGTMappingGroup) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TrustSecIPToSGTMappingGroup) toBody(ctx context.Context, state TrustSecIPToSGTMappingGroup) string { body := "" diff --git a/internal/provider/model_ise_trustsec_security_group.go b/internal/provider/model_ise_trustsec_security_group.go index 8021260..7b79ed8 100644 --- a/internal/provider/model_ise_trustsec_security_group.go +++ b/internal/provider/model_ise_trustsec_security_group.go @@ -49,6 +49,10 @@ func (data TrustSecSecurityGroup) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TrustSecSecurityGroup) toBody(ctx context.Context, state TrustSecSecurityGroup) string { body := "" diff --git a/internal/provider/model_ise_trustsec_security_group_acl.go b/internal/provider/model_ise_trustsec_security_group_acl.go index 3457ed6..a59de86 100644 --- a/internal/provider/model_ise_trustsec_security_group_acl.go +++ b/internal/provider/model_ise_trustsec_security_group_acl.go @@ -49,6 +49,10 @@ func (data TrustSecSecurityGroupACL) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data TrustSecSecurityGroupACL) toBody(ctx context.Context, state TrustSecSecurityGroupACL) string { body := "" diff --git a/internal/provider/model_ise_user_identity_group.go b/internal/provider/model_ise_user_identity_group.go index 96e1b70..aab38e7 100644 --- a/internal/provider/model_ise_user_identity_group.go +++ b/internal/provider/model_ise_user_identity_group.go @@ -47,6 +47,10 @@ func (data UserIdentityGroup) getPath() string { //template:end getPath +//template:begin getPathDelete + +//template:end getPathDelete + //template:begin toBody func (data UserIdentityGroup) toBody(ctx context.Context, state UserIdentityGroup) string { body := "" diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go new file mode 100644 index 0000000..938117a --- /dev/null +++ b/internal/provider/provider_test.go @@ -0,0 +1,49 @@ +// 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_join_domain_with_all_nodes.go b/internal/provider/resource_ise_active_directory_join_domain_with_all_nodes.go index 824abf5..8901c5c 100644 --- 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 @@ -201,7 +201,7 @@ func (r *ActiveDirectoryJoinDomainWithAllNodesResource) Delete(ctx context.Conte tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Delete", state.Id.ValueString())) body := state.toBody(ctx, state) - res, err := r.client.Put(state.getPathPut(), body) + res, err := r.client.Put(state.getPathDelete(), body) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete object (DELETE), got error: %s, %s", err, res.String())) return diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 5859add..213d0dc 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -10,6 +10,8 @@ description: |- ## 0.1.12 (unreleased) - Ignore error messages when attempting to delete default policy sets or rules +- Add `ise_active_directory_add_groups` resource +- Add `ise_active_directory_join_domain_with_all_nodes` resource ## 0.1.11