From 188780c44e7c6b46d7bf3c8f236267cd3e40e628 Mon Sep 17 00:00:00 2001 From: danischm Date: Fri, 1 Dec 2023 10:28:31 +0100 Subject: [PATCH] Add device admin condition resource --- CHANGELOG.md | 1 + docs/data-sources/device_admin_condition.md | 72 +++ docs/guides/changelog.md | 1 + docs/resources/device_admin_condition.md | 102 ++++ .../ise_device_admin_condition/data-source.tf | 3 + .../ise_device_admin_condition/import.sh | 1 + .../ise_device_admin_condition/resource.tf | 10 + gen/definitions/device_admin_condition.yaml | 232 ++++++++ .../data_source_ise_device_admin_condition.go | 279 +++++++++ ..._source_ise_device_admin_condition_test.go | 80 +++ .../model_ise_device_admin_condition.go | 558 ++++++++++++++++++ internal/provider/provider.go | 2 + .../resource_ise_device_admin_condition.go | 365 ++++++++++++ ...esource_ise_device_admin_condition_test.go | 101 ++++ templates/guides/changelog.md.tmpl | 1 + 15 files changed, 1808 insertions(+) create mode 100644 docs/data-sources/device_admin_condition.md create mode 100644 docs/resources/device_admin_condition.md create mode 100644 examples/data-sources/ise_device_admin_condition/data-source.tf create mode 100644 examples/resources/ise_device_admin_condition/import.sh create mode 100644 examples/resources/ise_device_admin_condition/resource.tf create mode 100644 gen/definitions/device_admin_condition.yaml create mode 100644 internal/provider/data_source_ise_device_admin_condition.go create mode 100644 internal/provider/data_source_ise_device_admin_condition_test.go create mode 100644 internal/provider/model_ise_device_admin_condition.go create mode 100644 internal/provider/resource_ise_device_admin_condition.go create mode 100644 internal/provider/resource_ise_device_admin_condition_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 6883059..e50f656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Add `ise_downloadable_acl` resource and data source - Add `ise_tacacs_command_set` resource and data source - Add `ise_tacacs_profile` resource and data source +- Add `ise_device_admin_condition` resource and data source ## 0.1.5 diff --git a/docs/data-sources/device_admin_condition.md b/docs/data-sources/device_admin_condition.md new file mode 100644 index 0000000..aca934d --- /dev/null +++ b/docs/data-sources/device_admin_condition.md @@ -0,0 +1,72 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "ise_device_admin_condition Data Source - terraform-provider-ise" +subcategory: "Policy" +description: |- + This data source can read the Device Admin Condition. +--- + +# ise_device_admin_condition (Data Source) + +This data source can read the Device Admin Condition. + +## Example Usage + +```terraform +data "ise_device_admin_condition" "example" { + id = "76d24097-41c4-4558-a4d0-a8c07ac08470" +} +``` + + +## Schema + +### Optional + +- `id` (String) The id of the object +- `name` (String) Condition name + +### Read-Only + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `children` (Attributes List) List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. (see [below for nested schema](#nestedatt--children)) +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `operator` (String) Equality operator + + +### Nested Schema for `children` + +Read-Only: + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `children` (Attributes List) List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. (see [below for nested schema](#nestedatt--children--children)) +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `id` (String) UUID for condition +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `name` (String) Condition name +- `operator` (String) Equality operator + + +### Nested Schema for `children.children` + +Read-Only: + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `id` (String) UUID for condition +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `name` (String) Condition name +- `operator` (String) Equality operator diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 5d7562e..096863e 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -12,6 +12,7 @@ description: |- - Add `ise_downloadable_acl` resource and data source - Add `ise_tacacs_command_set` resource and data source - Add `ise_tacacs_profile` resource and data source +- Add `ise_device_admin_condition` resource and data source ## 0.1.5 diff --git a/docs/resources/device_admin_condition.md b/docs/resources/device_admin_condition.md new file mode 100644 index 0000000..f307090 --- /dev/null +++ b/docs/resources/device_admin_condition.md @@ -0,0 +1,102 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "ise_device_admin_condition Resource - terraform-provider-ise" +subcategory: "Policy" +description: |- + This resource can manage a Device Admin Condition. +--- + +# ise_device_admin_condition (Resource) + +This resource can manage a Device Admin Condition. + +## Example Usage + +```terraform +resource "ise_device_admin_condition" "example" { + name = "Cond1" + description = "My description" + condition_type = "LibraryConditionAttributes" + is_negate = false + attribute_name = "EapAuthentication" + attribute_value = "EAP-TLS" + dictionary_name = "Network Access" + operator = "equals" +} +``` + + +## Schema + +### Required + +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + - Choices: `LibraryConditionAndBlock`, `LibraryConditionAttributes`, `LibraryConditionOrBlock` +- `name` (String) Condition name + +### Optional + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `children` (Attributes List) List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. (see [below for nested schema](#nestedatt--children)) +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `operator` (String) Equality operator + - Choices: `contains`, `endsWith`, `equals`, `greaterOrEquals`, `greaterThan`, `in`, `ipEquals`, `ipGreaterThan`, `ipLessThan`, `ipNotEquals`, `lessOrEquals`, `lessThan`, `matches`, `notContains`, `notEndsWith`, `notEquals`, `notIn`, `notStartsWith`, `startsWith` + +### Read-Only + +- `id` (String) The id of the object + + +### Nested Schema for `children` + +Required: + +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + - Choices: `ConditionAndBlock`, `ConditionAttributes`, `ConditionOrBlock`, `ConditionReference` + +Optional: + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `children` (Attributes List) List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. (see [below for nested schema](#nestedatt--children--children)) +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `id` (String) UUID for condition +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `name` (String) Condition name +- `operator` (String) Equality operator + - Choices: `contains`, `endsWith`, `equals`, `greaterOrEquals`, `greaterThan`, `in`, `ipEquals`, `ipGreaterThan`, `ipLessThan`, `ipNotEquals`, `lessOrEquals`, `lessThan`, `matches`, `notContains`, `notEndsWith`, `notEquals`, `notIn`, `notStartsWith`, `startsWith` + + +### Nested Schema for `children.children` + +Required: + +- `condition_type` (String) Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + - Choices: `ConditionAndBlock`, `ConditionAttributes`, `ConditionOrBlock`, `ConditionReference` + +Optional: + +- `attribute_name` (String) Dictionary attribute name +- `attribute_value` (String) Attribute value for condition. Value type is specified in dictionary object. +- `description` (String) Condition description +- `dictionary_name` (String) Dictionary name +- `dictionary_value` (String) Dictionary value +- `id` (String) UUID for condition +- `is_negate` (Boolean) Indicates whereas this condition is in negate mode +- `name` (String) Condition name +- `operator` (String) Equality operator + - Choices: `contains`, `endsWith`, `equals`, `greaterOrEquals`, `greaterThan`, `in`, `ipEquals`, `ipGreaterThan`, `ipLessThan`, `ipNotEquals`, `lessOrEquals`, `lessThan`, `matches`, `notContains`, `notEndsWith`, `notEquals`, `notIn`, `notStartsWith`, `startsWith` + +## Import + +Import is supported using the following syntax: + +```shell +terraform import ise_device_admin_condition.example "76d24097-41c4-4558-a4d0-a8c07ac08470" +``` diff --git a/examples/data-sources/ise_device_admin_condition/data-source.tf b/examples/data-sources/ise_device_admin_condition/data-source.tf new file mode 100644 index 0000000..6ffca1f --- /dev/null +++ b/examples/data-sources/ise_device_admin_condition/data-source.tf @@ -0,0 +1,3 @@ +data "ise_device_admin_condition" "example" { + id = "76d24097-41c4-4558-a4d0-a8c07ac08470" +} diff --git a/examples/resources/ise_device_admin_condition/import.sh b/examples/resources/ise_device_admin_condition/import.sh new file mode 100644 index 0000000..412b3e8 --- /dev/null +++ b/examples/resources/ise_device_admin_condition/import.sh @@ -0,0 +1 @@ +terraform import ise_device_admin_condition.example "76d24097-41c4-4558-a4d0-a8c07ac08470" diff --git a/examples/resources/ise_device_admin_condition/resource.tf b/examples/resources/ise_device_admin_condition/resource.tf new file mode 100644 index 0000000..2fbd702 --- /dev/null +++ b/examples/resources/ise_device_admin_condition/resource.tf @@ -0,0 +1,10 @@ +resource "ise_device_admin_condition" "example" { + name = "Cond1" + description = "My description" + condition_type = "LibraryConditionAttributes" + is_negate = false + attribute_name = "EapAuthentication" + attribute_value = "EAP-TLS" + dictionary_name = "Network Access" + operator = "equals" +} diff --git a/gen/definitions/device_admin_condition.yaml b/gen/definitions/device_admin_condition.yaml new file mode 100644 index 0000000..2e7dd7d --- /dev/null +++ b/gen/definitions/device_admin_condition.yaml @@ -0,0 +1,232 @@ +--- +name: Device Admin Condition +rest_endpoint: /api/v1/policy/device-admin/condition +data_source_name_query: true +id_path: response.id +doc_category: Policy +attributes: + - model_name: name + type: String + mandatory: true + description: Condition name + example: Cond1 + - model_name: description + type: String + description: Condition description + example: My description + - model_name: conditionType + type: String + mandatory: true + enum_values: + [ + LibraryConditionAndBlock, + LibraryConditionAttributes, + LibraryConditionOrBlock, + ] + description: Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + example: LibraryConditionAttributes + - model_name: isNegate + type: Bool + description: Indicates whereas this condition is in negate mode + example: false + - model_name: attributeName + type: String + description: Dictionary attribute name + example: EapAuthentication + minimum_test_value: '"EapAuthentication"' + - model_name: attributeValue + type: String + description: Attribute value for condition. Value type is specified in dictionary object. + example: EAP-TLS + minimum_test_value: '"EAP-TLS"' + - model_name: dictionaryName + type: String + description: Dictionary name + example: Network Access + minimum_test_value: '"Network Access"' + - model_name: dictionaryValue + type: String + description: Dictionary value + example: abc + exclude_test: true + - model_name: operator + type: String + enum_values: + [ + contains, + endsWith, + equals, + greaterOrEquals, + greaterThan, + in, + ipEquals, + ipGreaterThan, + ipLessThan, + ipNotEquals, + lessOrEquals, + lessThan, + matches, + notContains, + notEndsWith, + notEquals, + notIn, + notStartsWith, + startsWith, + ] + description: Equality operator + example: equals + minimum_test_value: '"equals"' + - model_name: children + type: List + description: List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. + exclude_test: true + attributes: + - model_name: name + type: String + description: Condition name + example: Cond1 + - model_name: description + type: String + description: Condition description + example: My description + - model_name: conditionType + type: String + mandatory: true + enum_values: + [ + ConditionAndBlock, + ConditionAttributes, + ConditionOrBlock, + ConditionReference, + ] + description: Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + example: ConditionAttributes + - model_name: id + tf_name: id + type: String + description: UUID for condition + example: 12345678-f0e7-456b-a2d1-876543320123 + - model_name: isNegate + type: Bool + description: Indicates whereas this condition is in negate mode + example: false + - model_name: attributeName + type: String + description: Dictionary attribute name + example: EapAuthentication + - model_name: attributeValue + type: String + description: Attribute value for condition. Value type is specified in dictionary object. + example: EAP-TLS + - model_name: dictionaryName + type: String + description: Dictionary name + example: Network Access + - model_name: dictionaryValue + type: String + description: Dictionary value + example: abc + exclude_test: true + - model_name: operator + type: String + enum_values: + [ + contains, + endsWith, + equals, + greaterOrEquals, + greaterThan, + in, + ipEquals, + ipGreaterThan, + ipLessThan, + ipNotEquals, + lessOrEquals, + lessThan, + matches, + notContains, + notEndsWith, + notEquals, + notIn, + notStartsWith, + startsWith, + ] + description: Equality operator + example: equals + - model_name: children + type: List + description: List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`. + exclude_test: true + attributes: + - model_name: name + type: String + description: Condition name + example: Cond1 + - model_name: description + type: String + description: Condition description + example: My description + - model_name: conditionType + type: String + mandatory: true + enum_values: + [ + ConditionAndBlock, + ConditionAttributes, + ConditionOrBlock, + ConditionReference, + ] + description: Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute. + example: ConditionAttributes + - model_name: id + tf_name: id + type: String + description: UUID for condition + example: 12345678-f0e7-456b-a2d1-876543320123 + - model_name: isNegate + type: Bool + description: Indicates whereas this condition is in negate mode + example: false + - model_name: attributeName + type: String + description: Dictionary attribute name + example: EapAuthentication + - model_name: attributeValue + type: String + description: Attribute value for condition. Value type is specified in dictionary object. + example: EAP-TLS + - model_name: dictionaryName + type: String + description: Dictionary name + example: Network Access + - model_name: dictionaryValue + type: String + description: Dictionary value + example: abc + exclude_test: true + - model_name: operator + type: String + enum_values: + [ + contains, + endsWith, + equals, + greaterOrEquals, + greaterThan, + in, + ipEquals, + ipGreaterThan, + ipLessThan, + ipNotEquals, + lessOrEquals, + lessThan, + matches, + notContains, + notEndsWith, + notEquals, + notIn, + notStartsWith, + startsWith, + ] + description: Equality operator + example: equals diff --git a/internal/provider/data_source_ise_device_admin_condition.go b/internal/provider/data_source_ise_device_admin_condition.go new file mode 100644 index 0000000..bb28268 --- /dev/null +++ b/internal/provider/data_source_ise_device_admin_condition.go @@ -0,0 +1,279 @@ +// 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-validators/datasourcevalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/netascode/go-ise" + "github.com/tidwall/gjson" +) + +//template:end imports + +//template:begin model + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &DeviceAdminConditionDataSource{} + _ datasource.DataSourceWithConfigure = &DeviceAdminConditionDataSource{} +) + +func NewDeviceAdminConditionDataSource() datasource.DataSource { + return &DeviceAdminConditionDataSource{} +} + +type DeviceAdminConditionDataSource struct { + client *ise.Client +} + +func (d *DeviceAdminConditionDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_device_admin_condition" +} + +func (d *DeviceAdminConditionDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "This data source can read the Device Admin Condition.", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the object", + Optional: true, + Computed: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "Condition name", + Optional: true, + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "Condition description", + Computed: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: "Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.", + Computed: true, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: "Indicates whereas this condition is in negate mode", + Computed: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary attribute name", + Computed: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: "Attribute value for condition. Value type is specified in dictionary object.", + Computed: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary name", + Computed: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: "Dictionary value", + Computed: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: "Equality operator", + Computed: true, + }, + "children": schema.ListNestedAttribute{ + MarkdownDescription: "List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: "Condition name", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "Condition description", + Computed: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: "Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.", + Computed: true, + }, + "id": schema.StringAttribute{ + MarkdownDescription: "UUID for condition", + Computed: true, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: "Indicates whereas this condition is in negate mode", + Computed: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary attribute name", + Computed: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: "Attribute value for condition. Value type is specified in dictionary object.", + Computed: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary name", + Computed: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: "Dictionary value", + Computed: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: "Equality operator", + Computed: true, + }, + "children": schema.ListNestedAttribute{ + MarkdownDescription: "List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: "Condition name", + Computed: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: "Condition description", + Computed: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: "Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.", + Computed: true, + }, + "id": schema.StringAttribute{ + MarkdownDescription: "UUID for condition", + Computed: true, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: "Indicates whereas this condition is in negate mode", + Computed: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary attribute name", + Computed: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: "Attribute value for condition. Value type is specified in dictionary object.", + Computed: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: "Dictionary name", + Computed: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: "Dictionary value", + Computed: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: "Equality operator", + Computed: true, + }, + }, + }, + }, + }, + }, + }, + }, + } +} +func (d *DeviceAdminConditionDataSource) ConfigValidators(ctx context.Context) []datasource.ConfigValidator { + return []datasource.ConfigValidator{ + datasourcevalidator.ExactlyOneOf( + path.MatchRoot("id"), + path.MatchRoot("name"), + ), + } +} + +func (d *DeviceAdminConditionDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + d.client = req.ProviderData.(*IseProviderData).Client +} + +//template:end model + +//template:begin read +func (d *DeviceAdminConditionDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var config DeviceAdminCondition + + // Read config + diags := req.Config.Get(ctx, &config) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String())) + if config.Id.IsNull() && !config.Name.IsNull() { + for page := 1; ; page++ { + res, err := d.client.Get(config.getPath()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve objects, got error: %s", err)) + return + } + if value := res.Get("response"); len(value.Array()) > 0 { + value.ForEach(func(k, v gjson.Result) bool { + if config.Name.ValueString() == v.Get("name").String() { + config.Id = types.StringValue(v.Get("id").String()) + tflog.Debug(ctx, fmt.Sprintf("%s: Found object with name '%v', id: %v", config.Id.String(), config.Name.ValueString(), config.Id.String())) + return false + } + return true + }) + } + if !config.Id.IsNull() || !res.Get("SearchResult.nextPage").Exists() { + break + } + } + + if config.Id.IsNull() { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to find object with name: %s", config.Name.ValueString())) + return + } + } + + res, err := d.client.Get(config.getPath() + "/" + config.Id.ValueString()) + if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err)) + return + } + + config.fromBody(ctx, res) + + tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString())) + + diags = resp.State.Set(ctx, &config) + resp.Diagnostics.Append(diags...) +} + +//template:end read diff --git a/internal/provider/data_source_ise_device_admin_condition_test.go b/internal/provider/data_source_ise_device_admin_condition_test.go new file mode 100644 index 0000000..df3dff4 --- /dev/null +++ b/internal/provider/data_source_ise_device_admin_condition_test.go @@ -0,0 +1,80 @@ +// 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 ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +//template:end imports + +//template:begin testAccDataSource +func TestAccDataSourceIseDeviceAdminCondition(t *testing.T) { + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "name", "Cond1")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "description", "My description")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "condition_type", "LibraryConditionAttributes")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "is_negate", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "attribute_name", "EapAuthentication")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "attribute_value", "EAP-TLS")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "dictionary_name", "Network Access")) + checks = append(checks, resource.TestCheckResourceAttr("data.ise_device_admin_condition.test", "operator", "equals")) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceIseDeviceAdminConditionConfig(), + Check: resource.ComposeTestCheckFunc(checks...), + }, + }, + }) +} + +//template:end testAccDataSource + +//template:begin testPrerequisites +//template:end testPrerequisites + +//template:begin testAccDataSourceConfig +func testAccDataSourceIseDeviceAdminConditionConfig() string { + config := `resource "ise_device_admin_condition" "test" {` + "\n" + config += ` name = "Cond1"` + "\n" + config += ` description = "My description"` + "\n" + config += ` condition_type = "LibraryConditionAttributes"` + "\n" + config += ` is_negate = false` + "\n" + config += ` attribute_name = "EapAuthentication"` + "\n" + config += ` attribute_value = "EAP-TLS"` + "\n" + config += ` dictionary_name = "Network Access"` + "\n" + config += ` operator = "equals"` + "\n" + config += `}` + "\n" + + config += ` + data "ise_device_admin_condition" "test" { + id = ise_device_admin_condition.test.id + } + ` + return config +} + +//template:end testAccDataSourceConfig diff --git a/internal/provider/model_ise_device_admin_condition.go b/internal/provider/model_ise_device_admin_condition.go new file mode 100644 index 0000000..060d57c --- /dev/null +++ b/internal/provider/model_ise_device_admin_condition.go @@ -0,0 +1,558 @@ +// 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" + "strconv" + + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" +) + +//template:end imports + +//template:begin types +type DeviceAdminCondition struct { + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + ConditionType types.String `tfsdk:"condition_type"` + IsNegate types.Bool `tfsdk:"is_negate"` + AttributeName types.String `tfsdk:"attribute_name"` + AttributeValue types.String `tfsdk:"attribute_value"` + DictionaryName types.String `tfsdk:"dictionary_name"` + DictionaryValue types.String `tfsdk:"dictionary_value"` + Operator types.String `tfsdk:"operator"` + Children []DeviceAdminConditionChildren `tfsdk:"children"` +} + +type DeviceAdminConditionChildren struct { + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + ConditionType types.String `tfsdk:"condition_type"` + Id types.String `tfsdk:"id"` + IsNegate types.Bool `tfsdk:"is_negate"` + AttributeName types.String `tfsdk:"attribute_name"` + AttributeValue types.String `tfsdk:"attribute_value"` + DictionaryName types.String `tfsdk:"dictionary_name"` + DictionaryValue types.String `tfsdk:"dictionary_value"` + Operator types.String `tfsdk:"operator"` + Children []DeviceAdminConditionChildrenChildren `tfsdk:"children"` +} + +type DeviceAdminConditionChildrenChildren struct { + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + ConditionType types.String `tfsdk:"condition_type"` + Id types.String `tfsdk:"id"` + IsNegate types.Bool `tfsdk:"is_negate"` + AttributeName types.String `tfsdk:"attribute_name"` + AttributeValue types.String `tfsdk:"attribute_value"` + DictionaryName types.String `tfsdk:"dictionary_name"` + DictionaryValue types.String `tfsdk:"dictionary_value"` + Operator types.String `tfsdk:"operator"` +} + +//template:end types + +//template:begin getPath +func (data DeviceAdminCondition) getPath() string { + return "/api/v1/policy/device-admin/condition" +} + +//template:end getPath + +//template:begin toBody +func (data DeviceAdminCondition) toBody(ctx context.Context, state DeviceAdminCondition) string { + body := "" + if !data.Name.IsNull() { + body, _ = sjson.Set(body, "name", data.Name.ValueString()) + } + if !data.Description.IsNull() { + body, _ = sjson.Set(body, "description", data.Description.ValueString()) + } + if !data.ConditionType.IsNull() { + body, _ = sjson.Set(body, "conditionType", data.ConditionType.ValueString()) + } + if !data.IsNegate.IsNull() { + body, _ = sjson.Set(body, "isNegate", data.IsNegate.ValueBool()) + } + if !data.AttributeName.IsNull() { + body, _ = sjson.Set(body, "attributeName", data.AttributeName.ValueString()) + } + if !data.AttributeValue.IsNull() { + body, _ = sjson.Set(body, "attributeValue", data.AttributeValue.ValueString()) + } + if !data.DictionaryName.IsNull() { + body, _ = sjson.Set(body, "dictionaryName", data.DictionaryName.ValueString()) + } + if !data.DictionaryValue.IsNull() { + body, _ = sjson.Set(body, "dictionaryValue", data.DictionaryValue.ValueString()) + } + if !data.Operator.IsNull() { + body, _ = sjson.Set(body, "operator", data.Operator.ValueString()) + } + if len(data.Children) > 0 { + body, _ = sjson.Set(body, "children", []interface{}{}) + for _, item := range data.Children { + itemBody := "" + if !item.Name.IsNull() { + itemBody, _ = sjson.Set(itemBody, "name", item.Name.ValueString()) + } + if !item.Description.IsNull() { + itemBody, _ = sjson.Set(itemBody, "description", item.Description.ValueString()) + } + if !item.ConditionType.IsNull() { + itemBody, _ = sjson.Set(itemBody, "conditionType", item.ConditionType.ValueString()) + } + if !item.Id.IsNull() { + itemBody, _ = sjson.Set(itemBody, "id", item.Id.ValueString()) + } + if !item.IsNegate.IsNull() { + itemBody, _ = sjson.Set(itemBody, "isNegate", item.IsNegate.ValueBool()) + } + if !item.AttributeName.IsNull() { + itemBody, _ = sjson.Set(itemBody, "attributeName", item.AttributeName.ValueString()) + } + if !item.AttributeValue.IsNull() { + itemBody, _ = sjson.Set(itemBody, "attributeValue", item.AttributeValue.ValueString()) + } + if !item.DictionaryName.IsNull() { + itemBody, _ = sjson.Set(itemBody, "dictionaryName", item.DictionaryName.ValueString()) + } + if !item.DictionaryValue.IsNull() { + itemBody, _ = sjson.Set(itemBody, "dictionaryValue", item.DictionaryValue.ValueString()) + } + if !item.Operator.IsNull() { + itemBody, _ = sjson.Set(itemBody, "operator", item.Operator.ValueString()) + } + if len(item.Children) > 0 { + itemBody, _ = sjson.Set(itemBody, "children", []interface{}{}) + for _, childItem := range item.Children { + itemChildBody := "" + if !childItem.Name.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "name", childItem.Name.ValueString()) + } + if !childItem.Description.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "description", childItem.Description.ValueString()) + } + if !childItem.ConditionType.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "conditionType", childItem.ConditionType.ValueString()) + } + if !childItem.Id.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "id", childItem.Id.ValueString()) + } + if !childItem.IsNegate.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "isNegate", childItem.IsNegate.ValueBool()) + } + if !childItem.AttributeName.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "attributeName", childItem.AttributeName.ValueString()) + } + if !childItem.AttributeValue.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "attributeValue", childItem.AttributeValue.ValueString()) + } + if !childItem.DictionaryName.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "dictionaryName", childItem.DictionaryName.ValueString()) + } + if !childItem.DictionaryValue.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "dictionaryValue", childItem.DictionaryValue.ValueString()) + } + if !childItem.Operator.IsNull() { + itemChildBody, _ = sjson.Set(itemChildBody, "operator", childItem.Operator.ValueString()) + } + itemBody, _ = sjson.SetRaw(itemBody, "children.-1", itemChildBody) + } + } + body, _ = sjson.SetRaw(body, "children.-1", itemBody) + } + } + return body +} + +//template:end toBody + +//template:begin fromBody +func (data *DeviceAdminCondition) fromBody(ctx context.Context, res gjson.Result) { + if value := res.Get("response.name"); value.Exists() { + data.Name = types.StringValue(value.String()) + } else { + data.Name = types.StringNull() + } + if value := res.Get("response.description"); value.Exists() { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + if value := res.Get("response.conditionType"); value.Exists() { + data.ConditionType = types.StringValue(value.String()) + } else { + data.ConditionType = types.StringNull() + } + if value := res.Get("response.isNegate"); value.Exists() { + data.IsNegate = types.BoolValue(value.Bool()) + } else { + data.IsNegate = types.BoolNull() + } + if value := res.Get("response.attributeName"); value.Exists() { + data.AttributeName = types.StringValue(value.String()) + } else { + data.AttributeName = types.StringNull() + } + if value := res.Get("response.attributeValue"); value.Exists() { + data.AttributeValue = types.StringValue(value.String()) + } else { + data.AttributeValue = types.StringNull() + } + if value := res.Get("response.dictionaryName"); value.Exists() { + data.DictionaryName = types.StringValue(value.String()) + } else { + data.DictionaryName = types.StringNull() + } + if value := res.Get("response.dictionaryValue"); value.Exists() { + data.DictionaryValue = types.StringValue(value.String()) + } else { + data.DictionaryValue = types.StringNull() + } + if value := res.Get("response.operator"); value.Exists() { + data.Operator = types.StringValue(value.String()) + } else { + data.Operator = types.StringNull() + } + if value := res.Get("response.children"); value.Exists() { + data.Children = make([]DeviceAdminConditionChildren, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := DeviceAdminConditionChildren{} + if cValue := v.Get("name"); cValue.Exists() { + item.Name = types.StringValue(cValue.String()) + } else { + item.Name = types.StringNull() + } + if cValue := v.Get("description"); cValue.Exists() { + item.Description = types.StringValue(cValue.String()) + } else { + item.Description = types.StringNull() + } + if cValue := v.Get("conditionType"); cValue.Exists() { + item.ConditionType = types.StringValue(cValue.String()) + } else { + item.ConditionType = types.StringNull() + } + if cValue := v.Get("id"); cValue.Exists() { + item.Id = types.StringValue(cValue.String()) + } else { + item.Id = types.StringNull() + } + if cValue := v.Get("isNegate"); cValue.Exists() { + item.IsNegate = types.BoolValue(cValue.Bool()) + } else { + item.IsNegate = types.BoolNull() + } + if cValue := v.Get("attributeName"); cValue.Exists() { + item.AttributeName = types.StringValue(cValue.String()) + } else { + item.AttributeName = types.StringNull() + } + if cValue := v.Get("attributeValue"); cValue.Exists() { + item.AttributeValue = types.StringValue(cValue.String()) + } else { + item.AttributeValue = types.StringNull() + } + if cValue := v.Get("dictionaryName"); cValue.Exists() { + item.DictionaryName = types.StringValue(cValue.String()) + } else { + item.DictionaryName = types.StringNull() + } + if cValue := v.Get("dictionaryValue"); cValue.Exists() { + item.DictionaryValue = types.StringValue(cValue.String()) + } else { + item.DictionaryValue = types.StringNull() + } + if cValue := v.Get("operator"); cValue.Exists() { + item.Operator = types.StringValue(cValue.String()) + } else { + item.Operator = types.StringNull() + } + if cValue := v.Get("children"); cValue.Exists() { + item.Children = make([]DeviceAdminConditionChildrenChildren, 0) + cValue.ForEach(func(ck, cv gjson.Result) bool { + cItem := DeviceAdminConditionChildrenChildren{} + if ccValue := cv.Get("name"); ccValue.Exists() { + cItem.Name = types.StringValue(ccValue.String()) + } else { + cItem.Name = types.StringNull() + } + if ccValue := cv.Get("description"); ccValue.Exists() { + cItem.Description = types.StringValue(ccValue.String()) + } else { + cItem.Description = types.StringNull() + } + if ccValue := cv.Get("conditionType"); ccValue.Exists() { + cItem.ConditionType = types.StringValue(ccValue.String()) + } else { + cItem.ConditionType = types.StringNull() + } + if ccValue := cv.Get("id"); ccValue.Exists() { + cItem.Id = types.StringValue(ccValue.String()) + } else { + cItem.Id = types.StringNull() + } + if ccValue := cv.Get("isNegate"); ccValue.Exists() { + cItem.IsNegate = types.BoolValue(ccValue.Bool()) + } else { + cItem.IsNegate = types.BoolNull() + } + if ccValue := cv.Get("attributeName"); ccValue.Exists() { + cItem.AttributeName = types.StringValue(ccValue.String()) + } else { + cItem.AttributeName = types.StringNull() + } + if ccValue := cv.Get("attributeValue"); ccValue.Exists() { + cItem.AttributeValue = types.StringValue(ccValue.String()) + } else { + cItem.AttributeValue = types.StringNull() + } + if ccValue := cv.Get("dictionaryName"); ccValue.Exists() { + cItem.DictionaryName = types.StringValue(ccValue.String()) + } else { + cItem.DictionaryName = types.StringNull() + } + if ccValue := cv.Get("dictionaryValue"); ccValue.Exists() { + cItem.DictionaryValue = types.StringValue(ccValue.String()) + } else { + cItem.DictionaryValue = types.StringNull() + } + if ccValue := cv.Get("operator"); ccValue.Exists() { + cItem.Operator = types.StringValue(ccValue.String()) + } else { + cItem.Operator = types.StringNull() + } + item.Children = append(item.Children, cItem) + return true + }) + } + data.Children = append(data.Children, item) + return true + }) + } +} + +//template:end fromBody + +//template:begin updateFromBody +func (data *DeviceAdminCondition) updateFromBody(ctx context.Context, res gjson.Result) { + if value := res.Get("response.name"); value.Exists() && !data.Name.IsNull() { + data.Name = types.StringValue(value.String()) + } else { + data.Name = types.StringNull() + } + if value := res.Get("response.description"); value.Exists() && !data.Description.IsNull() { + data.Description = types.StringValue(value.String()) + } else { + data.Description = types.StringNull() + } + if value := res.Get("response.conditionType"); value.Exists() && !data.ConditionType.IsNull() { + data.ConditionType = types.StringValue(value.String()) + } else { + data.ConditionType = types.StringNull() + } + if value := res.Get("response.isNegate"); value.Exists() && !data.IsNegate.IsNull() { + data.IsNegate = types.BoolValue(value.Bool()) + } else { + data.IsNegate = types.BoolNull() + } + if value := res.Get("response.attributeName"); value.Exists() && !data.AttributeName.IsNull() { + data.AttributeName = types.StringValue(value.String()) + } else { + data.AttributeName = types.StringNull() + } + if value := res.Get("response.attributeValue"); value.Exists() && !data.AttributeValue.IsNull() { + data.AttributeValue = types.StringValue(value.String()) + } else { + data.AttributeValue = types.StringNull() + } + if value := res.Get("response.dictionaryName"); value.Exists() && !data.DictionaryName.IsNull() { + data.DictionaryName = types.StringValue(value.String()) + } else { + data.DictionaryName = types.StringNull() + } + if value := res.Get("response.dictionaryValue"); value.Exists() && !data.DictionaryValue.IsNull() { + data.DictionaryValue = types.StringValue(value.String()) + } else { + data.DictionaryValue = types.StringNull() + } + if value := res.Get("response.operator"); value.Exists() && !data.Operator.IsNull() { + data.Operator = types.StringValue(value.String()) + } else { + data.Operator = types.StringNull() + } + for i := range data.Children { + keys := [...]string{"name", "description", "conditionType", "id", "isNegate", "attributeName", "attributeValue", "dictionaryName", "dictionaryValue", "operator"} + keyValues := [...]string{data.Children[i].Name.ValueString(), data.Children[i].Description.ValueString(), data.Children[i].ConditionType.ValueString(), data.Children[i].Id.ValueString(), strconv.FormatBool(data.Children[i].IsNegate.ValueBool()), data.Children[i].AttributeName.ValueString(), data.Children[i].AttributeValue.ValueString(), data.Children[i].DictionaryName.ValueString(), data.Children[i].DictionaryValue.ValueString(), data.Children[i].Operator.ValueString()} + + var r gjson.Result + res.Get("response.children").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.Children[i].Name.IsNull() { + data.Children[i].Name = types.StringValue(value.String()) + } else { + data.Children[i].Name = types.StringNull() + } + if value := r.Get("description"); value.Exists() && !data.Children[i].Description.IsNull() { + data.Children[i].Description = types.StringValue(value.String()) + } else { + data.Children[i].Description = types.StringNull() + } + if value := r.Get("conditionType"); value.Exists() && !data.Children[i].ConditionType.IsNull() { + data.Children[i].ConditionType = types.StringValue(value.String()) + } else { + data.Children[i].ConditionType = types.StringNull() + } + if value := r.Get("id"); value.Exists() && !data.Children[i].Id.IsNull() { + data.Children[i].Id = types.StringValue(value.String()) + } else { + data.Children[i].Id = types.StringNull() + } + if value := r.Get("isNegate"); value.Exists() && !data.Children[i].IsNegate.IsNull() { + data.Children[i].IsNegate = types.BoolValue(value.Bool()) + } else { + data.Children[i].IsNegate = types.BoolNull() + } + if value := r.Get("attributeName"); value.Exists() && !data.Children[i].AttributeName.IsNull() { + data.Children[i].AttributeName = types.StringValue(value.String()) + } else { + data.Children[i].AttributeName = types.StringNull() + } + if value := r.Get("attributeValue"); value.Exists() && !data.Children[i].AttributeValue.IsNull() { + data.Children[i].AttributeValue = types.StringValue(value.String()) + } else { + data.Children[i].AttributeValue = types.StringNull() + } + if value := r.Get("dictionaryName"); value.Exists() && !data.Children[i].DictionaryName.IsNull() { + data.Children[i].DictionaryName = types.StringValue(value.String()) + } else { + data.Children[i].DictionaryName = types.StringNull() + } + if value := r.Get("dictionaryValue"); value.Exists() && !data.Children[i].DictionaryValue.IsNull() { + data.Children[i].DictionaryValue = types.StringValue(value.String()) + } else { + data.Children[i].DictionaryValue = types.StringNull() + } + if value := r.Get("operator"); value.Exists() && !data.Children[i].Operator.IsNull() { + data.Children[i].Operator = types.StringValue(value.String()) + } else { + data.Children[i].Operator = types.StringNull() + } + for ci := range data.Children[i].Children { + keys := [...]string{"name", "description", "conditionType", "id", "isNegate", "attributeName", "attributeValue", "dictionaryName", "dictionaryValue", "operator"} + keyValues := [...]string{data.Children[i].Children[ci].Name.ValueString(), data.Children[i].Children[ci].Description.ValueString(), data.Children[i].Children[ci].ConditionType.ValueString(), data.Children[i].Children[ci].Id.ValueString(), strconv.FormatBool(data.Children[i].Children[ci].IsNegate.ValueBool()), data.Children[i].Children[ci].AttributeName.ValueString(), data.Children[i].Children[ci].AttributeValue.ValueString(), data.Children[i].Children[ci].DictionaryName.ValueString(), data.Children[i].Children[ci].DictionaryValue.ValueString(), data.Children[i].Children[ci].Operator.ValueString()} + + var cr gjson.Result + r.Get("children").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 { + cr = v + return false + } + return true + }, + ) + if value := cr.Get("name"); value.Exists() && !data.Children[i].Children[ci].Name.IsNull() { + data.Children[i].Children[ci].Name = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].Name = types.StringNull() + } + if value := cr.Get("description"); value.Exists() && !data.Children[i].Children[ci].Description.IsNull() { + data.Children[i].Children[ci].Description = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].Description = types.StringNull() + } + if value := cr.Get("conditionType"); value.Exists() && !data.Children[i].Children[ci].ConditionType.IsNull() { + data.Children[i].Children[ci].ConditionType = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].ConditionType = types.StringNull() + } + if value := cr.Get("id"); value.Exists() && !data.Children[i].Children[ci].Id.IsNull() { + data.Children[i].Children[ci].Id = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].Id = types.StringNull() + } + if value := cr.Get("isNegate"); value.Exists() && !data.Children[i].Children[ci].IsNegate.IsNull() { + data.Children[i].Children[ci].IsNegate = types.BoolValue(value.Bool()) + } else { + data.Children[i].Children[ci].IsNegate = types.BoolNull() + } + if value := cr.Get("attributeName"); value.Exists() && !data.Children[i].Children[ci].AttributeName.IsNull() { + data.Children[i].Children[ci].AttributeName = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].AttributeName = types.StringNull() + } + if value := cr.Get("attributeValue"); value.Exists() && !data.Children[i].Children[ci].AttributeValue.IsNull() { + data.Children[i].Children[ci].AttributeValue = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].AttributeValue = types.StringNull() + } + if value := cr.Get("dictionaryName"); value.Exists() && !data.Children[i].Children[ci].DictionaryName.IsNull() { + data.Children[i].Children[ci].DictionaryName = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].DictionaryName = types.StringNull() + } + if value := cr.Get("dictionaryValue"); value.Exists() && !data.Children[i].Children[ci].DictionaryValue.IsNull() { + data.Children[i].Children[ci].DictionaryValue = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].DictionaryValue = types.StringNull() + } + if value := cr.Get("operator"); value.Exists() && !data.Children[i].Children[ci].Operator.IsNull() { + data.Children[i].Children[ci].Operator = types.StringValue(value.String()) + } else { + data.Children[i].Children[ci].Operator = types.StringNull() + } + } + } +} + +//template:end updateFromBody diff --git a/internal/provider/provider.go b/internal/provider/provider.go index bbca150..bfab6a9 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -245,6 +245,7 @@ func (p *IseProvider) Resources(ctx context.Context) []func() resource.Resource NewAllowedProtocolsResource, NewAuthorizationProfileResource, NewCertificateAuthenticationProfileResource, + NewDeviceAdminConditionResource, NewDownloadableACLResource, NewEndpointIdentityGroupResource, NewInternalUserResource, @@ -274,6 +275,7 @@ func (p *IseProvider) DataSources(ctx context.Context) []func() datasource.DataS NewAllowedProtocolsDataSource, NewAuthorizationProfileDataSource, NewCertificateAuthenticationProfileDataSource, + NewDeviceAdminConditionDataSource, NewDownloadableACLDataSource, NewEndpointIdentityGroupDataSource, NewInternalUserDataSource, diff --git a/internal/provider/resource_ise_device_admin_condition.go b/internal/provider/resource_ise_device_admin_condition.go new file mode 100644 index 0000000..e4b78df --- /dev/null +++ b/internal/provider/resource_ise_device_admin_condition.go @@ -0,0 +1,365 @@ +// 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" + "strings" + + "github.com/CiscoDevNet/terraform-provider-ise/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" + "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/schema/validator" + "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 = &DeviceAdminConditionResource{} +var _ resource.ResourceWithImportState = &DeviceAdminConditionResource{} + +func NewDeviceAdminConditionResource() resource.Resource { + return &DeviceAdminConditionResource{} +} + +type DeviceAdminConditionResource struct { + client *ise.Client +} + +func (r *DeviceAdminConditionResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_device_admin_condition" +} + +func (r *DeviceAdminConditionResource) 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 a Device Admin Condition.").String, + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + MarkdownDescription: "The id of the object", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition name").String, + Required: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition description").String, + Optional: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.").AddStringEnumDescription("LibraryConditionAndBlock", "LibraryConditionAttributes", "LibraryConditionOrBlock").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("LibraryConditionAndBlock", "LibraryConditionAttributes", "LibraryConditionOrBlock"), + }, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whereas this condition is in negate mode").String, + Optional: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary attribute name").String, + Optional: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Attribute value for condition. Value type is specified in dictionary object.").String, + Optional: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary name").String, + Optional: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary value").String, + Optional: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Equality operator").AddStringEnumDescription("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith"), + }, + }, + "children": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`.").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition name").String, + Optional: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition description").String, + Optional: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.").AddStringEnumDescription("ConditionAndBlock", "ConditionAttributes", "ConditionOrBlock", "ConditionReference").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("ConditionAndBlock", "ConditionAttributes", "ConditionOrBlock", "ConditionReference"), + }, + }, + "id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("UUID for condition").String, + Optional: true, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whereas this condition is in negate mode").String, + Optional: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary attribute name").String, + Optional: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Attribute value for condition. Value type is specified in dictionary object.").String, + Optional: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary name").String, + Optional: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary value").String, + Optional: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Equality operator").AddStringEnumDescription("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith"), + }, + }, + "children": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("List of child conditions. `condition_type` must be one of `ConditionAndBlock`, `ConditionOrBlock`, `LibraryConditionAndBlock` or `LibraryConditionOrBlock`.").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition name").String, + Optional: true, + }, + "description": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Condition description").String, + Optional: true, + }, + "condition_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whether the record is the condition itself or a logical aggregation. Logical aggreation indicates that additional conditions are present under the children attribute.").AddStringEnumDescription("ConditionAndBlock", "ConditionAttributes", "ConditionOrBlock", "ConditionReference").String, + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("ConditionAndBlock", "ConditionAttributes", "ConditionOrBlock", "ConditionReference"), + }, + }, + "id": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("UUID for condition").String, + Optional: true, + }, + "is_negate": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Indicates whereas this condition is in negate mode").String, + Optional: true, + }, + "attribute_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary attribute name").String, + Optional: true, + }, + "attribute_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Attribute value for condition. Value type is specified in dictionary object.").String, + Optional: true, + }, + "dictionary_name": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary name").String, + Optional: true, + }, + "dictionary_value": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Dictionary value").String, + Optional: true, + }, + "operator": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Equality operator").AddStringEnumDescription("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("contains", "endsWith", "equals", "greaterOrEquals", "greaterThan", "in", "ipEquals", "ipGreaterThan", "ipLessThan", "ipNotEquals", "lessOrEquals", "lessThan", "matches", "notContains", "notEndsWith", "notEquals", "notIn", "notStartsWith", "startsWith"), + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (r *DeviceAdminConditionResource) 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 *DeviceAdminConditionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan DeviceAdminCondition + + // 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, DeviceAdminCondition{}) + 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 + } + plan.Id = types.StringValue(res.Get("response.id").String()) + + 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 *DeviceAdminConditionResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var state DeviceAdminCondition + + // 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())) + + res, err := r.client.Get(state.getPath() + "/" + state.Id.ValueString()) + if err != nil && strings.Contains(err.Error(), "StatusCode 404") { + resp.State.RemoveResource(ctx) + return + } else if err != nil { + resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String())) + return + } + + state.updateFromBody(ctx, res) + + 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 *DeviceAdminConditionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan, state DeviceAdminCondition + + // 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 *DeviceAdminConditionResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var state DeviceAdminCondition + + // 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())) + res, err := r.client.Delete(state.getPath() + "/" + state.Id.ValueString()) + 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 +func (r *DeviceAdminConditionResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +} + +//template:end import diff --git a/internal/provider/resource_ise_device_admin_condition_test.go b/internal/provider/resource_ise_device_admin_condition_test.go new file mode 100644 index 0000000..715ad54 --- /dev/null +++ b/internal/provider/resource_ise_device_admin_condition_test.go @@ -0,0 +1,101 @@ +// 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 TestAccIseDeviceAdminCondition(t *testing.T) { + var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "name", "Cond1")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "description", "My description")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "condition_type", "LibraryConditionAttributes")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "is_negate", "false")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "attribute_name", "EapAuthentication")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "attribute_value", "EAP-TLS")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "dictionary_name", "Network Access")) + checks = append(checks, resource.TestCheckResourceAttr("ise_device_admin_condition.test", "operator", "equals")) + + var steps []resource.TestStep + if os.Getenv("SKIP_MINIMUM_TEST") == "" { + steps = append(steps, resource.TestStep{ + Config: testAccIseDeviceAdminConditionConfig_minimum(), + }) + } + steps = append(steps, resource.TestStep{ + Config: testAccIseDeviceAdminConditionConfig_all(), + Check: resource.ComposeTestCheckFunc(checks...), + }) + steps = append(steps, resource.TestStep{ + ResourceName: "ise_device_admin_condition.test", + ImportState: true, + }) + + 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 testAccIseDeviceAdminConditionConfig_minimum() string { + config := `resource "ise_device_admin_condition" "test" {` + "\n" + config += ` name = "Cond1"` + "\n" + config += ` condition_type = "LibraryConditionAttributes"` + "\n" + config += ` attribute_name = "EapAuthentication"` + "\n" + config += ` attribute_value = "EAP-TLS"` + "\n" + config += ` dictionary_name = "Network Access"` + "\n" + config += ` operator = "equals"` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigMinimal + +//template:begin testAccConfigAll +func testAccIseDeviceAdminConditionConfig_all() string { + config := `resource "ise_device_admin_condition" "test" {` + "\n" + config += ` name = "Cond1"` + "\n" + config += ` description = "My description"` + "\n" + config += ` condition_type = "LibraryConditionAttributes"` + "\n" + config += ` is_negate = false` + "\n" + config += ` attribute_name = "EapAuthentication"` + "\n" + config += ` attribute_value = "EAP-TLS"` + "\n" + config += ` dictionary_name = "Network Access"` + "\n" + config += ` operator = "equals"` + "\n" + config += `}` + "\n" + return config +} + +//template:end testAccConfigAll diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 5d7562e..096863e 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -12,6 +12,7 @@ description: |- - Add `ise_downloadable_acl` resource and data source - Add `ise_tacacs_command_set` resource and data source - Add `ise_tacacs_profile` resource and data source +- Add `ise_device_admin_condition` resource and data source ## 0.1.5