vsphere/distributed_virtual_switch_structure.go
func schemaVMwareDVSConfigSpec() map[string]*schema.Schema {
	s := map[string]*schema.Schema{
		// DVSContactInfo
		"contact_detail": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The contact detail for this DVS.",
		},
		"contact_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The contact name for this DVS.",
		},

		// DistributedVirtualSwitchHostMemberConfigSpec
		"host": {
			Type:        schema.TypeSet,
			Optional:    true,
			Description: "A host member specification.",
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					// DistributedVirtualSwitchHostMemberPnicSpec
					"devices": {
						Type:        schema.TypeList,
						Description: "Name of the physical NIC to be added to the proxy switch.",
						Required:    true,
						MinItems:    1,
						Elem:        &schema.Schema{Type: schema.TypeString},
					},
					"host_system_id": {
						Type:         schema.TypeString,
						Required:     true,
						Description:  "The managed object ID of the host this specification applies to.",
						ValidateFunc: validation.NoZeroValues,
					},
				},
			},
		},

		// VMwareIpfixConfig (Netflow)
		"netflow_active_flow_timeout": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The number of seconds after which active flows are forced to be exported to the collector.",
			Default:      60,
			ValidateFunc: validation.IntBetween(60, 3600),
		},
		"netflow_collector_ip_address": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "IP address for the netflow collector, using IPv4 or IPv6. IPv6 is supported in vSphere Distributed Switch Version 6.0 or later.",
		},
		"netflow_collector_port": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The port for the netflow collector.",
			ValidateFunc: validation.IntBetween(0, 65535),
		},
		"netflow_idle_flow_timeout": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The number of seconds after which idle flows are forced to be exported to the collector.",
			Default:      15,
			ValidateFunc: validation.IntBetween(10, 600),
		},
		"netflow_internal_flows_only": {
			Type:        schema.TypeBool,
			Optional:    true,
			Description: "Whether to limit analysis to traffic that has both source and destination served by the same host.",
		},
		"netflow_observation_domain_id": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The observation Domain ID for the netflow collector.",
			ValidateFunc: validation.IntAtLeast(0),
		},
		"netflow_sampling_rate": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The ratio of total number of packets to the number of packets analyzed. Set to 0 to disable sampling, meaning that all packets are analyzed.",
			ValidateFunc: validation.IntAtLeast(0),
		},

		// LinkDiscoveryProtocolConfig
		"link_discovery_operation": {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  "Whether to advertise or listen for link discovery. Valid values are advertise, both, listen, and none.",
			Default:      string(types.LinkDiscoveryProtocolConfigOperationTypeListen),
			ValidateFunc: validation.StringInSlice(linkDiscoveryProtocolConfigOperationAllowedValues, false),
		},
		"link_discovery_protocol": {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  "The discovery protocol type. Valid values are cdp and lldp.",
			Default:      string(types.LinkDiscoveryProtocolConfigProtocolTypeCdp),
			ValidateFunc: validation.StringInSlice(linkDiscoveryProtocolConfigProtocolAllowedValues, false),
		},

		// DVSNameArrayUplinkPortPolicy
		"uplinks": {
			Type:        schema.TypeList,
			Optional:    true,
			Computed:    true,
			Description: "A list of uplink ports. The contents of this list control both the uplink count and names of the uplinks on the DVS across hosts.",
			Elem:        &schema.Schema{Type: schema.TypeString},
		},

		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "The name for the DVS. Must be unique in the folder that it is being created in.",
		},
		"description": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The description of the DVS.",
		},
		"ipv4_address": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The IPv4 address of the switch. This can be used to see the DVS as a unique device with NetFlow.",
		},
		"lacp_api_version": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The Link Aggregation Control Protocol group version in the switch. Can be one of singleLag or multipleLag.",
			ValidateFunc: validation.StringInSlice(lacpAPIVersionAllowedValues, false),
		},
		"max_mtu": {
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  "The maximum MTU on the switch.",
			ValidateFunc: validation.IntBetween(1, 9000),
		},
		"multicast_filtering_mode": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The multicast filtering mode on the switch. Can be one of legacyFiltering, or snooping.",
			ValidateFunc: validation.StringInSlice(multicastFilteringModeAllowedValues, false),
		},
		"network_resource_control_version": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The network I/O control version to use. Can be one of version2 or version3.",
			ValidateFunc: validation.StringInSlice(networkResourceControlAllowedValues, false),
		},

		"config_version": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "The version string of the configuration that this spec is trying to change.",
		},
	}

	structure.MergeSchema(s, schemaVMwareDVSPortSetting())
	structure.MergeSchema(s, schemaDvsHostInfrastructureTrafficResource())
	return s
}
func schemaVMwareDVSConfigSpec() map[string]*schema.Schema {
	s := map[string]*schema.Schema{
		// DVSContactInfo
		"contact_detail": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The contact detail for this DVS.",
		},
		"contact_name": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The contact name for this DVS.",
		},

		// DistributedVirtualSwitchHostMemberConfigSpec
		"host": {
			Type:        schema.TypeSet,
			Optional:    true,
			Description: "A host member specification.",
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					// DistributedVirtualSwitchHostMemberPnicSpec
					"devices": {
						Type:        schema.TypeList,
						Description: "Name of the physical NIC to be added to the proxy switch.",
						Required:    true,
						MinItems:    1,
						Elem:        &schema.Schema{Type: schema.TypeString},
					},
					"host_system_id": {
						Type:         schema.TypeString,
						Required:     true,
						Description:  "The managed object ID of the host this specification applies to.",
						ValidateFunc: validation.NoZeroValues,
					},
				},
			},
		},

		// VMwareIpfixConfig (Netflow)
		"netflow_active_flow_timeout": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The number of seconds after which active flows are forced to be exported to the collector.",
			Default:      60,
			ValidateFunc: validation.IntBetween(60, 3600),
		},
		"netflow_collector_ip_address": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "IP address for the netflow collector, using IPv4 or IPv6. IPv6 is supported in vSphere Distributed Switch Version 6.0 or later.",
		},
		"netflow_collector_port": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The port for the netflow collector.",
			ValidateFunc: validation.IntBetween(0, 65535),
		},
		"netflow_idle_flow_timeout": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The number of seconds after which idle flows are forced to be exported to the collector.",
			Default:      15,
			ValidateFunc: validation.IntBetween(10, 600),
		},
		"netflow_internal_flows_only": {
			Type:        schema.TypeBool,
			Optional:    true,
			Description: "Whether to limit analysis to traffic that has both source and destination served by the same host.",
		},
		"netflow_observation_domain_id": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The observation Domain ID for the netflow collector.",
			ValidateFunc: validation.IntAtLeast(0),
		},
		"netflow_sampling_rate": {
			Type:         schema.TypeInt,
			Optional:     true,
			Description:  "The ratio of total number of packets to the number of packets analyzed. Set to 0 to disable sampling, meaning that all packets are analyzed.",
			ValidateFunc: validation.IntAtLeast(0),
		},

		// LinkDiscoveryProtocolConfig
		"link_discovery_operation": {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  "Whether to advertise or listen for link discovery. Valid values are advertise, both, listen, and none.",
			Default:      string(types.LinkDiscoveryProtocolConfigOperationTypeListen),
			ValidateFunc: validation.StringInSlice(linkDiscoveryProtocolConfigOperationAllowedValues, false),
		},
		"link_discovery_protocol": {
			Type:         schema.TypeString,
			Optional:     true,
			Description:  "The discovery protocol type. Valid values are cdp and lldp.",
			Default:      string(types.LinkDiscoveryProtocolConfigProtocolTypeCdp),
			ValidateFunc: validation.StringInSlice(linkDiscoveryProtocolConfigProtocolAllowedValues, false),
		},

		// DVSNameArrayUplinkPortPolicy
		"uplinks": {
			Type:        schema.TypeList,
			Optional:    true,
			Computed:    true,
			Description: "A list of uplink ports. The contents of this list control both the uplink count and names of the uplinks on the DVS across hosts.",
			Elem:        &schema.Schema{Type: schema.TypeString},
		},

		"name": {
			Type:        schema.TypeString,
			Required:    true,
			Description: "The name for the DVS. Must be unique in the folder that it is being created in.",
		},
		"description": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The description of the DVS.",
		},
		"ipv4_address": {
			Type:        schema.TypeString,
			Optional:    true,
			Description: "The IPv4 address of the switch. This can be used to see the DVS as a unique device with NetFlow.",
		},
		"lacp_api_version": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The Link Aggregation Control Protocol group version in the switch. Can be one of singleLag or multipleLag.",
			ValidateFunc: validation.StringInSlice(lacpAPIVersionAllowedValues, false),
		},
		"max_mtu": {
			Type:         schema.TypeInt,
			Optional:     true,
			Computed:     true,
			Description:  "The maximum MTU on the switch.",
			ValidateFunc: validation.IntBetween(1, 9000),
		},
		"multicast_filtering_mode": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The multicast filtering mode on the switch. Can be one of legacyFiltering, or snooping.",
			ValidateFunc: validation.StringInSlice(multicastFilteringModeAllowedValues, false),
		},
		"network_resource_control_version": {
			Type:         schema.TypeString,
			Optional:     true,
			Computed:     true,
			Description:  "The network I/O control version to use. Can be one of version2 or version3.",
			ValidateFunc: validation.StringInSlice(networkResourceControlAllowedValues, false),
		},

		"config_version": {
			Type:        schema.TypeString,
			Computed:    true,
			Description: "The version string of the configuration that this spec is trying to change.",
		},
	}

	structure.MergeSchema(s, schemaVMwareDVSPortSetting())
	structure.MergeSchema(s, schemaDvsHostInfrastructureTrafficResource())
	return s
}
// schemaVMwareDVSConfigSpec returns schema items for resources that need to work
// with a VMwareDVSConfigSpec.