Skip to content

Commit

Permalink
update for read folder requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
ancoleman committed Mar 1, 2024
1 parent 64998cd commit 466fbd4
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/data-sources/ipsec_tunnel.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ data "scm_ipsec_tunnel" "example" {

- `id` (String) The Id param.

### Optional

- `folder` (String) The Folder param.

### Read-Only

- `anti_replay` (Boolean) Enable Anti-Replay check on this tunnel.
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/qos_policy_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ data "scm_qos_policy_rule" "example" {

- `id` (String) The Id param.

### Optional

- `folder` (String) The Folder param.

### Read-Only

- `action` (Attributes) The Action param. (see [below for nested schema](#nestedatt--action))
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/qos_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ data "scm_qos_profile" "example" {

- `id` (String) The Id param.

### Optional

- `folder` (String) The Folder param.

### Read-Only

- `aggregate_bandwidth` (Attributes) The AggregateBandwidth param. (see [below for nested schema](#nestedatt--aggregate_bandwidth))
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/remote_network.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ data "scm_remote_network" "example" {

- `id` (String) The Id param.

### Optional

- `folder` (String) The Folder param. String can either be a specific string(`"Remote Networks"`) or match this regex: `^[\s0-9a-zA-Z._-]{1,}$`. Default: `"Remote Networks"`.

### Read-Only

- `ecmp_load_balancing` (String) The EcmpLoadBalancing param. String must be one of these: `"enable"`, `"disable"`. Default: `"disable"`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/paloaltonetworks/scm-go v0.3.0
github.com/paloaltonetworks/scm-go v0.4.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ github.com/paloaltonetworks/scm-go v0.2.0 h1:LWXRpCjRCHvu0Cp8LBITxfL7lUa/ne0LUsZ
github.com/paloaltonetworks/scm-go v0.2.0/go.mod h1:8CiN/F+XcDSwup6WutVuV92+Rw+35F8aPDo+QFdoQeA=
github.com/paloaltonetworks/scm-go v0.3.0 h1:bTguA7GDVtNYA68TM2fEDHYg6leFnniXEWAmR+iJTdw=
github.com/paloaltonetworks/scm-go v0.3.0/go.mod h1:8CiN/F+XcDSwup6WutVuV92+Rw+35F8aPDo+QFdoQeA=
github.com/paloaltonetworks/scm-go v0.4.0 h1:Bdpw1S8KBYqtn1DNgURO5VUcKskaeyjlmBfXGgxz9VA=
github.com/paloaltonetworks/scm-go v0.4.0/go.mod h1:8CiN/F+XcDSwup6WutVuV92+Rw+35F8aPDo+QFdoQeA=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
19 changes: 17 additions & 2 deletions internal/provider/ipsec_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ type ipsecTunnelDsModel struct {
Tfid types.String `tfsdk:"tfid"`

// Input.
Id types.String `tfsdk:"id"`
Folder types.String `tfsdk:"folder"`
Id types.String `tfsdk:"id"`

// Output.
AntiReplay types.Bool `tfsdk:"anti_replay"`
Expand Down Expand Up @@ -720,7 +721,7 @@ func (d *ipsecTunnelDataSource) Schema(_ context.Context, _ datasource.SchemaReq
Description: "Retrieves a config item.",

Attributes: map[string]dsschema.Attribute{
// inputs:map[string]bool{"id":true} outputs:map[string]bool{"anti_replay":true, "auto_key":true, "copy_tos":true, "enable_gre_encapsulation":true, "id":true, "name":true, "tfid":true, "tunnel_monitor":true} forceNew:map[string]bool{"id":true}
// inputs:map[string]bool{"folder":true, "id":true} outputs:map[string]bool{"anti_replay":true, "auto_key":true, "copy_tos":true, "enable_gre_encapsulation":true, "id":true, "name":true, "tfid":true, "tunnel_monitor":true} forceNew:map[string]bool{"folder":true, "id":true}
"anti_replay": dsschema.BoolAttribute{
Description: "Enable Anti-Replay check on this tunnel.",
Computed: true,
Expand Down Expand Up @@ -881,6 +882,10 @@ func (d *ipsecTunnelDataSource) Schema(_ context.Context, _ datasource.SchemaReq
Description: "allow GRE over IPSec. Default: `false`.",
Computed: true,
},
"folder": dsschema.StringAttribute{
Description: "The Folder param.",
Optional: true,
},
"id": dsschema.StringAttribute{
Description: "The Id param.",
Required: true,
Expand Down Expand Up @@ -938,6 +943,7 @@ func (d *ipsecTunnelDataSource) Read(ctx context.Context, req datasource.ReadReq
"data_source_name": "scm_ipsec_tunnel",
"terraform_provider_function": "Read",
"id": state.Id.ValueString(),
"folder": state.Folder.ValueString(),
})

// Prepare to run the command.
Expand All @@ -948,6 +954,8 @@ func (d *ipsecTunnelDataSource) Read(ctx context.Context, req datasource.ReadReq

input.Id = state.Id.ValueString()

input.Folder = state.Folder.ValueStringPointer()

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand All @@ -959,6 +967,11 @@ func (d *ipsecTunnelDataSource) Read(ctx context.Context, req datasource.ReadReq
var idBuilder strings.Builder
idBuilder.WriteString(input.Id)

idBuilder.WriteString(IdSeparator)
if input.Folder != nil {
idBuilder.WriteString(*input.Folder)
}

// Store the answer to state.

state.Tfid = types.StringValue(idBuilder.String())
Expand Down Expand Up @@ -1834,6 +1847,8 @@ func (r *ipsecTunnelResource) Read(ctx context.Context, req resource.ReadRequest

input.Id = tokens[3]

input.Folder = &tokens[0]

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand Down
19 changes: 17 additions & 2 deletions internal/provider/qos_policy_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ type qosPolicyRuleDsModel struct {
Tfid types.String `tfsdk:"tfid"`

// Input.
Id types.String `tfsdk:"id"`
Folder types.String `tfsdk:"folder"`
Id types.String `tfsdk:"id"`

// Output.
Action qosPolicyRuleDsModel_tephihM_ActionObject `tfsdk:"action"`
Expand Down Expand Up @@ -566,7 +567,7 @@ func (d *qosPolicyRuleDataSource) Schema(_ context.Context, _ datasource.SchemaR
Description: "Retrieves a config item.",

Attributes: map[string]dsschema.Attribute{
// inputs:map[string]bool{"id":true} outputs:map[string]bool{"action":true, "description":true, "dscp_tos":true, "id":true, "name":true, "schedule":true, "tfid":true} forceNew:map[string]bool{"id":true}
// inputs:map[string]bool{"folder":true, "id":true} outputs:map[string]bool{"action":true, "description":true, "dscp_tos":true, "id":true, "name":true, "schedule":true, "tfid":true} forceNew:map[string]bool{"folder":true, "id":true}
"action": dsschema.SingleNestedAttribute{
Description: "The Action param.",
Computed: true,
Expand Down Expand Up @@ -668,6 +669,10 @@ func (d *qosPolicyRuleDataSource) Schema(_ context.Context, _ datasource.SchemaR
},
},
},
"folder": dsschema.StringAttribute{
Description: "The Folder param.",
Optional: true,
},
"id": dsschema.StringAttribute{
Description: "The Id param.",
Required: true,
Expand Down Expand Up @@ -710,6 +715,7 @@ func (d *qosPolicyRuleDataSource) Read(ctx context.Context, req datasource.ReadR
"data_source_name": "scm_qos_policy_rule",
"terraform_provider_function": "Read",
"id": state.Id.ValueString(),
"folder": state.Folder.ValueString(),
})

// Prepare to run the command.
Expand All @@ -720,6 +726,8 @@ func (d *qosPolicyRuleDataSource) Read(ctx context.Context, req datasource.ReadR

input.Id = state.Id.ValueString()

input.Folder = state.Folder.ValueStringPointer()

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand All @@ -731,6 +739,11 @@ func (d *qosPolicyRuleDataSource) Read(ctx context.Context, req datasource.ReadR
var idBuilder strings.Builder
idBuilder.WriteString(input.Id)

idBuilder.WriteString(IdSeparator)
if input.Folder != nil {
idBuilder.WriteString(*input.Folder)
}

// Store the answer to state.

state.Tfid = types.StringValue(idBuilder.String())
Expand Down Expand Up @@ -1336,6 +1349,8 @@ func (r *qosPolicyRuleResource) Read(ctx context.Context, req resource.ReadReque

input.Id = tokens[4]

input.Folder = &tokens[0]

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand Down
19 changes: 17 additions & 2 deletions internal/provider/qos_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ type qosProfileDsModel struct {
Tfid types.String `tfsdk:"tfid"`

// Input.
Id types.String `tfsdk:"id"`
Folder types.String `tfsdk:"folder"`
Id types.String `tfsdk:"id"`

// Output.
AggregateBandwidth *qosProfileDsModel_zGfKFAQ_AggregateBandwidthObject `tfsdk:"aggregate_bandwidth"`
Expand Down Expand Up @@ -543,7 +544,7 @@ func (d *qosProfileDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
Description: "Retrieves a config item.",

Attributes: map[string]dsschema.Attribute{
// inputs:map[string]bool{"id":true} outputs:map[string]bool{"aggregate_bandwidth":true, "class_bandwidth_type":true, "id":true, "name":true, "tfid":true} forceNew:map[string]bool{"id":true}
// inputs:map[string]bool{"folder":true, "id":true} outputs:map[string]bool{"aggregate_bandwidth":true, "class_bandwidth_type":true, "id":true, "name":true, "tfid":true} forceNew:map[string]bool{"folder":true, "id":true}
"aggregate_bandwidth": dsschema.SingleNestedAttribute{
Description: "The AggregateBandwidth param.",
Computed: true,
Expand Down Expand Up @@ -644,6 +645,10 @@ func (d *qosProfileDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
},
},
},
"folder": dsschema.StringAttribute{
Description: "The Folder param.",
Optional: true,
},
"id": dsschema.StringAttribute{
Description: "The Id param.",
Required: true,
Expand Down Expand Up @@ -682,6 +687,7 @@ func (d *qosProfileDataSource) Read(ctx context.Context, req datasource.ReadRequ
"data_source_name": "scm_qos_profile",
"terraform_provider_function": "Read",
"id": state.Id.ValueString(),
"folder": state.Folder.ValueString(),
})

// Prepare to run the command.
Expand All @@ -692,6 +698,8 @@ func (d *qosProfileDataSource) Read(ctx context.Context, req datasource.ReadRequ

input.Id = state.Id.ValueString()

input.Folder = state.Folder.ValueStringPointer()

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand All @@ -703,6 +711,11 @@ func (d *qosProfileDataSource) Read(ctx context.Context, req datasource.ReadRequ
var idBuilder strings.Builder
idBuilder.WriteString(input.Id)

idBuilder.WriteString(IdSeparator)
if input.Folder != nil {
idBuilder.WriteString(*input.Folder)
}

// Store the answer to state.

state.Tfid = types.StringValue(idBuilder.String())
Expand Down Expand Up @@ -1316,6 +1329,8 @@ func (r *qosProfileResource) Read(ctx context.Context, req resource.ReadRequest,

input.Id = tokens[3]

input.Folder = &tokens[0]

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand Down
18 changes: 16 additions & 2 deletions internal/provider/remote_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,8 @@ type remoteNetworkDsModel struct {
Tfid types.String `tfsdk:"tfid"`

// Input.
Id types.String `tfsdk:"id"`
Folder types.String `tfsdk:"folder"`
Id types.String `tfsdk:"id"`

// Output.
EcmpLoadBalancing types.String `tfsdk:"ecmp_load_balancing"`
Expand Down Expand Up @@ -606,7 +607,7 @@ func (d *remoteNetworkDataSource) Schema(_ context.Context, _ datasource.SchemaR
Description: "Retrieves a config item.",

Attributes: map[string]dsschema.Attribute{
// inputs:map[string]bool{"id":true} outputs:map[string]bool{"ecmp_load_balancing":true, "ecmp_tunnels":true, "id":true, "ipsec_tunnel":true, "license_type":true, "name":true, "protocol":true, "region":true, "secondary_ipsec_tunnel":true, "spn_name":true, "subnets":true, "tfid":true} forceNew:map[string]bool{"id":true}
// inputs:map[string]bool{"folder":true, "id":true} outputs:map[string]bool{"ecmp_load_balancing":true, "ecmp_tunnels":true, "id":true, "ipsec_tunnel":true, "license_type":true, "name":true, "protocol":true, "region":true, "secondary_ipsec_tunnel":true, "spn_name":true, "subnets":true, "tfid":true} forceNew:map[string]bool{"folder":true, "id":true}
"ecmp_load_balancing": dsschema.StringAttribute{
Description: "The EcmpLoadBalancing param. String must be one of these: `\"enable\"`, `\"disable\"`. Default: `\"disable\"`.",
Computed: true,
Expand Down Expand Up @@ -679,6 +680,11 @@ func (d *remoteNetworkDataSource) Schema(_ context.Context, _ datasource.SchemaR
},
},
},
"folder": dsschema.StringAttribute{
Description: "The Folder param. String can either be a specific string(`\"Remote Networks\"`) or match this regex: `^[\\s0-9a-zA-Z._-]{1,}$`. Default: `\"Remote Networks\"`.",
Optional: true,
Computed: true,
},
"id": dsschema.StringAttribute{
Description: "The Id param.",
Required: true,
Expand Down Expand Up @@ -813,6 +819,7 @@ func (d *remoteNetworkDataSource) Read(ctx context.Context, req datasource.ReadR
"data_source_name": "scm_remote_network",
"terraform_provider_function": "Read",
"id": state.Id.ValueString(),
"folder": state.Folder.ValueString(),
})

// Prepare to run the command.
Expand All @@ -823,6 +830,8 @@ func (d *remoteNetworkDataSource) Read(ctx context.Context, req datasource.ReadR

input.Id = state.Id.ValueString()

input.Folder = state.Folder.ValueString()

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand All @@ -834,6 +843,9 @@ func (d *remoteNetworkDataSource) Read(ctx context.Context, req datasource.ReadR
var idBuilder strings.Builder
idBuilder.WriteString(input.Id)

idBuilder.WriteString(IdSeparator)
idBuilder.WriteString(input.Folder)

// Store the answer to state.

state.Tfid = types.StringValue(idBuilder.String())
Expand Down Expand Up @@ -1598,6 +1610,8 @@ func (r *remoteNetworkResource) Read(ctx context.Context, req resource.ReadReque

input.Id = tokens[1]

input.Folder = tokens[0]

// Perform the operation.
ans, err := svc.Read(ctx, input)
if err != nil {
Expand Down

0 comments on commit 466fbd4

Please sign in to comment.