# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from . import _utilities, _tables
from . import outputs
from ._inputs import *

__all__ = ['Vnic']


class Vnic(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 distributed_port_group: Optional[pulumi.Input[str]] = None,
                 distributed_switch_port: Optional[pulumi.Input[str]] = None,
                 host: Optional[pulumi.Input[str]] = None,
                 ipv4: Optional[pulumi.Input[pulumi.InputType['VnicIpv4Args']]] = None,
                 ipv6: Optional[pulumi.Input[pulumi.InputType['VnicIpv6Args']]] = None,
                 mac: Optional[pulumi.Input[str]] = None,
                 mtu: Optional[pulumi.Input[int]] = None,
                 netstack: Optional[pulumi.Input[str]] = None,
                 portgroup: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides a VMware vSphere vnic resource.

        ## Example Usage

        ### S
        ### Create a vnic attached to a distributed virtual switch using the vmotion TCP/IP stack

        ```python
        import pulumi
        import pulumi_vsphere as vsphere

        dc = vsphere.get_datacenter(name="mydc")
        h1 = vsphere.get_host(name="esxi1.host.test",
            datacenter_id=dc.id)
        d1 = vsphere.DistributedVirtualSwitch("d1",
            datacenter_id=dc.id,
            hosts=[vsphere.DistributedVirtualSwitchHostArgs(
                host_system_id=h1.id,
                devices=["vnic3"],
            )])
        p1 = vsphere.DistributedPortGroup("p1",
            vlan_id=1234,
            distributed_virtual_switch_uuid=d1.id)
        v1 = vsphere.Vnic("v1",
            host=h1.id,
            distributed_switch_port=d1.id,
            distributed_port_group=p1.id,
            ipv4=vsphere.VnicIpv4Args(
                dhcp=True,
            ),
            netstack="vmotion")
        ```
        ### Create a vnic attached to a portgroup using the default TCP/IP stack

        ```python
        import pulumi
        import pulumi_vsphere as vsphere

        dc = vsphere.get_datacenter(name="mydc")
        h1 = vsphere.get_host(name="esxi1.host.test",
            datacenter_id=dc.id)
        hvs1 = vsphere.HostVirtualSwitch("hvs1",
            host_system_id=h1.id,
            network_adapters=[
                "vmnic3",
                "vmnic4",
            ],
            active_nics=["vmnic3"],
            standby_nics=["vmnic4"])
        p1 = vsphere.HostPortGroup("p1",
            virtual_switch_name=hvs1.name,
            host_system_id=h1.id)
        v1 = vsphere.Vnic("v1",
            host=h1.id,
            portgroup=p1.name,
            ipv4=vsphere.VnicIpv4Args(
                dhcp=True,
            ))
        ```
        ## Importing

        An existing vNic can be [imported][docs-import] into this resource
        via supplying the vNic's ID. An example is below:

        [docs-import]: /docs/import/index.html

        ```python
        import pulumi
        ```

        The above would import the vnic `vmk2` from host with ID `host-123`.

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] distributed_port_group: Key of the distributed portgroup the nic will connect to.
        :param pulumi.Input[str] distributed_switch_port: UUID of the DVSwitch the nic will be attached to. Do not set if you set portgroup.
        :param pulumi.Input[str] host: ESX host the interface belongs to
        :param pulumi.Input[pulumi.InputType['VnicIpv4Args']] ipv4: IPv4 settings. Either this or `ipv6` needs to be set. See  ipv4 options below.
        :param pulumi.Input[pulumi.InputType['VnicIpv6Args']] ipv6: IPv6 settings. Either this or `ipv6` needs to be set. See  ipv6 options below.
        :param pulumi.Input[str] mac: MAC address of the interface.
        :param pulumi.Input[int] mtu: MTU of the interface.
        :param pulumi.Input[str] netstack: TCP/IP stack setting for this interface. Possible values are 'defaultTcpipStack', 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default: `defaultTcpipStack`)
        :param pulumi.Input[str] portgroup: Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            __props__['distributed_port_group'] = distributed_port_group
            __props__['distributed_switch_port'] = distributed_switch_port
            if host is None and not opts.urn:
                raise TypeError("Missing required property 'host'")
            __props__['host'] = host
            __props__['ipv4'] = ipv4
            __props__['ipv6'] = ipv6
            __props__['mac'] = mac
            __props__['mtu'] = mtu
            __props__['netstack'] = netstack
            __props__['portgroup'] = portgroup
        super(Vnic, __self__).__init__(
            'vsphere:index/vnic:Vnic',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            distributed_port_group: Optional[pulumi.Input[str]] = None,
            distributed_switch_port: Optional[pulumi.Input[str]] = None,
            host: Optional[pulumi.Input[str]] = None,
            ipv4: Optional[pulumi.Input[pulumi.InputType['VnicIpv4Args']]] = None,
            ipv6: Optional[pulumi.Input[pulumi.InputType['VnicIpv6Args']]] = None,
            mac: Optional[pulumi.Input[str]] = None,
            mtu: Optional[pulumi.Input[int]] = None,
            netstack: Optional[pulumi.Input[str]] = None,
            portgroup: Optional[pulumi.Input[str]] = None) -> 'Vnic':
        """
        Get an existing Vnic resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] distributed_port_group: Key of the distributed portgroup the nic will connect to.
        :param pulumi.Input[str] distributed_switch_port: UUID of the DVSwitch the nic will be attached to. Do not set if you set portgroup.
        :param pulumi.Input[str] host: ESX host the interface belongs to
        :param pulumi.Input[pulumi.InputType['VnicIpv4Args']] ipv4: IPv4 settings. Either this or `ipv6` needs to be set. See  ipv4 options below.
        :param pulumi.Input[pulumi.InputType['VnicIpv6Args']] ipv6: IPv6 settings. Either this or `ipv6` needs to be set. See  ipv6 options below.
        :param pulumi.Input[str] mac: MAC address of the interface.
        :param pulumi.Input[int] mtu: MTU of the interface.
        :param pulumi.Input[str] netstack: TCP/IP stack setting for this interface. Possible values are 'defaultTcpipStack', 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default: `defaultTcpipStack`)
        :param pulumi.Input[str] portgroup: Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["distributed_port_group"] = distributed_port_group
        __props__["distributed_switch_port"] = distributed_switch_port
        __props__["host"] = host
        __props__["ipv4"] = ipv4
        __props__["ipv6"] = ipv6
        __props__["mac"] = mac
        __props__["mtu"] = mtu
        __props__["netstack"] = netstack
        __props__["portgroup"] = portgroup
        return Vnic(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="distributedPortGroup")
    def distributed_port_group(self) -> pulumi.Output[Optional[str]]:
        """
        Key of the distributed portgroup the nic will connect to.
        """
        return pulumi.get(self, "distributed_port_group")

    @property
    @pulumi.getter(name="distributedSwitchPort")
    def distributed_switch_port(self) -> pulumi.Output[Optional[str]]:
        """
        UUID of the DVSwitch the nic will be attached to. Do not set if you set portgroup.
        """
        return pulumi.get(self, "distributed_switch_port")

    @property
    @pulumi.getter
    def host(self) -> pulumi.Output[str]:
        """
        ESX host the interface belongs to
        """
        return pulumi.get(self, "host")

    @property
    @pulumi.getter
    def ipv4(self) -> pulumi.Output[Optional['outputs.VnicIpv4']]:
        """
        IPv4 settings. Either this or `ipv6` needs to be set. See  ipv4 options below.
        """
        return pulumi.get(self, "ipv4")

    @property
    @pulumi.getter
    def ipv6(self) -> pulumi.Output[Optional['outputs.VnicIpv6']]:
        """
        IPv6 settings. Either this or `ipv6` needs to be set. See  ipv6 options below.
        """
        return pulumi.get(self, "ipv6")

    @property
    @pulumi.getter
    def mac(self) -> pulumi.Output[str]:
        """
        MAC address of the interface.
        """
        return pulumi.get(self, "mac")

    @property
    @pulumi.getter
    def mtu(self) -> pulumi.Output[int]:
        """
        MTU of the interface.
        """
        return pulumi.get(self, "mtu")

    @property
    @pulumi.getter
    def netstack(self) -> pulumi.Output[Optional[str]]:
        """
        TCP/IP stack setting for this interface. Possible values are 'defaultTcpipStack', 'vmotion', 'vSphereProvisioning'. Changing this will force the creation of a new interface since it's not possible to change the stack once it gets created. (Default: `defaultTcpipStack`)
        """
        return pulumi.get(self, "netstack")

    @property
    @pulumi.getter
    def portgroup(self) -> pulumi.Output[Optional[str]]:
        """
        Portgroup to attach the nic to. Do not set if you set distributed_switch_port.
        """
        return pulumi.get(self, "portgroup")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

