# 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 copy
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from .. import _utilities
from . import outputs
from ._inputs import *

__all__ = [
    'GetVirtualMachinesResult',
    'AwaitableGetVirtualMachinesResult',
    'get_virtual_machines',
    'get_virtual_machines_output',
]

@pulumi.output_type
class GetVirtualMachinesResult:
    """
    A collection of values returned by getVirtualMachines.
    """
    def __init__(__self__, filters=None, id=None, node_name=None, tags=None, vms=None):
        if filters and not isinstance(filters, list):
            raise TypeError("Expected argument 'filters' to be a list")
        pulumi.set(__self__, "filters", filters)
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if node_name and not isinstance(node_name, str):
            raise TypeError("Expected argument 'node_name' to be a str")
        pulumi.set(__self__, "node_name", node_name)
        if tags and not isinstance(tags, list):
            raise TypeError("Expected argument 'tags' to be a list")
        pulumi.set(__self__, "tags", tags)
        if vms and not isinstance(vms, list):
            raise TypeError("Expected argument 'vms' to be a list")
        pulumi.set(__self__, "vms", vms)

    @property
    @pulumi.getter
    def filters(self) -> Optional[Sequence['outputs.GetVirtualMachinesFilterResult']]:
        return pulumi.get(self, "filters")

    @property
    @pulumi.getter
    def id(self) -> str:
        """
        The provider-assigned unique ID for this managed resource.
        """
        return pulumi.get(self, "id")

    @property
    @pulumi.getter(name="nodeName")
    def node_name(self) -> Optional[str]:
        """
        The node name.
        """
        return pulumi.get(self, "node_name")

    @property
    @pulumi.getter
    def tags(self) -> Optional[Sequence[str]]:
        """
        A list of tags of the VM.
        """
        return pulumi.get(self, "tags")

    @property
    @pulumi.getter
    def vms(self) -> Sequence['outputs.GetVirtualMachinesVmResult']:
        """
        The VMs list.
        """
        return pulumi.get(self, "vms")


class AwaitableGetVirtualMachinesResult(GetVirtualMachinesResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetVirtualMachinesResult(
            filters=self.filters,
            id=self.id,
            node_name=self.node_name,
            tags=self.tags,
            vms=self.vms)


def get_virtual_machines(filters: Optional[Sequence[Union['GetVirtualMachinesFilterArgs', 'GetVirtualMachinesFilterArgsDict']]] = None,
                         node_name: Optional[str] = None,
                         tags: Optional[Sequence[str]] = None,
                         opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetVirtualMachinesResult:
    """
    Retrieves information about all VMs in the Proxmox cluster.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_proxmoxve as proxmoxve

    ubuntu_vms = proxmoxve.VM.get_virtual_machines(tags=["ubuntu"])
    ubuntu_templates = proxmoxve.VM.get_virtual_machines(filters=[
            {
                "name": "template",
                "values": ["true"],
            },
            {
                "name": "status",
                "values": ["stopped"],
            },
            {
                "name": "name",
                "regex": True,
                "values": ["^ubuntu-20.*$"],
            },
            {
                "name": "node_name",
                "regex": True,
                "values": [
                    "node_us_[1-3]",
                    "node_eu_[1-3]",
                ],
            },
        ],
        tags=[
            "template",
            "latest",
        ])
    ```


    :param Sequence[Union['GetVirtualMachinesFilterArgs', 'GetVirtualMachinesFilterArgsDict']] filters: Filter blocks. The VM must satisfy all filter blocks to be included in the result.
    :param str node_name: The node name. All cluster nodes will be queried in case this is omitted
    :param Sequence[str] tags: A list of tags to filter the VMs. The VM must have all
           the tags to be included in the result.
    """
    __args__ = dict()
    __args__['filters'] = filters
    __args__['nodeName'] = node_name
    __args__['tags'] = tags
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('proxmoxve:VM/getVirtualMachines:getVirtualMachines', __args__, opts=opts, typ=GetVirtualMachinesResult).value

    return AwaitableGetVirtualMachinesResult(
        filters=pulumi.get(__ret__, 'filters'),
        id=pulumi.get(__ret__, 'id'),
        node_name=pulumi.get(__ret__, 'node_name'),
        tags=pulumi.get(__ret__, 'tags'),
        vms=pulumi.get(__ret__, 'vms'))
def get_virtual_machines_output(filters: Optional[pulumi.Input[Optional[Sequence[Union['GetVirtualMachinesFilterArgs', 'GetVirtualMachinesFilterArgsDict']]]]] = None,
                                node_name: Optional[pulumi.Input[Optional[str]]] = None,
                                tags: Optional[pulumi.Input[Optional[Sequence[str]]]] = None,
                                opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetVirtualMachinesResult]:
    """
    Retrieves information about all VMs in the Proxmox cluster.

    ## Example Usage

    ```python
    import pulumi
    import pulumi_proxmoxve as proxmoxve

    ubuntu_vms = proxmoxve.VM.get_virtual_machines(tags=["ubuntu"])
    ubuntu_templates = proxmoxve.VM.get_virtual_machines(filters=[
            {
                "name": "template",
                "values": ["true"],
            },
            {
                "name": "status",
                "values": ["stopped"],
            },
            {
                "name": "name",
                "regex": True,
                "values": ["^ubuntu-20.*$"],
            },
            {
                "name": "node_name",
                "regex": True,
                "values": [
                    "node_us_[1-3]",
                    "node_eu_[1-3]",
                ],
            },
        ],
        tags=[
            "template",
            "latest",
        ])
    ```


    :param Sequence[Union['GetVirtualMachinesFilterArgs', 'GetVirtualMachinesFilterArgsDict']] filters: Filter blocks. The VM must satisfy all filter blocks to be included in the result.
    :param str node_name: The node name. All cluster nodes will be queried in case this is omitted
    :param Sequence[str] tags: A list of tags to filter the VMs. The VM must have all
           the tags to be included in the result.
    """
    __args__ = dict()
    __args__['filters'] = filters
    __args__['nodeName'] = node_name
    __args__['tags'] = tags
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('proxmoxve:VM/getVirtualMachines:getVirtualMachines', __args__, opts=opts, typ=GetVirtualMachinesResult)
    return __ret__.apply(lambda __response__: GetVirtualMachinesResult(
        filters=pulumi.get(__response__, 'filters'),
        id=pulumi.get(__response__, 'id'),
        node_name=pulumi.get(__response__, 'node_name'),
        tags=pulumi.get(__response__, 'tags'),
        vms=pulumi.get(__response__, 'vms')))
