Skip to content

Commit

Permalink
Merge pull request #854 from Juniper/bump-sdk-version
Browse files Browse the repository at this point in the history
Bump SDK version
  • Loading branch information
chrismarget-j authored Sep 16, 2024
2 parents ded39c8 + cbb29be commit d47d714
Show file tree
Hide file tree
Showing 37 changed files with 307 additions and 382 deletions.
8 changes: 5 additions & 3 deletions apstra/analytics/telemetry_service_registry_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"strings"

"github.com/Juniper/apstra-go-sdk/apstra/enum"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
Expand Down Expand Up @@ -71,11 +73,11 @@ func (o TelemetryServiceRegistryEntry) ResourceAttributes() map[string]resourceS
Required: true,
},
"storage_schema_path": resourceSchema.StringAttribute{
MarkdownDescription: "Storage Schema Path. Must be one of:\n - " + strings.Join([]string{utils.StringersToFriendlyString(apstra.StorageSchemaPathIBA_STRING_DATA), utils.StringersToFriendlyString(apstra.StorageSchemaPathIBA_INTEGER_DATA)}, "\n - ") + "\n",
MarkdownDescription: "Storage Schema Path. Must be one of:\n - " + strings.Join([]string{utils.StringersToFriendlyString(enum.StorageSchemaPathIBA_STRING_DATA), utils.StringersToFriendlyString(enum.StorageSchemaPathIBA_INTEGER_DATA)}, "\n - ") + "\n",
Required: true,
Validators: []validator.String{
stringvalidator.LengthAtLeast(1),
stringvalidator.OneOf(utils.StringersToFriendlyString(apstra.StorageSchemaPathIBA_STRING_DATA), utils.StringersToFriendlyString(apstra.StorageSchemaPathIBA_INTEGER_DATA)),
stringvalidator.OneOf(utils.StringersToFriendlyString(enum.StorageSchemaPathIBA_STRING_DATA), utils.StringersToFriendlyString(enum.StorageSchemaPathIBA_INTEGER_DATA)),
},
},
"description": resourceSchema.StringAttribute{
Expand Down Expand Up @@ -104,7 +106,7 @@ func (o *TelemetryServiceRegistryEntry) LoadApiData(ctx context.Context, in *aps
}

func (o *TelemetryServiceRegistryEntry) Request(_ context.Context, diags *diag.Diagnostics) *apstra.TelemetryServiceRegistryEntry {
var storageSchemaPath apstra.StorageSchemaPath
var storageSchemaPath enum.StorageSchemaPath
err := utils.ApiStringerFromFriendlyString(&storageSchemaPath, o.StorageSchemaPath.ValueString())
if err != nil {
diags.AddError("Failed to Parse Storage Schema Path", err.Error())
Expand Down
29 changes: 15 additions & 14 deletions apstra/blueprint/blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
apiversions "github.com/Juniper/terraform-provider-apstra/apstra/api_versions"
apstraplanmodifier "github.com/Juniper/terraform-provider-apstra/apstra/apstra_plan_modifier"
apstravalidator "github.com/Juniper/terraform-provider-apstra/apstra/apstra_validator"
Expand Down Expand Up @@ -844,9 +845,9 @@ func (o *Blueprint) FabricSettings(ctx context.Context, diags *diag.Diagnostics)
}

if utils.HasValue(o.EvpnType5Routes) {
result.EvpnGenerateType5HostRoutes = &apstra.FeatureSwitchEnumDisabled
result.EvpnGenerateType5HostRoutes = &enum.FeatureSwitchEnumDisabled
if o.EvpnType5Routes.ValueBool() {
result.EvpnGenerateType5HostRoutes = &apstra.FeatureSwitchEnumEnabled
result.EvpnGenerateType5HostRoutes = &enum.FeatureSwitchEnumEnabled
}
}

Expand All @@ -863,30 +864,30 @@ func (o *Blueprint) FabricSettings(ctx context.Context, diags *diag.Diagnostics)
}

if utils.HasValue(o.JunosEvpnMaxNexthopAndInterfaceNumber) {
result.JunosEvpnMaxNexthopAndInterfaceNumber = &apstra.FeatureSwitchEnumDisabled
result.JunosEvpnMaxNexthopAndInterfaceNumber = &enum.FeatureSwitchEnumDisabled
if o.JunosEvpnMaxNexthopAndInterfaceNumber.ValueBool() {
result.JunosEvpnMaxNexthopAndInterfaceNumber = &apstra.FeatureSwitchEnumEnabled
result.JunosEvpnMaxNexthopAndInterfaceNumber = &enum.FeatureSwitchEnumEnabled
}
}

if utils.HasValue(o.JunosEvpnRoutingInstanceModeMacVrf) {
result.JunosEvpnRoutingInstanceVlanAware = &apstra.FeatureSwitchEnumDisabled
result.JunosEvpnRoutingInstanceVlanAware = &enum.FeatureSwitchEnumDisabled
if o.JunosEvpnRoutingInstanceModeMacVrf.ValueBool() {
result.JunosEvpnRoutingInstanceVlanAware = &apstra.FeatureSwitchEnumEnabled
result.JunosEvpnRoutingInstanceVlanAware = &enum.FeatureSwitchEnumEnabled
}
}

if utils.HasValue(o.JunosExOverlayEcmp) {
result.JunosExOverlayEcmp = &apstra.FeatureSwitchEnumDisabled
result.JunosExOverlayEcmp = &enum.FeatureSwitchEnumDisabled
if o.JunosExOverlayEcmp.ValueBool() {
result.JunosExOverlayEcmp = &apstra.FeatureSwitchEnumEnabled
result.JunosExOverlayEcmp = &enum.FeatureSwitchEnumEnabled
}
}

if utils.HasValue(o.JunosGracefulRestart) {
result.JunosGracefulRestart = &apstra.FeatureSwitchEnumDisabled
result.JunosGracefulRestart = &enum.FeatureSwitchEnumDisabled
if o.JunosGracefulRestart.ValueBool() {
result.JunosGracefulRestart = &apstra.FeatureSwitchEnumEnabled
result.JunosGracefulRestart = &enum.FeatureSwitchEnumEnabled
}
}

Expand All @@ -907,9 +908,9 @@ func (o *Blueprint) FabricSettings(ctx context.Context, diags *diag.Diagnostics)
}

