forked from CiscoDevNet/terraform-provider-sdwan
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add policy object security protocol list resource and data source
- Loading branch information
Showing
16 changed files
with
880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "sdwan_policy_object_security_protocol_list Data Source - terraform-provider-sdwan" | ||
subcategory: "Policy Objects" | ||
description: |- | ||
This data source can read the Policy Object Security Protocol List Policy_object. | ||
--- | ||
|
||
# sdwan_policy_object_security_protocol_list (Data Source) | ||
|
||
This data source can read the Policy Object Security Protocol List Policy_object. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "sdwan_policy_object_security_protocol_list" "example" { | ||
id = "f6b2c44c-693c-4763-b010-895aa3d236bd" | ||
feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `feature_profile_id` (String) Feature Profile ID | ||
- `id` (String) The id of the Policy_object | ||
|
||
### Read-Only | ||
|
||
- `description` (String) The description of the Policy_object | ||
- `entries` (Attributes List) (see [below for nested schema](#nestedatt--entries)) | ||
- `name` (String) The name of the Policy_object | ||
- `version` (Number) The version of the Policy_object | ||
|
||
<a id="nestedatt--entries"></a> | ||
### Nested Schema for `entries` | ||
|
||
Read-Only: | ||
|
||
- `protocol_names` (String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "sdwan_policy_object_security_protocol_list Resource - terraform-provider-sdwan" | ||
subcategory: "Policy Objects" | ||
description: |- | ||
This resource can manage a Policy Object Security Protocol List Policy_object. | ||
Minimum SD-WAN Manager version: 20.12.0 | ||
--- | ||
|
||
# sdwan_policy_object_security_protocol_list (Resource) | ||
|
||
This resource can manage a Policy Object Security Protocol List Policy_object. | ||
- Minimum SD-WAN Manager version: `20.12.0` | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "sdwan_policy_object_security_protocol_list" "example" { | ||
name = "Example" | ||
description = "My Example" | ||
feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" | ||
entries = [ | ||
{ | ||
protocol_names = "aol" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `entries` (Attributes List) (see [below for nested schema](#nestedatt--entries)) | ||
- `feature_profile_id` (String) Feature Profile ID | ||
- `name` (String) The name of the Policy_object | ||
|
||
### Optional | ||
|
||
- `description` (String) The description of the Policy_object | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The id of the Policy_object | ||
- `version` (Number) The version of the Policy_object | ||
|
||
<a id="nestedatt--entries"></a> | ||
### Nested Schema for `entries` | ||
|
||
Optional: | ||
|
||
- `protocol_names` (String) - Choices: `snmp`, `icmp`, `tcp`, `udp`, `echo`, `telnet`, `wins`, `n2h2server`, `nntp`, `pptp`, `rtsp`, `bootpc`, `gdoi`, `tacacs`, `gopher`, `icabrowser`, `skinny`, `sunrpc`, `biff`, `router`, `ircs`, `orasrv`, `ms-cluster-net`, `kermit`, `isakmp`, `sshell`, `realsecure`, `ircu`, `appleqtc`, `pwdgen`, `rdb-dbs-disp`, `creativepartnr`, `finger`, `ftps`, `giop`, `rsvd`, `hp-alarm-mgr`, `uucp`, `kerberos`, `imap`, `time`, `bootps`, `tftp`, `oracle`, `snmptrap`, `http`, `qmtp`, `radius`, `oracle-em-vp`, `tarantella`, `pcanywheredata`, `ldap`, `mgcp`, `sqlsrv`, `hsrp`, `cisco-net-mgmt`, `smtp`, `pcanywherestat`, `exec`, `send`, `stun`, `syslog`, `ms-sql-m`, `citrix`, `creativeserver`, `cifs`, `cisco-sys`, `cisco-tna`, `ms-dotnetster`, `gtpv1`, `gtpv0`, `imap3`, `fcip-port`, `netbios-dgm`, `sip-tls`, `pop3s`, `cisco-fna`, `802-11-iapp`, `oem-agent`, `cisco-tdp`, `tr-rsrb`, `r-winsock`, `sql-net`, `syslog-conn`, `tacacs-ds`, `h225ras`, `ace-svr`, `dhcp-failover`, `igmpv3lite`, `irc-serv`, `entrust-svcs`, `dbcontrol_agent`, `cisco-svcs`, `ipsec-msft`, `microsoft-ds`, `ms-sna`, `rsvp_tunnel`, `rsvp-encap`, `hp-collector`, `netbios-ns`, `msexch-routing`, `h323`, `l2tp`, `ldap-admin`, `pop3`, `h323callsigalt`, `ms-sql`, `iscsi-target`, `webster`, `lotusnote`, `ipx`, `entrust-svc-hand`, `citriximaclient`, `rtc-pm-port`, `ftp`, `aol`, `xdmcp`, `oraclenames`, `login`, `iscsi`, `ttc`, `imaps`, `socks`, `ssh`, `dnsix`, `daytime`, `sip`, `discard`, `ntp`, `ldaps`, `https`, `vdolive`, `ica`, `net8-cman`, `cuseeme`, `netstat`, `sms`, `streamworks`, `rtelnet`, `who`, `kazaa`, `ssp`, `dbase`, `timed`, `cddbp`, `telnets`, `ymsgr`, `ident`, `bgp`, `ddns-v3`, `vqp`, `irc`, `ipass`, `x11`, `dns`, `lotusmtap`, `mysql`, `nfs`, `msnmsgr`, `netshow`, `sqlserv`, `hp-managed-node`, `ncp`, `shell`, `realmedia`, `msrpc`, `clp` | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import sdwan_policy_object_security_protocol_list.example "f6b2c44c-693c-4763-b010-895aa3d236bd" | ||
``` |
4 changes: 4 additions & 0 deletions
4
examples/data-sources/sdwan_policy_object_security_protocol_list/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
data "sdwan_policy_object_security_protocol_list" "example" { | ||
id = "f6b2c44c-693c-4763-b010-895aa3d236bd" | ||
feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" | ||
} |
1 change: 1 addition & 0 deletions
1
examples/resources/sdwan_policy_object_security_protocol_list/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import sdwan_policy_object_security_protocol_list.example "f6b2c44c-693c-4763-b010-895aa3d236bd" |
10 changes: 10 additions & 0 deletions
10
examples/resources/sdwan_policy_object_security_protocol_list/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "sdwan_policy_object_security_protocol_list" "example" { | ||
name = "Example" | ||
description = "My Example" | ||
feature_profile_id = "f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac" | ||
entries = [ | ||
{ | ||
protocol_names = "aol" | ||
} | ||
] | ||
} |
29 changes: 29 additions & 0 deletions
29
gen/definitions/profile_parcels/policy_object_security_protocol_list.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Policy Object Security Protocol List | ||
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/security-protocolname | ||
minimum_version: 20.12.0 | ||
test_tags: [SDWAN_2012] | ||
skip_minimum_test: true | ||
parcel_type: policy_object | ||
attributes: | ||
- tf_name: feature_profile_id | ||
reference: true | ||
type: String | ||
mandatory: true | ||
description: Feature Profile ID | ||
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac | ||
test_value: sdwan_policy_object_feature_profile.test.id | ||
- model_name: entries | ||
mandatory: true | ||
attributes: | ||
- model_name: protocolName | ||
tf_name: protocol_names | ||
id: true | ||
mandatory: true | ||
example: aol | ||
|
||
test_prerequisites: | | ||
resource "sdwan_policy_object_feature_profile" "test" { | ||
name = "POLICY_OBJECT_FP_1" | ||
description = "My policy object feature profile 1" | ||
} |
File renamed without changes.
133 changes: 133 additions & 0 deletions
133
internal/provider/data_source_sdwan_policy_object_security_protocol_list.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// 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 | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin imports | ||
import ( | ||
"context" | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
"github.com/netascode/go-sdwan" | ||
) | ||
|
||
// End of section. //template:end imports | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin model | ||
|
||
// Ensure the implementation satisfies the expected interfaces. | ||
var ( | ||
_ datasource.DataSource = &PolicyObjectSecurityProtocolListProfileParcelDataSource{} | ||
_ datasource.DataSourceWithConfigure = &PolicyObjectSecurityProtocolListProfileParcelDataSource{} | ||
) | ||
|
||
func NewPolicyObjectSecurityProtocolListProfileParcelDataSource() datasource.DataSource { | ||
return &PolicyObjectSecurityProtocolListProfileParcelDataSource{} | ||
} | ||
|
||
type PolicyObjectSecurityProtocolListProfileParcelDataSource struct { | ||
client *sdwan.Client | ||
} | ||
|
||
func (d *PolicyObjectSecurityProtocolListProfileParcelDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_policy_object_security_protocol_list" | ||
} | ||
|
||
func (d *PolicyObjectSecurityProtocolListProfileParcelDataSource) 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 Policy Object Security Protocol List Policy_object.", | ||
|
||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
MarkdownDescription: "The id of the Policy_object", | ||
Required: true, | ||
}, | ||
"version": schema.Int64Attribute{ | ||
MarkdownDescription: "The version of the Policy_object", | ||
Computed: true, | ||
}, | ||
"name": schema.StringAttribute{ | ||
MarkdownDescription: "The name of the Policy_object", | ||
Computed: true, | ||
}, | ||
"description": schema.StringAttribute{ | ||
MarkdownDescription: "The description of the Policy_object", | ||
Computed: true, | ||
}, | ||
"feature_profile_id": schema.StringAttribute{ | ||
MarkdownDescription: "Feature Profile ID", | ||
Required: true, | ||
}, | ||
"entries": schema.ListNestedAttribute{ | ||
MarkdownDescription: "", | ||
Computed: true, | ||
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"protocol_names": schema.StringAttribute{ | ||
MarkdownDescription: "", | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (d *PolicyObjectSecurityProtocolListProfileParcelDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
d.client = req.ProviderData.(*SdwanProviderData).Client | ||
} | ||
|
||
// End of section. //template:end model | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin read | ||
func (d *PolicyObjectSecurityProtocolListProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
var config PolicyObjectSecurityProtocolList | ||
|
||
// 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())) | ||
|
||
res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(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.Name.ValueString())) | ||
|
||
diags = resp.State.Set(ctx, &config) | ||
resp.Diagnostics.Append(diags...) | ||
} | ||
|
||
// End of section. //template:end read |
81 changes: 81 additions & 0 deletions
81
internal/provider/data_source_sdwan_policy_object_security_protocol_list_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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 | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin imports | ||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
) | ||
|
||
// End of section. //template:end imports | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource | ||
func TestAccDataSourceSdwanPolicyObjectSecurityProtocolListProfileParcel(t *testing.T) { | ||
if os.Getenv("SDWAN_2012") == "" { | ||
t.Skip("skipping test, set environment variable SDWAN_2012") | ||
} | ||
var checks []resource.TestCheckFunc | ||
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_policy_object_security_protocol_list.test", "entries.0.protocol_names", "aol")) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceSdwanPolicyObjectSecurityProtocolListPrerequisitesProfileParcelConfig + testAccDataSourceSdwanPolicyObjectSecurityProtocolListProfileParcelConfig(), | ||
Check: resource.ComposeTestCheckFunc(checks...), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
// End of section. //template:end testAccDataSource | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites | ||
const testAccDataSourceSdwanPolicyObjectSecurityProtocolListPrerequisitesProfileParcelConfig = ` | ||
resource "sdwan_policy_object_feature_profile" "test" { | ||
name = "POLICY_OBJECT_FP_1" | ||
description = "My policy object feature profile 1" | ||
} | ||
` | ||
|
||
// End of section. //template:end testPrerequisites | ||
|
||
// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig | ||
func testAccDataSourceSdwanPolicyObjectSecurityProtocolListProfileParcelConfig() string { | ||
config := `resource "sdwan_policy_object_security_protocol_list" "test" {` + "\n" | ||
config += ` name = "TF_TEST"` + "\n" | ||
config += ` description = "Terraform integration test"` + "\n" | ||
config += ` feature_profile_id = sdwan_policy_object_feature_profile.test.id` + "\n" | ||
config += ` entries = [{` + "\n" | ||
config += ` protocol_names = "aol"` + "\n" | ||
config += ` }]` + "\n" | ||
config += `}` + "\n" | ||
|
||
config += ` | ||
data "sdwan_policy_object_security_protocol_list" "test" { | ||
id = sdwan_policy_object_security_protocol_list.test.id | ||
feature_profile_id = sdwan_policy_object_feature_profile.test.id | ||
} | ||
` | ||
return config | ||
} | ||
|
||
// End of section. //template:end testAccDataSourceConfig |
Oops, something went wrong.