Skip to content

Commit

Permalink
rename various instances of "children" to "child_primitives"
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Jul 31, 2023
1 parent 2dc46de commit 40e83ab
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 105 deletions.
28 changes: 14 additions & 14 deletions apstra/connectivity_template/bgp_peering_generic_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type BgpPeeringGenericSystem struct {
NeighborAsnDynamic types.Bool `tfsdk:"neighbor_asn_dynamic"`
PeerFromLoopback types.Bool `tfsdk:"peer_from_loopback"`
PeerTo types.String `tfsdk:"peer_to"`
Children types.Set `tfsdk:"children"`
ChildPrimitives types.Set `tfsdk:"child_primitives"`
Primitive types.String `tfsdk:"primitive"`
}

Expand Down Expand Up @@ -137,9 +137,9 @@ func (o BgpPeeringGenericSystem) DataSourceAttributes() map[string]dataSourceSch
Optional: true,
Validators: []validator.String{stringvalidator.OneOf(peerTo...)},
},
"children": dataSourceSchema.SetAttribute{
"child_primitives": dataSourceSchema.SetAttribute{
MarkdownDescription: "Set of JSON strings describing Connectivity Template Primitives " +
"which are children of this Connectivity Template JsonPrimitive. Use the `primitive` " +
"which are children of this Connectivity Template Primitive. Use the `primitive` " +
"attribute of other Connectivity Template Primitives data sources here.",
ElementType: types.StringType,
Validators: []validator.Set{setvalidator.SizeAtLeast(1)},
Expand Down Expand Up @@ -207,20 +207,20 @@ func (o BgpPeeringGenericSystem) Marshal(ctx context.Context, diags *diag.Diagno
obj.PeerTo = apstra.CtPrimitiveBgpPeerToInterfaceOrIpEndpoint.String()
}

var children []string
diags.Append(o.Children.ElementsAs(ctx, &children, false)...)
var childPrimitives []string
diags.Append(o.ChildPrimitives.ElementsAs(ctx, &childPrimitives, false)...)
if diags.HasError() {
return ""
}

// sort the children by their SHA1 sums for easier comparison of nested strings
sort.Slice(children, func(i, j int) bool {
sum1 := sha1.Sum([]byte(children[i]))
sum2 := sha1.Sum([]byte(children[j]))
// sort the childPrimitives by their SHA1 sums for easier comparison of nested strings
sort.Slice(childPrimitives, func(i, j int) bool {
sum1 := sha1.Sum([]byte(childPrimitives[i]))
sum2 := sha1.Sum([]byte(childPrimitives[j]))
return bytes.Compare(sum1[:], sum2[:]) >= 0
})

obj.Children = children
obj.ChildPrimitives = childPrimitives

data, err := json.Marshal(&obj)
if err != nil {
Expand Down Expand Up @@ -276,7 +276,7 @@ func (o *BgpPeeringGenericSystem) loadSdkPrimitive(ctx context.Context, in apstr
o.NeighborAsnDynamic = types.BoolValue(attributes.NeighborAsnDynamic)
o.PeerFromLoopback = types.BoolValue(attributes.PeerFromLoopback)
o.PeerTo = types.StringValue(attributes.PeerTo.String())
o.Children = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
o.ChildPrimitives = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
}

var _ JsonPrimitive = &bgpPeeringGenericSystemPrototype{}
Expand All @@ -295,7 +295,7 @@ type bgpPeeringGenericSystemPrototype struct {
NeighborAsnDynamic bool `json:"neighbor_asn_dynamic"`
PeerFromLoopback bool `json:"peer_from_loopback"`
PeerTo string `json:"peer_to"`
Children []string `json:"children"`
ChildPrimitives []string `json:"child_primitives"`
}

func (o bgpPeeringGenericSystemPrototype) attributes(_ context.Context, path path.Path, diags *diag.Diagnostics) apstra.ConnectivityTemplatePrimitiveAttributes {
Expand Down Expand Up @@ -363,15 +363,15 @@ func (o bgpPeeringGenericSystemPrototype) ToSdkPrimitive(ctx context.Context, pa
return nil
}

children := ChildPrimitivesFromListOfJsonStrings(ctx, o.Children, path, diags)
childPrimitives := ChildPrimitivesFromListOfJsonStrings(ctx, o.ChildPrimitives, path, diags)
if diags.HasError() {
return nil
}

return &apstra.ConnectivityTemplatePrimitive{
Id: nil, // calculated later
Attributes: attributes,
Subpolicies: children,
Subpolicies: childPrimitives,
BatchId: nil, // calculated later
PipelineId: nil, // calculated later
}
Expand Down
28 changes: 14 additions & 14 deletions apstra/connectivity_template/ip_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type IpLink struct {
Ipv4AddressingType types.String `tfsdk:"ipv4_addressing_type"`
Ipv6AddressingType types.String `tfsdk:"ipv6_addressing_type"`
Primitive types.String `tfsdk:"primitive"`
Children types.Set `tfsdk:"children"`
ChildPrimitives types.Set `tfsdk:"child_primitives"`
}

func (o IpLink) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
Expand Down Expand Up @@ -74,9 +74,9 @@ func (o IpLink) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
"Template JsonPrimitive data source",
Computed: true,
},
"children": dataSourceSchema.SetAttribute{
"child_primitives": dataSourceSchema.SetAttribute{
MarkdownDescription: "Set of JSON strings describing Connectivity Template Primitives " +
"which are children of this Connectivity Template JsonPrimitive. Use the `primitive` " +
"which are children of this Connectivity Template Primitive. Use the `primitive` " +
"attribute of other Connectivity Template Primitives data sources here.",
ElementType: types.StringType,
Validators: []validator.Set{setvalidator.SizeAtLeast(1)},
Expand All @@ -86,16 +86,16 @@ func (o IpLink) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
}

func (o IpLink) Marshal(ctx context.Context, diags *diag.Diagnostics) string {
var children []string
diags.Append(o.Children.ElementsAs(ctx, &children, false)...)
var childPrimitives []string
diags.Append(o.ChildPrimitives.ElementsAs(ctx, &childPrimitives, false)...)
if diags.HasError() {
return ""
}

// sort the children by their SHA1 sums for easier comparison of nested strings
sort.Slice(children, func(i, j int) bool {
sum1 := sha1.Sum([]byte(children[i]))
sum2 := sha1.Sum([]byte(children[j]))
// sort the childPrimitives by their SHA1 sums for easier comparison of nested strings
sort.Slice(childPrimitives, func(i, j int) bool {
sum1 := sha1.Sum([]byte(childPrimitives[i]))
sum2 := sha1.Sum([]byte(childPrimitives[j]))
return bytes.Compare(sum1[:], sum2[:]) >= 0
})

Expand All @@ -105,7 +105,7 @@ func (o IpLink) Marshal(ctx context.Context, diags *diag.Diagnostics) string {
VlanId: nil,
Ipv4AddressingType: o.Ipv4AddressingType.ValueString(),
Ipv6AddressingType: o.Ipv6AddressingType.ValueString(),
Children: children,
ChildPrimitives: childPrimitives,
}

if !o.VlanId.IsNull() {
Expand Down Expand Up @@ -159,7 +159,7 @@ func (o *IpLink) loadSdkPrimitive(ctx context.Context, in apstra.ConnectivityTem
}
o.Ipv4AddressingType = types.StringValue(attributes.IPv4AddressingType.String())
o.Ipv6AddressingType = types.StringValue(attributes.IPv6AddressingType.String())
o.Children = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
o.ChildPrimitives = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
}

var _ JsonPrimitive = &ipLinkPrototype{}
Expand All @@ -170,7 +170,7 @@ type ipLinkPrototype struct {
VlanId *int64 `json:"vlan_id,omitempty"`
Ipv4AddressingType string `json:"ipv4_addressing_type"`
Ipv6AddressingType string `json:"ipv6_addressing_type"`
Children []string `json:"children,omitempty"`
ChildPrimitives []string `json:"child_primitives,omitempty"`
}

func (o ipLinkPrototype) attributes(_ context.Context, path path.Path, diags *diag.Diagnostics) apstra.ConnectivityTemplatePrimitiveAttributes {
Expand Down Expand Up @@ -208,15 +208,15 @@ func (o ipLinkPrototype) ToSdkPrimitive(ctx context.Context, path path.Path, dia
return nil
}

children := ChildPrimitivesFromListOfJsonStrings(ctx, o.Children, path, diags)
childPrimitives := ChildPrimitivesFromListOfJsonStrings(ctx, o.ChildPrimitives, path, diags)
if diags.HasError() {
return nil
}

return &apstra.ConnectivityTemplatePrimitive{
Id: nil, // calculated later
Attributes: attributes,
Subpolicies: children,
Subpolicies: childPrimitives,
BatchId: nil, // calculated later
PipelineId: nil, // calculated later
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/connectivity_template/routing_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (o RoutingPolicy) DataSourceAttributes() map[string]dataSourceSchema.Attrib
"primitive": dataSourceSchema.StringAttribute{
MarkdownDescription: "JSON output for use in the `primitives` field of an " +
"`apstra_datacenter_connectivity_template` resource or a different Connectivity " +
"Template JsonPrimitive data source",
"Template Primitive data source",
Computed: true,
},
}
Expand Down
42 changes: 21 additions & 21 deletions apstra/connectivity_template/vn_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
var _ Primitive = &VnSingle{}

type VnSingle struct {
VnId types.String `tfsdk:"vn_id"`
Tagged types.Bool `tfsdk:"tagged"`
Primitive types.String `tfsdk:"primitive"`
Children types.Set `tfsdk:"children"`
VnId types.String `tfsdk:"vn_id"`
Tagged types.Bool `tfsdk:"tagged"`
Primitive types.String `tfsdk:"primitive"`
ChildPrimitives types.Set `tfsdk:"child_primitives"`
}

func (o VnSingle) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
Expand All @@ -45,9 +45,9 @@ func (o VnSingle) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
"Template JsonPrimitive data source",
Computed: true,
},
"children": dataSourceSchema.SetAttribute{
"child_primitives": dataSourceSchema.SetAttribute{
MarkdownDescription: "Set of JSON strings describing Connectivity Template Primitives " +
"which are children of this Connectivity Template JsonPrimitive. Use the `primitive` " +
"which are children of this Connectivity Template Primitive. Use the `primitive` " +
"attribute of other Connectivity Template Primitives data sources here.",
ElementType: types.StringType,
Validators: []validator.Set{setvalidator.SizeAtLeast(1)},
Expand All @@ -57,23 +57,23 @@ func (o VnSingle) DataSourceAttributes() map[string]dataSourceSchema.Attribute {
}

func (o VnSingle) Marshal(ctx context.Context, diags *diag.Diagnostics) string {
var children []string
diags.Append(o.Children.ElementsAs(ctx, &children, false)...)
var childPrimitives []string
diags.Append(o.ChildPrimitives.ElementsAs(ctx, &childPrimitives, false)...)
if diags.HasError() {
return ""
}

// sort the children by their SHA1 sums for easier comparison of nested strings
sort.Slice(children, func(i, j int) bool {
sum1 := sha1.Sum([]byte(children[i]))
sum2 := sha1.Sum([]byte(children[j]))
// sort the childPrimitives by their SHA1 sums for easier comparison of nested strings
sort.Slice(childPrimitives, func(i, j int) bool {
sum1 := sha1.Sum([]byte(childPrimitives[i]))
sum2 := sha1.Sum([]byte(childPrimitives[j]))
return bytes.Compare(sum1[:], sum2[:]) >= 0
})

obj := vnSinglePrototype{
VnId: o.VnId.ValueString(),
Tagged: o.Tagged.ValueBool(),
Children: children,
VnId: o.VnId.ValueString(),
Tagged: o.Tagged.ValueBool(),
ChildPrimitives: childPrimitives,
}

data, err := json.Marshal(&obj)
Expand Down Expand Up @@ -107,15 +107,15 @@ func (o *VnSingle) loadSdkPrimitive(ctx context.Context, in apstra.ConnectivityT
o.VnId = types.StringNull()
}
o.Tagged = types.BoolValue(attributes.Tagged)
o.Children = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
o.ChildPrimitives = utils.SetValueOrNull(ctx, types.StringType, SdkPrimitivesToJsonStrings(ctx, in.Subpolicies, diags), diags)
}

var _ JsonPrimitive = &vnSinglePrototype{}

type vnSinglePrototype struct {
VnId string `json:"vn_id"`
Tagged bool `json:"tagged"`
Children []string `json:"children,omitempty"`
VnId string `json:"vn_id"`
Tagged bool `json:"tagged"`
ChildPrimitives []string `json:"child_primitives,omitempty"`
}

func (o vnSinglePrototype) attributes(_ context.Context, _ path.Path, _ *diag.Diagnostics) apstra.ConnectivityTemplatePrimitiveAttributes {
Expand All @@ -132,15 +132,15 @@ func (o vnSinglePrototype) ToSdkPrimitive(ctx context.Context, path path.Path, d
return nil
}

children := ChildPrimitivesFromListOfJsonStrings(ctx, o.Children, path, diags)
childPrimitives := ChildPrimitivesFromListOfJsonStrings(ctx, o.ChildPrimitives, path, diags)
if diags.HasError() {
return nil
}

return &apstra.ConnectivityTemplatePrimitive{
Id: nil, // calculated later
Attributes: attributes,
Subpolicies: children,
Subpolicies: childPrimitives,
BatchId: nil, // calculated later
PipelineId: nil, // calculated later
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *dataSourceDatacenterCtBgpPeeringGenericSystem) Schema(_ context.Context
resp.Schema = schema.Schema{
MarkdownDescription: "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` " +
"resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.",
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
Attributes: connectivitytemplate.BgpPeeringGenericSystem{}.DataSourceAttributes(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/data_source_datacenter_ct_ip_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *dataSourceDatacenterCtIpLink) Schema(_ context.Context, _ datasource.Sc
resp.Schema = schema.Schema{
MarkdownDescription: "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` " +
"resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.",
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
Attributes: connectivitytemplate.IpLink{}.DataSourceAttributes(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/data_source_datacenter_ct_routing_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *dataSourceDatacenterCtRoutingPolicy) Schema(_ context.Context, _ dataso
resp.Schema = schema.Schema{
MarkdownDescription: "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` " +
"resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.",
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
Attributes: connectivitytemplate.RoutingPolicy{}.DataSourceAttributes(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/data_source_datacenter_ct_static_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *dataSourceDatacenterCtStaticRoute) Schema(_ context.Context, _ datasour
resp.Schema = schema.Schema{
MarkdownDescription: "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` " +
"resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.",
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
Attributes: connectivitytemplate.StaticRoute{}.DataSourceAttributes(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion apstra/data_source_datacenter_ct_virtual_network_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *dataSourceDatacenterCtVnSingle) Schema(_ context.Context, _ datasource.
resp.Schema = schema.Schema{
MarkdownDescription: "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` " +
"resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.",
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
Attributes: connectivitytemplate.VnSingle{}.DataSourceAttributes(),
}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/data-sources/datacenter_ct_bgp_peering_generic_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
page_title: "apstra_datacenter_ct_bgp_peering_generic_system Data Source - terraform-provider-apstra"
subcategory: ""
description: |-
This data source composes a Connectivity Template Primitive as a JSON string, suitable for use in the primitives attribute of either an apstra_datacenter_connectivity_template resource or the children attribute of a Different Connectivity Template JsonPrimitive.
This data source composes a Connectivity Template Primitive as a JSON string, suitable for use in the primitives attribute of either an apstra_datacenter_connectivity_template resource or the child_primitives attribute of a Different Connectivity Template Primitive.
---

# apstra_datacenter_ct_bgp_peering_generic_system (Data Source)

This data source composes a Connectivity Template Primitive as a JSON string, suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` resource or the `children` attribute of a Different Connectivity Template JsonPrimitive.
This data source composes a Connectivity Template Primitive as a JSON string, suitable for use in the `primitives` attribute of either an `apstra_datacenter_connectivity_template` resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.

## Example Usage

Expand Down Expand Up @@ -53,7 +53,7 @@ data "apstra_datacenter_ct_bgp_peering_generic_system" "bgp_server" {
# "neighbor_asn_dynamic": false,
# "peer_from_loopback": false,
# "peer_to": "interface_or_ip_endpoint",
# "children": null
# "child_primitives": null
# }
# }
Expand All @@ -63,7 +63,7 @@ data "apstra_datacenter_ct_ip_link" "ip_link_with_bgp" {
vlan_id = 3
ipv4_addressing_type = "numbered"
ipv6_addressing_type = "link_local"
children = [
child_primitives = [
data.apstra_datacenter_ct_bgp_peering_generic_system.bgp_server.primitive,
]
}
Expand All @@ -78,8 +78,8 @@ data "apstra_datacenter_ct_ip_link" "ip_link_with_bgp" {
# "vlan_id": 3,
# "ipv4_addressing_type": "numbered",
# "ipv6_addressing_type": "link_local",
# "children": [
# "{\"type\":\"AttachLogicalLink\",\"data\":{\"ipv4_afi_enabled\":true,\"ipv6_afi_enabled\":true,\"ttl\":1,\"bfd_enabled\":true,\"password\":\"big secret\",\"keepalive_time\":null,\"hold_time\":null,\"ipv4_addressing_type\":\"addressed\",\"ipv6_addressing_type\":\"link_local\",\"local_asn\":null,\"neighbor_asn_dynamic\":false,\"peer_from_loopback\":false,\"peer_to\":\"interface_or_ip_endpoint\",\"children\":null}}"
# "child_primitives": [
# "{\"type\":\"AttachLogicalLink\",\"data\":{\"ipv4_afi_enabled\":true,\"ipv6_afi_enabled\":true,\"ttl\":1,\"bfd_enabled\":true,\"password\":\"big secret\",\"keepalive_time\":null,\"hold_time\":null,\"ipv4_addressing_type\":\"addressed\",\"ipv6_addressing_type\":\"link_local\",\"local_asn\":null,\"neighbor_asn_dynamic\":false,\"peer_from_loopback\":false,\"peer_to\":\"interface_or_ip_endpoint\",\"child_primitives\":null}}"
# ]
# }
# }
Expand All @@ -105,7 +105,7 @@ resource "apstra_datacenter_connectivity_template" "t" {
### Optional

- `bfd_enabled` (Boolean) Enable BFD.
- `children` (Set of String) Set of JSON strings describing Connectivity Template Primitives which are children of this Connectivity Template JsonPrimitive. Use the `primitive` attribute of other Connectivity Template Primitives data sources here.
- `child_primitives` (Set of String) Set of JSON strings describing Connectivity Template Primitives which are children of this Connectivity Template Primitive. Use the `primitive` attribute of other Connectivity Template Primitives data sources here.
- `hold_time` (Number) BGP hold time (seconds).
- `ipv4_addressing_type` (String) One of `none`, `addressed` (or omit)
- `ipv4_afi_enabled` (Boolean) IPv4 Address Family Identifier
Expand Down
Loading

0 comments on commit 40e83ab

Please sign in to comment.