if utils.HasValue(o.OptimizeRoutingZoneFootprint) {
result.OptimiseSzFootprint = &apstra.FeatureSwitchEnumDisabled
result.OptimiseSzFootprint = &enum.FeatureSwitchEnumDisabled
if o.OptimizeRoutingZoneFootprint.ValueBool() {
result.OptimiseSzFootprint = &apstra.FeatureSwitchEnumEnabled
result.OptimiseSzFootprint = &enum.FeatureSwitchEnumEnabled
}
}

Expand Down Expand Up @@ -960,10 +961,10 @@ func boolAttrValueFromBoolPtr(b *bool) types.Bool {
return types.BoolValue(*b)
}

func boolAttrValueFromFeatureswitchEnumPtr(fs *apstra.FeatureSwitchEnum) types.Bool {
func boolAttrValueFromFeatureswitchEnumPtr(fs *enum.FeatureSwitchEnum) types.Bool {
if fs == nil {
return types.BoolNull()
}

return types.BoolValue(fs.Value == apstra.FeatureSwitchEnumEnabled.Value)
return types.BoolValue(fs.Value == enum.FeatureSwitchEnumEnabled.Value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
apstravalidator "github.com/Juniper/terraform-provider-apstra/apstra/apstra_validator"
"github.com/Juniper/terraform-provider-apstra/apstra/constants"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
Expand Down Expand Up @@ -194,8 +195,8 @@ func (o BgpPeeringGenericSystem) attributes(_ context.Context, diags *diag.Diagn
// Label: o.Name.ValueString(), // todo is this necessary?
Bfd: o.BfdEnabled.ValueBool(),
Holdtime: holdTime,
Ipv4Safi: o.Ipv4AddressingType.ValueString() != utils.StringersToFriendlyString(apstra.InterfaceNumberingIpv4TypeNone),
Ipv6Safi: o.Ipv6AddressingType.ValueString() != utils.StringersToFriendlyString(apstra.InterfaceNumberingIpv6TypeNone),
Ipv4Safi: o.Ipv4AddressingType.ValueString() != utils.StringersToFriendlyString(enum.InterfaceNumberingIpv4TypeNone),
Ipv6Safi: o.Ipv6AddressingType.ValueString() != utils.StringersToFriendlyString(enum.InterfaceNumberingIpv6TypeNone),
Keepalive: keepaliveTime,
LocalAsn: localAsn,
NeighborAsnDynamic: o.NeighborAsnDynamic.ValueBool(),
Expand Down
26 changes: 14 additions & 12 deletions apstra/blueprint/datacenter_external_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package blueprint
import (
"context"
"fmt"
"math"
"net"
"strings"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
"github.com/Juniper/terraform-provider-apstra/apstra/constants"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework-nettypes/iptypes"
Expand All @@ -20,9 +25,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"math"
"net"
"strings"
)

type DatacenterExternalGateway struct {
Expand Down Expand Up @@ -87,12 +89,12 @@ func (o DatacenterExternalGateway) ResourceAttributes() map[string]resourceSchem
},
"evpn_route_types": resourceSchema.StringAttribute{
MarkdownDescription: fmt.Sprintf(`EVPN route types. Valid values are: ["%s"]. Default: %q`,
strings.Join(apstra.RemoteGatewayRouteTypesEnum.Values(), `", "`),
apstra.RemoteGatewayRouteTypesAll.Value),
strings.Join(enum.RemoteGatewayRouteTypesEnum.Values(), `", "`),
enum.RemoteGatewayRouteTypesAll.Value),
Optional: true,
Computed: true,
Default: stringdefault.StaticString(apstra.RemoteGatewayRouteTypesAll.Value),
Validators: []validator.String{stringvalidator.OneOf(apstra.RemoteGatewayRouteTypesEnum.Values()...)},
Default: stringdefault.StaticString(enum.RemoteGatewayRouteTypesAll.Value),
Validators: []validator.String{stringvalidator.OneOf(enum.RemoteGatewayRouteTypesEnum.Values()...)},
},
"local_gateway_nodes": resourceSchema.SetAttribute{
MarkdownDescription: "Set of IDs of switch nodes which will be configured to peer with the External Gateway",
Expand Down Expand Up @@ -158,8 +160,8 @@ func (o DatacenterExternalGateway) DataSourceAttributes() map[string]dataSourceS
},
"evpn_route_types": dataSourceSchema.StringAttribute{
MarkdownDescription: fmt.Sprintf(`EVPN route types. Valid values are: ["%s"]. Default: %q`,
strings.Join(apstra.RemoteGatewayRouteTypesEnum.Values(), `", "`),
apstra.RemoteGatewayRouteTypesAll.Value),
strings.Join(enum.RemoteGatewayRouteTypesEnum.Values(), `", "`),
enum.RemoteGatewayRouteTypesAll.Value),
Computed: true,
},
"local_gateway_nodes": dataSourceSchema.SetAttribute{
Expand Down Expand Up @@ -214,8 +216,8 @@ func (o DatacenterExternalGateway) DataSourceAttributesAsFilter() map[string]dat
},
"evpn_route_types": dataSourceSchema.StringAttribute{
MarkdownDescription: fmt.Sprintf(`EVPN route types. Valid values are: ["%s"]. Default: %q`,
strings.Join(apstra.RemoteGatewayRouteTypesEnum.Values(), `", "`),
apstra.RemoteGatewayRouteTypesAll.Value),
strings.Join(enum.RemoteGatewayRouteTypesEnum.Values(), `", "`),
enum.RemoteGatewayRouteTypesAll.Value),
Optional: true,
},
"local_gateway_nodes": dataSourceSchema.SetAttribute{
Expand All @@ -232,7 +234,7 @@ func (o DatacenterExternalGateway) DataSourceAttributesAsFilter() map[string]dat
}

func (o *DatacenterExternalGateway) Request(ctx context.Context, diags *diag.Diagnostics) *apstra.RemoteGatewayData {
routeTypes := apstra.RemoteGatewayRouteTypesEnum.Parse(o.EvpnRouteTypes.ValueString())
routeTypes := enum.RemoteGatewayRouteTypesEnum.Parse(o.EvpnRouteTypes.ValueString())
// skipping nil check because input validation should make that impossible

var localGwNodes []apstra.ObjectId
Expand Down
8 changes: 4 additions & 4 deletions apstra/blueprint/datacenter_generic_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"regexp"
"sort"

"github.com/Juniper/terraform-provider-apstra/apstra/constants"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
apiversions "github.com/Juniper/terraform-provider-apstra/apstra/api_versions"
"github.com/Juniper/terraform-provider-apstra/apstra/constants"
"github.com/Juniper/terraform-provider-apstra/apstra/design"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework-nettypes/cidrtypes"
Expand Down Expand Up @@ -158,10 +158,10 @@ func (o DatacenterGenericSystem) ResourceAttributes() map[string]resourceSchema.
},
"deploy_mode": resourceSchema.StringAttribute{
MarkdownDescription: fmt.Sprintf("Set the Apstra Deploy Mode for this Generic System. Default: `%s`",
apstra.DeployModeDeploy),
enum.DeployModeDeploy),
Optional: true,
Computed: true,
Default: stringdefault.StaticString(apstra.DeployModeDeploy.String()),
Default: stringdefault.StaticString(enum.DeployModeDeploy.String()),
Validators: []validator.String{stringvalidator.OneOf(utils.AllNodeDeployModes()...)},
},
"clear_cts_on_destroy": resourceSchema.BoolAttribute{
Expand Down
7 changes: 4 additions & 3 deletions apstra/blueprint/datacenter_routing_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"regexp"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/apstra-go-sdk/apstra/enum"
apstravalidator "github.com/Juniper/terraform-provider-apstra/apstra/apstra_validator"
"github.com/Juniper/terraform-provider-apstra/apstra/constants"
"github.com/Juniper/terraform-provider-apstra/apstra/design"
Expand All @@ -24,7 +25,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

var junosEvpnIrbModeDefault = apstra.JunosEvpnIrbModeAsymmetric.Value
var junosEvpnIrbModeDefault = enum.JunosEvpnIrbModeAsymmetric.Value

type DatacenterRoutingZone struct {
Id types.String `tfsdk:"id"`
Expand Down Expand Up @@ -285,7 +286,7 @@ func (o DatacenterRoutingZone) ResourceAttributes() map[string]resourceSchema.At
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
Validators: []validator.String{stringvalidator.OneOf(apstra.JunosEvpnIrbModes.Values()...)},
Validators: []validator.String{stringvalidator.OneOf(enum.JunosEvpnIrbModes.Values()...)},
// Default: DO NOT USE stringdefault.StaticString(apstra.JunosEvpnIrbModeAsymmetric.Value) here
// because that will set the attribute for Apstra < 4.2.0 (which do not support it) leading to
// confusion.
Expand Down Expand Up @@ -332,7 +333,7 @@ func (o *DatacenterRoutingZone) Request(ctx context.Context, client *apstra.Clie
RoutingPolicyId: apstra.ObjectId(o.RoutingPolicyId.ValueString()),
VlanId: vlan,
VniId: vni,
JunosEvpnIrbMode: apstra.JunosEvpnIrbModes.Parse(o.JunosEvpnIrbMode.ValueString()),
JunosEvpnIrbMode: enum.JunosEvpnIrbModes.Parse(o.JunosEvpnIrbMode.ValueString()),
RtPolicy: &apstra.RtPolicy{
ImportRTs: importRTs,
ExportRTs: exportRTs,
Expand Down
Loading

0 comments on commit d47d714

Please sign in to comment.