From 33e26db08e248989b7babac50c4898dcd032648b Mon Sep 17 00:00:00 2001 From: stephybun Date: Wed, 12 Jun 2024 11:26:46 +0200 Subject: [PATCH] `network` - remove legacy generated resource ID parsers (#26302) * remove public ip address, network interface, network security groups and local network gateway legacy parsers * remove application gateway, ip group and public ip prefix legacy parsers * remove network gateway connection, virtual network peering, and private link service legacy id parsers * remove bgp connection, hub route table, hub virtual network connection, nat gateway and security partner provider legacy id parsers * remove vpn gateway nat rule, vpn connection, virtual wan, virtual hub, route map and point to site vpn gateway legacy id parsers * remove virtual network gateway, vmss public ip address, service endpoint policy and all express route legacy id parsers * remove unused application gateway http listener id parser --- .../apimanagement/api_management_resource.go | 5 +- .../cdn/cdn_frontdoor_origin_resource.go | 4 +- .../compute/linux_virtual_machine_resource.go | 3 +- .../orchestrated_virtual_machine_scale_set.go | 7 +- .../compute/virtual_machine_scale_set.go | 7 +- .../windows_virtual_machine_resource.go | 3 +- .../services/containers/kubernetes_addons.go | 4 +- .../containers/kubernetes_nodepool.go | 4 +- ...integration_runtime_azure_ssis_resource.go | 3 +- ...ctory_managed_private_endpoint_resource.go | 4 +- .../services/firewall/firewall_resource.go | 8 +- .../services/kusto/kusto_cluster_resource.go | 5 +- .../loadbalancer/loadbalancer_resource.go | 6 +- .../services/network/bastion_host_resource.go | 2 +- .../network/custom_ip_prefix_resource.go | 4 +- .../express_route_connection_resource.go | 14 +- .../network/ip_group_cidr_resource.go | 3 +- .../migration/network_watcher_flow_log.go | 6 +- .../network/network_interface_resource.go | 3 +- .../network_watcher_flow_log_resource.go | 12 +- .../network/parse/application_gateway.go | 72 ----- .../application_gateway_http_listener.go | 78 ----- .../application_gateway_http_listener_test.go | 131 --------- .../network/parse/application_gateway_test.go | 115 -------- .../services/network/parse/bgp_connection.go | 78 ----- .../network/parse/bgp_connection_test.go | 131 --------- .../network/parse/custom_ip_prefix.go | 72 ----- .../network/parse/custom_ip_prefix_test.go | 115 -------- .../network/parse/express_route_circuit.go | 72 ----- .../express_route_circuit_authorization.go | 78 ----- ...xpress_route_circuit_authorization_test.go | 131 --------- .../parse/express_route_circuit_connection.go | 84 ------ .../express_route_circuit_connection_test.go | 147 ---------- .../parse/express_route_circuit_peering.go | 134 --------- .../express_route_circuit_peering_test.go | 267 ------------------ .../parse/express_route_circuit_test.go | 115 -------- .../network/parse/express_route_connection.go | 78 ----- .../parse/express_route_connection_test.go | 131 --------- .../network/parse/express_route_gateway.go | 72 ----- .../parse/express_route_gateway_test.go | 115 -------- .../network/parse/express_route_port.go | 116 -------- .../parse/express_route_port_authorization.go | 78 ----- .../express_route_port_authorization_test.go | 131 --------- .../network/parse/express_route_port_test.go | 232 --------------- .../services/network/parse/hub_route_table.go | 134 --------- .../network/parse/hub_route_table_test.go | 267 ------------------ .../parse/hub_virtual_network_connection.go | 78 ----- .../hub_virtual_network_connection_test.go | 131 --------- internal/services/network/parse/ip_group.go | 72 ----- .../services/network/parse/ip_group_test.go | 115 -------- .../network/parse/local_network_gateway.go | 72 ----- .../parse/local_network_gateway_test.go | 115 -------- .../services/network/parse/nat_gateway.go | 72 ----- .../nat_gateway_public_ip_association.go | 37 --- .../nat_gateway_public_ip_association_test.go | 81 ------ ...at_gateway_public_ip_prefix_association.go | 37 --- ...teway_public_ip_prefix_association_test.go | 81 ------ .../network/parse/nat_gateway_test.go | 115 -------- .../parse/network_gateway_connection.go | 72 ----- .../parse/network_gateway_connection_test.go | 115 -------- .../network/parse/network_interface.go | 72 ----- .../network/parse/network_interface_test.go | 115 -------- .../network/parse/network_security_group.go | 116 -------- .../parse/network_security_group_test.go | 232 --------------- .../parse/point_to_site_vpn_gateway.go | 72 ----- .../parse/point_to_site_vpn_gateway_test.go | 115 -------- .../network/parse/private_link_service.go | 72 ----- .../parse/private_link_service_test.go | 115 -------- .../network/parse/public_ip_address.go | 72 ----- .../network/parse/public_ip_address_test.go | 115 -------- .../network/parse/public_ip_prefix.go | 72 ----- .../network/parse/public_ip_prefix_test.go | 115 -------- internal/services/network/parse/route_map.go | 78 ----- .../services/network/parse/route_map_test.go | 131 --------- .../parse/security_partner_provider.go | 72 ----- .../parse/security_partner_provider_test.go | 115 -------- .../subnet_service_endpoint_storage_policy.go | 72 ----- ...et_service_endpoint_storage_policy_test.go | 115 -------- .../services/network/parse/virtual_hub.go | 72 ----- .../parse/virtual_hub_ip_configuration.go | 78 ----- .../virtual_hub_ip_configuration_test.go | 131 --------- .../network/parse/virtual_hub_test.go | 115 -------- ...ual_machine_scale_set_public_ip_address.go | 96 ------- ...achine_scale_set_public_ip_address_test.go | 179 ------------ .../network/parse/virtual_network_gateway.go | 72 ----- .../parse/virtual_network_gateway_nat_rule.go | 78 ----- .../virtual_network_gateway_nat_rule_test.go | 131 --------- .../parse/virtual_network_gateway_test.go | 115 -------- .../network/parse/virtual_network_peering.go | 78 ----- .../parse/virtual_network_peering_test.go | 131 --------- .../services/network/parse/virtual_wan.go | 72 ----- .../network/parse/virtual_wan_test.go | 115 -------- .../services/network/parse/vpn_connection.go | 78 ----- .../network/parse/vpn_connection_test.go | 131 --------- .../network/parse/vpn_gateway_nat_rule.go | 78 ----- .../parse/vpn_gateway_nat_rule_test.go | 131 --------- ...private_endpoint_connection_data_source.go | 5 +- .../services/network/public_ip_resource.go | 3 +- internal/services/network/resourceids.go | 49 ---- .../services/network/route_map_resource.go | 4 +- internal/services/network/subnet_resource.go | 4 +- .../application_gateway_http_listener_id.go | 26 -- ...plication_gateway_http_listener_id_test.go | 91 ------ .../validate/application_gateway_id.go | 26 -- .../validate/application_gateway_id_test.go | 79 ------ .../network/validate/bgp_connection_id.go | 26 -- .../validate/bgp_connection_id_test.go | 91 ------ .../network/validate/custom_ip_prefix_id.go | 26 -- .../validate/custom_ip_prefix_id_test.go | 79 ------ .../express_route_circuit_authorization_id.go | 26 -- ...ess_route_circuit_authorization_id_test.go | 91 ------ .../express_route_circuit_connection_id.go | 26 -- ...xpress_route_circuit_connection_id_test.go | 103 ------- .../validate/express_route_circuit_id.go | 26 -- .../validate/express_route_circuit_id_test.go | 79 ------ .../express_route_circuit_peering_id.go | 26 -- .../express_route_circuit_peering_id_test.go | 91 ------ .../validate/express_route_connection_id.go | 26 -- .../express_route_connection_id_test.go | 91 ------ .../validate/express_route_gateway_id.go | 26 -- .../validate/express_route_gateway_id_test.go | 79 ------ .../express_route_port_authorization_id.go | 26 -- ...xpress_route_port_authorization_id_test.go | 91 ------ .../network/validate/express_route_port_id.go | 26 -- .../validate/express_route_port_id_test.go | 79 ------ .../network/validate/hub_route_table_id.go | 26 -- .../validate/hub_route_table_id_test.go | 91 ------ .../hub_virtual_network_connection_id.go | 26 -- .../hub_virtual_network_connection_id_test.go | 91 ------ .../services/network/validate/ip_group_id.go | 26 -- .../network/validate/ip_group_id_test.go | 79 ------ .../validate/local_network_gateway_id.go | 26 -- .../validate/local_network_gateway_id_test.go | 79 ------ .../network/validate/nat_gateway_id.go | 26 -- .../network/validate/nat_gateway_id_test.go | 79 ------ .../validate/network_gateway_connection_id.go | 26 -- .../network_gateway_connection_id_test.go | 79 ------ .../network/validate/network_interface_id.go | 26 -- .../validate/network_interface_id_test.go | 79 ------ .../validate/network_security_group_id.go | 26 -- .../network_security_group_id_test.go | 79 ------ .../validate/point_to_site_vpn_gateway_id.go | 26 -- .../point_to_site_vpn_gateway_id_test.go | 79 ------ .../validate/private_link_service_id.go | 26 -- .../validate/private_link_service_id_test.go | 79 ------ .../network/validate/public_ip_address_id.go | 26 -- .../validate/public_ip_address_id_test.go | 79 ------ .../network/validate/public_ip_prefix_id.go | 26 -- .../validate/public_ip_prefix_id_test.go | 79 ------ .../services/network/validate/route_map_id.go | 26 -- .../network/validate/route_map_id_test.go | 91 ------ .../validate/security_partner_provider_id.go | 26 -- .../security_partner_provider_id_test.go | 79 ------ ...bnet_service_endpoint_storage_policy_id.go | 26 -- ...service_endpoint_storage_policy_id_test.go | 79 ------ .../network/validate/virtual_hub_id.go | 26 -- .../network/validate/virtual_hub_id_test.go | 79 ------ .../virtual_hub_ip_configuration_id.go | 26 -- .../virtual_hub_ip_configuration_id_test.go | 91 ------ ..._machine_scale_set_public_ip_address_id.go | 26 -- ...ine_scale_set_public_ip_address_id_test.go | 127 --------- .../validate/virtual_network_gateway_id.go | 26 -- .../virtual_network_gateway_id_test.go | 79 ------ .../virtual_network_gateway_nat_rule_id.go | 26 -- ...irtual_network_gateway_nat_rule_id_test.go | 91 ------ .../validate/virtual_network_peering_id.go | 26 -- .../virtual_network_peering_id_test.go | 91 ------ .../network/validate/virtual_wan_id.go | 26 -- .../network/validate/virtual_wan_id_test.go | 79 ------ .../network/validate/vpn_connection_id.go | 26 -- .../validate/vpn_connection_id_test.go | 91 ------ .../validate/vpn_gateway_nat_rule_id.go | 26 -- .../validate/vpn_gateway_nat_rule_id_test.go | 91 ------ .../virtual_hub_connection_resource.go | 8 +- .../services/network/virtual_hub_resource.go | 5 +- .../virtual_hub_route_table_route_resource.go | 3 +- ...ual_network_gateway_connection_resource.go | 9 +- ...rtual_network_gateway_nat_rule_resource.go | 3 +- .../virtual_network_gateway_resource.go | 3 +- .../network/virtual_network_resource.go | 9 +- .../vpn_gateway_connection_resource.go | 13 +- .../services/network/vpn_gateway_resource.go | 3 +- .../network_virtual_appliance_resource.go | 2 +- .../paloalto/schema/destination_nat.go | 4 +- .../paloalto/schema/network_profile.go | 13 +- 185 files changed, 94 insertions(+), 12287 deletions(-) delete mode 100644 internal/services/network/parse/application_gateway.go delete mode 100644 internal/services/network/parse/application_gateway_http_listener.go delete mode 100644 internal/services/network/parse/application_gateway_http_listener_test.go delete mode 100644 internal/services/network/parse/application_gateway_test.go delete mode 100644 internal/services/network/parse/bgp_connection.go delete mode 100644 internal/services/network/parse/bgp_connection_test.go delete mode 100644 internal/services/network/parse/custom_ip_prefix.go delete mode 100644 internal/services/network/parse/custom_ip_prefix_test.go delete mode 100644 internal/services/network/parse/express_route_circuit.go delete mode 100644 internal/services/network/parse/express_route_circuit_authorization.go delete mode 100644 internal/services/network/parse/express_route_circuit_authorization_test.go delete mode 100644 internal/services/network/parse/express_route_circuit_connection.go delete mode 100644 internal/services/network/parse/express_route_circuit_connection_test.go delete mode 100644 internal/services/network/parse/express_route_circuit_peering.go delete mode 100644 internal/services/network/parse/express_route_circuit_peering_test.go delete mode 100644 internal/services/network/parse/express_route_circuit_test.go delete mode 100644 internal/services/network/parse/express_route_connection.go delete mode 100644 internal/services/network/parse/express_route_connection_test.go delete mode 100644 internal/services/network/parse/express_route_gateway.go delete mode 100644 internal/services/network/parse/express_route_gateway_test.go delete mode 100644 internal/services/network/parse/express_route_port.go delete mode 100644 internal/services/network/parse/express_route_port_authorization.go delete mode 100644 internal/services/network/parse/express_route_port_authorization_test.go delete mode 100644 internal/services/network/parse/express_route_port_test.go delete mode 100644 internal/services/network/parse/hub_route_table.go delete mode 100644 internal/services/network/parse/hub_route_table_test.go delete mode 100644 internal/services/network/parse/hub_virtual_network_connection.go delete mode 100644 internal/services/network/parse/hub_virtual_network_connection_test.go delete mode 100644 internal/services/network/parse/ip_group.go delete mode 100644 internal/services/network/parse/ip_group_test.go delete mode 100644 internal/services/network/parse/local_network_gateway.go delete mode 100644 internal/services/network/parse/local_network_gateway_test.go delete mode 100644 internal/services/network/parse/nat_gateway.go delete mode 100644 internal/services/network/parse/nat_gateway_public_ip_association.go delete mode 100644 internal/services/network/parse/nat_gateway_public_ip_association_test.go delete mode 100644 internal/services/network/parse/nat_gateway_public_ip_prefix_association.go delete mode 100644 internal/services/network/parse/nat_gateway_public_ip_prefix_association_test.go delete mode 100644 internal/services/network/parse/nat_gateway_test.go delete mode 100644 internal/services/network/parse/network_gateway_connection.go delete mode 100644 internal/services/network/parse/network_gateway_connection_test.go delete mode 100644 internal/services/network/parse/network_interface.go delete mode 100644 internal/services/network/parse/network_interface_test.go delete mode 100644 internal/services/network/parse/network_security_group.go delete mode 100644 internal/services/network/parse/network_security_group_test.go delete mode 100644 internal/services/network/parse/point_to_site_vpn_gateway.go delete mode 100644 internal/services/network/parse/point_to_site_vpn_gateway_test.go delete mode 100644 internal/services/network/parse/private_link_service.go delete mode 100644 internal/services/network/parse/private_link_service_test.go delete mode 100644 internal/services/network/parse/public_ip_address.go delete mode 100644 internal/services/network/parse/public_ip_address_test.go delete mode 100644 internal/services/network/parse/public_ip_prefix.go delete mode 100644 internal/services/network/parse/public_ip_prefix_test.go delete mode 100644 internal/services/network/parse/route_map.go delete mode 100644 internal/services/network/parse/route_map_test.go delete mode 100644 internal/services/network/parse/security_partner_provider.go delete mode 100644 internal/services/network/parse/security_partner_provider_test.go delete mode 100644 internal/services/network/parse/subnet_service_endpoint_storage_policy.go delete mode 100644 internal/services/network/parse/subnet_service_endpoint_storage_policy_test.go delete mode 100644 internal/services/network/parse/virtual_hub.go delete mode 100644 internal/services/network/parse/virtual_hub_ip_configuration.go delete mode 100644 internal/services/network/parse/virtual_hub_ip_configuration_test.go delete mode 100644 internal/services/network/parse/virtual_hub_test.go delete mode 100644 internal/services/network/parse/virtual_machine_scale_set_public_ip_address.go delete mode 100644 internal/services/network/parse/virtual_machine_scale_set_public_ip_address_test.go delete mode 100644 internal/services/network/parse/virtual_network_gateway.go delete mode 100644 internal/services/network/parse/virtual_network_gateway_nat_rule.go delete mode 100644 internal/services/network/parse/virtual_network_gateway_nat_rule_test.go delete mode 100644 internal/services/network/parse/virtual_network_gateway_test.go delete mode 100644 internal/services/network/parse/virtual_network_peering.go delete mode 100644 internal/services/network/parse/virtual_network_peering_test.go delete mode 100644 internal/services/network/parse/virtual_wan.go delete mode 100644 internal/services/network/parse/virtual_wan_test.go delete mode 100644 internal/services/network/parse/vpn_connection.go delete mode 100644 internal/services/network/parse/vpn_connection_test.go delete mode 100644 internal/services/network/parse/vpn_gateway_nat_rule.go delete mode 100644 internal/services/network/parse/vpn_gateway_nat_rule_test.go delete mode 100644 internal/services/network/validate/application_gateway_http_listener_id.go delete mode 100644 internal/services/network/validate/application_gateway_http_listener_id_test.go delete mode 100644 internal/services/network/validate/application_gateway_id.go delete mode 100644 internal/services/network/validate/application_gateway_id_test.go delete mode 100644 internal/services/network/validate/bgp_connection_id.go delete mode 100644 internal/services/network/validate/bgp_connection_id_test.go delete mode 100644 internal/services/network/validate/custom_ip_prefix_id.go delete mode 100644 internal/services/network/validate/custom_ip_prefix_id_test.go delete mode 100644 internal/services/network/validate/express_route_circuit_authorization_id.go delete mode 100644 internal/services/network/validate/express_route_circuit_authorization_id_test.go delete mode 100644 internal/services/network/validate/express_route_circuit_connection_id.go delete mode 100644 internal/services/network/validate/express_route_circuit_connection_id_test.go delete mode 100644 internal/services/network/validate/express_route_circuit_id.go delete mode 100644 internal/services/network/validate/express_route_circuit_id_test.go delete mode 100644 internal/services/network/validate/express_route_circuit_peering_id.go delete mode 100644 internal/services/network/validate/express_route_circuit_peering_id_test.go delete mode 100644 internal/services/network/validate/express_route_connection_id.go delete mode 100644 internal/services/network/validate/express_route_connection_id_test.go delete mode 100644 internal/services/network/validate/express_route_gateway_id.go delete mode 100644 internal/services/network/validate/express_route_gateway_id_test.go delete mode 100644 internal/services/network/validate/express_route_port_authorization_id.go delete mode 100644 internal/services/network/validate/express_route_port_authorization_id_test.go delete mode 100644 internal/services/network/validate/express_route_port_id.go delete mode 100644 internal/services/network/validate/express_route_port_id_test.go delete mode 100644 internal/services/network/validate/hub_route_table_id.go delete mode 100644 internal/services/network/validate/hub_route_table_id_test.go delete mode 100644 internal/services/network/validate/hub_virtual_network_connection_id.go delete mode 100644 internal/services/network/validate/hub_virtual_network_connection_id_test.go delete mode 100644 internal/services/network/validate/ip_group_id.go delete mode 100644 internal/services/network/validate/ip_group_id_test.go delete mode 100644 internal/services/network/validate/local_network_gateway_id.go delete mode 100644 internal/services/network/validate/local_network_gateway_id_test.go delete mode 100644 internal/services/network/validate/nat_gateway_id.go delete mode 100644 internal/services/network/validate/nat_gateway_id_test.go delete mode 100644 internal/services/network/validate/network_gateway_connection_id.go delete mode 100644 internal/services/network/validate/network_gateway_connection_id_test.go delete mode 100644 internal/services/network/validate/network_interface_id.go delete mode 100644 internal/services/network/validate/network_interface_id_test.go delete mode 100644 internal/services/network/validate/network_security_group_id.go delete mode 100644 internal/services/network/validate/network_security_group_id_test.go delete mode 100644 internal/services/network/validate/point_to_site_vpn_gateway_id.go delete mode 100644 internal/services/network/validate/point_to_site_vpn_gateway_id_test.go delete mode 100644 internal/services/network/validate/private_link_service_id.go delete mode 100644 internal/services/network/validate/private_link_service_id_test.go delete mode 100644 internal/services/network/validate/public_ip_address_id.go delete mode 100644 internal/services/network/validate/public_ip_address_id_test.go delete mode 100644 internal/services/network/validate/public_ip_prefix_id.go delete mode 100644 internal/services/network/validate/public_ip_prefix_id_test.go delete mode 100644 internal/services/network/validate/route_map_id.go delete mode 100644 internal/services/network/validate/route_map_id_test.go delete mode 100644 internal/services/network/validate/security_partner_provider_id.go delete mode 100644 internal/services/network/validate/security_partner_provider_id_test.go delete mode 100644 internal/services/network/validate/subnet_service_endpoint_storage_policy_id.go delete mode 100644 internal/services/network/validate/subnet_service_endpoint_storage_policy_id_test.go delete mode 100644 internal/services/network/validate/virtual_hub_id.go delete mode 100644 internal/services/network/validate/virtual_hub_id_test.go delete mode 100644 internal/services/network/validate/virtual_hub_ip_configuration_id.go delete mode 100644 internal/services/network/validate/virtual_hub_ip_configuration_id_test.go delete mode 100644 internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id.go delete mode 100644 internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id_test.go delete mode 100644 internal/services/network/validate/virtual_network_gateway_id.go delete mode 100644 internal/services/network/validate/virtual_network_gateway_id_test.go delete mode 100644 internal/services/network/validate/virtual_network_gateway_nat_rule_id.go delete mode 100644 internal/services/network/validate/virtual_network_gateway_nat_rule_id_test.go delete mode 100644 internal/services/network/validate/virtual_network_peering_id.go delete mode 100644 internal/services/network/validate/virtual_network_peering_id_test.go delete mode 100644 internal/services/network/validate/virtual_wan_id.go delete mode 100644 internal/services/network/validate/virtual_wan_id_test.go delete mode 100644 internal/services/network/validate/vpn_connection_id.go delete mode 100644 internal/services/network/validate/vpn_connection_id_test.go delete mode 100644 internal/services/network/validate/vpn_gateway_nat_rule_id.go delete mode 100644 internal/services/network/validate/vpn_gateway_nat_rule_id_test.go diff --git a/internal/services/apimanagement/api_management_resource.go b/internal/services/apimanagement/api_management_resource.go index 33a51077a207..c4e405854eb2 100644 --- a/internal/services/apimanagement/api_management_resource.go +++ b/internal/services/apimanagement/api_management_resource.go @@ -35,7 +35,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/schemaz" apimValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -230,7 +229,7 @@ func resourceApiManagementSchema() map[string]*pluginsdk.Schema { "public_ip_address_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "private_ip_addresses": { @@ -601,7 +600,7 @@ func resourceApiManagementSchema() map[string]*pluginsdk.Schema { "public_ip_address_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "public_network_access_enabled": { diff --git a/internal/services/cdn/cdn_frontdoor_origin_resource.go b/internal/services/cdn/cdn_frontdoor_origin_resource.go index 4505ebd60113..5a0086f66a40 100644 --- a/internal/services/cdn/cdn_frontdoor_origin_resource.go +++ b/internal/services/cdn/cdn_frontdoor_origin_resource.go @@ -10,6 +10,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2021-06-01/cdn" // nolint: staticcheck "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/privatelinkservices" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -17,7 +18,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/azuresdkhacks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/cdn/validate" - privateLinkServiceParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -465,7 +465,7 @@ func expandPrivateLinkSettings(input []interface{}, skuName cdn.SkuName, enableC // Private Link Service ID here... settings := input[0].(map[string]interface{}) targetType := settings["target_type"].(string) - _, err := privateLinkServiceParse.PrivateLinkServiceID(settings["private_link_target_id"].(string)) + _, err := privatelinkservices.ParsePrivateLinkServiceID(settings["private_link_target_id"].(string)) if err != nil && targetType == "" { // It is not a Load Balancer and the Target Type is empty, which is invalid... return nil, fmt.Errorf("either 'private_link' or 'target_type' must be specified") diff --git a/internal/services/compute/linux_virtual_machine_resource.go b/internal/services/compute/linux_virtual_machine_resource.go index e179e97ae6e5..2a27490e543f 100644 --- a/internal/services/compute/linux_virtual_machine_resource.go +++ b/internal/services/compute/linux_virtual_machine_resource.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/base64" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -80,7 +79,7 @@ func resourceLinuxVirtualMachine() *pluginsdk.Resource { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.NetworkInterfaceID, + ValidateFunc: commonids.ValidateNetworkInterfaceID, }, }, diff --git a/internal/services/compute/orchestrated_virtual_machine_scale_set.go b/internal/services/compute/orchestrated_virtual_machine_scale_set.go index f7ae6a4dd76d..9993959250ff 100644 --- a/internal/services/compute/orchestrated_virtual_machine_scale_set.go +++ b/internal/services/compute/orchestrated_virtual_machine_scale_set.go @@ -13,10 +13,11 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2024-03-01/virtualmachinescalesets" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/applicationsecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networksecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -308,7 +309,7 @@ func OrchestratedVirtualMachineScaleSetNetworkInterfaceSchema() *pluginsdk.Schem "network_security_group_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: networkValidate.NetworkSecurityGroupID, + ValidateFunc: networksecuritygroups.ValidateNetworkSecurityGroupID, }, "primary": { @@ -439,7 +440,7 @@ func orchestratedVirtualMachineScaleSetPublicIPAddressSchema() *pluginsdk.Schema Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: networkValidate.PublicIpPrefixID, + ValidateFunc: publicipprefixes.ValidatePublicIPPrefixID, }, "sku_name": { diff --git a/internal/services/compute/virtual_machine_scale_set.go b/internal/services/compute/virtual_machine_scale_set.go index 90b80e76a487..d8517126b0e1 100644 --- a/internal/services/compute/virtual_machine_scale_set.go +++ b/internal/services/compute/virtual_machine_scale_set.go @@ -14,10 +14,11 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-03/galleryapplicationversions" "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2024-03-01/virtualmachinescalesets" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/applicationsecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networksecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" azValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -110,7 +111,7 @@ func VirtualMachineScaleSetNetworkInterfaceSchema() *pluginsdk.Schema { "network_security_group_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: networkValidate.NetworkSecurityGroupID, + ValidateFunc: networksecuritygroups.ValidateNetworkSecurityGroupID, }, "primary": { Type: pluginsdk.TypeBool, @@ -743,7 +744,7 @@ func virtualMachineScaleSetPublicIPAddressSchema() *pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: networkValidate.PublicIpPrefixID, + ValidateFunc: publicipprefixes.ValidatePublicIPPrefixID, }, }, }, diff --git a/internal/services/compute/windows_virtual_machine_resource.go b/internal/services/compute/windows_virtual_machine_resource.go index 297adaa3952e..022649757924 100644 --- a/internal/services/compute/windows_virtual_machine_resource.go +++ b/internal/services/compute/windows_virtual_machine_resource.go @@ -27,7 +27,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/base64" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -89,7 +88,7 @@ func resourceWindowsVirtualMachine() *pluginsdk.Resource { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.NetworkInterfaceID, + ValidateFunc: commonids.ValidateNetworkInterfaceID, }, }, diff --git a/internal/services/containers/kubernetes_addons.go b/internal/services/containers/kubernetes_addons.go index 5abd571b41f7..1c82df9cf75b 100644 --- a/internal/services/containers/kubernetes_addons.go +++ b/internal/services/containers/kubernetes_addons.go @@ -10,11 +10,11 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/applicationgateways" "github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/workspaces" "github.com/hashicorp/go-azure-sdk/sdk/environments" commonValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" containerValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/validate" - applicationGatewayValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) @@ -163,7 +163,7 @@ func schemaKubernetesAddOns() map[string]*pluginsdk.Schema { "ingress_application_gateway.0.subnet_cidr", "ingress_application_gateway.0.subnet_id", }, - ValidateFunc: applicationGatewayValidate.ApplicationGatewayID, + ValidateFunc: applicationgateways.ValidateApplicationGatewayID, }, "gateway_name": { Type: pluginsdk.TypeString, diff --git a/internal/services/containers/kubernetes_nodepool.go b/internal/services/containers/kubernetes_nodepool.go index 38c9229f32e1..9d16cda6bff5 100644 --- a/internal/services/containers/kubernetes_nodepool.go +++ b/internal/services/containers/kubernetes_nodepool.go @@ -21,11 +21,11 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters" "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/applicationsecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/internal/features" computeValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/compute/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -165,7 +165,7 @@ func SchemaDefaultNodePool() *pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: networkValidate.PublicIpPrefixID, + ValidateFunc: publicipprefixes.ValidatePublicIPPrefixID, RequiredWith: func() []string { if !features.FourPointOhBeta() { return []string{"default_node_pool.0.enable_node_public_ip"} diff --git a/internal/services/datafactory/data_factory_integration_runtime_azure_ssis_resource.go b/internal/services/datafactory/data_factory_integration_runtime_azure_ssis_resource.go index 0134feb10872..45811d41ef32 100644 --- a/internal/services/datafactory/data_factory_integration_runtime_azure_ssis_resource.go +++ b/internal/services/datafactory/data_factory_integration_runtime_azure_ssis_resource.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/parse" sqlValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -204,7 +203,7 @@ func resourceDataFactoryIntegrationRuntimeAzureSsis() *pluginsdk.Resource { MaxItems: 2, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, }, diff --git a/internal/services/datafactory/data_factory_managed_private_endpoint_resource.go b/internal/services/datafactory/data_factory_managed_private_endpoint_resource.go index 62e2f906fa04..3e2456cfdb88 100644 --- a/internal/services/datafactory/data_factory_managed_private_endpoint_resource.go +++ b/internal/services/datafactory/data_factory_managed_private_endpoint_resource.go @@ -12,12 +12,12 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/factories" "github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/managedprivateendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/privatelinkservices" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/validate" - networkParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -118,7 +118,7 @@ func resourceDataFactoryManagedPrivateEndpointCreate(d *pluginsdk.ResourceData, subResourceName := d.Get("subresource_name").(string) fqdns := d.Get("fqdns").([]interface{}) - if _, err := networkParse.PrivateLinkServiceID(targetResourceId); err == nil { + if _, err := privatelinkservices.ParsePrivateLinkServiceID(targetResourceId); err == nil { if len(subResourceName) > 0 { return fmt.Errorf("`subresource_name` should not be specified when target resource is `Private Link Service`") } diff --git a/internal/services/firewall/firewall_resource.go b/internal/services/firewall/firewall_resource.go index fc43906c6ef2..10c0f690c6eb 100644 --- a/internal/services/firewall/firewall_resource.go +++ b/internal/services/firewall/firewall_resource.go @@ -18,13 +18,13 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/firewallpolicies" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/azurefirewalls" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualwans" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/firewall/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -110,7 +110,7 @@ func resourceFirewall() *pluginsdk.Resource { "public_ip_address_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "private_ip_address": { Type: pluginsdk.TypeString, @@ -141,7 +141,7 @@ func resourceFirewall() *pluginsdk.Resource { "public_ip_address_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "private_ip_address": { Type: pluginsdk.TypeString, @@ -200,7 +200,7 @@ func resourceFirewall() *pluginsdk.Resource { "virtual_hub_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: networkValidate.VirtualHubID, + ValidateFunc: virtualwans.ValidateVirtualHubID, }, "public_ip_count": { Type: pluginsdk.TypeInt, diff --git a/internal/services/kusto/kusto_cluster_resource.go b/internal/services/kusto/kusto_cluster_resource.go index ec700a2af72c..7f7906af6a86 100644 --- a/internal/services/kusto/kusto_cluster_resource.go +++ b/internal/services/kusto/kusto_cluster_resource.go @@ -25,7 +25,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -156,13 +155,13 @@ func resourceKustoCluster() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "data_management_public_ip_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, }, diff --git a/internal/services/loadbalancer/loadbalancer_resource.go b/internal/services/loadbalancer/loadbalancer_resource.go index 3391188b2828..2c052ba84922 100644 --- a/internal/services/loadbalancer/loadbalancer_resource.go +++ b/internal/services/loadbalancer/loadbalancer_resource.go @@ -21,11 +21,11 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/loadbalancers" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -460,14 +460,14 @@ func resourceArmLoadBalancerSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, Computed: true, // TODO: why is this computed? - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "public_ip_prefix_id": { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: networkValidate.PublicIpPrefixID, + ValidateFunc: publicipprefixes.ValidatePublicIPPrefixID, }, "private_ip_address_allocation": { diff --git a/internal/services/network/bastion_host_resource.go b/internal/services/network/bastion_host_resource.go index ca1b5e2b3a3a..1196e59c85ed 100644 --- a/internal/services/network/bastion_host_resource.go +++ b/internal/services/network/bastion_host_resource.go @@ -96,7 +96,7 @@ func resourceBastionHost() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, }, diff --git a/internal/services/network/custom_ip_prefix_resource.go b/internal/services/network/custom_ip_prefix_resource.go index f670d0878965..aa04c68bcf6e 100644 --- a/internal/services/network/custom_ip_prefix_resource.go +++ b/internal/services/network/custom_ip_prefix_resource.go @@ -55,7 +55,7 @@ func (CustomIpPrefixResource) ModelObject() interface{} { } func (CustomIpPrefixResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return validate.CustomIpPrefixID + return customipprefixes.ValidateCustomIPPrefixID } func (r CustomIpPrefixResource) Arguments() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ @@ -93,7 +93,7 @@ func (r CustomIpPrefixResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validate.CustomIpPrefixID, + ValidateFunc: customipprefixes.ValidateCustomIPPrefixID, }, "roa_validity_end_date": { diff --git a/internal/services/network/express_route_connection_resource.go b/internal/services/network/express_route_connection_resource.go index 4e8ac17b58b9..f596e3e6de71 100644 --- a/internal/services/network/express_route_connection_resource.go +++ b/internal/services/network/express_route_connection_resource.go @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/expressrouteconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/expressroutegateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualwans" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -97,20 +97,20 @@ func resourceExpressRouteConnection() *pluginsdk.Resource { "inbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "outbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "associated_route_table_id": { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, AtLeastOneOf: []string{"routing.0.associated_route_table_id", "routing.0.propagated_route_table"}, }, @@ -138,7 +138,7 @@ func resourceExpressRouteConnection() *pluginsdk.Resource { Computed: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, }, AtLeastOneOf: []string{"routing.0.propagated_route_table.0.labels", "routing.0.propagated_route_table.0.route_table_ids"}, }, @@ -251,7 +251,7 @@ func resourceExpressRouteConnectionRead(d *pluginsdk.ResourceData, meta interfac if v := props.ExpressRouteCircuitPeering.Id; v != nil { circuitPeeringID = *v } - peeringId, err := parse.ExpressRouteCircuitPeeringIDInsensitively(circuitPeeringID) + peeringId, err := commonids.ParseExpressRouteCircuitPeeringIDInsensitively(circuitPeeringID) if err != nil { return err } @@ -399,7 +399,7 @@ func flattenExpressRouteConnectionRouting(input *expressrouteconnections.Routing if input.AssociatedRouteTable != nil && input.AssociatedRouteTable.Id != nil { associatedRouteTableId = *input.AssociatedRouteTable.Id } - routeTableId, err := parse.HubRouteTableIDInsensitively(associatedRouteTableId) + routeTableId, err := virtualwans.ParseHubRouteTableIDInsensitively(associatedRouteTableId) if err != nil { return nil, err } diff --git a/internal/services/network/ip_group_cidr_resource.go b/internal/services/network/ip_group_cidr_resource.go index 080374636096..f24c187194ad 100644 --- a/internal/services/network/ip_group_cidr_resource.go +++ b/internal/services/network/ip_group_cidr_resource.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -43,7 +42,7 @@ func resourceIpGroupCidr() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.IpGroupID, + ValidateFunc: ipgroups.ValidateIPGroupID, }, "cidr": { Type: pluginsdk.TypeString, diff --git a/internal/services/network/migration/network_watcher_flow_log.go b/internal/services/network/migration/network_watcher_flow_log.go index 38d1855cd892..cae87386e56b 100644 --- a/internal/services/network/migration/network_watcher_flow_log.go +++ b/internal/services/network/migration/network_watcher_flow_log.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/flowlogs" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/networkwatchers" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networksecuritygroups" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -153,11 +153,11 @@ func (NetworkWatcherFlowLogV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { } else { // The `name` is introduced as an attribute since 0e528be. If users have provisioned this resource prior to that commit, and didn't run a `refresh` for the flow log. Then the state won't have `name` included. // In this case, we will use the Portal way to construct the flow log name. - nsgId, err := parse.NetworkSecurityGroupID(parts[1]) + nsgId, err := networksecuritygroups.ParseNetworkSecurityGroupID(parts[1]) if err != nil { return rawState, err } - name = fmt.Sprintf("Microsoft.Network%s%s", watcherId.ResourceGroupName, nsgId.Name) + name = fmt.Sprintf("Microsoft.Network%s%s", watcherId.ResourceGroupName, nsgId.NetworkSecurityGroupName) if len(name) > 80 { name = name[:80] } diff --git a/internal/services/network/network_interface_resource.go b/internal/services/network/network_interface_resource.go index 6aac8b9ad45c..020c8b725d56 100644 --- a/internal/services/network/network_interface_resource.go +++ b/internal/services/network/network_interface_resource.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" lbvalidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/loadbalancer/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -105,7 +104,7 @@ func resourceNetworkInterface() *pluginsdk.Resource { "public_ip_address_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "primary": { diff --git a/internal/services/network/network_watcher_flow_log_resource.go b/internal/services/network/network_watcher_flow_log_resource.go index 368a2bc488f5..7ea995858151 100644 --- a/internal/services/network/network_watcher_flow_log_resource.go +++ b/internal/services/network/network_watcher_flow_log_resource.go @@ -15,13 +15,13 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/flowlogs" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networksecuritygroups" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networkwatchers" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/migration" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -75,7 +75,7 @@ func resourceNetworkWatcherFlowLog() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.NetworkSecurityGroupID, + ValidateFunc: networksecuritygroups.ValidateNetworkSecurityGroupID, }, "storage_account_id": { @@ -191,7 +191,7 @@ func resourceNetworkWatcherFlowLogCreate(d *pluginsdk.ResourceData, meta interfa defer cancel() id := flowlogs.NewFlowLogID(subscriptionId, d.Get("resource_group_name").(string), d.Get("network_watcher_name").(string), d.Get("name").(string)) - nsgId, err := parse.NetworkSecurityGroupID(d.Get("network_security_group_id").(string)) + nsgId, err := networksecuritygroups.ParseNetworkSecurityGroupID(d.Get("network_security_group_id").(string)) if err != nil { return err } @@ -285,7 +285,7 @@ func resourceNetworkWatcherFlowLogUpdate(d *pluginsdk.ResourceData, meta interfa payload := existing.Model - nsgId, err := parse.NetworkSecurityGroupID(d.Get("network_security_group_id").(string)) + nsgId, err := networksecuritygroups.ParseNetworkSecurityGroupID(d.Get("network_security_group_id").(string)) if err != nil { return err } @@ -374,7 +374,7 @@ func resourceNetworkWatcherFlowLogRead(d *pluginsdk.ResourceData, meta interface } networkSecurityGroupId := "" - nsgId, err := parse.NetworkSecurityGroupIDInsensitively(props.TargetResourceId) + nsgId, err := networksecuritygroups.ParseNetworkSecurityGroupIDInsensitively(props.TargetResourceId) if err == nil { networkSecurityGroupId = nsgId.ID() } @@ -409,7 +409,7 @@ func resourceNetworkWatcherFlowLogDelete(d *pluginsdk.ResourceData, meta interfa return fmt.Errorf("retreiving %s: `properties` or `properties.TargetResourceID` was nil", id) } - networkSecurityGroupId, err := parse.NetworkSecurityGroupIDInsensitively(resp.Model.Properties.TargetResourceId) + networkSecurityGroupId, err := networksecuritygroups.ParseNetworkSecurityGroupIDInsensitively(resp.Model.Properties.TargetResourceId) if err != nil { return fmt.Errorf("parsing %q as a Network Security Group ID: %+v", resp.Model.Properties.TargetResourceId, err) } diff --git a/internal/services/network/parse/application_gateway.go b/internal/services/network/parse/application_gateway.go deleted file mode 100644 index c397884013f5..000000000000 --- a/internal/services/network/parse/application_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ApplicationGatewayId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewApplicationGatewayID(subscriptionId, resourceGroup, name string) ApplicationGatewayId { - return ApplicationGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id ApplicationGatewayId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Application Gateway", segmentsStr) -} - -func (id ApplicationGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// ApplicationGatewayID parses a ApplicationGateway ID into an ApplicationGatewayId struct -func ApplicationGatewayID(input string) (*ApplicationGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ApplicationGateway ID: %+v", input, err) - } - - resourceId := ApplicationGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("applicationGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/application_gateway_http_listener.go b/internal/services/network/parse/application_gateway_http_listener.go deleted file mode 100644 index 356bb11afad4..000000000000 --- a/internal/services/network/parse/application_gateway_http_listener.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ApplicationGatewayHTTPListenerId struct { - SubscriptionId string - ResourceGroup string - ApplicationGatewayName string - HttpListenerName string -} - -func NewApplicationGatewayHTTPListenerID(subscriptionId, resourceGroup, applicationGatewayName, httpListenerName string) ApplicationGatewayHTTPListenerId { - return ApplicationGatewayHTTPListenerId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ApplicationGatewayName: applicationGatewayName, - HttpListenerName: httpListenerName, - } -} - -func (id ApplicationGatewayHTTPListenerId) String() string { - segments := []string{ - fmt.Sprintf("Http Listener Name %q", id.HttpListenerName), - fmt.Sprintf("Application Gateway Name %q", id.ApplicationGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Application Gateway H T T P Listener", segmentsStr) -} - -func (id ApplicationGatewayHTTPListenerId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s/httpListeners/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ApplicationGatewayName, id.HttpListenerName) -} - -// ApplicationGatewayHTTPListenerID parses a ApplicationGatewayHTTPListener ID into an ApplicationGatewayHTTPListenerId struct -func ApplicationGatewayHTTPListenerID(input string) (*ApplicationGatewayHTTPListenerId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ApplicationGatewayHTTPListener ID: %+v", input, err) - } - - resourceId := ApplicationGatewayHTTPListenerId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ApplicationGatewayName, err = id.PopSegment("applicationGateways"); err != nil { - return nil, err - } - if resourceId.HttpListenerName, err = id.PopSegment("httpListeners"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/application_gateway_http_listener_test.go b/internal/services/network/parse/application_gateway_http_listener_test.go deleted file mode 100644 index c27f6499486c..000000000000 --- a/internal/services/network/parse/application_gateway_http_listener_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ApplicationGatewayHTTPListenerId{} - -func TestApplicationGatewayHTTPListenerIDFormatter(t *testing.T) { - actual := NewApplicationGatewayHTTPListenerID("12345678-1234-9876-4563-123456789012", "resGroup1", "applicationGateway1", "httpListener1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/httpListener1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestApplicationGatewayHTTPListenerID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ApplicationGatewayHTTPListenerId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ApplicationGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ApplicationGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/", - Error: true, - }, - - { - // missing HttpListenerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/", - Error: true, - }, - - { - // missing value for HttpListenerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/httpListener1", - Expected: &ApplicationGatewayHTTPListenerId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ApplicationGatewayName: "applicationGateway1", - HttpListenerName: "httpListener1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/APPLICATIONGATEWAY1/HTTPLISTENERS/HTTPLISTENER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ApplicationGatewayHTTPListenerID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { - t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) - } - if actual.HttpListenerName != v.Expected.HttpListenerName { - t.Fatalf("Expected %q but got %q for HttpListenerName", v.Expected.HttpListenerName, actual.HttpListenerName) - } - } -} diff --git a/internal/services/network/parse/application_gateway_test.go b/internal/services/network/parse/application_gateway_test.go deleted file mode 100644 index a8b6d40d474a..000000000000 --- a/internal/services/network/parse/application_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ApplicationGatewayId{} - -func TestApplicationGatewayIDFormatter(t *testing.T) { - actual := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "applicationGateway1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestApplicationGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ApplicationGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1", - Expected: &ApplicationGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "applicationGateway1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/APPLICATIONGATEWAY1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ApplicationGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/bgp_connection.go b/internal/services/network/parse/bgp_connection.go deleted file mode 100644 index 70edb9a1a28f..000000000000 --- a/internal/services/network/parse/bgp_connection.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type BgpConnectionId struct { - SubscriptionId string - ResourceGroup string - VirtualHubName string - Name string -} - -func NewBgpConnectionID(subscriptionId, resourceGroup, virtualHubName, name string) BgpConnectionId { - return BgpConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualHubName: virtualHubName, - Name: name, - } -} - -func (id BgpConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Virtual Hub Name %q", id.VirtualHubName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Bgp Connection", segmentsStr) -} - -func (id BgpConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/bgpConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualHubName, id.Name) -} - -// BgpConnectionID parses a BgpConnection ID into an BgpConnectionId struct -func BgpConnectionID(input string) (*BgpConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an BgpConnection ID: %+v", input, err) - } - - resourceId := BgpConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualHubName, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("bgpConnections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/bgp_connection_test.go b/internal/services/network/parse/bgp_connection_test.go deleted file mode 100644 index b1ee58e7efc9..000000000000 --- a/internal/services/network/parse/bgp_connection_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = BgpConnectionId{} - -func TestBgpConnectionIDFormatter(t *testing.T) { - actual := NewBgpConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualHub1", "connection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/connection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestBgpConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *BgpConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/connection1", - Expected: &BgpConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "connection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/BGPCONNECTIONS/CONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := BgpConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/custom_ip_prefix.go b/internal/services/network/parse/custom_ip_prefix.go deleted file mode 100644 index 5a29d81a2b04..000000000000 --- a/internal/services/network/parse/custom_ip_prefix.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type CustomIpPrefixId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewCustomIpPrefixID(subscriptionId, resourceGroup, name string) CustomIpPrefixId { - return CustomIpPrefixId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id CustomIpPrefixId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Custom Ip Prefix", segmentsStr) -} - -func (id CustomIpPrefixId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/customIPPrefixes/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// CustomIpPrefixID parses a CustomIpPrefix ID into an CustomIpPrefixId struct -func CustomIpPrefixID(input string) (*CustomIpPrefixId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an CustomIpPrefix ID: %+v", input, err) - } - - resourceId := CustomIpPrefixId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("customIPPrefixes"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/custom_ip_prefix_test.go b/internal/services/network/parse/custom_ip_prefix_test.go deleted file mode 100644 index 7576e4a74305..000000000000 --- a/internal/services/network/parse/custom_ip_prefix_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = CustomIpPrefixId{} - -func TestCustomIpPrefixIDFormatter(t *testing.T) { - actual := NewCustomIpPrefixID("12345678-1234-9876-4563-123456789012", "resGroup1", "prefix1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/prefix1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestCustomIpPrefixID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *CustomIpPrefixId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/prefix1", - Expected: &CustomIpPrefixId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "prefix1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/CUSTOMIPPREFIXES/PREFIX1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := CustomIpPrefixID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/express_route_circuit.go b/internal/services/network/parse/express_route_circuit.go deleted file mode 100644 index c3883b35d4b3..000000000000 --- a/internal/services/network/parse/express_route_circuit.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteCircuitId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewExpressRouteCircuitID(subscriptionId, resourceGroup, name string) ExpressRouteCircuitId { - return ExpressRouteCircuitId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id ExpressRouteCircuitId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Circuit", segmentsStr) -} - -func (id ExpressRouteCircuitId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// ExpressRouteCircuitID parses a ExpressRouteCircuit ID into an ExpressRouteCircuitId struct -func ExpressRouteCircuitID(input string) (*ExpressRouteCircuitId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteCircuit ID: %+v", input, err) - } - - resourceId := ExpressRouteCircuitId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("expressRouteCircuits"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_circuit_authorization.go b/internal/services/network/parse/express_route_circuit_authorization.go deleted file mode 100644 index c44d986fd2d2..000000000000 --- a/internal/services/network/parse/express_route_circuit_authorization.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteCircuitAuthorizationId struct { - SubscriptionId string - ResourceGroup string - ExpressRouteCircuitName string - AuthorizationName string -} - -func NewExpressRouteCircuitAuthorizationID(subscriptionId, resourceGroup, expressRouteCircuitName, authorizationName string) ExpressRouteCircuitAuthorizationId { - return ExpressRouteCircuitAuthorizationId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ExpressRouteCircuitName: expressRouteCircuitName, - AuthorizationName: authorizationName, - } -} - -func (id ExpressRouteCircuitAuthorizationId) String() string { - segments := []string{ - fmt.Sprintf("Authorization Name %q", id.AuthorizationName), - fmt.Sprintf("Express Route Circuit Name %q", id.ExpressRouteCircuitName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Circuit Authorization", segmentsStr) -} - -func (id ExpressRouteCircuitAuthorizationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/authorizations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ExpressRouteCircuitName, id.AuthorizationName) -} - -// ExpressRouteCircuitAuthorizationID parses a ExpressRouteCircuitAuthorization ID into an ExpressRouteCircuitAuthorizationId struct -func ExpressRouteCircuitAuthorizationID(input string) (*ExpressRouteCircuitAuthorizationId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteCircuitAuthorization ID: %+v", input, err) - } - - resourceId := ExpressRouteCircuitAuthorizationId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ExpressRouteCircuitName, err = id.PopSegment("expressRouteCircuits"); err != nil { - return nil, err - } - if resourceId.AuthorizationName, err = id.PopSegment("authorizations"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_circuit_authorization_test.go b/internal/services/network/parse/express_route_circuit_authorization_test.go deleted file mode 100644 index b91870bfec98..000000000000 --- a/internal/services/network/parse/express_route_circuit_authorization_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteCircuitAuthorizationId{} - -func TestExpressRouteCircuitAuthorizationIDFormatter(t *testing.T) { - actual := NewExpressRouteCircuitAuthorizationID("12345678-1234-9876-4563-123456789012", "resGroup1", "expressRouteCircuit1", "authorization1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/authorization1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteCircuitAuthorizationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteCircuitAuthorizationId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Error: true, - }, - - { - // missing AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/", - Error: true, - }, - - { - // missing value for AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/authorization1", - Expected: &ExpressRouteCircuitAuthorizationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "expressRouteCircuit1", - AuthorizationName: "authorization1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/EXPRESSROUTECIRCUIT1/AUTHORIZATIONS/AUTHORIZATION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteCircuitAuthorizationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { - t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) - } - if actual.AuthorizationName != v.Expected.AuthorizationName { - t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) - } - } -} diff --git a/internal/services/network/parse/express_route_circuit_connection.go b/internal/services/network/parse/express_route_circuit_connection.go deleted file mode 100644 index 0fef4466467f..000000000000 --- a/internal/services/network/parse/express_route_circuit_connection.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteCircuitConnectionId struct { - SubscriptionId string - ResourceGroup string - ExpressRouteCircuitName string - PeeringName string - ConnectionName string -} - -func NewExpressRouteCircuitConnectionID(subscriptionId, resourceGroup, expressRouteCircuitName, peeringName, connectionName string) ExpressRouteCircuitConnectionId { - return ExpressRouteCircuitConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ExpressRouteCircuitName: expressRouteCircuitName, - PeeringName: peeringName, - ConnectionName: connectionName, - } -} - -func (id ExpressRouteCircuitConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Connection Name %q", id.ConnectionName), - fmt.Sprintf("Peering Name %q", id.PeeringName), - fmt.Sprintf("Express Route Circuit Name %q", id.ExpressRouteCircuitName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Circuit Connection", segmentsStr) -} - -func (id ExpressRouteCircuitConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/connections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ExpressRouteCircuitName, id.PeeringName, id.ConnectionName) -} - -// ExpressRouteCircuitConnectionID parses a ExpressRouteCircuitConnection ID into an ExpressRouteCircuitConnectionId struct -func ExpressRouteCircuitConnectionID(input string) (*ExpressRouteCircuitConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteCircuitConnection ID: %+v", input, err) - } - - resourceId := ExpressRouteCircuitConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ExpressRouteCircuitName, err = id.PopSegment("expressRouteCircuits"); err != nil { - return nil, err - } - if resourceId.PeeringName, err = id.PopSegment("peerings"); err != nil { - return nil, err - } - if resourceId.ConnectionName, err = id.PopSegment("connections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_circuit_connection_test.go b/internal/services/network/parse/express_route_circuit_connection_test.go deleted file mode 100644 index 98fa01aad29b..000000000000 --- a/internal/services/network/parse/express_route_circuit_connection_test.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteCircuitConnectionId{} - -func TestExpressRouteCircuitConnectionIDFormatter(t *testing.T) { - actual := NewExpressRouteCircuitConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "circuit1", "peering1", "connection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/connection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteCircuitConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteCircuitConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Error: true, - }, - - { - // missing PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/", - Error: true, - }, - - { - // missing value for PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/", - Error: true, - }, - - { - // missing ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/", - Error: true, - }, - - { - // missing value for ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/connection1", - Expected: &ExpressRouteCircuitConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "circuit1", - PeeringName: "peering1", - ConnectionName: "connection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/CIRCUIT1/PEERINGS/PEERING1/CONNECTIONS/CONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteCircuitConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { - t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) - } - if actual.PeeringName != v.Expected.PeeringName { - t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) - } - if actual.ConnectionName != v.Expected.ConnectionName { - t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) - } - } -} diff --git a/internal/services/network/parse/express_route_circuit_peering.go b/internal/services/network/parse/express_route_circuit_peering.go deleted file mode 100644 index fdfb179af685..000000000000 --- a/internal/services/network/parse/express_route_circuit_peering.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteCircuitPeeringId struct { - SubscriptionId string - ResourceGroup string - ExpressRouteCircuitName string - PeeringName string -} - -func NewExpressRouteCircuitPeeringID(subscriptionId, resourceGroup, expressRouteCircuitName, peeringName string) ExpressRouteCircuitPeeringId { - return ExpressRouteCircuitPeeringId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ExpressRouteCircuitName: expressRouteCircuitName, - PeeringName: peeringName, - } -} - -func (id ExpressRouteCircuitPeeringId) String() string { - segments := []string{ - fmt.Sprintf("Peering Name %q", id.PeeringName), - fmt.Sprintf("Express Route Circuit Name %q", id.ExpressRouteCircuitName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Circuit Peering", segmentsStr) -} - -func (id ExpressRouteCircuitPeeringId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ExpressRouteCircuitName, id.PeeringName) -} - -// ExpressRouteCircuitPeeringID parses a ExpressRouteCircuitPeering ID into an ExpressRouteCircuitPeeringId struct -func ExpressRouteCircuitPeeringID(input string) (*ExpressRouteCircuitPeeringId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteCircuitPeering ID: %+v", input, err) - } - - resourceId := ExpressRouteCircuitPeeringId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ExpressRouteCircuitName, err = id.PopSegment("expressRouteCircuits"); err != nil { - return nil, err - } - if resourceId.PeeringName, err = id.PopSegment("peerings"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} - -// ExpressRouteCircuitPeeringIDInsensitively parses an ExpressRouteCircuitPeering ID into an ExpressRouteCircuitPeeringId struct, insensitively -// This should only be used to parse an ID for rewriting, the ExpressRouteCircuitPeeringID -// method should be used instead for validation etc. -// -// Whilst this may seem strange, this enables Terraform have consistent casing -// which works around issues in Core, whilst handling broken API responses. -func ExpressRouteCircuitPeeringIDInsensitively(input string) (*ExpressRouteCircuitPeeringId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := ExpressRouteCircuitPeeringId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - // find the correct casing for the 'expressRouteCircuits' segment - expressRouteCircuitsKey := "expressRouteCircuits" - for key := range id.Path { - if strings.EqualFold(key, expressRouteCircuitsKey) { - expressRouteCircuitsKey = key - break - } - } - if resourceId.ExpressRouteCircuitName, err = id.PopSegment(expressRouteCircuitsKey); err != nil { - return nil, err - } - - // find the correct casing for the 'peerings' segment - peeringsKey := "peerings" - for key := range id.Path { - if strings.EqualFold(key, peeringsKey) { - peeringsKey = key - break - } - } - if resourceId.PeeringName, err = id.PopSegment(peeringsKey); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_circuit_peering_test.go b/internal/services/network/parse/express_route_circuit_peering_test.go deleted file mode 100644 index 240d509ca006..000000000000 --- a/internal/services/network/parse/express_route_circuit_peering_test.go +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteCircuitPeeringId{} - -func TestExpressRouteCircuitPeeringIDFormatter(t *testing.T) { - actual := NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "resGroup1", "erCircuit1", "peering1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/peering1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteCircuitPeeringID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteCircuitPeeringId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Error: true, - }, - - { - // missing PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/", - Error: true, - }, - - { - // missing value for PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/peering1", - Expected: &ExpressRouteCircuitPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "erCircuit1", - PeeringName: "peering1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/ERCIRCUIT1/PEERINGS/PEERING1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteCircuitPeeringID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { - t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) - } - if actual.PeeringName != v.Expected.PeeringName { - t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) - } - } -} - -func TestExpressRouteCircuitPeeringIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteCircuitPeeringId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Error: true, - }, - - { - // missing PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/", - Error: true, - }, - - { - // missing value for PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/peering1", - Expected: &ExpressRouteCircuitPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "erCircuit1", - PeeringName: "peering1", - }, - }, - - { - // lower-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressroutecircuits/erCircuit1/peerings/peering1", - Expected: &ExpressRouteCircuitPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "erCircuit1", - PeeringName: "peering1", - }, - }, - - { - // upper-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/EXPRESSROUTECIRCUITS/erCircuit1/PEERINGS/peering1", - Expected: &ExpressRouteCircuitPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "erCircuit1", - PeeringName: "peering1", - }, - }, - - { - // mixed-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ExPrEsSrOuTeCiRcUiTs/erCircuit1/PeErInGs/peering1", - Expected: &ExpressRouteCircuitPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteCircuitName: "erCircuit1", - PeeringName: "peering1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteCircuitPeeringIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { - t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) - } - if actual.PeeringName != v.Expected.PeeringName { - t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) - } - } -} diff --git a/internal/services/network/parse/express_route_circuit_test.go b/internal/services/network/parse/express_route_circuit_test.go deleted file mode 100644 index 4d869ccc4d23..000000000000 --- a/internal/services/network/parse/express_route_circuit_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteCircuitId{} - -func TestExpressRouteCircuitIDFormatter(t *testing.T) { - actual := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "resGroup1", "erCircuit1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteCircuitID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteCircuitId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1", - Expected: &ExpressRouteCircuitId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "erCircuit1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/ERCIRCUIT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteCircuitID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/express_route_connection.go b/internal/services/network/parse/express_route_connection.go deleted file mode 100644 index ba07ec1a42f2..000000000000 --- a/internal/services/network/parse/express_route_connection.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteConnectionId struct { - SubscriptionId string - ResourceGroup string - ExpressRouteGatewayName string - Name string -} - -func NewExpressRouteConnectionID(subscriptionId, resourceGroup, expressRouteGatewayName, name string) ExpressRouteConnectionId { - return ExpressRouteConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ExpressRouteGatewayName: expressRouteGatewayName, - Name: name, - } -} - -func (id ExpressRouteConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Express Route Gateway Name %q", id.ExpressRouteGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Connection", segmentsStr) -} - -func (id ExpressRouteConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteGateways/%s/expressRouteConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ExpressRouteGatewayName, id.Name) -} - -// ExpressRouteConnectionID parses a ExpressRouteConnection ID into an ExpressRouteConnectionId struct -func ExpressRouteConnectionID(input string) (*ExpressRouteConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteConnection ID: %+v", input, err) - } - - resourceId := ExpressRouteConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ExpressRouteGatewayName, err = id.PopSegment("expressRouteGateways"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("expressRouteConnections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_connection_test.go b/internal/services/network/parse/express_route_connection_test.go deleted file mode 100644 index 982d40bffef8..000000000000 --- a/internal/services/network/parse/express_route_connection_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteConnectionId{} - -func TestExpressRouteConnectionIDFormatter(t *testing.T) { - actual := NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "ergw1", "erConnection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/erConnection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRouteGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRouteGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/erConnection1", - Expected: &ExpressRouteConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRouteGatewayName: "ergw1", - Name: "erConnection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEGATEWAYS/ERGW1/EXPRESSROUTECONNECTIONS/ERCONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { - t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/express_route_gateway.go b/internal/services/network/parse/express_route_gateway.go deleted file mode 100644 index b7d410ad3bd7..000000000000 --- a/internal/services/network/parse/express_route_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRouteGatewayId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewExpressRouteGatewayID(subscriptionId, resourceGroup, name string) ExpressRouteGatewayId { - return ExpressRouteGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id ExpressRouteGatewayId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Gateway", segmentsStr) -} - -func (id ExpressRouteGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// ExpressRouteGatewayID parses a ExpressRouteGateway ID into an ExpressRouteGatewayId struct -func ExpressRouteGatewayID(input string) (*ExpressRouteGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRouteGateway ID: %+v", input, err) - } - - resourceId := ExpressRouteGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("expressRouteGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_gateway_test.go b/internal/services/network/parse/express_route_gateway_test.go deleted file mode 100644 index 366581ae0a8c..000000000000 --- a/internal/services/network/parse/express_route_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRouteGatewayId{} - -func TestExpressRouteGatewayIDFormatter(t *testing.T) { - actual := NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "ergw1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRouteGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRouteGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1", - Expected: &ExpressRouteGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "ergw1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEGATEWAYS/ERGW1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRouteGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/express_route_port.go b/internal/services/network/parse/express_route_port.go deleted file mode 100644 index 4ab18e179b7d..000000000000 --- a/internal/services/network/parse/express_route_port.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRoutePortId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewExpressRoutePortID(subscriptionId, resourceGroup, name string) ExpressRoutePortId { - return ExpressRoutePortId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id ExpressRoutePortId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Port", segmentsStr) -} - -func (id ExpressRoutePortId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// ExpressRoutePortID parses a ExpressRoutePort ID into an ExpressRoutePortId struct -func ExpressRoutePortID(input string) (*ExpressRoutePortId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRoutePort ID: %+v", input, err) - } - - resourceId := ExpressRoutePortId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("expressRoutePorts"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} - -// ExpressRoutePortIDInsensitively parses an ExpressRoutePort ID into an ExpressRoutePortId struct, insensitively -// This should only be used to parse an ID for rewriting, the ExpressRoutePortID -// method should be used instead for validation etc. -// -// Whilst this may seem strange, this enables Terraform have consistent casing -// which works around issues in Core, whilst handling broken API responses. -func ExpressRoutePortIDInsensitively(input string) (*ExpressRoutePortId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := ExpressRoutePortId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - // find the correct casing for the 'expressRoutePorts' segment - expressRoutePortsKey := "expressRoutePorts" - for key := range id.Path { - if strings.EqualFold(key, expressRoutePortsKey) { - expressRoutePortsKey = key - break - } - } - if resourceId.Name, err = id.PopSegment(expressRoutePortsKey); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_port_authorization.go b/internal/services/network/parse/express_route_port_authorization.go deleted file mode 100644 index df8347a1d715..000000000000 --- a/internal/services/network/parse/express_route_port_authorization.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type ExpressRoutePortAuthorizationId struct { - SubscriptionId string - ResourceGroup string - ExpressRoutePortName string - AuthorizationName string -} - -func NewExpressRoutePortAuthorizationID(subscriptionId, resourceGroup, expressRoutePortName, authorizationName string) ExpressRoutePortAuthorizationId { - return ExpressRoutePortAuthorizationId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ExpressRoutePortName: expressRoutePortName, - AuthorizationName: authorizationName, - } -} - -func (id ExpressRoutePortAuthorizationId) String() string { - segments := []string{ - fmt.Sprintf("Authorization Name %q", id.AuthorizationName), - fmt.Sprintf("Express Route Port Name %q", id.ExpressRoutePortName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Express Route Port Authorization", segmentsStr) -} - -func (id ExpressRoutePortAuthorizationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s/authorizations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ExpressRoutePortName, id.AuthorizationName) -} - -// ExpressRoutePortAuthorizationID parses a ExpressRoutePortAuthorization ID into an ExpressRoutePortAuthorizationId struct -func ExpressRoutePortAuthorizationID(input string) (*ExpressRoutePortAuthorizationId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an ExpressRoutePortAuthorization ID: %+v", input, err) - } - - resourceId := ExpressRoutePortAuthorizationId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ExpressRoutePortName, err = id.PopSegment("expressRoutePorts"); err != nil { - return nil, err - } - if resourceId.AuthorizationName, err = id.PopSegment("authorizations"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/express_route_port_authorization_test.go b/internal/services/network/parse/express_route_port_authorization_test.go deleted file mode 100644 index dc31653c1632..000000000000 --- a/internal/services/network/parse/express_route_port_authorization_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRoutePortAuthorizationId{} - -func TestExpressRoutePortAuthorizationIDFormatter(t *testing.T) { - actual := NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "resGroup1", "port1", "authorization1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/authorization1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRoutePortAuthorizationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRoutePortAuthorizationId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ExpressRoutePortName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ExpressRoutePortName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/", - Error: true, - }, - - { - // missing AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/", - Error: true, - }, - - { - // missing value for AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/authorization1", - Expected: &ExpressRoutePortAuthorizationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ExpressRoutePortName: "port1", - AuthorizationName: "authorization1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEPORTS/PORT1/AUTHORIZATIONS/AUTHORIZATION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRoutePortAuthorizationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { - t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) - } - if actual.AuthorizationName != v.Expected.AuthorizationName { - t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) - } - } -} diff --git a/internal/services/network/parse/express_route_port_test.go b/internal/services/network/parse/express_route_port_test.go deleted file mode 100644 index c58dc93835ee..000000000000 --- a/internal/services/network/parse/express_route_port_test.go +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = ExpressRoutePortId{} - -func TestExpressRoutePortIDFormatter(t *testing.T) { - actual := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "resGroup1", "port1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestExpressRoutePortID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRoutePortId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1", - Expected: &ExpressRoutePortId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "port1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEPORTS/PORT1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRoutePortID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} - -func TestExpressRoutePortIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ExpressRoutePortId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1", - Expected: &ExpressRoutePortId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "port1", - }, - }, - - { - // lower-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressrouteports/port1", - Expected: &ExpressRoutePortId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "port1", - }, - }, - - { - // upper-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/EXPRESSROUTEPORTS/port1", - Expected: &ExpressRoutePortId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "port1", - }, - }, - - { - // mixed-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ExPrEsSrOuTePoRtS/port1", - Expected: &ExpressRoutePortId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "port1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ExpressRoutePortIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/hub_route_table.go b/internal/services/network/parse/hub_route_table.go deleted file mode 100644 index 40d89d85d55d..000000000000 --- a/internal/services/network/parse/hub_route_table.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type HubRouteTableId struct { - SubscriptionId string - ResourceGroup string - VirtualHubName string - Name string -} - -func NewHubRouteTableID(subscriptionId, resourceGroup, virtualHubName, name string) HubRouteTableId { - return HubRouteTableId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualHubName: virtualHubName, - Name: name, - } -} - -func (id HubRouteTableId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Virtual Hub Name %q", id.VirtualHubName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Hub Route Table", segmentsStr) -} - -func (id HubRouteTableId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/hubRouteTables/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualHubName, id.Name) -} - -// HubRouteTableID parses a HubRouteTable ID into an HubRouteTableId struct -func HubRouteTableID(input string) (*HubRouteTableId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an HubRouteTable ID: %+v", input, err) - } - - resourceId := HubRouteTableId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualHubName, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("hubRouteTables"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} - -// HubRouteTableIDInsensitively parses an HubRouteTable ID into an HubRouteTableId struct, insensitively -// This should only be used to parse an ID for rewriting, the HubRouteTableID -// method should be used instead for validation etc. -// -// Whilst this may seem strange, this enables Terraform have consistent casing -// which works around issues in Core, whilst handling broken API responses. -func HubRouteTableIDInsensitively(input string) (*HubRouteTableId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := HubRouteTableId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - // find the correct casing for the 'virtualHubs' segment - virtualHubsKey := "virtualHubs" - for key := range id.Path { - if strings.EqualFold(key, virtualHubsKey) { - virtualHubsKey = key - break - } - } - if resourceId.VirtualHubName, err = id.PopSegment(virtualHubsKey); err != nil { - return nil, err - } - - // find the correct casing for the 'hubRouteTables' segment - hubRouteTablesKey := "hubRouteTables" - for key := range id.Path { - if strings.EqualFold(key, hubRouteTablesKey) { - hubRouteTablesKey = key - break - } - } - if resourceId.Name, err = id.PopSegment(hubRouteTablesKey); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/hub_route_table_test.go b/internal/services/network/parse/hub_route_table_test.go deleted file mode 100644 index fc64f8e47ec0..000000000000 --- a/internal/services/network/parse/hub_route_table_test.go +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = HubRouteTableId{} - -func TestHubRouteTableIDFormatter(t *testing.T) { - actual := NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualHub1", "routeTable1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestHubRouteTableID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HubRouteTableId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1", - Expected: &HubRouteTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "routeTable1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/HUBROUTETABLES/ROUTETABLE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := HubRouteTableID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} - -func TestHubRouteTableIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HubRouteTableId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1", - Expected: &HubRouteTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "routeTable1", - }, - }, - - { - // lower-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualhubs/virtualHub1/hubroutetables/routeTable1", - Expected: &HubRouteTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "routeTable1", - }, - }, - - { - // upper-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/VIRTUALHUBS/virtualHub1/HUBROUTETABLES/routeTable1", - Expected: &HubRouteTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "routeTable1", - }, - }, - - { - // mixed-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ViRtUaLhUbS/virtualHub1/HuBrOuTeTaBlEs/routeTable1", - Expected: &HubRouteTableId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "routeTable1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := HubRouteTableIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/hub_virtual_network_connection.go b/internal/services/network/parse/hub_virtual_network_connection.go deleted file mode 100644 index be3c8f2d91d3..000000000000 --- a/internal/services/network/parse/hub_virtual_network_connection.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type HubVirtualNetworkConnectionId struct { - SubscriptionId string - ResourceGroup string - VirtualHubName string - Name string -} - -func NewHubVirtualNetworkConnectionID(subscriptionId, resourceGroup, virtualHubName, name string) HubVirtualNetworkConnectionId { - return HubVirtualNetworkConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualHubName: virtualHubName, - Name: name, - } -} - -func (id HubVirtualNetworkConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Virtual Hub Name %q", id.VirtualHubName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Hub Virtual Network Connection", segmentsStr) -} - -func (id HubVirtualNetworkConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/hubVirtualNetworkConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualHubName, id.Name) -} - -// HubVirtualNetworkConnectionID parses a HubVirtualNetworkConnection ID into an HubVirtualNetworkConnectionId struct -func HubVirtualNetworkConnectionID(input string) (*HubVirtualNetworkConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an HubVirtualNetworkConnection ID: %+v", input, err) - } - - resourceId := HubVirtualNetworkConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualHubName, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("hubVirtualNetworkConnections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/hub_virtual_network_connection_test.go b/internal/services/network/parse/hub_virtual_network_connection_test.go deleted file mode 100644 index 10a2bdb1018a..000000000000 --- a/internal/services/network/parse/hub_virtual_network_connection_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = HubVirtualNetworkConnectionId{} - -func TestHubVirtualNetworkConnectionIDFormatter(t *testing.T) { - actual := NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualHub1", "hubConnection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/hubConnection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestHubVirtualNetworkConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *HubVirtualNetworkConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/hubConnection1", - Expected: &HubVirtualNetworkConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - Name: "hubConnection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/HUBVIRTUALNETWORKCONNECTIONS/HUBCONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := HubVirtualNetworkConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/ip_group.go b/internal/services/network/parse/ip_group.go deleted file mode 100644 index 24f750560808..000000000000 --- a/internal/services/network/parse/ip_group.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type IpGroupId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewIpGroupID(subscriptionId, resourceGroup, name string) IpGroupId { - return IpGroupId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id IpGroupId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Ip Group", segmentsStr) -} - -func (id IpGroupId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/ipGroups/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// IpGroupID parses a IpGroup ID into an IpGroupId struct -func IpGroupID(input string) (*IpGroupId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an IpGroup ID: %+v", input, err) - } - - resourceId := IpGroupId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("ipGroups"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/ip_group_test.go b/internal/services/network/parse/ip_group_test.go deleted file mode 100644 index 926c6bfea7bc..000000000000 --- a/internal/services/network/parse/ip_group_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = IpGroupId{} - -func TestIpGroupIDFormatter(t *testing.T) { - actual := NewIpGroupID("12345678-1234-9876-4563-123456789012", "resGroup1", "group1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/group1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestIpGroupID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *IpGroupId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/group1", - Expected: &IpGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "group1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/IPGROUPS/GROUP1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := IpGroupID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/local_network_gateway.go b/internal/services/network/parse/local_network_gateway.go deleted file mode 100644 index 9c76ea5aa7a7..000000000000 --- a/internal/services/network/parse/local_network_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type LocalNetworkGatewayId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewLocalNetworkGatewayID(subscriptionId, resourceGroup, name string) LocalNetworkGatewayId { - return LocalNetworkGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id LocalNetworkGatewayId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Local Network Gateway", segmentsStr) -} - -func (id LocalNetworkGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/localNetworkGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// LocalNetworkGatewayID parses a LocalNetworkGateway ID into an LocalNetworkGatewayId struct -func LocalNetworkGatewayID(input string) (*LocalNetworkGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an LocalNetworkGateway ID: %+v", input, err) - } - - resourceId := LocalNetworkGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("localNetworkGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/local_network_gateway_test.go b/internal/services/network/parse/local_network_gateway_test.go deleted file mode 100644 index cf4259fb8507..000000000000 --- a/internal/services/network/parse/local_network_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = LocalNetworkGatewayId{} - -func TestLocalNetworkGatewayIDFormatter(t *testing.T) { - actual := NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "localNetworkGateway1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/localNetworkGateway1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestLocalNetworkGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *LocalNetworkGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/localNetworkGateway1", - Expected: &LocalNetworkGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "localNetworkGateway1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/LOCALNETWORKGATEWAYS/LOCALNETWORKGATEWAY1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := LocalNetworkGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/nat_gateway.go b/internal/services/network/parse/nat_gateway.go deleted file mode 100644 index bbcd485481cf..000000000000 --- a/internal/services/network/parse/nat_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NatGatewayId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewNatGatewayID(subscriptionId, resourceGroup, name string) NatGatewayId { - return NatGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id NatGatewayId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Nat Gateway", segmentsStr) -} - -func (id NatGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/natGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// NatGatewayID parses a NatGateway ID into an NatGatewayId struct -func NatGatewayID(input string) (*NatGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an NatGateway ID: %+v", input, err) - } - - resourceId := NatGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("natGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/nat_gateway_public_ip_association.go b/internal/services/network/parse/nat_gateway_public_ip_association.go deleted file mode 100644 index 8fb847f164cd..000000000000 --- a/internal/services/network/parse/nat_gateway_public_ip_association.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "fmt" - "strings" -) - -type NatGatewayPublicIPAddressAssociationId struct { - NatGateway NatGatewayId - PublicIPAddressID string -} - -func NatGatewayPublicIPAddressAssociationID(input string) (*NatGatewayPublicIPAddressAssociationId, error) { - segments := strings.Split(input, "|") - if len(segments) != 2 { - return nil, fmt.Errorf("Expected an ID in the format `{natGatewayID}|{publicIPAddressID} but got %q", input) - } - - natGatewayId, err := NatGatewayID(segments[0]) - if err != nil { - return nil, fmt.Errorf("parsing NAT Gateway ID %q: %+v", segments[0], err) - } - - // whilst we need the Resource ID, we may as well validate it - publicIPAddress := segments[1] - if _, err := PublicIpAddressID(publicIPAddress); err != nil { - return nil, fmt.Errorf("parsing Public IP Address ID %q: %+v", publicIPAddress, err) - } - - return &NatGatewayPublicIPAddressAssociationId{ - NatGateway: *natGatewayId, - PublicIPAddressID: publicIPAddress, - }, nil -} diff --git a/internal/services/network/parse/nat_gateway_public_ip_association_test.go b/internal/services/network/parse/nat_gateway_public_ip_association_test.go deleted file mode 100644 index 28453ef955b6..000000000000 --- a/internal/services/network/parse/nat_gateway_public_ip_association_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "testing" -) - -func TestNatGatewayPublicIPAddressAssociationID(t *testing.T) { - testData := []struct { - Name string - Input string - Error bool - Expect *NatGatewayPublicIPAddressAssociationId - }{ - { - Name: "Empty", - Input: "", - Error: true, - }, - { - Name: "One Segment", - Input: "hello", - Error: true, - }, - { - Name: "Two Segments Invalid ID's", - Input: "hello|world", - Error: true, - }, - { - Name: "Missing Nat Gateway Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways", - Error: true, - }, - { - Name: "Nat Gateway ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1", - Error: true, - }, - { - Name: "Public IP Address ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPAddresses/myPublicIpAddress1", - Error: true, - }, - { - Name: "Nat Gateway / Public IP Association ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPAddresses/myPublicIpAddress1", - Error: false, - Expect: &NatGatewayPublicIPAddressAssociationId{ - NatGateway: NatGatewayId{ - Name: "gateway1", - ResourceGroup: "group1", - }, - PublicIPAddressID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPAddresses/myPublicIpAddress1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) - - actual, err := NatGatewayPublicIPAddressAssociationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.NatGateway.Name != v.Expect.NatGateway.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expect.NatGateway.Name, actual.NatGateway.Name) - } - - if actual.NatGateway.ResourceGroup != v.Expect.NatGateway.ResourceGroup { - t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.NatGateway.ResourceGroup, actual.NatGateway.ResourceGroup) - } - } -} diff --git a/internal/services/network/parse/nat_gateway_public_ip_prefix_association.go b/internal/services/network/parse/nat_gateway_public_ip_prefix_association.go deleted file mode 100644 index 962669dfd8d1..000000000000 --- a/internal/services/network/parse/nat_gateway_public_ip_prefix_association.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "fmt" - "strings" -) - -type NatGatewayPublicIPPrefixAssociationId struct { - NatGateway NatGatewayId - PublicIPPrefixID string -} - -func NatGatewayPublicIPPrefixAssociationID(input string) (*NatGatewayPublicIPPrefixAssociationId, error) { - segments := strings.Split(input, "|") - if len(segments) != 2 { - return nil, fmt.Errorf("Expected an ID in the format `{natGatewayID}|{publicIPPrefixID} but got %q", input) - } - - natGatewayId, err := NatGatewayID(segments[0]) - if err != nil { - return nil, fmt.Errorf("parsing NAT Gateway ID %q: %+v", segments[0], err) - } - - // whilst we need the Resource ID, we may as well validate it - publicIPPrefix := segments[1] - if _, err := PublicIpPrefixID(publicIPPrefix); err != nil { - return nil, fmt.Errorf("parsing Public IP Address ID %q: %+v", publicIPPrefix, err) - } - - return &NatGatewayPublicIPPrefixAssociationId{ - NatGateway: *natGatewayId, - PublicIPPrefixID: publicIPPrefix, - }, nil -} diff --git a/internal/services/network/parse/nat_gateway_public_ip_prefix_association_test.go b/internal/services/network/parse/nat_gateway_public_ip_prefix_association_test.go deleted file mode 100644 index 325ae8c2a277..000000000000 --- a/internal/services/network/parse/nat_gateway_public_ip_prefix_association_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -import ( - "testing" -) - -func TestNatGatewayPublicIPPrefixAssociationID(t *testing.T) { - testData := []struct { - Name string - Input string - Error bool - Expect *NatGatewayPublicIPPrefixAssociationId - }{ - { - Name: "Empty", - Input: "", - Error: true, - }, - { - Name: "One Segment", - Input: "hello", - Error: true, - }, - { - Name: "Two Segments Invalid ID's", - Input: "hello|world", - Error: true, - }, - { - Name: "Missing Nat Gateway Value", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways", - Error: true, - }, - { - Name: "Nat Gateway ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1", - Error: true, - }, - { - Name: "Public IP Address ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPPrefixes/myPublicIPPrefix1", - Error: true, - }, - { - Name: "Nat Gateway / Public IP Association ID", - Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/natGateways/gateway1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPPrefixes/myPublicIPPrefix1", - Error: false, - Expect: &NatGatewayPublicIPPrefixAssociationId{ - NatGateway: NatGatewayId{ - Name: "gateway1", - ResourceGroup: "group1", - }, - PublicIPPrefixID: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/publicIPPrefixes/myPublicIPPrefix1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Name) - - actual, err := NatGatewayPublicIPPrefixAssociationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expected a value but got an error: %s", err) - } - - if actual.NatGateway.Name != v.Expect.NatGateway.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expect.NatGateway.Name, actual.NatGateway.Name) - } - - if actual.NatGateway.ResourceGroup != v.Expect.NatGateway.ResourceGroup { - t.Fatalf("Expected %q but got %q for Resource Group", v.Expect.NatGateway.ResourceGroup, actual.NatGateway.ResourceGroup) - } - } -} diff --git a/internal/services/network/parse/nat_gateway_test.go b/internal/services/network/parse/nat_gateway_test.go deleted file mode 100644 index cff95f73872a..000000000000 --- a/internal/services/network/parse/nat_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NatGatewayId{} - -func TestNatGatewayIDFormatter(t *testing.T) { - actual := NewNatGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "gateway1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/gateway1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNatGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NatGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/gateway1", - Expected: &NatGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "gateway1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NATGATEWAYS/GATEWAY1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NatGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/network_gateway_connection.go b/internal/services/network/parse/network_gateway_connection.go deleted file mode 100644 index 7b1d9ca562f9..000000000000 --- a/internal/services/network/parse/network_gateway_connection.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NetworkGatewayConnectionId struct { - SubscriptionId string - ResourceGroup string - ConnectionName string -} - -func NewNetworkGatewayConnectionID(subscriptionId, resourceGroup, connectionName string) NetworkGatewayConnectionId { - return NetworkGatewayConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ConnectionName: connectionName, - } -} - -func (id NetworkGatewayConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Connection Name %q", id.ConnectionName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Network Gateway Connection", segmentsStr) -} - -func (id NetworkGatewayConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/connections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ConnectionName) -} - -// NetworkGatewayConnectionID parses a NetworkGatewayConnection ID into an NetworkGatewayConnectionId struct -func NetworkGatewayConnectionID(input string) (*NetworkGatewayConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an NetworkGatewayConnection ID: %+v", input, err) - } - - resourceId := NetworkGatewayConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ConnectionName, err = id.PopSegment("connections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/network_gateway_connection_test.go b/internal/services/network/parse/network_gateway_connection_test.go deleted file mode 100644 index 3a007f8bb5ed..000000000000 --- a/internal/services/network/parse/network_gateway_connection_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NetworkGatewayConnectionId{} - -func TestNetworkGatewayConnectionIDFormatter(t *testing.T) { - actual := NewNetworkGatewayConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "connection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/connection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNetworkGatewayConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NetworkGatewayConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/connection1", - Expected: &NetworkGatewayConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ConnectionName: "connection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/CONNECTIONS/CONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NetworkGatewayConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ConnectionName != v.Expected.ConnectionName { - t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) - } - } -} diff --git a/internal/services/network/parse/network_interface.go b/internal/services/network/parse/network_interface.go deleted file mode 100644 index d5d6a319aa0b..000000000000 --- a/internal/services/network/parse/network_interface.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NetworkInterfaceId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewNetworkInterfaceID(subscriptionId, resourceGroup, name string) NetworkInterfaceId { - return NetworkInterfaceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id NetworkInterfaceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Network Interface", segmentsStr) -} - -func (id NetworkInterfaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkInterfaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// NetworkInterfaceID parses a NetworkInterface ID into an NetworkInterfaceId struct -func NetworkInterfaceID(input string) (*NetworkInterfaceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an NetworkInterface ID: %+v", input, err) - } - - resourceId := NetworkInterfaceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("networkInterfaces"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/network_interface_test.go b/internal/services/network/parse/network_interface_test.go deleted file mode 100644 index 2fec1c1f060f..000000000000 --- a/internal/services/network/parse/network_interface_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NetworkInterfaceId{} - -func TestNetworkInterfaceIDFormatter(t *testing.T) { - actual := NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "resGroup1", "networkInterface1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/networkInterface1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNetworkInterfaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NetworkInterfaceId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/networkInterface1", - Expected: &NetworkInterfaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "networkInterface1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NETWORKINTERFACES/NETWORKINTERFACE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NetworkInterfaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/network_security_group.go b/internal/services/network/parse/network_security_group.go deleted file mode 100644 index fcdcc14d56e4..000000000000 --- a/internal/services/network/parse/network_security_group.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type NetworkSecurityGroupId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewNetworkSecurityGroupID(subscriptionId, resourceGroup, name string) NetworkSecurityGroupId { - return NetworkSecurityGroupId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id NetworkSecurityGroupId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Network Security Group", segmentsStr) -} - -func (id NetworkSecurityGroupId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// NetworkSecurityGroupID parses a NetworkSecurityGroup ID into an NetworkSecurityGroupId struct -func NetworkSecurityGroupID(input string) (*NetworkSecurityGroupId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an NetworkSecurityGroup ID: %+v", input, err) - } - - resourceId := NetworkSecurityGroupId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("networkSecurityGroups"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} - -// NetworkSecurityGroupIDInsensitively parses an NetworkSecurityGroup ID into an NetworkSecurityGroupId struct, insensitively -// This should only be used to parse an ID for rewriting, the NetworkSecurityGroupID -// method should be used instead for validation etc. -// -// Whilst this may seem strange, this enables Terraform have consistent casing -// which works around issues in Core, whilst handling broken API responses. -func NetworkSecurityGroupIDInsensitively(input string) (*NetworkSecurityGroupId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, err - } - - resourceId := NetworkSecurityGroupId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - // find the correct casing for the 'networkSecurityGroups' segment - networkSecurityGroupsKey := "networkSecurityGroups" - for key := range id.Path { - if strings.EqualFold(key, networkSecurityGroupsKey) { - networkSecurityGroupsKey = key - break - } - } - if resourceId.Name, err = id.PopSegment(networkSecurityGroupsKey); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/network_security_group_test.go b/internal/services/network/parse/network_security_group_test.go deleted file mode 100644 index 035d98830bbf..000000000000 --- a/internal/services/network/parse/network_security_group_test.go +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = NetworkSecurityGroupId{} - -func TestNetworkSecurityGroupIDFormatter(t *testing.T) { - actual := NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "resGroup1", "securityGroup1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/securityGroup1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestNetworkSecurityGroupID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NetworkSecurityGroupId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/securityGroup1", - Expected: &NetworkSecurityGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "securityGroup1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/SECURITYGROUP1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NetworkSecurityGroupID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} - -func TestNetworkSecurityGroupIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *NetworkSecurityGroupId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/securityGroup1", - Expected: &NetworkSecurityGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "securityGroup1", - }, - }, - - { - // lower-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networksecuritygroups/securityGroup1", - Expected: &NetworkSecurityGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "securityGroup1", - }, - }, - - { - // upper-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/NETWORKSECURITYGROUPS/securityGroup1", - Expected: &NetworkSecurityGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "securityGroup1", - }, - }, - - { - // mixed-cased segment names - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/NeTwOrKsEcUrItYgRoUpS/securityGroup1", - Expected: &NetworkSecurityGroupId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "securityGroup1", - }, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := NetworkSecurityGroupIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/point_to_site_vpn_gateway.go b/internal/services/network/parse/point_to_site_vpn_gateway.go deleted file mode 100644 index c5776804cd0b..000000000000 --- a/internal/services/network/parse/point_to_site_vpn_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PointToSiteVpnGatewayId struct { - SubscriptionId string - ResourceGroup string - P2sVpnGatewayName string -} - -func NewPointToSiteVpnGatewayID(subscriptionId, resourceGroup, p2sVpnGatewayName string) PointToSiteVpnGatewayId { - return PointToSiteVpnGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - P2sVpnGatewayName: p2sVpnGatewayName, - } -} - -func (id PointToSiteVpnGatewayId) String() string { - segments := []string{ - fmt.Sprintf("P2s Vpn Gateway Name %q", id.P2sVpnGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Point To Site Vpn Gateway", segmentsStr) -} - -func (id PointToSiteVpnGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/p2sVpnGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.P2sVpnGatewayName) -} - -// PointToSiteVpnGatewayID parses a PointToSiteVpnGateway ID into an PointToSiteVpnGatewayId struct -func PointToSiteVpnGatewayID(input string) (*PointToSiteVpnGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an PointToSiteVpnGateway ID: %+v", input, err) - } - - resourceId := PointToSiteVpnGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.P2sVpnGatewayName, err = id.PopSegment("p2sVpnGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/point_to_site_vpn_gateway_test.go b/internal/services/network/parse/point_to_site_vpn_gateway_test.go deleted file mode 100644 index df8c64f00bb2..000000000000 --- a/internal/services/network/parse/point_to_site_vpn_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PointToSiteVpnGatewayId{} - -func TestPointToSiteVpnGatewayIDFormatter(t *testing.T) { - actual := NewPointToSiteVpnGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "pointToSite1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/pointToSite1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPointToSiteVpnGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PointToSiteVpnGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing P2sVpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for P2sVpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/pointToSite1", - Expected: &PointToSiteVpnGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - P2sVpnGatewayName: "pointToSite1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/P2SVPNGATEWAYS/POINTTOSITE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PointToSiteVpnGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.P2sVpnGatewayName != v.Expected.P2sVpnGatewayName { - t.Fatalf("Expected %q but got %q for P2sVpnGatewayName", v.Expected.P2sVpnGatewayName, actual.P2sVpnGatewayName) - } - } -} diff --git a/internal/services/network/parse/private_link_service.go b/internal/services/network/parse/private_link_service.go deleted file mode 100644 index 2f0ab1f4bfe8..000000000000 --- a/internal/services/network/parse/private_link_service.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PrivateLinkServiceId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewPrivateLinkServiceID(subscriptionId, resourceGroup, name string) PrivateLinkServiceId { - return PrivateLinkServiceId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id PrivateLinkServiceId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Private Link Service", segmentsStr) -} - -func (id PrivateLinkServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// PrivateLinkServiceID parses a PrivateLinkService ID into an PrivateLinkServiceId struct -func PrivateLinkServiceID(input string) (*PrivateLinkServiceId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an PrivateLinkService ID: %+v", input, err) - } - - resourceId := PrivateLinkServiceId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("privateLinkServices"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/private_link_service_test.go b/internal/services/network/parse/private_link_service_test.go deleted file mode 100644 index eca40533dcbc..000000000000 --- a/internal/services/network/parse/private_link_service_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PrivateLinkServiceId{} - -func TestPrivateLinkServiceIDFormatter(t *testing.T) { - actual := NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "resGroup1", "privateLinkService1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/privateLinkService1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPrivateLinkServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateLinkServiceId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/privateLinkService1", - Expected: &PrivateLinkServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "privateLinkService1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PRIVATELINKSERVICES/PRIVATELINKSERVICE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PrivateLinkServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/public_ip_address.go b/internal/services/network/parse/public_ip_address.go deleted file mode 100644 index 41c6efc04a5f..000000000000 --- a/internal/services/network/parse/public_ip_address.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PublicIpAddressId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewPublicIpAddressID(subscriptionId, resourceGroup, name string) PublicIpAddressId { - return PublicIpAddressId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id PublicIpAddressId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Public Ip Address", segmentsStr) -} - -func (id PublicIpAddressId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// PublicIpAddressID parses a PublicIpAddress ID into an PublicIpAddressId struct -func PublicIpAddressID(input string) (*PublicIpAddressId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an PublicIpAddress ID: %+v", input, err) - } - - resourceId := PublicIpAddressId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("publicIPAddresses"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/public_ip_address_test.go b/internal/services/network/parse/public_ip_address_test.go deleted file mode 100644 index 4b58dbd39117..000000000000 --- a/internal/services/network/parse/public_ip_address_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PublicIpAddressId{} - -func TestPublicIpAddressIDFormatter(t *testing.T) { - actual := NewPublicIpAddressID("12345678-1234-9876-4563-123456789012", "resGroup1", "publicIpAddress1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/publicIpAddress1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPublicIpAddressID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PublicIpAddressId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/publicIpAddress1", - Expected: &PublicIpAddressId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "publicIpAddress1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PUBLICIPADDRESSES/PUBLICIPADDRESS1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PublicIpAddressID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/public_ip_prefix.go b/internal/services/network/parse/public_ip_prefix.go deleted file mode 100644 index 183e79e164a1..000000000000 --- a/internal/services/network/parse/public_ip_prefix.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type PublicIpPrefixId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewPublicIpPrefixID(subscriptionId, resourceGroup, name string) PublicIpPrefixId { - return PublicIpPrefixId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id PublicIpPrefixId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Public Ip Prefix", segmentsStr) -} - -func (id PublicIpPrefixId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPPrefixes/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// PublicIpPrefixID parses a PublicIpPrefix ID into an PublicIpPrefixId struct -func PublicIpPrefixID(input string) (*PublicIpPrefixId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an PublicIpPrefix ID: %+v", input, err) - } - - resourceId := PublicIpPrefixId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("publicIPPrefixes"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/public_ip_prefix_test.go b/internal/services/network/parse/public_ip_prefix_test.go deleted file mode 100644 index 9a7183038113..000000000000 --- a/internal/services/network/parse/public_ip_prefix_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = PublicIpPrefixId{} - -func TestPublicIpPrefixIDFormatter(t *testing.T) { - actual := NewPublicIpPrefixID("12345678-1234-9876-4563-123456789012", "resGroup1", "publicIpPrefix1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIpPrefix1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestPublicIpPrefixID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PublicIpPrefixId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIpPrefix1", - Expected: &PublicIpPrefixId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "publicIpPrefix1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PUBLICIPPREFIXES/PUBLICIPPREFIX1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := PublicIpPrefixID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/route_map.go b/internal/services/network/parse/route_map.go deleted file mode 100644 index e9239fddb899..000000000000 --- a/internal/services/network/parse/route_map.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type RouteMapId struct { - SubscriptionId string - ResourceGroup string - VirtualHubName string - Name string -} - -func NewRouteMapID(subscriptionId, resourceGroup, virtualHubName, name string) RouteMapId { - return RouteMapId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualHubName: virtualHubName, - Name: name, - } -} - -func (id RouteMapId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Virtual Hub Name %q", id.VirtualHubName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Route Map", segmentsStr) -} - -func (id RouteMapId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/routeMaps/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualHubName, id.Name) -} - -// RouteMapID parses a RouteMap ID into an RouteMapId struct -func RouteMapID(input string) (*RouteMapId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an RouteMap ID: %+v", input, err) - } - - resourceId := RouteMapId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualHubName, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("routeMaps"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/route_map_test.go b/internal/services/network/parse/route_map_test.go deleted file mode 100644 index 65c73adf61b2..000000000000 --- a/internal/services/network/parse/route_map_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = RouteMapId{} - -func TestRouteMapIDFormatter(t *testing.T) { - actual := NewRouteMapID("12345678-1234-9876-4563-123456789012", "resGroup1", "vhub1", "routeMap1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/routeMap1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestRouteMapID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *RouteMapId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/routeMap1", - Expected: &RouteMapId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "vhub1", - Name: "routeMap1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VHUB1/ROUTEMAPS/ROUTEMAP1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := RouteMapID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/security_partner_provider.go b/internal/services/network/parse/security_partner_provider.go deleted file mode 100644 index 74790b079581..000000000000 --- a/internal/services/network/parse/security_partner_provider.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SecurityPartnerProviderId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewSecurityPartnerProviderID(subscriptionId, resourceGroup, name string) SecurityPartnerProviderId { - return SecurityPartnerProviderId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id SecurityPartnerProviderId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Security Partner Provider", segmentsStr) -} - -func (id SecurityPartnerProviderId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/securityPartnerProviders/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// SecurityPartnerProviderID parses a SecurityPartnerProvider ID into an SecurityPartnerProviderId struct -func SecurityPartnerProviderID(input string) (*SecurityPartnerProviderId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SecurityPartnerProvider ID: %+v", input, err) - } - - resourceId := SecurityPartnerProviderId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("securityPartnerProviders"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/security_partner_provider_test.go b/internal/services/network/parse/security_partner_provider_test.go deleted file mode 100644 index 6a249e2f1ba6..000000000000 --- a/internal/services/network/parse/security_partner_provider_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SecurityPartnerProviderId{} - -func TestSecurityPartnerProviderIDFormatter(t *testing.T) { - actual := NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "resGroup1", "partnerProvider1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/partnerProvider1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSecurityPartnerProviderID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SecurityPartnerProviderId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/partnerProvider1", - Expected: &SecurityPartnerProviderId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "partnerProvider1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/SECURITYPARTNERPROVIDERS/PARTNERPROVIDER1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SecurityPartnerProviderID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/subnet_service_endpoint_storage_policy.go b/internal/services/network/parse/subnet_service_endpoint_storage_policy.go deleted file mode 100644 index 5780785f5fdc..000000000000 --- a/internal/services/network/parse/subnet_service_endpoint_storage_policy.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type SubnetServiceEndpointStoragePolicyId struct { - SubscriptionId string - ResourceGroup string - ServiceEndpointPolicyName string -} - -func NewSubnetServiceEndpointStoragePolicyID(subscriptionId, resourceGroup, serviceEndpointPolicyName string) SubnetServiceEndpointStoragePolicyId { - return SubnetServiceEndpointStoragePolicyId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - ServiceEndpointPolicyName: serviceEndpointPolicyName, - } -} - -func (id SubnetServiceEndpointStoragePolicyId) String() string { - segments := []string{ - fmt.Sprintf("Service Endpoint Policy Name %q", id.ServiceEndpointPolicyName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Subnet Service Endpoint Storage Policy", segmentsStr) -} - -func (id SubnetServiceEndpointStoragePolicyId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/serviceEndpointPolicies/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.ServiceEndpointPolicyName) -} - -// SubnetServiceEndpointStoragePolicyID parses a SubnetServiceEndpointStoragePolicy ID into an SubnetServiceEndpointStoragePolicyId struct -func SubnetServiceEndpointStoragePolicyID(input string) (*SubnetServiceEndpointStoragePolicyId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an SubnetServiceEndpointStoragePolicy ID: %+v", input, err) - } - - resourceId := SubnetServiceEndpointStoragePolicyId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.ServiceEndpointPolicyName, err = id.PopSegment("serviceEndpointPolicies"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/subnet_service_endpoint_storage_policy_test.go b/internal/services/network/parse/subnet_service_endpoint_storage_policy_test.go deleted file mode 100644 index 9c04429689ac..000000000000 --- a/internal/services/network/parse/subnet_service_endpoint_storage_policy_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = SubnetServiceEndpointStoragePolicyId{} - -func TestSubnetServiceEndpointStoragePolicyIDFormatter(t *testing.T) { - actual := NewSubnetServiceEndpointStoragePolicyID("12345678-1234-9876-4563-123456789012", "resGroup1", "policy1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/policy1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestSubnetServiceEndpointStoragePolicyID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *SubnetServiceEndpointStoragePolicyId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing ServiceEndpointPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for ServiceEndpointPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/policy1", - Expected: &SubnetServiceEndpointStoragePolicyId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - ServiceEndpointPolicyName: "policy1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/SERVICEENDPOINTPOLICIES/POLICY1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := SubnetServiceEndpointStoragePolicyID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { - t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) - } - } -} diff --git a/internal/services/network/parse/virtual_hub.go b/internal/services/network/parse/virtual_hub.go deleted file mode 100644 index 2fb6dd75056f..000000000000 --- a/internal/services/network/parse/virtual_hub.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualHubId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewVirtualHubID(subscriptionId, resourceGroup, name string) VirtualHubId { - return VirtualHubId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id VirtualHubId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Hub", segmentsStr) -} - -func (id VirtualHubId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// VirtualHubID parses a VirtualHub ID into an VirtualHubId struct -func VirtualHubID(input string) (*VirtualHubId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualHub ID: %+v", input, err) - } - - resourceId := VirtualHubId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_hub_ip_configuration.go b/internal/services/network/parse/virtual_hub_ip_configuration.go deleted file mode 100644 index 5fa24771bfa4..000000000000 --- a/internal/services/network/parse/virtual_hub_ip_configuration.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualHubIpConfigurationId struct { - SubscriptionId string - ResourceGroup string - VirtualHubName string - IpConfigurationName string -} - -func NewVirtualHubIpConfigurationID(subscriptionId, resourceGroup, virtualHubName, ipConfigurationName string) VirtualHubIpConfigurationId { - return VirtualHubIpConfigurationId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualHubName: virtualHubName, - IpConfigurationName: ipConfigurationName, - } -} - -func (id VirtualHubIpConfigurationId) String() string { - segments := []string{ - fmt.Sprintf("Ip Configuration Name %q", id.IpConfigurationName), - fmt.Sprintf("Virtual Hub Name %q", id.VirtualHubName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Hub Ip Configuration", segmentsStr) -} - -func (id VirtualHubIpConfigurationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/ipConfigurations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualHubName, id.IpConfigurationName) -} - -// VirtualHubIpConfigurationID parses a VirtualHubIpConfiguration ID into an VirtualHubIpConfigurationId struct -func VirtualHubIpConfigurationID(input string) (*VirtualHubIpConfigurationId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualHubIpConfiguration ID: %+v", input, err) - } - - resourceId := VirtualHubIpConfigurationId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualHubName, err = id.PopSegment("virtualHubs"); err != nil { - return nil, err - } - if resourceId.IpConfigurationName, err = id.PopSegment("ipConfigurations"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_hub_ip_configuration_test.go b/internal/services/network/parse/virtual_hub_ip_configuration_test.go deleted file mode 100644 index 92c527b3b11f..000000000000 --- a/internal/services/network/parse/virtual_hub_ip_configuration_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualHubIpConfigurationId{} - -func TestVirtualHubIpConfigurationIDFormatter(t *testing.T) { - actual := NewVirtualHubIpConfigurationID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualHub1", "ipConfiguration1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/ipConfiguration1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualHubIpConfigurationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualHubIpConfigurationId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // missing IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Error: true, - }, - - { - // missing value for IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/ipConfiguration1", - Expected: &VirtualHubIpConfigurationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualHubName: "virtualHub1", - IpConfigurationName: "ipConfiguration1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/IPCONFIGURATIONS/IPCONFIGURATION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualHubIpConfigurationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualHubName != v.Expected.VirtualHubName { - t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) - } - if actual.IpConfigurationName != v.Expected.IpConfigurationName { - t.Fatalf("Expected %q but got %q for IpConfigurationName", v.Expected.IpConfigurationName, actual.IpConfigurationName) - } - } -} diff --git a/internal/services/network/parse/virtual_hub_test.go b/internal/services/network/parse/virtual_hub_test.go deleted file mode 100644 index 4e0abfbbc79d..000000000000 --- a/internal/services/network/parse/virtual_hub_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualHubId{} - -func TestVirtualHubIDFormatter(t *testing.T) { - actual := NewVirtualHubID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualHub1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualHubID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualHubId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1", - Expected: &VirtualHubId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "virtualHub1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualHubID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/virtual_machine_scale_set_public_ip_address.go b/internal/services/network/parse/virtual_machine_scale_set_public_ip_address.go deleted file mode 100644 index 155ea3eea23d..000000000000 --- a/internal/services/network/parse/virtual_machine_scale_set_public_ip_address.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualMachineScaleSetPublicIPAddressId struct { - SubscriptionId string - ResourceGroup string - VirtualMachineScaleSetName string - VirtualMachineName string - NetworkInterfaceName string - IpConfigurationName string - PublicIPAddressName string -} - -func NewVirtualMachineScaleSetPublicIPAddressID(subscriptionId, resourceGroup, virtualMachineScaleSetName, virtualMachineName, networkInterfaceName, ipConfigurationName, publicIPAddressName string) VirtualMachineScaleSetPublicIPAddressId { - return VirtualMachineScaleSetPublicIPAddressId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualMachineScaleSetName: virtualMachineScaleSetName, - VirtualMachineName: virtualMachineName, - NetworkInterfaceName: networkInterfaceName, - IpConfigurationName: ipConfigurationName, - PublicIPAddressName: publicIPAddressName, - } -} - -func (id VirtualMachineScaleSetPublicIPAddressId) String() string { - segments := []string{ - fmt.Sprintf("Public I P Address Name %q", id.PublicIPAddressName), - fmt.Sprintf("Ip Configuration Name %q", id.IpConfigurationName), - fmt.Sprintf("Network Interface Name %q", id.NetworkInterfaceName), - fmt.Sprintf("Virtual Machine Name %q", id.VirtualMachineName), - fmt.Sprintf("Virtual Machine Scale Set Name %q", id.VirtualMachineScaleSetName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Machine Scale Set Public I P Address", segmentsStr) -} - -func (id VirtualMachineScaleSetPublicIPAddressId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s/networkInterfaces/%s/ipConfigurations/%s/publicIPAddresses/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualMachineScaleSetName, id.VirtualMachineName, id.NetworkInterfaceName, id.IpConfigurationName, id.PublicIPAddressName) -} - -// VirtualMachineScaleSetPublicIPAddressID parses a VirtualMachineScaleSetPublicIPAddress ID into an VirtualMachineScaleSetPublicIPAddressId struct -func VirtualMachineScaleSetPublicIPAddressID(input string) (*VirtualMachineScaleSetPublicIPAddressId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualMachineScaleSetPublicIPAddress ID: %+v", input, err) - } - - resourceId := VirtualMachineScaleSetPublicIPAddressId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualMachineScaleSetName, err = id.PopSegment("virtualMachineScaleSets"); err != nil { - return nil, err - } - if resourceId.VirtualMachineName, err = id.PopSegment("virtualMachines"); err != nil { - return nil, err - } - if resourceId.NetworkInterfaceName, err = id.PopSegment("networkInterfaces"); err != nil { - return nil, err - } - if resourceId.IpConfigurationName, err = id.PopSegment("ipConfigurations"); err != nil { - return nil, err - } - if resourceId.PublicIPAddressName, err = id.PopSegment("publicIPAddresses"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_machine_scale_set_public_ip_address_test.go b/internal/services/network/parse/virtual_machine_scale_set_public_ip_address_test.go deleted file mode 100644 index d3d39d927194..000000000000 --- a/internal/services/network/parse/virtual_machine_scale_set_public_ip_address_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualMachineScaleSetPublicIPAddressId{} - -func TestVirtualMachineScaleSetPublicIPAddressIDFormatter(t *testing.T) { - actual := NewVirtualMachineScaleSetPublicIPAddressID("12345678-1234-9876-4563-123456789012", "resGroup1", "scaleSet1", "virtualMachine1", "networkInterface1", "ipConfiguration1", "publicIpAddress1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/publicIpAddress1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualMachineScaleSetPublicIPAddressID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualMachineScaleSetPublicIPAddressId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualMachineScaleSetName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/", - Error: true, - }, - - { - // missing value for VirtualMachineScaleSetName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/", - Error: true, - }, - - { - // missing VirtualMachineName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/", - Error: true, - }, - - { - // missing value for VirtualMachineName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/", - Error: true, - }, - - { - // missing NetworkInterfaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/", - Error: true, - }, - - { - // missing value for NetworkInterfaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/", - Error: true, - }, - - { - // missing IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/", - Error: true, - }, - - { - // missing value for IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/", - Error: true, - }, - - { - // missing PublicIPAddressName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/", - Error: true, - }, - - { - // missing value for PublicIPAddressName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/publicIpAddress1", - Expected: &VirtualMachineScaleSetPublicIPAddressId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualMachineScaleSetName: "scaleSet1", - VirtualMachineName: "virtualMachine1", - NetworkInterfaceName: "networkInterface1", - IpConfigurationName: "ipConfiguration1", - PublicIPAddressName: "publicIpAddress1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.COMPUTE/VIRTUALMACHINESCALESETS/SCALESET1/VIRTUALMACHINES/VIRTUALMACHINE1/NETWORKINTERFACES/NETWORKINTERFACE1/IPCONFIGURATIONS/IPCONFIGURATION1/PUBLICIPADDRESSES/PUBLICIPADDRESS1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualMachineScaleSetPublicIPAddressID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { - t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) - } - if actual.VirtualMachineName != v.Expected.VirtualMachineName { - t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) - } - if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { - t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) - } - if actual.IpConfigurationName != v.Expected.IpConfigurationName { - t.Fatalf("Expected %q but got %q for IpConfigurationName", v.Expected.IpConfigurationName, actual.IpConfigurationName) - } - if actual.PublicIPAddressName != v.Expected.PublicIPAddressName { - t.Fatalf("Expected %q but got %q for PublicIPAddressName", v.Expected.PublicIPAddressName, actual.PublicIPAddressName) - } - } -} diff --git a/internal/services/network/parse/virtual_network_gateway.go b/internal/services/network/parse/virtual_network_gateway.go deleted file mode 100644 index 0c9cc1ce3520..000000000000 --- a/internal/services/network/parse/virtual_network_gateway.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualNetworkGatewayId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewVirtualNetworkGatewayID(subscriptionId, resourceGroup, name string) VirtualNetworkGatewayId { - return VirtualNetworkGatewayId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id VirtualNetworkGatewayId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Network Gateway", segmentsStr) -} - -func (id VirtualNetworkGatewayId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// VirtualNetworkGatewayID parses a VirtualNetworkGateway ID into an VirtualNetworkGatewayId struct -func VirtualNetworkGatewayID(input string) (*VirtualNetworkGatewayId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualNetworkGateway ID: %+v", input, err) - } - - resourceId := VirtualNetworkGatewayId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("virtualNetworkGateways"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_network_gateway_nat_rule.go b/internal/services/network/parse/virtual_network_gateway_nat_rule.go deleted file mode 100644 index 3ede31162adf..000000000000 --- a/internal/services/network/parse/virtual_network_gateway_nat_rule.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualNetworkGatewayNatRuleId struct { - SubscriptionId string - ResourceGroup string - VirtualNetworkGatewayName string - NatRuleName string -} - -func NewVirtualNetworkGatewayNatRuleID(subscriptionId, resourceGroup, virtualNetworkGatewayName, natRuleName string) VirtualNetworkGatewayNatRuleId { - return VirtualNetworkGatewayNatRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualNetworkGatewayName: virtualNetworkGatewayName, - NatRuleName: natRuleName, - } -} - -func (id VirtualNetworkGatewayNatRuleId) String() string { - segments := []string{ - fmt.Sprintf("Nat Rule Name %q", id.NatRuleName), - fmt.Sprintf("Virtual Network Gateway Name %q", id.VirtualNetworkGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Network Gateway Nat Rule", segmentsStr) -} - -func (id VirtualNetworkGatewayNatRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s/natRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualNetworkGatewayName, id.NatRuleName) -} - -// VirtualNetworkGatewayNatRuleID parses a VirtualNetworkGatewayNatRule ID into an VirtualNetworkGatewayNatRuleId struct -func VirtualNetworkGatewayNatRuleID(input string) (*VirtualNetworkGatewayNatRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualNetworkGatewayNatRule ID: %+v", input, err) - } - - resourceId := VirtualNetworkGatewayNatRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualNetworkGatewayName, err = id.PopSegment("virtualNetworkGateways"); err != nil { - return nil, err - } - if resourceId.NatRuleName, err = id.PopSegment("natRules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_network_gateway_nat_rule_test.go b/internal/services/network/parse/virtual_network_gateway_nat_rule_test.go deleted file mode 100644 index e73308c60d31..000000000000 --- a/internal/services/network/parse/virtual_network_gateway_nat_rule_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualNetworkGatewayNatRuleId{} - -func TestVirtualNetworkGatewayNatRuleIDFormatter(t *testing.T) { - actual := NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "gw1", "rule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/rule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualNetworkGatewayNatRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualNetworkGatewayNatRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualNetworkGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualNetworkGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/", - Error: true, - }, - - { - // missing NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/", - Error: true, - }, - - { - // missing value for NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/rule1", - Expected: &VirtualNetworkGatewayNatRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualNetworkGatewayName: "gw1", - NatRuleName: "rule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKGATEWAYS/GW1/NATRULES/RULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualNetworkGatewayNatRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualNetworkGatewayName != v.Expected.VirtualNetworkGatewayName { - t.Fatalf("Expected %q but got %q for VirtualNetworkGatewayName", v.Expected.VirtualNetworkGatewayName, actual.VirtualNetworkGatewayName) - } - if actual.NatRuleName != v.Expected.NatRuleName { - t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) - } - } -} diff --git a/internal/services/network/parse/virtual_network_gateway_test.go b/internal/services/network/parse/virtual_network_gateway_test.go deleted file mode 100644 index 6da6c28e25fe..000000000000 --- a/internal/services/network/parse/virtual_network_gateway_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualNetworkGatewayId{} - -func TestVirtualNetworkGatewayIDFormatter(t *testing.T) { - actual := NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "resGroup1", "gw1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualNetworkGatewayID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualNetworkGatewayId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1", - Expected: &VirtualNetworkGatewayId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "gw1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKGATEWAYS/GW1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualNetworkGatewayID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/virtual_network_peering.go b/internal/services/network/parse/virtual_network_peering.go deleted file mode 100644 index b588eaa7fa6a..000000000000 --- a/internal/services/network/parse/virtual_network_peering.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualNetworkPeeringId struct { - SubscriptionId string - ResourceGroup string - VirtualNetworkName string - Name string -} - -func NewVirtualNetworkPeeringID(subscriptionId, resourceGroup, virtualNetworkName, name string) VirtualNetworkPeeringId { - return VirtualNetworkPeeringId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VirtualNetworkName: virtualNetworkName, - Name: name, - } -} - -func (id VirtualNetworkPeeringId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Virtual Network Name %q", id.VirtualNetworkName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Network Peering", segmentsStr) -} - -func (id VirtualNetworkPeeringId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/virtualNetworkPeerings/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VirtualNetworkName, id.Name) -} - -// VirtualNetworkPeeringID parses a VirtualNetworkPeering ID into an VirtualNetworkPeeringId struct -func VirtualNetworkPeeringID(input string) (*VirtualNetworkPeeringId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualNetworkPeering ID: %+v", input, err) - } - - resourceId := VirtualNetworkPeeringId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VirtualNetworkName, err = id.PopSegment("virtualNetworks"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("virtualNetworkPeerings"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_network_peering_test.go b/internal/services/network/parse/virtual_network_peering_test.go deleted file mode 100644 index 3e0c9b9d922d..000000000000 --- a/internal/services/network/parse/virtual_network_peering_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualNetworkPeeringId{} - -func TestVirtualNetworkPeeringIDFormatter(t *testing.T) { - actual := NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "resGroup1", "vnet1", "vnetPeering1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/vnetPeering1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualNetworkPeeringID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualNetworkPeeringId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VirtualNetworkName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VirtualNetworkName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/vnetPeering1", - Expected: &VirtualNetworkPeeringId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VirtualNetworkName: "vnet1", - Name: "vnetPeering1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKS/VNET1/VIRTUALNETWORKPEERINGS/VNETPEERING1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualNetworkPeeringID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VirtualNetworkName != v.Expected.VirtualNetworkName { - t.Fatalf("Expected %q but got %q for VirtualNetworkName", v.Expected.VirtualNetworkName, actual.VirtualNetworkName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/virtual_wan.go b/internal/services/network/parse/virtual_wan.go deleted file mode 100644 index 796f3e19cb08..000000000000 --- a/internal/services/network/parse/virtual_wan.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VirtualWanId struct { - SubscriptionId string - ResourceGroup string - Name string -} - -func NewVirtualWanID(subscriptionId, resourceGroup, name string) VirtualWanId { - return VirtualWanId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - Name: name, - } -} - -func (id VirtualWanId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Virtual Wan", segmentsStr) -} - -func (id VirtualWanId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualWans/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) -} - -// VirtualWanID parses a VirtualWan ID into an VirtualWanId struct -func VirtualWanID(input string) (*VirtualWanId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VirtualWan ID: %+v", input, err) - } - - resourceId := VirtualWanId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.Name, err = id.PopSegment("virtualWans"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/virtual_wan_test.go b/internal/services/network/parse/virtual_wan_test.go deleted file mode 100644 index 358ebc8ca9bb..000000000000 --- a/internal/services/network/parse/virtual_wan_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VirtualWanId{} - -func TestVirtualWanIDFormatter(t *testing.T) { - actual := NewVirtualWanID("12345678-1234-9876-4563-123456789012", "resGroup1", "virtualWan1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/virtualWan1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVirtualWanID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VirtualWanId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/virtualWan1", - Expected: &VirtualWanId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - Name: "virtualWan1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALWANS/VIRTUALWAN1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VirtualWanID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/vpn_connection.go b/internal/services/network/parse/vpn_connection.go deleted file mode 100644 index 756f34853865..000000000000 --- a/internal/services/network/parse/vpn_connection.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VpnConnectionId struct { - SubscriptionId string - ResourceGroup string - VpnGatewayName string - Name string -} - -func NewVpnConnectionID(subscriptionId, resourceGroup, vpnGatewayName, name string) VpnConnectionId { - return VpnConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VpnGatewayName: vpnGatewayName, - Name: name, - } -} - -func (id VpnConnectionId) String() string { - segments := []string{ - fmt.Sprintf("Name %q", id.Name), - fmt.Sprintf("Vpn Gateway Name %q", id.VpnGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Vpn Connection", segmentsStr) -} - -func (id VpnConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s/vpnConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VpnGatewayName, id.Name) -} - -// VpnConnectionID parses a VpnConnection ID into an VpnConnectionId struct -func VpnConnectionID(input string) (*VpnConnectionId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VpnConnection ID: %+v", input, err) - } - - resourceId := VpnConnectionId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VpnGatewayName, err = id.PopSegment("vpnGateways"); err != nil { - return nil, err - } - if resourceId.Name, err = id.PopSegment("vpnConnections"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/vpn_connection_test.go b/internal/services/network/parse/vpn_connection_test.go deleted file mode 100644 index d4c864f07621..000000000000 --- a/internal/services/network/parse/vpn_connection_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VpnConnectionId{} - -func TestVpnConnectionIDFormatter(t *testing.T) { - actual := NewVpnConnectionID("12345678-1234-9876-4563-123456789012", "resGroup1", "vpnGateway1", "vpnConnection1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/vpnConnection1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVpnConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VpnConnectionId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/", - Error: true, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/", - Error: true, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/vpnConnection1", - Expected: &VpnConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VpnGatewayName: "vpnGateway1", - Name: "vpnConnection1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VPNGATEWAYS/VPNGATEWAY1/VPNCONNECTIONS/VPNCONNECTION1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VpnConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VpnGatewayName != v.Expected.VpnGatewayName { - t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) - } - if actual.Name != v.Expected.Name { - t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) - } - } -} diff --git a/internal/services/network/parse/vpn_gateway_nat_rule.go b/internal/services/network/parse/vpn_gateway_nat_rule.go deleted file mode 100644 index eb9d2a24957f..000000000000 --- a/internal/services/network/parse/vpn_gateway_nat_rule.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -type VpnGatewayNatRuleId struct { - SubscriptionId string - ResourceGroup string - VpnGatewayName string - NatRuleName string -} - -func NewVpnGatewayNatRuleID(subscriptionId, resourceGroup, vpnGatewayName, natRuleName string) VpnGatewayNatRuleId { - return VpnGatewayNatRuleId{ - SubscriptionId: subscriptionId, - ResourceGroup: resourceGroup, - VpnGatewayName: vpnGatewayName, - NatRuleName: natRuleName, - } -} - -func (id VpnGatewayNatRuleId) String() string { - segments := []string{ - fmt.Sprintf("Nat Rule Name %q", id.NatRuleName), - fmt.Sprintf("Vpn Gateway Name %q", id.VpnGatewayName), - fmt.Sprintf("Resource Group %q", id.ResourceGroup), - } - segmentsStr := strings.Join(segments, " / ") - return fmt.Sprintf("%s: (%s)", "Vpn Gateway Nat Rule", segmentsStr) -} - -func (id VpnGatewayNatRuleId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s/natRules/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.VpnGatewayName, id.NatRuleName) -} - -// VpnGatewayNatRuleID parses a VpnGatewayNatRule ID into an VpnGatewayNatRuleId struct -func VpnGatewayNatRuleID(input string) (*VpnGatewayNatRuleId, error) { - id, err := resourceids.ParseAzureResourceID(input) - if err != nil { - return nil, fmt.Errorf("parsing %q as an VpnGatewayNatRule ID: %+v", input, err) - } - - resourceId := VpnGatewayNatRuleId{ - SubscriptionId: id.SubscriptionID, - ResourceGroup: id.ResourceGroup, - } - - if resourceId.SubscriptionId == "" { - return nil, fmt.Errorf("ID was missing the 'subscriptions' element") - } - - if resourceId.ResourceGroup == "" { - return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") - } - - if resourceId.VpnGatewayName, err = id.PopSegment("vpnGateways"); err != nil { - return nil, err - } - if resourceId.NatRuleName, err = id.PopSegment("natRules"); err != nil { - return nil, err - } - - if err := id.ValidateNoEmptySegments(input); err != nil { - return nil, err - } - - return &resourceId, nil -} diff --git a/internal/services/network/parse/vpn_gateway_nat_rule_test.go b/internal/services/network/parse/vpn_gateway_nat_rule_test.go deleted file mode 100644 index a93cac033e4c..000000000000 --- a/internal/services/network/parse/vpn_gateway_nat_rule_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package parse - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.Id = VpnGatewayNatRuleId{} - -func TestVpnGatewayNatRuleIDFormatter(t *testing.T) { - actual := NewVpnGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "resGroup1", "vpnGateway1", "natRule1").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/natRule1" - if actual != expected { - t.Fatalf("Expected %q but got %q", expected, actual) - } -} - -func TestVpnGatewayNatRuleID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *VpnGatewayNatRuleId - }{ - - { - // empty - Input: "", - Error: true, - }, - - { - // missing SubscriptionId - Input: "/", - Error: true, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Error: true, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Error: true, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Error: true, - }, - - { - // missing VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Error: true, - }, - - { - // missing value for VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/", - Error: true, - }, - - { - // missing NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/", - Error: true, - }, - - { - // missing value for NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/", - Error: true, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/natRule1", - Expected: &VpnGatewayNatRuleId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroup: "resGroup1", - VpnGatewayName: "vpnGateway1", - NatRuleName: "natRule1", - }, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VPNGATEWAYS/VPNGATEWAY1/NATRULES/NATRULE1", - Error: true, - }, - } - - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := VpnGatewayNatRuleID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %s", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - if actual.ResourceGroup != v.Expected.ResourceGroup { - t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) - } - if actual.VpnGatewayName != v.Expected.VpnGatewayName { - t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) - } - if actual.NatRuleName != v.Expected.NatRuleName { - t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) - } - } -} diff --git a/internal/services/network/private_endpoint_connection_data_source.go b/internal/services/network/private_endpoint_connection_data_source.go index 3d6fbf6b31f7..813e711033e8 100644 --- a/internal/services/network/private_endpoint_connection_data_source.go +++ b/internal/services/network/private_endpoint_connection_data_source.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/networkinterfaces" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/privateendpoints" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -134,7 +133,7 @@ func dataSourcePrivateEndpointConnectionRead(d *pluginsdk.ResourceData, meta int } func flattenNetworkInterface(networkInterfaceId string) interface{} { - id, err := parse.NetworkInterfaceID(networkInterfaceId) + id, err := commonids.ParseNetworkInterfaceID(networkInterfaceId) if err != nil { return []interface{}{} } @@ -142,7 +141,7 @@ func flattenNetworkInterface(networkInterfaceId string) interface{} { return []interface{}{ map[string]interface{}{ "id": id.ID(), - "name": id.Name, + "name": id.NetworkInterfaceName, }, } } diff --git a/internal/services/network/public_ip_resource.go b/internal/services/network/public_ip_resource.go index c3737f33e1a6..1d3288f06118 100644 --- a/internal/services/network/public_ip_resource.go +++ b/internal/services/network/public_ip_resource.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/ddosprotectionplans" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipaddresses" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/publicipprefixes" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -160,7 +161,7 @@ func resourcePublicIp() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: validate.PublicIpPrefixID, + ValidateFunc: publicipprefixes.ValidatePublicIPPrefixID, }, "ip_tags": { diff --git a/internal/services/network/resourceids.go b/internal/services/network/resourceids.go index caa7829c1ec1..64ab011777f2 100644 --- a/internal/services/network/resourceids.go +++ b/internal/services/network/resourceids.go @@ -4,19 +4,8 @@ package network // Core bits and pieces -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ApplicationGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ApplicationGatewayHTTPListener -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/httpListener1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ApplicationGatewayURLPathMapPathRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/urlPathMaps/urlPathMap1/pathRules/pathRule1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=IpGroup -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/group1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NetworkInterface -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/networkInterface1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NetworkSecurityGroup -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/securityGroup1 -rewrite=true -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PublicIpAddress -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/publicIpAddress1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PublicIpPrefix -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIpPrefix1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkDnsServers -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/network1/dnsServers/default -rewrite=true -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkPeering -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/vnetPeering1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NetworkGatewayConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/connection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PrivateLinkService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/privateLinkService1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LocalNetworkGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/localNetworkGateway1 // Application Gateway //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ApplicationGatewayPrivateLinkConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Network/applicationGateways/applicationGateway1/privateLinkConfigurations/privateLinkConfiguration1 -rewrite=true @@ -35,55 +24,17 @@ package network //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SslProfile -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Network/applicationGateways/applicationGateway1/sslProfiles/sslprofile1 -rewrite=true //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=TrustedClientCertificate -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Network/applicationGateways/applicationGateway1/trustedClientCertificates/trustedClientCert1 -rewrite=true -// NAT Gateway -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NatGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/gateway1 -// NOTE: the Nat Gateway <-> Public IP Association can't be generated at this time - // Private Link //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PrivateDnsZoneConfig -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateEndpoints/endpoint1/privateDnsZoneGroups/privateDnsZoneGroup1/privateDnsZoneConfigs/privateDnsZoneConfig1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PrivateDnsZoneGroup -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateEndpoints/endpoint1/privateDnsZoneGroups/privateDnsZoneGroup1 // ^ these two looks like it should be in Private DNS - alas no, it's actually nested and entirely managed within the Private Endpoint // Virtual Hubs -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=BgpConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/connection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HubRouteTable -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1 -rewrite=true //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HubRouteTableRoute -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1/routes/route1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=HubVirtualNetworkConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/hubConnection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SecurityPartnerProvider -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/partnerProvider1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualHub -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualHubIpConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/ipConfiguration1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualWan -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/virtualWan1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=PointToSiteVpnGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/pointToSite1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VpnConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/vpnConnection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VpnGatewayNatRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/natRule1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=RouteMap -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/routeMap1 - -// Subnet Service Endpoint Policy -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=SubnetServiceEndpointStoragePolicy -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/policy1 - -// Express Route Port -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRoutePort -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1 -rewrite=true -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRoutePortAuthorization -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/authorization1 // Virtual Network Gateway -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkGatewayIpConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/ipConfigurations/cfg1 -rewrite=true -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkGatewayNatRule -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/rule1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualNetworkGatewayPolicyGroup -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/virtualNetworkGatewayPolicyGroups/policyGroup1 -// Express Route Connection -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteCircuit -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteCircuitPeering -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/peering1 -rewrite=true -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteGateway -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteCircuitConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/connection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteConnection -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/erConnection1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=ExpressRouteCircuitAuthorization -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/authorization1 - // Network //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=NetworkInterfaceIpConfiguration -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/networkInterface1/ipConfigurations/config1 - -// Virtual Machine Scale Set -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=VirtualMachineScaleSetPublicIPAddress -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/publicIpAddress1 - -// Custom IP Prefix -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=CustomIpPrefix -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/prefix1 diff --git a/internal/services/network/route_map_resource.go b/internal/services/network/route_map_resource.go index 55c88c5afa5b..529c37f1ffff 100644 --- a/internal/services/network/route_map_resource.go +++ b/internal/services/network/route_map_resource.go @@ -62,7 +62,7 @@ func (r RouteMapResource) ModelObject() interface{} { } func (r RouteMapResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { - return validate.RouteMapID + return virtualwans.ValidateRouteMapID } func (r RouteMapResource) Arguments() map[string]*pluginsdk.Schema { @@ -78,7 +78,7 @@ func (r RouteMapResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.VirtualHubID, + ValidateFunc: virtualwans.ValidateVirtualHubID, }, "rule": { diff --git a/internal/services/network/subnet_resource.go b/internal/services/network/subnet_resource.go index 98722b7612bc..38e2d95971c2 100644 --- a/internal/services/network/subnet_resource.go +++ b/internal/services/network/subnet_resource.go @@ -14,12 +14,12 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/serviceendpointpolicies" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/subnets" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -150,7 +150,7 @@ func resourceSubnet() *pluginsdk.Resource { Optional: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.SubnetServiceEndpointStoragePolicyID, + ValidateFunc: serviceendpointpolicies.ValidateServiceEndpointPolicyID, }, }, diff --git a/internal/services/network/validate/application_gateway_http_listener_id.go b/internal/services/network/validate/application_gateway_http_listener_id.go deleted file mode 100644 index f5d66416fee5..000000000000 --- a/internal/services/network/validate/application_gateway_http_listener_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ApplicationGatewayHTTPListenerID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ApplicationGatewayHTTPListenerID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/application_gateway_http_listener_id_test.go b/internal/services/network/validate/application_gateway_http_listener_id_test.go deleted file mode 100644 index 0d3bec51c14b..000000000000 --- a/internal/services/network/validate/application_gateway_http_listener_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestApplicationGatewayHTTPListenerID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ApplicationGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ApplicationGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/", - Valid: false, - }, - - { - // missing HttpListenerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/", - Valid: false, - }, - - { - // missing value for HttpListenerName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1/httpListeners/httpListener1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/APPLICATIONGATEWAY1/HTTPLISTENERS/HTTPLISTENER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ApplicationGatewayHTTPListenerID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/application_gateway_id.go b/internal/services/network/validate/application_gateway_id.go deleted file mode 100644 index 25ea18e209cd..000000000000 --- a/internal/services/network/validate/application_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ApplicationGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ApplicationGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/application_gateway_id_test.go b/internal/services/network/validate/application_gateway_id_test.go deleted file mode 100644 index 4b578027ecca..000000000000 --- a/internal/services/network/validate/application_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestApplicationGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/applicationGateways/applicationGateway1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/APPLICATIONGATEWAY1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ApplicationGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/bgp_connection_id.go b/internal/services/network/validate/bgp_connection_id.go deleted file mode 100644 index 8ca8969ba05d..000000000000 --- a/internal/services/network/validate/bgp_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func BgpConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.BgpConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/bgp_connection_id_test.go b/internal/services/network/validate/bgp_connection_id_test.go deleted file mode 100644 index cb4e2be6d040..000000000000 --- a/internal/services/network/validate/bgp_connection_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestBgpConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/bgpConnections/connection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/BGPCONNECTIONS/CONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := BgpConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/custom_ip_prefix_id.go b/internal/services/network/validate/custom_ip_prefix_id.go deleted file mode 100644 index 942d239fdbb4..000000000000 --- a/internal/services/network/validate/custom_ip_prefix_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func CustomIpPrefixID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.CustomIpPrefixID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/custom_ip_prefix_id_test.go b/internal/services/network/validate/custom_ip_prefix_id_test.go deleted file mode 100644 index 80e4ff859ee7..000000000000 --- a/internal/services/network/validate/custom_ip_prefix_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestCustomIpPrefixID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/customIPPrefixes/prefix1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/CUSTOMIPPREFIXES/PREFIX1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := CustomIpPrefixID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_circuit_authorization_id.go b/internal/services/network/validate/express_route_circuit_authorization_id.go deleted file mode 100644 index 802a679f6d38..000000000000 --- a/internal/services/network/validate/express_route_circuit_authorization_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteCircuitAuthorizationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteCircuitAuthorizationID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_circuit_authorization_id_test.go b/internal/services/network/validate/express_route_circuit_authorization_id_test.go deleted file mode 100644 index dfd329efe354..000000000000 --- a/internal/services/network/validate/express_route_circuit_authorization_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteCircuitAuthorizationID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Valid: false, - }, - - { - // missing AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/", - Valid: false, - }, - - { - // missing value for AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuit1/authorizations/authorization1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/EXPRESSROUTECIRCUIT1/AUTHORIZATIONS/AUTHORIZATION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteCircuitAuthorizationID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_circuit_connection_id.go b/internal/services/network/validate/express_route_circuit_connection_id.go deleted file mode 100644 index ff96020753f2..000000000000 --- a/internal/services/network/validate/express_route_circuit_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteCircuitConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteCircuitConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_circuit_connection_id_test.go b/internal/services/network/validate/express_route_circuit_connection_id_test.go deleted file mode 100644 index 74e2dffc741c..000000000000 --- a/internal/services/network/validate/express_route_circuit_connection_id_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteCircuitConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Valid: false, - }, - - { - // missing PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/", - Valid: false, - }, - - { - // missing value for PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/", - Valid: false, - }, - - { - // missing ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/", - Valid: false, - }, - - { - // missing value for ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/circuit1/peerings/peering1/connections/connection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/CIRCUIT1/PEERINGS/PEERING1/CONNECTIONS/CONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteCircuitConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_circuit_id.go b/internal/services/network/validate/express_route_circuit_id.go deleted file mode 100644 index f252995ebeb2..000000000000 --- a/internal/services/network/validate/express_route_circuit_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteCircuitID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteCircuitID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_circuit_id_test.go b/internal/services/network/validate/express_route_circuit_id_test.go deleted file mode 100644 index 7b8ab76a3a59..000000000000 --- a/internal/services/network/validate/express_route_circuit_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteCircuitID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/ERCIRCUIT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteCircuitID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_circuit_peering_id.go b/internal/services/network/validate/express_route_circuit_peering_id.go deleted file mode 100644 index b1f22bea00fa..000000000000 --- a/internal/services/network/validate/express_route_circuit_peering_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteCircuitPeeringID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteCircuitPeeringID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_circuit_peering_id_test.go b/internal/services/network/validate/express_route_circuit_peering_id_test.go deleted file mode 100644 index b3ad2934aa15..000000000000 --- a/internal/services/network/validate/express_route_circuit_peering_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteCircuitPeeringID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ExpressRouteCircuitName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/", - Valid: false, - }, - - { - // missing PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/", - Valid: false, - }, - - { - // missing value for PeeringName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteCircuits/erCircuit1/peerings/peering1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTECIRCUITS/ERCIRCUIT1/PEERINGS/PEERING1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteCircuitPeeringID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_connection_id.go b/internal/services/network/validate/express_route_connection_id.go deleted file mode 100644 index 2d56bb4b2dbb..000000000000 --- a/internal/services/network/validate/express_route_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_connection_id_test.go b/internal/services/network/validate/express_route_connection_id_test.go deleted file mode 100644 index 83a6f706ae39..000000000000 --- a/internal/services/network/validate/express_route_connection_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ExpressRouteGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ExpressRouteGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1/expressRouteConnections/erConnection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEGATEWAYS/ERGW1/EXPRESSROUTECONNECTIONS/ERCONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_gateway_id.go b/internal/services/network/validate/express_route_gateway_id.go deleted file mode 100644 index 224e73e470b8..000000000000 --- a/internal/services/network/validate/express_route_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRouteGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRouteGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_gateway_id_test.go b/internal/services/network/validate/express_route_gateway_id_test.go deleted file mode 100644 index 756f949fe596..000000000000 --- a/internal/services/network/validate/express_route_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRouteGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRouteGateways/ergw1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEGATEWAYS/ERGW1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRouteGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_port_authorization_id.go b/internal/services/network/validate/express_route_port_authorization_id.go deleted file mode 100644 index f79b6b2de0bb..000000000000 --- a/internal/services/network/validate/express_route_port_authorization_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRoutePortAuthorizationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRoutePortAuthorizationID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_port_authorization_id_test.go b/internal/services/network/validate/express_route_port_authorization_id_test.go deleted file mode 100644 index b70a50a927e7..000000000000 --- a/internal/services/network/validate/express_route_port_authorization_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRoutePortAuthorizationID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ExpressRoutePortName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ExpressRoutePortName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/", - Valid: false, - }, - - { - // missing AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/", - Valid: false, - }, - - { - // missing value for AuthorizationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1/authorizations/authorization1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEPORTS/PORT1/AUTHORIZATIONS/AUTHORIZATION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRoutePortAuthorizationID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/express_route_port_id.go b/internal/services/network/validate/express_route_port_id.go deleted file mode 100644 index d644c449f2b2..000000000000 --- a/internal/services/network/validate/express_route_port_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func ExpressRoutePortID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.ExpressRoutePortID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/express_route_port_id_test.go b/internal/services/network/validate/express_route_port_id_test.go deleted file mode 100644 index d9efc307ff75..000000000000 --- a/internal/services/network/validate/express_route_port_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestExpressRoutePortID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/expressRoutePorts/port1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/EXPRESSROUTEPORTS/PORT1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := ExpressRoutePortID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/hub_route_table_id.go b/internal/services/network/validate/hub_route_table_id.go deleted file mode 100644 index 8f4601df40b1..000000000000 --- a/internal/services/network/validate/hub_route_table_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func HubRouteTableID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.HubRouteTableID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/hub_route_table_id_test.go b/internal/services/network/validate/hub_route_table_id_test.go deleted file mode 100644 index a8345c101153..000000000000 --- a/internal/services/network/validate/hub_route_table_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestHubRouteTableID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/routeTable1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/HUBROUTETABLES/ROUTETABLE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := HubRouteTableID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/hub_virtual_network_connection_id.go b/internal/services/network/validate/hub_virtual_network_connection_id.go deleted file mode 100644 index 8e3648c8177f..000000000000 --- a/internal/services/network/validate/hub_virtual_network_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func HubVirtualNetworkConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.HubVirtualNetworkConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/hub_virtual_network_connection_id_test.go b/internal/services/network/validate/hub_virtual_network_connection_id_test.go deleted file mode 100644 index a0cfe1802765..000000000000 --- a/internal/services/network/validate/hub_virtual_network_connection_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestHubVirtualNetworkConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubVirtualNetworkConnections/hubConnection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/HUBVIRTUALNETWORKCONNECTIONS/HUBCONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := HubVirtualNetworkConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/ip_group_id.go b/internal/services/network/validate/ip_group_id.go deleted file mode 100644 index c4e7975a72e7..000000000000 --- a/internal/services/network/validate/ip_group_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func IpGroupID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.IpGroupID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/ip_group_id_test.go b/internal/services/network/validate/ip_group_id_test.go deleted file mode 100644 index 47a732e86856..000000000000 --- a/internal/services/network/validate/ip_group_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestIpGroupID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/ipGroups/group1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/IPGROUPS/GROUP1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := IpGroupID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/local_network_gateway_id.go b/internal/services/network/validate/local_network_gateway_id.go deleted file mode 100644 index 589e9fcdc178..000000000000 --- a/internal/services/network/validate/local_network_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func LocalNetworkGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.LocalNetworkGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/local_network_gateway_id_test.go b/internal/services/network/validate/local_network_gateway_id_test.go deleted file mode 100644 index 3a9eb63b0bd0..000000000000 --- a/internal/services/network/validate/local_network_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestLocalNetworkGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/localNetworkGateways/localNetworkGateway1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/LOCALNETWORKGATEWAYS/LOCALNETWORKGATEWAY1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := LocalNetworkGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/nat_gateway_id.go b/internal/services/network/validate/nat_gateway_id.go deleted file mode 100644 index 38b7b4d1d8cc..000000000000 --- a/internal/services/network/validate/nat_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func NatGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NatGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/nat_gateway_id_test.go b/internal/services/network/validate/nat_gateway_id_test.go deleted file mode 100644 index e56e58ef9c0f..000000000000 --- a/internal/services/network/validate/nat_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNatGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/natGateways/gateway1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NATGATEWAYS/GATEWAY1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NatGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/network_gateway_connection_id.go b/internal/services/network/validate/network_gateway_connection_id.go deleted file mode 100644 index fd18bdc59187..000000000000 --- a/internal/services/network/validate/network_gateway_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func NetworkGatewayConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NetworkGatewayConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/network_gateway_connection_id_test.go b/internal/services/network/validate/network_gateway_connection_id_test.go deleted file mode 100644 index 1e77eb621892..000000000000 --- a/internal/services/network/validate/network_gateway_connection_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNetworkGatewayConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ConnectionName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/connections/connection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/CONNECTIONS/CONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NetworkGatewayConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/network_interface_id.go b/internal/services/network/validate/network_interface_id.go deleted file mode 100644 index a876d5bfe8d4..000000000000 --- a/internal/services/network/validate/network_interface_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func NetworkInterfaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NetworkInterfaceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/network_interface_id_test.go b/internal/services/network/validate/network_interface_id_test.go deleted file mode 100644 index b5fbab66f7a1..000000000000 --- a/internal/services/network/validate/network_interface_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNetworkInterfaceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkInterfaces/networkInterface1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NETWORKINTERFACES/NETWORKINTERFACE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NetworkInterfaceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/network_security_group_id.go b/internal/services/network/validate/network_security_group_id.go deleted file mode 100644 index c1e166cf032c..000000000000 --- a/internal/services/network/validate/network_security_group_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func NetworkSecurityGroupID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.NetworkSecurityGroupID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/network_security_group_id_test.go b/internal/services/network/validate/network_security_group_id_test.go deleted file mode 100644 index 6a1c8647b8be..000000000000 --- a/internal/services/network/validate/network_security_group_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestNetworkSecurityGroupID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/networkSecurityGroups/securityGroup1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/SECURITYGROUP1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := NetworkSecurityGroupID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/point_to_site_vpn_gateway_id.go b/internal/services/network/validate/point_to_site_vpn_gateway_id.go deleted file mode 100644 index a9dd0d4cd102..000000000000 --- a/internal/services/network/validate/point_to_site_vpn_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func PointToSiteVpnGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PointToSiteVpnGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/point_to_site_vpn_gateway_id_test.go b/internal/services/network/validate/point_to_site_vpn_gateway_id_test.go deleted file mode 100644 index aa454092ea76..000000000000 --- a/internal/services/network/validate/point_to_site_vpn_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPointToSiteVpnGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing P2sVpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for P2sVpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/p2sVpnGateways/pointToSite1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/P2SVPNGATEWAYS/POINTTOSITE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PointToSiteVpnGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/private_link_service_id.go b/internal/services/network/validate/private_link_service_id.go deleted file mode 100644 index 870796c26250..000000000000 --- a/internal/services/network/validate/private_link_service_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func PrivateLinkServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PrivateLinkServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/private_link_service_id_test.go b/internal/services/network/validate/private_link_service_id_test.go deleted file mode 100644 index b9d0f45ad893..000000000000 --- a/internal/services/network/validate/private_link_service_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPrivateLinkServiceID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/privateLinkServices/privateLinkService1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PRIVATELINKSERVICES/PRIVATELINKSERVICE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PrivateLinkServiceID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/public_ip_address_id.go b/internal/services/network/validate/public_ip_address_id.go deleted file mode 100644 index 25fa0a7c49d8..000000000000 --- a/internal/services/network/validate/public_ip_address_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func PublicIpAddressID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PublicIpAddressID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/public_ip_address_id_test.go b/internal/services/network/validate/public_ip_address_id_test.go deleted file mode 100644 index f24c3a59d0bd..000000000000 --- a/internal/services/network/validate/public_ip_address_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPublicIpAddressID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPAddresses/publicIpAddress1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PUBLICIPADDRESSES/PUBLICIPADDRESS1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PublicIpAddressID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/public_ip_prefix_id.go b/internal/services/network/validate/public_ip_prefix_id.go deleted file mode 100644 index 33fd58611e40..000000000000 --- a/internal/services/network/validate/public_ip_prefix_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func PublicIpPrefixID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.PublicIpPrefixID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/public_ip_prefix_id_test.go b/internal/services/network/validate/public_ip_prefix_id_test.go deleted file mode 100644 index 0cc1097e6a7b..000000000000 --- a/internal/services/network/validate/public_ip_prefix_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestPublicIpPrefixID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/publicIPPrefixes/publicIpPrefix1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/PUBLICIPPREFIXES/PUBLICIPPREFIX1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := PublicIpPrefixID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/route_map_id.go b/internal/services/network/validate/route_map_id.go deleted file mode 100644 index 93b519374cc8..000000000000 --- a/internal/services/network/validate/route_map_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func RouteMapID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.RouteMapID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/route_map_id_test.go b/internal/services/network/validate/route_map_id_test.go deleted file mode 100644 index fa48d0ac7f02..000000000000 --- a/internal/services/network/validate/route_map_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestRouteMapID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/vhub1/routeMaps/routeMap1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VHUB1/ROUTEMAPS/ROUTEMAP1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := RouteMapID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/security_partner_provider_id.go b/internal/services/network/validate/security_partner_provider_id.go deleted file mode 100644 index 71c7407d90c8..000000000000 --- a/internal/services/network/validate/security_partner_provider_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func SecurityPartnerProviderID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SecurityPartnerProviderID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/security_partner_provider_id_test.go b/internal/services/network/validate/security_partner_provider_id_test.go deleted file mode 100644 index 27a23d34bc2a..000000000000 --- a/internal/services/network/validate/security_partner_provider_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSecurityPartnerProviderID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/securityPartnerProviders/partnerProvider1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/SECURITYPARTNERPROVIDERS/PARTNERPROVIDER1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SecurityPartnerProviderID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/subnet_service_endpoint_storage_policy_id.go b/internal/services/network/validate/subnet_service_endpoint_storage_policy_id.go deleted file mode 100644 index 33e5ebacccd7..000000000000 --- a/internal/services/network/validate/subnet_service_endpoint_storage_policy_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func SubnetServiceEndpointStoragePolicyID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.SubnetServiceEndpointStoragePolicyID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/subnet_service_endpoint_storage_policy_id_test.go b/internal/services/network/validate/subnet_service_endpoint_storage_policy_id_test.go deleted file mode 100644 index 053cc4237265..000000000000 --- a/internal/services/network/validate/subnet_service_endpoint_storage_policy_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestSubnetServiceEndpointStoragePolicyID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing ServiceEndpointPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for ServiceEndpointPolicyName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/serviceEndpointPolicies/policy1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/SERVICEENDPOINTPOLICIES/POLICY1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := SubnetServiceEndpointStoragePolicyID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_hub_id.go b/internal/services/network/validate/virtual_hub_id.go deleted file mode 100644 index f8a7a27e9264..000000000000 --- a/internal/services/network/validate/virtual_hub_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualHubID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualHubID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_hub_id_test.go b/internal/services/network/validate/virtual_hub_id_test.go deleted file mode 100644 index fe550f97e04a..000000000000 --- a/internal/services/network/validate/virtual_hub_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualHubID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualHubID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_hub_ip_configuration_id.go b/internal/services/network/validate/virtual_hub_ip_configuration_id.go deleted file mode 100644 index 835785040fc1..000000000000 --- a/internal/services/network/validate/virtual_hub_ip_configuration_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualHubIpConfigurationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualHubIpConfigurationID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_hub_ip_configuration_id_test.go b/internal/services/network/validate/virtual_hub_ip_configuration_id_test.go deleted file mode 100644 index e3a11f76aa6b..000000000000 --- a/internal/services/network/validate/virtual_hub_ip_configuration_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualHubIpConfigurationID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualHubName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/", - Valid: false, - }, - - { - // missing IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/", - Valid: false, - }, - - { - // missing value for IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualHubs/virtualHub1/ipConfigurations/ipConfiguration1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALHUBS/VIRTUALHUB1/IPCONFIGURATIONS/IPCONFIGURATION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualHubIpConfigurationID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id.go b/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id.go deleted file mode 100644 index fc6a655ee12b..000000000000 --- a/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualMachineScaleSetPublicIPAddressID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualMachineScaleSetPublicIPAddressID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id_test.go b/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id_test.go deleted file mode 100644 index c1ef148513d6..000000000000 --- a/internal/services/network/validate/virtual_machine_scale_set_public_ip_address_id_test.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualMachineScaleSetPublicIPAddressID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualMachineScaleSetName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/", - Valid: false, - }, - - { - // missing value for VirtualMachineScaleSetName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/", - Valid: false, - }, - - { - // missing VirtualMachineName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/", - Valid: false, - }, - - { - // missing value for VirtualMachineName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/", - Valid: false, - }, - - { - // missing NetworkInterfaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/", - Valid: false, - }, - - { - // missing value for NetworkInterfaceName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/", - Valid: false, - }, - - { - // missing IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/", - Valid: false, - }, - - { - // missing value for IpConfigurationName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/", - Valid: false, - }, - - { - // missing PublicIPAddressName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/", - Valid: false, - }, - - { - // missing value for PublicIPAddressName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleSet1/virtualMachines/virtualMachine1/networkInterfaces/networkInterface1/ipConfigurations/ipConfiguration1/publicIPAddresses/publicIpAddress1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.COMPUTE/VIRTUALMACHINESCALESETS/SCALESET1/VIRTUALMACHINES/VIRTUALMACHINE1/NETWORKINTERFACES/NETWORKINTERFACE1/IPCONFIGURATIONS/IPCONFIGURATION1/PUBLICIPADDRESSES/PUBLICIPADDRESS1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualMachineScaleSetPublicIPAddressID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_network_gateway_id.go b/internal/services/network/validate/virtual_network_gateway_id.go deleted file mode 100644 index 68c3cd0512f1..000000000000 --- a/internal/services/network/validate/virtual_network_gateway_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualNetworkGatewayID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualNetworkGatewayID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_network_gateway_id_test.go b/internal/services/network/validate/virtual_network_gateway_id_test.go deleted file mode 100644 index 1b3938e12659..000000000000 --- a/internal/services/network/validate/virtual_network_gateway_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualNetworkGatewayID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKGATEWAYS/GW1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualNetworkGatewayID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_network_gateway_nat_rule_id.go b/internal/services/network/validate/virtual_network_gateway_nat_rule_id.go deleted file mode 100644 index d413625862a3..000000000000 --- a/internal/services/network/validate/virtual_network_gateway_nat_rule_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualNetworkGatewayNatRuleID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualNetworkGatewayNatRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_network_gateway_nat_rule_id_test.go b/internal/services/network/validate/virtual_network_gateway_nat_rule_id_test.go deleted file mode 100644 index ee3ac79a3c13..000000000000 --- a/internal/services/network/validate/virtual_network_gateway_nat_rule_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualNetworkGatewayNatRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualNetworkGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualNetworkGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/", - Valid: false, - }, - - { - // missing NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/", - Valid: false, - }, - - { - // missing value for NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/rule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKGATEWAYS/GW1/NATRULES/RULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualNetworkGatewayNatRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_network_peering_id.go b/internal/services/network/validate/virtual_network_peering_id.go deleted file mode 100644 index c57c69900dc2..000000000000 --- a/internal/services/network/validate/virtual_network_peering_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualNetworkPeeringID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualNetworkPeeringID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_network_peering_id_test.go b/internal/services/network/validate/virtual_network_peering_id_test.go deleted file mode 100644 index c68d4a53c7ee..000000000000 --- a/internal/services/network/validate/virtual_network_peering_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualNetworkPeeringID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VirtualNetworkName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VirtualNetworkName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/vnetPeering1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALNETWORKS/VNET1/VIRTUALNETWORKPEERINGS/VNETPEERING1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualNetworkPeeringID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/virtual_wan_id.go b/internal/services/network/validate/virtual_wan_id.go deleted file mode 100644 index 9c4a39416bcd..000000000000 --- a/internal/services/network/validate/virtual_wan_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VirtualWanID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VirtualWanID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/virtual_wan_id_test.go b/internal/services/network/validate/virtual_wan_id_test.go deleted file mode 100644 index 88a10a3dfa75..000000000000 --- a/internal/services/network/validate/virtual_wan_id_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVirtualWanID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/virtualWans/virtualWan1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VIRTUALWANS/VIRTUALWAN1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VirtualWanID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/vpn_connection_id.go b/internal/services/network/validate/vpn_connection_id.go deleted file mode 100644 index ce5ac03a4d89..000000000000 --- a/internal/services/network/validate/vpn_connection_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VpnConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VpnConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/vpn_connection_id_test.go b/internal/services/network/validate/vpn_connection_id_test.go deleted file mode 100644 index a03c47c158b7..000000000000 --- a/internal/services/network/validate/vpn_connection_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVpnConnectionID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/", - Valid: false, - }, - - { - // missing Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/", - Valid: false, - }, - - { - // missing value for Name - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/vpnConnections/vpnConnection1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VPNGATEWAYS/VPNGATEWAY1/VPNCONNECTIONS/VPNCONNECTION1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VpnConnectionID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/validate/vpn_gateway_nat_rule_id.go b/internal/services/network/validate/vpn_gateway_nat_rule_id.go deleted file mode 100644 index 43dc59ef4128..000000000000 --- a/internal/services/network/validate/vpn_gateway_nat_rule_id.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" -) - -func VpnGatewayNatRuleID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := parse.VpnGatewayNatRuleID(v); err != nil { - errors = append(errors, err) - } - - return -} diff --git a/internal/services/network/validate/vpn_gateway_nat_rule_id_test.go b/internal/services/network/validate/vpn_gateway_nat_rule_id_test.go deleted file mode 100644 index 76e73f524c99..000000000000 --- a/internal/services/network/validate/vpn_gateway_nat_rule_id_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package validate - -// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten - -import "testing" - -func TestVpnGatewayNatRuleID(t *testing.T) { - cases := []struct { - Input string - Valid bool - }{ - - { - // empty - Input: "", - Valid: false, - }, - - { - // missing SubscriptionId - Input: "/", - Valid: false, - }, - - { - // missing value for SubscriptionId - Input: "/subscriptions/", - Valid: false, - }, - - { - // missing ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", - Valid: false, - }, - - { - // missing value for ResourceGroup - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", - Valid: false, - }, - - { - // missing VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/", - Valid: false, - }, - - { - // missing value for VpnGatewayName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/", - Valid: false, - }, - - { - // missing NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/", - Valid: false, - }, - - { - // missing value for NatRuleName - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/", - Valid: false, - }, - - { - // valid - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Network/vpnGateways/vpnGateway1/natRules/natRule1", - Valid: true, - }, - - { - // upper-cased - Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.NETWORK/VPNGATEWAYS/VPNGATEWAY1/NATRULES/NATRULE1", - Valid: false, - }, - } - for _, tc := range cases { - t.Logf("[DEBUG] Testing Value %s", tc.Input) - _, errors := VpnGatewayNatRuleID(tc.Input, "test") - valid := len(errors) == 0 - - if tc.Valid != valid { - t.Fatalf("Expected %t but got %t", tc.Valid, valid) - } - } -} diff --git a/internal/services/network/virtual_hub_connection_resource.go b/internal/services/network/virtual_hub_connection_resource.go index a8522baa15d4..76758e0565a0 100644 --- a/internal/services/network/virtual_hub_connection_resource.go +++ b/internal/services/network/virtual_hub_connection_resource.go @@ -81,20 +81,20 @@ func resourceVirtualHubConnection() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, AtLeastOneOf: []string{"routing.0.associated_route_table_id", "routing.0.propagated_route_table", "routing.0.static_vnet_route"}, }, "inbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "outbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "propagated_route_table": { @@ -121,7 +121,7 @@ func resourceVirtualHubConnection() *pluginsdk.Resource { Computed: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, }, AtLeastOneOf: []string{"routing.0.propagated_route_table.0.labels", "routing.0.propagated_route_table.0.route_table_ids"}, }, diff --git a/internal/services/network/virtual_hub_resource.go b/internal/services/network/virtual_hub_resource.go index ef02e547301c..8099de10ba6d 100644 --- a/internal/services/network/virtual_hub_resource.go +++ b/internal/services/network/virtual_hub_resource.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -36,7 +35,7 @@ func resourceVirtualHub() *pluginsdk.Resource { Update: resourceVirtualHubCreateUpdate, Delete: resourceVirtualHubDelete, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.VirtualHubID(id) + _, err := virtualwans.ParseVirtualHubID(id) return err }), @@ -80,7 +79,7 @@ func resourceVirtualHub() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, ForceNew: true, - ValidateFunc: networkValidate.VirtualWanID, + ValidateFunc: virtualwans.ValidateVirtualWANID, }, "virtual_router_asn": { diff --git a/internal/services/network/virtual_hub_route_table_route_resource.go b/internal/services/network/virtual_hub_route_table_route_resource.go index 5bce7a22b34a..031f1b4685fc 100644 --- a/internal/services/network/virtual_hub_route_table_route_resource.go +++ b/internal/services/network/virtual_hub_route_table_route_resource.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -47,7 +46,7 @@ func resourceVirtualHubRouteTableRoute() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: networkValidate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, }, "name": { diff --git a/internal/services/network/virtual_network_gateway_connection_resource.go b/internal/services/network/virtual_network_gateway_connection_resource.go index 0cac9002284f..49f02816c91e 100644 --- a/internal/services/network/virtual_network_gateway_connection_resource.go +++ b/internal/services/network/virtual_network_gateway_connection_resource.go @@ -15,13 +15,12 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/expressroutecircuits" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/localnetworkgateways" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualnetworkgatewayconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualnetworkgateways" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -131,7 +130,7 @@ func resourceVirtualNetworkGatewayConnection() *pluginsdk.Resource { "local_network_gateway_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.LocalNetworkGatewayID, + ValidateFunc: localnetworkgateways.ValidateLocalNetworkGatewayID, }, // TODO 4.0: change this from enable_* to *_enabled @@ -639,13 +638,13 @@ func getVirtualNetworkGatewayConnectionProperties(d *pluginsdk.ResourceData, vir } if v, ok := d.GetOk("peer_virtual_network_gateway_id"); ok { - gwid, err := parse.VirtualNetworkGatewayID(v.(string)) + gwid, err := virtualnetworkgateways.ParseVirtualNetworkGatewayID(v.(string)) if err != nil { return nil, err } props.VirtualNetworkGateway2 = &virtualnetworkgatewayconnections.VirtualNetworkGateway{ Id: pointer.To(gwid.ID()), - Name: &gwid.Name, + Name: &gwid.VirtualNetworkGatewayName, Properties: virtualnetworkgatewayconnections.VirtualNetworkGatewayPropertiesFormat{ IPConfigurations: &[]virtualnetworkgatewayconnections.VirtualNetworkGatewayIPConfiguration{}, }, diff --git a/internal/services/network/virtual_network_gateway_nat_rule_resource.go b/internal/services/network/virtual_network_gateway_nat_rule_resource.go index 4b6b7446ca32..f6815576625b 100644 --- a/internal/services/network/virtual_network_gateway_nat_rule_resource.go +++ b/internal/services/network/virtual_network_gateway_nat_rule_resource.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualnetworkgateways" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -196,7 +195,7 @@ func resourceVirtualNetworkGatewayNatRuleRead(d *pluginsdk.ResourceData, meta in d.Set("name", id.NatRuleName) d.Set("resource_group_name", id.ResourceGroupName) - vnetGatewayId := parse.NewVirtualNetworkGatewayID(id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkGatewayName) + vnetGatewayId := virtualnetworkgateways.NewVirtualNetworkGatewayID(id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkGatewayName) d.Set("virtual_network_gateway_id", vnetGatewayId.ID()) if model := resp.Model; model != nil { diff --git a/internal/services/network/virtual_network_gateway_resource.go b/internal/services/network/virtual_network_gateway_resource.go index 228a8dd31c04..1ed4d5d6d4a9 100644 --- a/internal/services/network/virtual_network_gateway_resource.go +++ b/internal/services/network/virtual_network_gateway_resource.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/localnetworkgateways" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualnetworkgateways" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -612,7 +613,7 @@ func resourceVirtualNetworkGatewaySchema() map[string]*pluginsdk.Schema { "default_local_network_gateway_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.LocalNetworkGatewayID, + ValidateFunc: localnetworkgateways.ValidateLocalNetworkGatewayID, }, "bgp_route_translation_for_nat_enabled": { diff --git a/internal/services/network/virtual_network_resource.go b/internal/services/network/virtual_network_resource.go index ceb4a1e2cb08..5c6190e4639b 100644 --- a/internal/services/network/virtual_network_resource.go +++ b/internal/services/network/virtual_network_resource.go @@ -23,7 +23,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/suppress" @@ -429,12 +428,12 @@ func resourceVirtualNetworkUpdate(d *pluginsdk.ResourceData, meta interface{}) e if payload.Properties != nil && payload.Properties.Subnets != nil { for _, subnet := range *payload.Properties.Subnets { if subnet.Properties != nil && subnet.Properties.NetworkSecurityGroup != nil && subnet.Properties.NetworkSecurityGroup.Id != nil { - parsedNsgID, err := parse.NetworkSecurityGroupID(*subnet.Properties.NetworkSecurityGroup.Id) + parsedNsgID, err := networksecuritygroups.ParseNetworkSecurityGroupID(*subnet.Properties.NetworkSecurityGroup.Id) if err != nil { return err } - networkSecurityGroupName := parsedNsgID.Name + networkSecurityGroupName := parsedNsgID.NetworkSecurityGroupName if !utils.SliceContainsValue(networkSecurityGroupNames, networkSecurityGroupName) { networkSecurityGroupNames = append(networkSecurityGroupNames, networkSecurityGroupName) } @@ -795,12 +794,12 @@ func expandAzureRmVirtualNetworkVirtualNetworkSecurityGroupNames(d *pluginsdk.Re networkSecurityGroupId := subnet["security_group"].(string) if networkSecurityGroupId != "" { - parsedNsgID, err := parse.NetworkSecurityGroupID(networkSecurityGroupId) + parsedNsgID, err := networksecuritygroups.ParseNetworkSecurityGroupID(networkSecurityGroupId) if err != nil { return nil, err } - networkSecurityGroupName := parsedNsgID.Name + networkSecurityGroupName := parsedNsgID.NetworkSecurityGroupName if !utils.SliceContainsValue(nsgNames, networkSecurityGroupName) { nsgNames = append(nsgNames, networkSecurityGroupName) } diff --git a/internal/services/network/vpn_gateway_connection_resource.go b/internal/services/network/vpn_gateway_connection_resource.go index beb32e47df19..34f9b2f4cedb 100644 --- a/internal/services/network/vpn_gateway_connection_resource.go +++ b/internal/services/network/vpn_gateway_connection_resource.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -80,19 +79,19 @@ func resourceVPNGatewayConnection() *pluginsdk.Resource { "associated_route_table": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, }, "inbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "outbound_route_map_id": { Type: pluginsdk.TypeString, Optional: true, - ValidateFunc: validate.RouteMapID, + ValidateFunc: virtualwans.ValidateRouteMapID, }, "propagated_route_table": { @@ -107,7 +106,7 @@ func resourceVPNGatewayConnection() *pluginsdk.Resource { Required: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.HubRouteTableID, + ValidateFunc: virtualwans.ValidateHubRouteTableID, }, }, @@ -151,7 +150,7 @@ func resourceVPNGatewayConnection() *pluginsdk.Resource { Optional: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.VpnGatewayNatRuleID, + ValidateFunc: virtualwans.ValidateNatRuleID, }, }, @@ -160,7 +159,7 @@ func resourceVPNGatewayConnection() *pluginsdk.Resource { Optional: true, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: validate.VpnGatewayNatRuleID, + ValidateFunc: virtualwans.ValidateNatRuleID, }, }, diff --git a/internal/services/network/vpn_gateway_resource.go b/internal/services/network/vpn_gateway_resource.go index 2ace2bd64caa..fda056f62031 100644 --- a/internal/services/network/vpn_gateway_resource.go +++ b/internal/services/network/vpn_gateway_resource.go @@ -18,7 +18,6 @@ import ( commonValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -61,7 +60,7 @@ func resourceVPNGateway() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.VirtualHubID, + ValidateFunc: virtualwans.ValidateVirtualHubID, }, "routing_preference": { diff --git a/internal/services/paloalto/network_virtual_appliance_resource.go b/internal/services/paloalto/network_virtual_appliance_resource.go index d4bba56a01ba..812a60cf4731 100644 --- a/internal/services/paloalto/network_virtual_appliance_resource.go +++ b/internal/services/paloalto/network_virtual_appliance_resource.go @@ -53,7 +53,7 @@ func (r NetworkVirtualApplianceResource) Arguments() map[string]*schema.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: validate.VirtualHubID, + ValidateFunc: virtualwans.ValidateVirtualHubID, }, } } diff --git a/internal/services/paloalto/schema/destination_nat.go b/internal/services/paloalto/schema/destination_nat.go index 2f84394ad85d..268d56f430e4 100644 --- a/internal/services/paloalto/schema/destination_nat.go +++ b/internal/services/paloalto/schema/destination_nat.go @@ -7,9 +7,9 @@ import ( "strconv" "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/paloaltonetworks/2023-09-01/firewalls" helpersValidate "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/paloalto/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -69,7 +69,7 @@ func FrontendEndpointSchema() *pluginsdk.Schema { "public_ip_address_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, "port": { diff --git a/internal/services/paloalto/schema/network_profile.go b/internal/services/paloalto/schema/network_profile.go index 330f9a4741b2..17eecabbe912 100644 --- a/internal/services/paloalto/schema/network_profile.go +++ b/internal/services/paloalto/schema/network_profile.go @@ -5,9 +5,10 @@ package schema import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/networkvirtualappliances" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/virtualwans" "github.com/hashicorp/go-azure-sdk/resource-manager/paloaltonetworks/2023-09-01/firewalls" - networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" ) @@ -56,7 +57,7 @@ func VnetNetworkProfileSchema() *pluginsdk.Schema { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, @@ -66,7 +67,7 @@ func VnetNetworkProfileSchema() *pluginsdk.Schema { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, @@ -225,7 +226,7 @@ func VHubNetworkProfileSchema() *pluginsdk.Schema { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: networkValidate.VirtualHubID, + ValidateFunc: virtualwans.ValidateVirtualHubID, }, "network_virtual_appliance_id": { @@ -241,7 +242,7 @@ func VHubNetworkProfileSchema() *pluginsdk.Schema { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, }, @@ -251,7 +252,7 @@ func VHubNetworkProfileSchema() *pluginsdk.Schema { MinItems: 1, Elem: &pluginsdk.Schema{ Type: pluginsdk.TypeString, - ValidateFunc: networkValidate.PublicIpAddressID, + ValidateFunc: commonids.ValidatePublicIPAddressID, }, },