# coding=utf-8
# *** WARNING: this file was generated by pulumigen. ***
# *** 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 ... import meta as _meta

__all__ = [
    'LeaseCandidate',
    'LeaseCandidateSpec',
    'LeaseCandidateSpecPatch',
]

@pulumi.output_type
class LeaseCandidate(dict):
    """
    LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
    """
    @staticmethod
    def __key_warning(key: str):
        suggest = None
        if key == "apiVersion":
            suggest = "api_version"

        if suggest:
            pulumi.log.warn(f"Key '{key}' not found in LeaseCandidate. Access the value via the '{suggest}' property getter instead.")

    def __getitem__(self, key: str) -> Any:
        LeaseCandidate.__key_warning(key)
        return super().__getitem__(key)

    def get(self, key: str, default = None) -> Any:
        LeaseCandidate.__key_warning(key)
        return super().get(key, default)

    def __init__(__self__, *,
                 api_version: Optional[str] = None,
                 kind: Optional[str] = None,
                 metadata: Optional['_meta.v1.outputs.ObjectMeta'] = None,
                 spec: Optional['outputs.LeaseCandidateSpec'] = None):
        """
        LeaseCandidate defines a candidate for a Lease object. Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
        :param str api_version: APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
        :param str kind: Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
        :param '_meta.v1.ObjectMetaArgs' metadata: More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
        :param 'LeaseCandidateSpecArgs' spec: spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
        """
        if api_version is not None:
            pulumi.set(__self__, "api_version", 'coordination.k8s.io/v1alpha2')
        if kind is not None:
            pulumi.set(__self__, "kind", 'LeaseCandidate')
        if metadata is not None:
            pulumi.set(__self__, "metadata", metadata)
        if spec is not None:
            pulumi.set(__self__, "spec", spec)

    @property
    @pulumi.getter(name="apiVersion")
    def api_version(self) -> Optional[str]:
        """
        APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
        """
        return pulumi.get(self, "api_version")

    @property
    @pulumi.getter
    def kind(self) -> Optional[str]:
        """
        Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
        """
        return pulumi.get(self, "kind")

    @property
    @pulumi.getter
    def metadata(self) -> Optional['_meta.v1.outputs.ObjectMeta']:
        """
        More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
        """
        return pulumi.get(self, "metadata")

    @property
    @pulumi.getter
    def spec(self) -> Optional['outputs.LeaseCandidateSpec']:
        """
        spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
        """
        return pulumi.get(self, "spec")


@pulumi.output_type
class LeaseCandidateSpec(dict):
    """
    LeaseCandidateSpec is a specification of a Lease.
    """
    @staticmethod
    def __key_warning(key: str):
        suggest = None
        if key == "binaryVersion":
            suggest = "binary_version"
        elif key == "leaseName":
            suggest = "lease_name"
        elif key == "emulationVersion":
            suggest = "emulation_version"
        elif key == "pingTime":
            suggest = "ping_time"
        elif key == "renewTime":
            suggest = "renew_time"

        if suggest:
            pulumi.log.warn(f"Key '{key}' not found in LeaseCandidateSpec. Access the value via the '{suggest}' property getter instead.")

    def __getitem__(self, key: str) -> Any:
        LeaseCandidateSpec.__key_warning(key)
        return super().__getitem__(key)

    def get(self, key: str, default = None) -> Any:
        LeaseCandidateSpec.__key_warning(key)
        return super().get(key, default)

    def __init__(__self__, *,
                 binary_version: str,
                 lease_name: str,
                 strategy: str,
                 emulation_version: Optional[str] = None,
                 ping_time: Optional[str] = None,
                 renew_time: Optional[str] = None):
        """
        LeaseCandidateSpec is a specification of a Lease.
        :param str binary_version: BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.
        :param str lease_name: LeaseName is the name of the lease for which this candidate is contending. This field is immutable.
        :param str strategy: Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
        :param str emulation_version: EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is "OldestEmulationVersion"
        :param str ping_time: PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.
        :param str renew_time: RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.
        """
        pulumi.set(__self__, "binary_version", binary_version)
        pulumi.set(__self__, "lease_name", lease_name)
        pulumi.set(__self__, "strategy", strategy)
        if emulation_version is not None:
            pulumi.set(__self__, "emulation_version", emulation_version)
        if ping_time is not None:
            pulumi.set(__self__, "ping_time", ping_time)
        if renew_time is not None:
            pulumi.set(__self__, "renew_time", renew_time)

    @property
    @pulumi.getter(name="binaryVersion")
    def binary_version(self) -> str:
        """
        BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.
        """
        return pulumi.get(self, "binary_version")

    @property
    @pulumi.getter(name="leaseName")
    def lease_name(self) -> str:
        """
        LeaseName is the name of the lease for which this candidate is contending. This field is immutable.
        """
        return pulumi.get(self, "lease_name")

    @property
    @pulumi.getter
    def strategy(self) -> str:
        """
        Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
        """
        return pulumi.get(self, "strategy")

    @property
    @pulumi.getter(name="emulationVersion")
    def emulation_version(self) -> Optional[str]:
        """
        EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is "OldestEmulationVersion"
        """
        return pulumi.get(self, "emulation_version")

    @property
    @pulumi.getter(name="pingTime")
    def ping_time(self) -> Optional[str]:
        """
        PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.
        """
        return pulumi.get(self, "ping_time")

    @property
    @pulumi.getter(name="renewTime")
    def renew_time(self) -> Optional[str]:
        """
        RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.
        """
        return pulumi.get(self, "renew_time")


