# 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, overload
from .. import _utilities

__all__ = ['KubernetesAddonInitArgs', 'KubernetesAddon']

@pulumi.input_type
class KubernetesAddonInitArgs:
    def __init__(__self__, *,
                 cluster_id: pulumi.Input[str],
                 version: pulumi.Input[str],
                 name: Optional[pulumi.Input[str]] = None):
        """
        The set of arguments for constructing a KubernetesAddon resource.
        :param pulumi.Input[str] cluster_id: The id of kubernetes cluster.
        :param pulumi.Input[str] version: The current version of addon.
        :param pulumi.Input[str] name: The name of addon.
        """
        pulumi.set(__self__, "cluster_id", cluster_id)
        pulumi.set(__self__, "version", version)
        if name is not None:
            pulumi.set(__self__, "name", name)

    @property
    @pulumi.getter(name="clusterId")
    def cluster_id(self) -> pulumi.Input[str]:
        """
        The id of kubernetes cluster.
        """
        return pulumi.get(self, "cluster_id")

    @cluster_id.setter
    def cluster_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "cluster_id", value)

    @property
    @pulumi.getter
    def version(self) -> pulumi.Input[str]:
        """
        The current version of addon.
        """
        return pulumi.get(self, "version")

    @version.setter
    def version(self, value: pulumi.Input[str]):
        pulumi.set(self, "version", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The name of addon.
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name", value)


@pulumi.input_type
class _KubernetesAddonState:
    def __init__(__self__, *,
                 can_upgrade: Optional[pulumi.Input[bool]] = None,
                 cluster_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 next_version: Optional[pulumi.Input[str]] = None,
                 required: Optional[pulumi.Input[bool]] = None,
                 version: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering KubernetesAddon resources.
        :param pulumi.Input[bool] can_upgrade: Is the addon ready for upgrade.
        :param pulumi.Input[str] cluster_id: The id of kubernetes cluster.
        :param pulumi.Input[str] name: The name of addon.
        :param pulumi.Input[str] next_version: The version which addon can be upgraded to.
        :param pulumi.Input[bool] required: Is it a mandatory addon to be installed.
        :param pulumi.Input[str] version: The current version of addon.
        """
        if can_upgrade is not None:
            pulumi.set(__self__, "can_upgrade", can_upgrade)
        if cluster_id is not None:
            pulumi.set(__self__, "cluster_id", cluster_id)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if next_version is not None:
            pulumi.set(__self__, "next_version", next_version)
        if required is not None:
            pulumi.set(__self__, "required", required)
        if version is not None:
            pulumi.set(__self__, "version", version)

    @property
    @pulumi.getter(name="canUpgrade")
    def can_upgrade(self) -> Optional[pulumi.Input[bool]]:
        """
        Is the addon ready for upgrade.
        """
        return pulumi.get(self, "can_upgrade")

    @can_upgrade.setter
    def can_upgrade(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "can_upgrade", value)

    @property
    @pulumi.getter(name="clusterId")
    def cluster_id(self) -> Optional[pulumi.Input[str]]:
        """
        The id of kubernetes cluster.
        """
        return pulumi.get(self, "cluster_id")

    @cluster_id.setter
    def cluster_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "cluster_id", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The name of addon.
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "name", value)

    @property
    @pulumi.getter(name="nextVersion")
    def next_version(self) -> Optional[pulumi.Input[str]]:
        """
        The version which addon can be upgraded to.
        """
        return pulumi.get(self, "next_version")

    @next_version.setter
    def next_version(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "next_version", value)

    @property
    @pulumi.getter
    def required(self) -> Optional[pulumi.Input[bool]]:
        """
        Is it a mandatory addon to be installed.
        """
        return pulumi.get(self, "required")

    @required.setter
    def required(self, value: Optional[pulumi.Input[bool]]):
        pulumi.set(self, "required", value)

    @property
    @pulumi.getter
    def version(self) -> Optional[pulumi.Input[str]]:
        """
        The current version of addon.
        """
        return pulumi.get(self, "version")

    @version.setter
    def version(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "version", value)


class KubernetesAddon(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 cluster_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 version: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        This resource will help you to manage addon in Kubernetes Cluster.

        > **NOTE:** Available in 1.150.0+.

        ## Example Usage

        **Create a managed cluster**

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "tf-test"
        default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
        default_instance_types = alicloud.ecs.get_instance_types(availability_zone=default_zones.zones[0].id,
            cpu_core_count=2,
            memory_size=4,
            kubernetes_node_role="Worker")
        default_network = alicloud.vpc.Network("defaultNetwork",
            vpc_name=name,
            cidr_block="10.1.0.0/21")
        default_switch = alicloud.vpc.Switch("defaultSwitch",
            vswitch_name=name,
            vpc_id=default_network.id,
            cidr_block="10.1.1.0/24",
            zone_id=default_zones.zones[0].id)
        default_key_pair = alicloud.ecs.KeyPair("defaultKeyPair", key_pair_name=name)
        default_managed_kubernetes = None
        if 1 == True:
            default_managed_kubernetes = alicloud.cs.ManagedKubernetes("defaultManagedKubernetes",
                cluster_spec="ack.pro.small",
                is_enterprise_security_group=True,
                worker_number=2,
                password="Hello1234",
                pod_cidr="172.20.0.0/16",
                service_cidr="172.21.0.0/20",
                worker_vswitch_ids=[default_switch.id],
                worker_instance_types=[default_instance_types.instance_types[0].id])
        ```
        **Installing of addon**
        When a cluster is created, some system addons and those specified at the time of cluster creation will be installed, so when an addon resource is applied:
        * If the addon already exists in the cluster and its version is the same as the specified version, it will be skipped and will not be reinstalled.
        * If the addon already exists in the cluster and its version is different from the specified version, the addon will be upgraded.
        * If the addon does not exist in the cluster, it will be installed.

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        ack_node_problem_detector = alicloud.cs.KubernetesAddon("ack-node-problem-detector",
            cluster_id=alicloud_cs_managed_kubernetes["default"][0]["id"],
            version="1.2.7")
        ```
        **Upgrading of addon**
        First, check the `next_version` field of the addon that can be upgraded to through the `.tfstate file`, then overwrite the `version` field with the value of `next_version` and apply.
        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        ack_node_problem_detector = alicloud.cs.KubernetesAddon("ack-node-problem-detector",
            cluster_id=alicloud_cs_managed_kubernetes["default"][0]["id"],
            version="1.2.8")
        # upgrade from 1.2.7 to 1.2.8
        ```

        ## Import

        Cluster addon can be imported by cluster id and addon name. Then write the addon.tf file according to the result of `terraform plan`.

        ```sh
         $ pulumi import alicloud:cs/kubernetesAddon:KubernetesAddon alicloud_cs_kubernetes_addon.my_addon <cluster_id>:<addon_name>
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] cluster_id: The id of kubernetes cluster.
        :param pulumi.Input[str] name: The name of addon.
        :param pulumi.Input[str] version: The current version of addon.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: KubernetesAddonInitArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        This resource will help you to manage addon in Kubernetes Cluster.

        > **NOTE:** Available in 1.150.0+.

        ## Example Usage

        **Create a managed cluster**

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "tf-test"
        default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
        default_instance_types = alicloud.ecs.get_instance_types(availability_zone=default_zones.zones[0].id,
            cpu_core_count=2,
            memory_size=4,
            kubernetes_node_role="Worker")
        default_network = alicloud.vpc.Network("defaultNetwork",
            vpc_name=name,
            cidr_block="10.1.0.0/21")
        default_switch = alicloud.vpc.Switch("defaultSwitch",
            vswitch_name=name,
            vpc_id=default_network.id,
            cidr_block="10.1.1.0/24",
            zone_id=default_zones.zones[0].id)
        default_key_pair = alicloud.ecs.KeyPair("defaultKeyPair", key_pair_name=name)
        default_managed_kubernetes = None
        if 1 == True:
            default_managed_kubernetes = alicloud.cs.ManagedKubernetes("defaultManagedKubernetes",
                cluster_spec="ack.pro.small",
                is_enterprise_security_group=True,
                worker_number=2,
                password="Hello1234",
                pod_cidr="172.20.0.0/16",
                service_cidr="172.21.0.0/20",
                worker_vswitch_ids=[default_switch.id],
                worker_instance_types=[default_instance_types.instance_types[0].id])
        ```
        **Installing of addon**
        When a cluster is created, some system addons and those specified at the time of cluster creation will be installed, so when an addon resource is applied:
        * If the addon already exists in the cluster and its version is the same as the specified version, it will be skipped and will not be reinstalled.
        * If the addon already exists in the cluster and its version is different from the specified version, the addon will be upgraded.
        * If the addon does not exist in the cluster, it will be installed.

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        ack_node_problem_detector = alicloud.cs.KubernetesAddon("ack-node-problem-detector",
            cluster_id=alicloud_cs_managed_kubernetes["default"][0]["id"],
            version="1.2.7")
        ```
        **Upgrading of addon**
        First, check the `next_version` field of the addon that can be upgraded to through the `.tfstate file`, then overwrite the `version` field with the value of `next_version` and apply.
        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        ack_node_problem_detector = alicloud.cs.KubernetesAddon("ack-node-problem-detector",
            cluster_id=alicloud_cs_managed_kubernetes["default"][0]["id"],
            version="1.2.8")
        # upgrade from 1.2.7 to 1.2.8
        ```

        ## Import

        Cluster addon can be imported by cluster id and addon name. Then write the addon.tf file according to the result of `terraform plan`.

        ```sh
         $ pulumi import alicloud:cs/kubernetesAddon:KubernetesAddon alicloud_cs_kubernetes_addon.my_addon <cluster_id>:<addon_name>
        ```

        :param str resource_name: The name of the resource.
        :param KubernetesAddonInitArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(KubernetesAddonInitArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 cluster_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 version: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        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__ = KubernetesAddonInitArgs.__new__(KubernetesAddonInitArgs)

            if cluster_id is None and not opts.urn:
                raise TypeError("Missing required property 'cluster_id'")
            __props__.__dict__["cluster_id"] = cluster_id
            __props__.__dict__["name"] = name
            if version is None and not opts.urn:
                raise TypeError("Missing required property 'version'")
            __props__.__dict__["version"] = version
            __props__.__dict__["can_upgrade"] = None
            __props__.__dict__["next_version"] = None
            __props__.__dict__["required"] = None
        super(KubernetesAddon, __self__).__init__(
            'alicloud:cs/kubernetesAddon:KubernetesAddon',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            can_upgrade: Optional[pulumi.Input[bool]] = None,
            cluster_id: Optional[pulumi.Input[str]] = None,
            name: Optional[pulumi.Input[str]] = None,
            next_version: Optional[pulumi.Input[str]] = None,
            required: Optional[pulumi.Input[bool]] = None,
            version: Optional[pulumi.Input[str]] = None) -> 'KubernetesAddon':
        """
        Get an existing KubernetesAddon 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[bool] can_upgrade: Is the addon ready for upgrade.
        :param pulumi.Input[str] cluster_id: The id of kubernetes cluster.
        :param pulumi.Input[str] name: The name of addon.
        :param pulumi.Input[str] next_version: The version which addon can be upgraded to.
        :param pulumi.Input[bool] required: Is it a mandatory addon to be installed.
        :param pulumi.Input[str] version: The current version of addon.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _KubernetesAddonState.__new__(_KubernetesAddonState)

        __props__.__dict__["can_upgrade"] = can_upgrade
        __props__.__dict__["cluster_id"] = cluster_id
        __props__.__dict__["name"] = name
        __props__.__dict__["next_version"] = next_version
        __props__.__dict__["required"] = required
        __props__.__dict__["version"] = version
        return KubernetesAddon(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="canUpgrade")
    def can_upgrade(self) -> pulumi.Output[bool]:
        """
        Is the addon ready for upgrade.
        """
        return pulumi.get(self, "can_upgrade")

    @property
    @pulumi.getter(name="clusterId")
    def cluster_id(self) -> pulumi.Output[str]:
        """
        The id of kubernetes cluster.
        """
        return pulumi.get(self, "cluster_id")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        The name of addon.
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="nextVersion")
    def next_version(self) -> pulumi.Output[str]:
        """
        The version which addon can be upgraded to.
        """
        return pulumi.get(self, "next_version")

    @property
    @pulumi.getter
    def required(self) -> pulumi.Output[bool]:
        """
        Is it a mandatory addon to be installed.
        """
        return pulumi.get(self, "required")

    @property
    @pulumi.getter
    def version(self) -> pulumi.Output[str]:
        """
        The current version of addon.
        """
        return pulumi.get(self, "version")

