From 2ed614e39d7df1a648427c6015383b1a1f4037ca Mon Sep 17 00:00:00 2001 From: Chris Marget Date: Mon, 16 Sep 2024 12:52:47 -0400 Subject: [PATCH] use `enum` package for objects which have moved --- .../data_source_datacenter_blueprint_test.go | 3 +- ...source_datacenter_external_gateway_test.go | 12 ++- ...r_connectivity_template_primitives_test.go | 5 +- ...ource_datacenter_device_allocation_test.go | 95 ++++++++++--------- ...source_datacenter_external_gateway_test.go | 30 +++--- ...esource_datacenter_security_policy_test.go | 48 +++++----- ...eform_allocation_group_integration_test.go | 23 ++--- ...resource_freeform_link_integration_test.go | 9 +- ...form_resource_generator_integraion_test.go | 35 +++---- ...ource_freeform_resource_integraion_test.go | 61 ++++++------ ...source_freeform_system_integration_test.go | 13 +-- 11 files changed, 174 insertions(+), 160 deletions(-) diff --git a/apstra/data_source_datacenter_blueprint_test.go b/apstra/data_source_datacenter_blueprint_test.go index 2e97c251..7c087ba1 100644 --- a/apstra/data_source_datacenter_blueprint_test.go +++ b/apstra/data_source_datacenter_blueprint_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/go-version" @@ -51,7 +52,7 @@ func TestDatasourceDatacenterBlueprint(t *testing.T) { }, // DefaultSviL3Mtu: nil, EsiMacMsb: utils.ToPtr(uint8(4)), - EvpnGenerateType5HostRoutes: &apstra.FeatureSwitchEnumEnabled, + EvpnGenerateType5HostRoutes: &enum.FeatureSwitchEnumEnabled, ExternalRouterMtu: utils.ToPtr(uint16(9002)), // FabricL3Mtu: nil, Ipv6Enabled: utils.ToPtr(true), diff --git a/apstra/data_source_datacenter_external_gateway_test.go b/apstra/data_source_datacenter_external_gateway_test.go index 38ba280c..ad955d91 100644 --- a/apstra/data_source_datacenter_external_gateway_test.go +++ b/apstra/data_source_datacenter_external_gateway_test.go @@ -5,12 +5,14 @@ package tfapstra_test import ( "context" "fmt" + "math/rand" + "testing" + "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "math/rand" - "testing" ) const ( @@ -47,7 +49,7 @@ func TestDatacenterExternalGateway(t *testing.T) { rgConfigs := []apstra.RemoteGatewayData{ { - RouteTypes: apstra.RemoteGatewayRouteTypesAll, + RouteTypes: enum.RemoteGatewayRouteTypesAll, LocalGwNodes: leafIds, GwAsn: rand.Uint32(), GwIp: randIpvAddressMust(t, "10.0.0.0/8"), @@ -58,7 +60,7 @@ func TestDatacenterExternalGateway(t *testing.T) { Password: &password, }, { - RouteTypes: apstra.RemoteGatewayRouteTypesFiveOnly, + RouteTypes: enum.RemoteGatewayRouteTypesFiveOnly, LocalGwNodes: leafIds, GwAsn: rand.Uint32(), GwIp: randIpvAddressMust(t, "10.0.0.0/8"), @@ -137,7 +139,7 @@ func TestDatacenterExternalGateway(t *testing.T) { resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - //Steps: stepsById, + // Steps: stepsById, Steps: append(stepsById, stepsByName...), }) } diff --git a/apstra/resource_datacenter_connectivity_template_primitives_test.go b/apstra/resource_datacenter_connectivity_template_primitives_test.go index 42106c6f..50d2c77a 100644 --- a/apstra/resource_datacenter_connectivity_template_primitives_test.go +++ b/apstra/resource_datacenter_connectivity_template_primitives_test.go @@ -5,7 +5,6 @@ package tfapstra_test import ( "context" "fmt" - testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "math/rand/v2" "net" "strconv" @@ -13,8 +12,10 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" "github.com/Juniper/terraform-provider-apstra/apstra/constants" + testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/stretchr/testify/require" @@ -798,7 +799,7 @@ func randomRoutingZoneConstraints(t testing.TB, ctx context.Context, count int, for i := range result { policyId, err := client.CreateRoutingZoneConstraint(ctx, &apstra.RoutingZoneConstraintData{ Label: acctest.RandString(6), - Mode: oneOf(apstra.RoutingZoneConstraintModeAllow, apstra.RoutingZoneConstraintModeDeny, apstra.RoutingZoneConstraintModeNone), + Mode: oneOf(enum.RoutingZoneConstraintModeAllow, enum.RoutingZoneConstraintModeDeny, enum.RoutingZoneConstraintModeNone), MaxRoutingZones: oneOf(nil, utils.ToPtr(0), utils.ToPtr(1), utils.ToPtr(2)), RoutingZoneIds: nil, }) diff --git a/apstra/resource_datacenter_device_allocation_test.go b/apstra/resource_datacenter_device_allocation_test.go index 1dabeced..a90e5c06 100644 --- a/apstra/resource_datacenter_device_allocation_test.go +++ b/apstra/resource_datacenter_device_allocation_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -153,7 +154,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { IP: net.IP{1, 1, 1, 1}, Mask: net.CIDRMask(32, 32), }, - deployMode: utils.StringersToFriendlyString(apstra.DeployModeReady), + deployMode: utils.StringersToFriendlyString(enum.DeployModeReady), tags: []string{"one"}, }, }, @@ -161,12 +162,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "SPINE1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "spine1.test"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "1.1.1.1/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "1"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "one"), }, @@ -184,7 +185,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { IP: net.IP{2, 2, 2, 2}, Mask: net.CIDRMask(32, 32), }, - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), tags: []string{"two", "2"}, }, }, @@ -192,12 +193,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "SPINE2"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "spine2.test"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "2"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "2.2.2.2/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "2"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "two"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "2"), @@ -219,8 +220,8 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-7x10-Leaf"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), }, }, { @@ -233,7 +234,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { hostname: "leafstartminimalhostname.com", asn: utils.ToPtr(1), loopbackIpv4: &net.IPNet{IP: net.IP{1, 1, 1, 1}, Mask: net.CIDRMask(32, 32)}, - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), tags: []string{"one", "1"}, }, }, @@ -243,12 +244,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-7x10-Leaf"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "leaf_start_minimal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "leafstartminimalhostname.com"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "1.1.1.1/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "2"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "one"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "1"), @@ -266,12 +267,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-7x10-Leaf"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "leaf_start_minimal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "leafstartminimalhostname.com"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "1.1.1.1/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), }, }, { @@ -302,7 +303,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { hostname: "leafstartmaximalhostname.com", asn: utils.ToPtr(1), loopbackIpv4: &net.IPNet{IP: net.IP{1, 1, 1, 1}, Mask: net.CIDRMask(32, 32)}, - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), tags: []string{"one", "1"}, }, }, @@ -312,12 +313,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-7x10-Leaf"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "leaf_start_maximal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "leafstartmaximalhostname.com"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "1.1.1.1/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "2"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "one"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "1"), @@ -335,12 +336,12 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-7x10-Leaf"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "leaf_start_maximal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "leafstartmaximalhostname.com"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.asn", "1"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.loopback_ipv4", "1.1.1.1/32"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), }, }, { @@ -373,8 +374,8 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), }, }, { @@ -385,7 +386,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { systemAttributes: &systemAttributes{ name: "access_start_minimal_name", hostname: "accessstartminimalhostname.com", - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), tags: []string{"one", "1"}, }, }, @@ -395,10 +396,10 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "access_start_minimal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "accessstartminimalhostname.com"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "2"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "one"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "1"), @@ -416,10 +417,10 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "access_start_minimal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "accessstartminimalhostname.com"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), }, }, { @@ -448,7 +449,7 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { systemAttributes: &systemAttributes{ name: "access_start_maximal_name", hostname: "accessstartmaximalhostname.com", - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), tags: []string{"one", "1"}, }, }, @@ -458,10 +459,10 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "access_start_maximal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "accessstartmaximalhostname.com"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.#", "2"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "one"), resource.TestCheckTypeSetElemAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.tags.*", "1"), @@ -479,10 +480,10 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "interface_map_name", "Juniper_vQFX__AOS-8x10-1"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "node_id"), resource.TestCheckResourceAttrSet(resourceDataCenterDeviceAllocationRefName, "device_profile_node_id"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.name", "access_start_maximal_name"), resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.hostname", "accessstartmaximalhostname.com"), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), }, }, { @@ -509,13 +510,13 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { nodeName: "l2_one_access_002_leaf1", initialInterfaceMapId: "Juniper_vQFX__AOS-7x10-Leaf", systemAttributes: &systemAttributes{ - deployMode: utils.StringersToFriendlyString(apstra.DeployModeNone), + deployMode: utils.StringersToFriendlyString(enum.DeployModeNone), }, }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), }, }, { @@ -524,13 +525,13 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { nodeName: "l2_one_access_002_leaf1", initialInterfaceMapId: "Juniper_vQFX__AOS-7x10-Leaf", systemAttributes: &systemAttributes{ - deployMode: utils.StringersToFriendlyString(apstra.DeployModeDrain), + deployMode: utils.StringersToFriendlyString(enum.DeployModeDrain), }, }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeDrain)), }, }, }, @@ -558,13 +559,13 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { nodeName: "l2_esi_acs_dual_001_leaf2", initialInterfaceMapId: "Juniper_vQFX__AOS-7x10-Leaf", systemAttributes: &systemAttributes{ - deployMode: utils.StringersToFriendlyString(apstra.DeployModeReady), + deployMode: utils.StringersToFriendlyString(enum.DeployModeReady), }, }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), }, }, { @@ -573,13 +574,13 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { nodeName: "l2_esi_acs_dual_001_leaf2", initialInterfaceMapId: "Juniper_vQFX__AOS-7x10-Leaf", systemAttributes: &systemAttributes{ - deployMode: utils.StringersToFriendlyString(apstra.DeployModeNone), + deployMode: utils.StringersToFriendlyString(enum.DeployModeNone), }, }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeNone)), }, }, { @@ -588,13 +589,13 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { nodeName: "l2_esi_acs_dual_001_leaf2", initialInterfaceMapId: "Juniper_vQFX__AOS-7x10-Leaf", systemAttributes: &systemAttributes{ - deployMode: utils.StringersToFriendlyString(apstra.DeployModeReady), + deployMode: utils.StringersToFriendlyString(enum.DeployModeReady), }, }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), }, }, { @@ -605,8 +606,8 @@ func TestResourceDatacenterDeviceAllocation(t *testing.T) { }, checks: []resource.TestCheckFunc{ resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "blueprint_id", bpClient.Id().String()), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), - resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(apstra.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), + resource.TestCheckResourceAttr(resourceDataCenterDeviceAllocationRefName, "system_attributes.deploy_mode", utils.StringersToFriendlyString(enum.DeployModeReady)), }, }, }, diff --git a/apstra/resource_datacenter_external_gateway_test.go b/apstra/resource_datacenter_external_gateway_test.go index 56c6978f..610c2005 100644 --- a/apstra/resource_datacenter_external_gateway_test.go +++ b/apstra/resource_datacenter_external_gateway_test.go @@ -5,13 +5,15 @@ package tfapstra_test import ( "context" "fmt" - "github.com/Juniper/apstra-go-sdk/apstra" - testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" "net" "strconv" "strings" "testing" + + "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" + testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) const ( @@ -35,7 +37,7 @@ type testCaseResourceExternalGateway struct { name string ipAddress net.IP asn uint32 - routeTypes apstra.RemoteGatewayRouteTypes + routeTypes enum.RemoteGatewayRouteTypes nodes string ttl *uint8 keepaliveTime *uint16 @@ -74,7 +76,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { name: "name1", ipAddress: net.IP{1, 1, 1, 1}, asn: 1, - routeTypes: apstra.RemoteGatewayRouteTypesAll, + routeTypes: enum.RemoteGatewayRouteTypesAll, nodes: leafIds[0], testCheckFunc: resource.ComposeAggregateTestCheckFunc([]resource.TestCheckFunc{ resource.TestCheckResourceAttrSet("apstra_datacenter_external_gateway.test", "id"), @@ -82,7 +84,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "name", "name1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ip_address", "1.1.1.1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "asn", "1"), - resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", apstra.RemoteGatewayRouteTypesAll.Value), + resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", enum.RemoteGatewayRouteTypesAll.Value), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.#", "1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.0", leafIds[0]), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ttl", "30"), // default @@ -94,7 +96,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { name: "name2", ipAddress: net.IP{1, 1, 1, 2}, asn: 2, - routeTypes: apstra.RemoteGatewayRouteTypesFiveOnly, + routeTypes: enum.RemoteGatewayRouteTypesFiveOnly, nodes: strings.Join(leafIds[1:], `","`), testCheckFunc: resource.ComposeAggregateTestCheckFunc([]resource.TestCheckFunc{ resource.TestCheckResourceAttrSet("apstra_datacenter_external_gateway.test", "id"), @@ -102,7 +104,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "name", "name2"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ip_address", "1.1.1.2"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "asn", "2"), - resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", apstra.RemoteGatewayRouteTypesFiveOnly.Value), + resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", enum.RemoteGatewayRouteTypesFiveOnly.Value), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.#", strconv.Itoa(len(leafIds)-1)), resource.TestCheckTypeSetElemAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.*", leafIds[1]), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ttl", "30"), // default @@ -114,7 +116,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { name: "name3", ipAddress: net.IP{1, 1, 1, 3}, asn: 3, - routeTypes: apstra.RemoteGatewayRouteTypesAll, + routeTypes: enum.RemoteGatewayRouteTypesAll, nodes: leafIds[0], ttl: &uint8Val3, keepaliveTime: &uint16Val1, @@ -126,7 +128,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "name", "name3"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ip_address", "1.1.1.3"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "asn", "3"), - resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", apstra.RemoteGatewayRouteTypesAll.Value), + resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", enum.RemoteGatewayRouteTypesAll.Value), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.#", "1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.0", leafIds[0]), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ttl", "3"), @@ -139,7 +141,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { name: "name1", ipAddress: net.IP{1, 1, 1, 1}, asn: 1, - routeTypes: apstra.RemoteGatewayRouteTypesAll, + routeTypes: enum.RemoteGatewayRouteTypesAll, nodes: leafIds[0], testCheckFunc: resource.ComposeAggregateTestCheckFunc([]resource.TestCheckFunc{ resource.TestCheckResourceAttrSet("apstra_datacenter_external_gateway.test", "id"), @@ -147,7 +149,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "name", "name1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ip_address", "1.1.1.1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "asn", "1"), - resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", apstra.RemoteGatewayRouteTypesAll.Value), + resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", enum.RemoteGatewayRouteTypesAll.Value), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.#", "1"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.0", leafIds[0]), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ttl", "30"), // default @@ -159,7 +161,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { name: "name2", ipAddress: net.IP{1, 1, 1, 2}, asn: 2, - routeTypes: apstra.RemoteGatewayRouteTypesFiveOnly, + routeTypes: enum.RemoteGatewayRouteTypesFiveOnly, nodes: strings.Join(leafIds[1:], `","`), password: "big secret2", testCheckFunc: resource.ComposeAggregateTestCheckFunc([]resource.TestCheckFunc{ @@ -168,7 +170,7 @@ func TestResourceDatacenterExternalGateway(t *testing.T) { resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "name", "name2"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ip_address", "1.1.1.2"), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "asn", "2"), - resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", apstra.RemoteGatewayRouteTypesFiveOnly.Value), + resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "evpn_route_types", enum.RemoteGatewayRouteTypesFiveOnly.Value), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.#", strconv.Itoa(len(leafIds)-1)), resource.TestCheckTypeSetElemAttr("apstra_datacenter_external_gateway.test", "local_gateway_nodes.*", leafIds[1]), resource.TestCheckResourceAttr("apstra_datacenter_external_gateway.test", "ttl", "30"), // default diff --git a/apstra/resource_datacenter_security_policy_test.go b/apstra/resource_datacenter_security_policy_test.go index 2bc0e073..a0a32192 100644 --- a/apstra/resource_datacenter_security_policy_test.go +++ b/apstra/resource_datacenter_security_policy_test.go @@ -5,16 +5,18 @@ package tfapstra_test import ( "context" "fmt" + "strconv" + "strings" + "testing" + "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" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "strconv" - "strings" - "testing" ) const ( @@ -75,12 +77,12 @@ func (o testCaseResourceSecurityPolicy) renderConfig(bpId apstra.ObjectId) strin return sb.String() } - renderEstablished := func(tsq *apstra.TcpStateQualifier) string { + renderEstablished := func(tsq *enum.TcpStateQualifier) string { if tsq == nil { return "null" } - return strconv.FormatBool(*tsq == apstra.TcpStateQualifierEstablished) + return strconv.FormatBool(*tsq == enum.TcpStateQualifierEstablished) } renderRule := func(rule apstra.PolicyRule) string { @@ -238,8 +240,8 @@ func TestResourceDatacenterSecurityPolicy(t *testing.T) { Data: &apstra.PolicyRuleData{ Label: "60", Description: "", - Protocol: apstra.PolicyRuleProtocolIcmp, - Action: apstra.PolicyRuleActionDeny, + Protocol: enum.PolicyRuleProtocolIcmp, + Action: enum.PolicyRuleActionDeny, }, }, }, @@ -263,8 +265,8 @@ func TestResourceDatacenterSecurityPolicy(t *testing.T) { Data: &apstra.PolicyRuleData{ Label: "70", Description: "seventy", - Protocol: apstra.PolicyRuleProtocolIp, - Action: apstra.PolicyRuleActionDenyLog, + Protocol: enum.PolicyRuleProtocolIp, + Action: enum.PolicyRuleActionDenyLog, }, }, }, @@ -291,25 +293,25 @@ func TestResourceDatacenterSecurityPolicy(t *testing.T) { Data: &apstra.PolicyRuleData{ Label: "80", Description: "eighty", - Protocol: apstra.PolicyRuleProtocolUdp, - Action: apstra.PolicyRuleActionPermit, + Protocol: enum.PolicyRuleProtocolUdp, + Action: enum.PolicyRuleActionPermit, }, }, { Data: &apstra.PolicyRuleData{ Label: "81", Description: "eightyone", - Protocol: apstra.PolicyRuleProtocolTcp, - Action: apstra.PolicyRuleActionPermitLog, + Protocol: enum.PolicyRuleProtocolTcp, + Action: enum.PolicyRuleActionPermitLog, }, }, { Data: &apstra.PolicyRuleData{ Label: "82", Description: "eightytwo", - Protocol: apstra.PolicyRuleProtocolTcp, - Action: apstra.PolicyRuleActionPermit, - TcpStateQualifier: &apstra.TcpStateQualifierEstablished, + Protocol: enum.PolicyRuleProtocolTcp, + Action: enum.PolicyRuleActionPermit, + TcpStateQualifier: &enum.TcpStateQualifierEstablished, SrcPort: apstra.PortRanges{ {First: 1, Last: 1}, {First: 3, Last: 5}, @@ -360,25 +362,25 @@ func TestResourceDatacenterSecurityPolicy(t *testing.T) { Data: &apstra.PolicyRuleData{ Label: "90", Description: "ninety", - Protocol: apstra.PolicyRuleProtocolUdp, - Action: apstra.PolicyRuleActionPermit, + Protocol: enum.PolicyRuleProtocolUdp, + Action: enum.PolicyRuleActionPermit, }, }, { Data: &apstra.PolicyRuleData{ Label: "91", Description: "ninetyone", - Protocol: apstra.PolicyRuleProtocolTcp, - Action: apstra.PolicyRuleActionPermitLog, + Protocol: enum.PolicyRuleProtocolTcp, + Action: enum.PolicyRuleActionPermitLog, }, }, { Data: &apstra.PolicyRuleData{ Label: "92", Description: "ninetytwo", - Protocol: apstra.PolicyRuleProtocolTcp, - Action: apstra.PolicyRuleActionPermit, - TcpStateQualifier: &apstra.TcpStateQualifierEstablished, + Protocol: enum.PolicyRuleProtocolTcp, + Action: enum.PolicyRuleActionPermit, + TcpStateQualifier: &enum.TcpStateQualifierEstablished, SrcPort: apstra.PortRanges{ {First: 1, Last: 1}, {First: 7, Last: 9}, diff --git a/apstra/resource_freeform_allocation_group_integration_test.go b/apstra/resource_freeform_allocation_group_integration_test.go index 91326a1b..afc1f79d 100644 --- a/apstra/resource_freeform_allocation_group_integration_test.go +++ b/apstra/resource_freeform_allocation_group_integration_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" @@ -32,7 +33,7 @@ resource %q %q { type resourceAllocGroup struct { blueprintId string name string - groupType apstra.ResourcePoolType + groupType enum.ResourcePoolType poolIds []string } @@ -184,7 +185,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_asn"), - groupType: apstra.ResourcePoolTypeAsn, + groupType: enum.ResourcePoolTypeAsn, poolIds: []string{newAsnPool(t)}, }, }, @@ -192,7 +193,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_asn"), - groupType: apstra.ResourcePoolTypeAsn, + groupType: enum.ResourcePoolTypeAsn, poolIds: []string{newAsnPool(t), newAsnPool(t)}, }, }, @@ -204,7 +205,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_int"), - groupType: apstra.ResourcePoolTypeInt, + groupType: enum.ResourcePoolTypeInt, poolIds: []string{newIntPool(t)}, }, }, @@ -212,7 +213,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_int"), - groupType: apstra.ResourcePoolTypeInt, + groupType: enum.ResourcePoolTypeInt, poolIds: []string{newIntPool(t)}, }, }, @@ -224,7 +225,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_vni"), - groupType: apstra.ResourcePoolTypeVni, + groupType: enum.ResourcePoolTypeVni, poolIds: []string{newVniPool(t)}, }, }, @@ -232,7 +233,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_vni"), - groupType: apstra.ResourcePoolTypeVni, + groupType: enum.ResourcePoolTypeVni, poolIds: []string{newVniPool(t)}, }, }, @@ -244,7 +245,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_ipv4"), - groupType: apstra.ResourcePoolTypeIpv4, + groupType: enum.ResourcePoolTypeIpv4, poolIds: []string{newIpv4Pool(t)}, }, }, @@ -252,7 +253,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_ipv4"), - groupType: apstra.ResourcePoolTypeIpv4, + groupType: enum.ResourcePoolTypeIpv4, poolIds: []string{newIpv4Pool(t)}, }, }, @@ -264,7 +265,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_ipv6"), - groupType: apstra.ResourcePoolTypeIpv6, + groupType: enum.ResourcePoolTypeIpv6, poolIds: []string{newIpv6Pool(t)}, }, }, @@ -272,7 +273,7 @@ func TestResourceAllocGroup(t *testing.T) { config: resourceAllocGroup{ blueprintId: bp.Id().String(), name: nameByKey("test_ipv6"), - groupType: apstra.ResourcePoolTypeIpv6, + groupType: enum.ResourcePoolTypeIpv6, poolIds: []string{newIpv6Pool(t)}, }, }, diff --git a/apstra/resource_freeform_link_integration_test.go b/apstra/resource_freeform_link_integration_test.go index 0f9cc443..3c908583 100644 --- a/apstra/resource_freeform_link_integration_test.go +++ b/apstra/resource_freeform_link_integration_test.go @@ -12,6 +12,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" @@ -136,7 +137,7 @@ func TestResourceFreeformLink(t *testing.T) { // create an ipv4 allocation group ipv4AllocGroupId, err := bp.CreateAllocGroup(ctx, &apstra.FreeformAllocGroupData{ Name: acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv4, + Type: enum.ResourcePoolTypeIpv4, PoolIds: []apstra.ObjectId{"Private-10_0_0_0-8"}, }) require.NoError(t, err) @@ -144,7 +145,7 @@ func TestResourceFreeformLink(t *testing.T) { // create an ipv6 allocation group ipv6AllocGroupId, err := bp.CreateAllocGroup(ctx, &apstra.FreeformAllocGroupData{ Name: acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv6, + Type: enum.ResourcePoolTypeIpv6, PoolIds: []apstra.ObjectId{"Private-fc01-a05-fab-48"}, }) require.NoError(t, err) @@ -169,7 +170,7 @@ func TestResourceFreeformLink(t *testing.T) { associateIpResourcesToLinksDone = true _, err = bp.CreateResourceGenerator(ctx, &apstra.FreeformResourceGeneratorData{ - ResourceType: apstra.FFResourceTypeIpv4, + ResourceType: enum.FFResourceTypeIpv4, Label: acctest.RandString(6), Scope: "node(type='link', name='target')", AllocatedFrom: &ipv4AllocGroupId, @@ -179,7 +180,7 @@ func TestResourceFreeformLink(t *testing.T) { require.NoError(t, err) _, err = bp.CreateResourceGenerator(ctx, &apstra.FreeformResourceGeneratorData{ - ResourceType: apstra.FFResourceTypeIpv6, + ResourceType: enum.FFResourceTypeIpv6, Label: acctest.RandString(6), Scope: "node(type='link', name='target')", AllocatedFrom: &ipv6AllocGroupId, diff --git a/apstra/resource_freeform_resource_generator_integraion_test.go b/apstra/resource_freeform_resource_generator_integraion_test.go index 6e7203e3..24530d1a 100644 --- a/apstra/resource_freeform_resource_generator_integraion_test.go +++ b/apstra/resource_freeform_resource_generator_integraion_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" @@ -36,7 +37,7 @@ resource %q %q { type resourceFreeformResourceGenerator struct { blueprintId string name string - resourceType apstra.FFResourceType + resourceType enum.FFResourceType scope string allocatedFrom string containerId string @@ -106,7 +107,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "ipv4AlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv4, + Type: enum.ResourcePoolTypeIpv4, PoolIds: []apstra.ObjectId{ipv4poolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -132,7 +133,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "ipv6AlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv6, + Type: enum.ResourcePoolTypeIpv6, PoolIds: []apstra.ObjectId{ipv6poolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -157,7 +158,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "vniAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeVni, + Type: enum.ResourcePoolTypeVni, PoolIds: []apstra.ObjectId{vniPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -182,7 +183,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "asnAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeAsn, + Type: enum.ResourcePoolTypeAsn, PoolIds: []apstra.ObjectId{asnPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -207,7 +208,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "intAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeInt, + Type: enum.ResourcePoolTypeInt, PoolIds: []apstra.ObjectId{intPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -231,7 +232,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { config: resourceFreeformResourceGenerator{ blueprintId: bp.Id().String(), name: acctest.RandString(6), - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, scope: "node('system', name='target')", allocatedFrom: string(newAsnAllocationGroup(t)), containerId: string(groupId), @@ -241,7 +242,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { config: resourceFreeformResourceGenerator{ blueprintId: bp.Id().String(), name: acctest.RandString(6), - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, scope: "node('system', deploy_mode='deploy', name='target')", allocatedFrom: string(newAsnAllocationGroup(t)), containerId: string(groupId), @@ -256,7 +257,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { // blueprintId: bp.Id().String(), // name: acctest.RandString(6), // containerId: string(groupId), - // resourceType: apstra.FFResourceTypeVni, + // resourceType: enum.FFResourceTypeVni, // }, // }, // }, @@ -269,7 +270,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeInt, + resourceType: enum.FFResourceTypeInt, allocatedFrom: string(newIntAllocationGroup(t)), }, }, @@ -279,7 +280,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', deploy_mode='deploy', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeInt, + resourceType: enum.FFResourceTypeInt, allocatedFrom: string(newIntAllocationGroup(t)), }, }, @@ -293,7 +294,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeIpv4, + resourceType: enum.FFResourceTypeIpv4, allocatedFrom: string(newIpv4AllocationGroup(t)), subnetPrefixLen: utils.ToPtr(27), }, @@ -304,7 +305,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', deploy_mode='deploy', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeIpv4, + resourceType: enum.FFResourceTypeIpv4, allocatedFrom: string(newIpv4AllocationGroup(t)), subnetPrefixLen: utils.ToPtr(28), }, @@ -319,7 +320,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeIpv6, + resourceType: enum.FFResourceTypeIpv6, allocatedFrom: string(newIpv6AllocationGroup(t)), subnetPrefixLen: utils.ToPtr(127), }, @@ -330,7 +331,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', deploy_mode='deploy', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeIpv6, + resourceType: enum.FFResourceTypeIpv6, allocatedFrom: string(newIpv6AllocationGroup(t)), subnetPrefixLen: utils.ToPtr(126), }, @@ -345,7 +346,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, allocatedFrom: string(newVniAllocationGroup(t)), }, }, @@ -355,7 +356,7 @@ func TestResourceFreeformResourceGenerator(t *testing.T) { name: acctest.RandString(6), scope: "node('system', deploy_mode='deploy', name='target')", containerId: string(groupId), - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, allocatedFrom: string(newVniAllocationGroup(t)), }, }, diff --git a/apstra/resource_freeform_resource_integraion_test.go b/apstra/resource_freeform_resource_integraion_test.go index 7d442e4a..605eb5fd 100644 --- a/apstra/resource_freeform_resource_integraion_test.go +++ b/apstra/resource_freeform_resource_integraion_test.go @@ -11,6 +11,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/Juniper/terraform-provider-apstra/apstra/utils" @@ -40,7 +41,7 @@ type resourceFreeformResource struct { blueprintId string name string groupId apstra.ObjectId - resourceType apstra.FFResourceType + resourceType enum.FFResourceType integerValue *int ipv4Value net.IPNet ipv6Value net.IPNet @@ -75,13 +76,13 @@ func (o resourceFreeformResource) testChecks(t testing.TB, rType, rName string) if o.integerValue != nil { result.append(t, "TestCheckResourceAttr", "integer_value", strconv.Itoa(*o.integerValue)) } else { - if o.resourceType == apstra.FFResourceTypeHostIpv4 || o.resourceType == apstra.FFResourceTypeHostIpv6 { + if o.resourceType == enum.FFResourceTypeHostIpv4 || o.resourceType == enum.FFResourceTypeHostIpv6 { result.append(t, "TestCheckNoResourceAttr", "integer_value") } - if o.resourceType == apstra.FFResourceTypeIpv4 && o.allocatedFrom == "" { + if o.resourceType == enum.FFResourceTypeIpv4 && o.allocatedFrom == "" { result.append(t, "TestCheckNoResourceAttr", "integer_value") } - if o.resourceType == apstra.FFResourceTypeIpv6 && o.allocatedFrom == "" { + if o.resourceType == enum.FFResourceTypeIpv6 && o.allocatedFrom == "" { result.append(t, "TestCheckNoResourceAttr", "integer_value") } } @@ -91,10 +92,10 @@ func (o resourceFreeformResource) testChecks(t testing.TB, rType, rName string) if o.ipv6Value.String() != "" { result.append(t, "TestCheckResourceAttr", "ipv6_value", o.ipv6Value.String()) } - if o.resourceType == apstra.FFResourceTypeIpv4 || o.resourceType == apstra.FFResourceTypeHostIpv4 { + if o.resourceType == enum.FFResourceTypeIpv4 || o.resourceType == enum.FFResourceTypeHostIpv4 { result.append(t, "TestCheckResourceAttrSet", "ipv4_value") } - if o.resourceType == apstra.FFResourceTypeIpv6 || o.resourceType == apstra.FFResourceTypeHostIpv6 { + if o.resourceType == enum.FFResourceTypeIpv6 || o.resourceType == enum.FFResourceTypeHostIpv6 { result.append(t, "TestCheckResourceAttrSet", "ipv6_value") } if o.allocatedFrom == "" { @@ -155,7 +156,7 @@ func TestResourceFreeformResource(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "ipv4AlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv4, + Type: enum.ResourcePoolTypeIpv4, PoolIds: []apstra.ObjectId{ipv4poolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -181,7 +182,7 @@ func TestResourceFreeformResource(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "ipv6AlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeIpv6, + Type: enum.ResourcePoolTypeIpv6, PoolIds: []apstra.ObjectId{ipv6poolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -206,7 +207,7 @@ func TestResourceFreeformResource(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "vniAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeVni, + Type: enum.ResourcePoolTypeVni, PoolIds: []apstra.ObjectId{vniPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -231,7 +232,7 @@ func TestResourceFreeformResource(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "asnAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeAsn, + Type: enum.ResourcePoolTypeAsn, PoolIds: []apstra.ObjectId{asnPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -255,7 +256,7 @@ func TestResourceFreeformResource(t *testing.T) { // now create the allocation group allocGroupCfg := apstra.FreeformAllocGroupData{ Name: "intAlGr-" + acctest.RandString(6), - Type: apstra.ResourcePoolTypeInt, + Type: enum.ResourcePoolTypeInt, PoolIds: []apstra.ObjectId{intPoolId}, } allocGroup, err := bp.CreateAllocGroup(ctx, utils.ToPtr(allocGroupCfg)) @@ -311,7 +312,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, integerValue: utils.ToPtr(65535), }, }, @@ -320,7 +321,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, integerValue: utils.ToPtr(65536), }, }, @@ -329,7 +330,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, allocatedFrom: newAsnAllocationGroup(t), }, }, @@ -338,7 +339,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, allocatedFrom: newAsnAllocationGroup(t), assignedTo: randomSysIds(t, sysCount/3), }, @@ -348,7 +349,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeAsn, + resourceType: enum.FFResourceTypeAsn, integerValue: utils.ToPtr(65536), }, }, @@ -361,7 +362,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, integerValue: utils.ToPtr(4498), assignedTo: randomSysIds(t, sysCount/3), }, @@ -375,7 +376,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeInt, + resourceType: enum.FFResourceTypeInt, integerValue: utils.ToPtr(4498), assignedTo: randomSysIds(t, sysCount/3), }, @@ -385,7 +386,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeInt, + resourceType: enum.FFResourceTypeInt, allocatedFrom: newIntAllocationGroup(t), assignedTo: randomSysIds(t, sysCount/3), }, @@ -395,7 +396,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeInt, + resourceType: enum.FFResourceTypeInt, integerValue: utils.ToPtr(459), }, }, @@ -408,7 +409,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeIpv4, + resourceType: enum.FFResourceTypeIpv4, ipv4Value: randomSlash31(t, "192.168.2.0/24"), }, }, @@ -417,7 +418,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeIpv4, + resourceType: enum.FFResourceTypeIpv4, integerValue: utils.ToPtr(30), allocatedFrom: newIpv4AllocationGroup(t), }, @@ -427,7 +428,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeIpv4, + resourceType: enum.FFResourceTypeIpv4, ipv4Value: randomSlash31(t, "10.168.2.0/24"), }, }, @@ -440,7 +441,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeIpv6, + resourceType: enum.FFResourceTypeIpv6, ipv6Value: randomSlash127(t, "2001:db8::/32"), assignedTo: randomSysIds(t, sysCount/3), }, @@ -450,7 +451,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeIpv6, + resourceType: enum.FFResourceTypeIpv6, integerValue: utils.ToPtr(64), allocatedFrom: newIpv6AllocationGroup(t), }, @@ -460,7 +461,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeIpv6, + resourceType: enum.FFResourceTypeIpv6, ipv6Value: randomSlash127(t, "2001:db8::/32"), }, }, @@ -473,7 +474,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, allocatedFrom: newVniAllocationGroup(t), }, }, @@ -482,7 +483,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, integerValue: utils.ToPtr(rand.IntN(10000) + 4096), }, }, @@ -491,7 +492,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[0], - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, integerValue: utils.ToPtr(rand.IntN(10000) + 4096), }, }, @@ -500,7 +501,7 @@ func TestResourceFreeformResource(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), groupId: groupIds[1], - resourceType: apstra.FFResourceTypeVni, + resourceType: enum.FFResourceTypeVni, allocatedFrom: newVniAllocationGroup(t), assignedTo: randomSysIds(t, sysCount/3), }, diff --git a/apstra/resource_freeform_system_integration_test.go b/apstra/resource_freeform_system_integration_test.go index 3fe9d5cc..c2cdadef 100644 --- a/apstra/resource_freeform_system_integration_test.go +++ b/apstra/resource_freeform_system_integration_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/Juniper/apstra-go-sdk/apstra" + "github.com/Juniper/apstra-go-sdk/apstra/enum" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/hashicorp/go-version" @@ -116,7 +117,7 @@ func TestResourceFreeformSystem(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), hostname: acctest.RandString(6), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeExternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), }, @@ -138,7 +139,7 @@ func TestResourceFreeformSystem(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), hostname: acctest.RandString(6), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeExternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), }, @@ -156,7 +157,7 @@ func TestResourceFreeformSystem(t *testing.T) { blueprintId: bp.Id().String(), name: acctest.RandString(6), hostname: acctest.RandString(6), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeExternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), }, @@ -180,7 +181,7 @@ func TestResourceFreeformSystem(t *testing.T) { name: acctest.RandString(6), hostname: acctest.RandString(6), deviceProfileId: string(dpId), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeInternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), }, @@ -204,7 +205,7 @@ func TestResourceFreeformSystem(t *testing.T) { name: acctest.RandString(6), hostname: acctest.RandString(6), deviceProfileId: string(dpId), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeInternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), }, @@ -224,7 +225,7 @@ func TestResourceFreeformSystem(t *testing.T) { name: acctest.RandString(6), hostname: acctest.RandString(6), deviceProfileId: string(dpId), - deployMode: apstra.DeployModeDeploy.String(), + deployMode: enum.DeployModeDeploy.String(), systemType: apstra.SystemTypeInternal.String(), tags: randomStrings(rand.Intn(10)+2, 6), },