@pulumi.output_type
class LeaseCandidateSpecPatch(dict):
    """
    LeaseCandidateSpec is a specification of a Lease.
    """
    @staticmethod
    def __key_warning(key: str):
        suggest = None
        if key == "binaryVersion":
            suggest = "binary_version"
        elif key == "emulationVersion":
            suggest = "emulation_version"
        elif key == "leaseName":
            suggest = "lease_name"
        elif key == "pingTime":
            suggest = "ping_time"
        elif key == "renewTime":
            suggest = "renew_time"

        if suggest:
            pulumi.log.warn(f"Key '{key}' not found in LeaseCandidateSpecPatch. Access the value via the '{suggest}' property getter instead.")

    def __getitem__(self, key: str) -> Any:
        LeaseCandidateSpecPatch.__key_warning(key)
        return super().__getitem__(key)

    def get(self, key: str, default = None) -> Any:
        LeaseCandidateSpecPatch.__key_warning(key)
        return super().get(key, default)

    def __init__(__self__, *,
                 binary_version: Optional[str] = None,
                 emulation_version: Optional[str] = None,
                 lease_name: Optional[str] = None,
                 ping_time: Optional[str] = None,
                 renew_time: Optional[str] = None,
                 strategy: Optional[str] = None):
        """
        LeaseCandidateSpec is a specification of a Lease.
        :param str binary_version: BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.
        :param str emulation_version: EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is "OldestEmulationVersion"
        :param str lease_name: LeaseName is the name of the lease for which this candidate is contending. This field is immutable.
        :param str ping_time: PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.
        :param str renew_time: RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.
        :param str strategy: Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
        """
        if binary_version is not None:
            pulumi.set(__self__, "binary_version", binary_version)
        if emulation_version is not None:
            pulumi.set(__self__, "emulation_version", emulation_version)
        if lease_name is not None:
            pulumi.set(__self__, "lease_name", lease_name)
        if ping_time is not None:
            pulumi.set(__self__, "ping_time", ping_time)
        if renew_time is not None:
            pulumi.set(__self__, "renew_time", renew_time)
        if strategy is not None:
            pulumi.set(__self__, "strategy", strategy)

    @property
    @pulumi.getter(name="binaryVersion")
    def binary_version(self) -> Optional[str]:
        """
        BinaryVersion is the binary version. It must be in a semver format without leading `v`. This field is required.
        """
        return pulumi.get(self, "binary_version")

    @property
    @pulumi.getter(name="emulationVersion")
    def emulation_version(self) -> Optional[str]:
        """
        EmulationVersion is the emulation version. It must be in a semver format without leading `v`. EmulationVersion must be less than or equal to BinaryVersion. This field is required when strategy is "OldestEmulationVersion"
        """
        return pulumi.get(self, "emulation_version")

    @property
    @pulumi.getter(name="leaseName")
    def lease_name(self) -> Optional[str]:
        """
        LeaseName is the name of the lease for which this candidate is contending. This field is immutable.
        """
        return pulumi.get(self, "lease_name")

    @property
    @pulumi.getter(name="pingTime")
    def ping_time(self) -> Optional[str]:
        """
        PingTime is the last time that the server has requested the LeaseCandidate to renew. It is only done during leader election to check if any LeaseCandidates have become ineligible. When PingTime is updated, the LeaseCandidate will respond by updating RenewTime.
        """
        return pulumi.get(self, "ping_time")

    @property
    @pulumi.getter(name="renewTime")
    def renew_time(self) -> Optional[str]:
        """
        RenewTime is the time that the LeaseCandidate was last updated. Any time a Lease needs to do leader election, the PingTime field is updated to signal to the LeaseCandidate that they should update the RenewTime. Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew. The PingTime field is updated regularly to prevent garbage collection for still active LeaseCandidates.
        """
        return pulumi.get(self, "renew_time")

    @property
    @pulumi.getter
    def strategy(self) -> Optional[str]:
        """
        Strategy is the strategy that coordinated leader election will use for picking the leader. If multiple candidates for the same Lease return different strategies, the strategy provided by the candidate with the latest BinaryVersion will be used. If there is still conflict, this is a user error and coordinated leader election will not operate the Lease until resolved. (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
        """
        return pulumi.get(self, "strategy")


