# 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 json
import warnings
import pulumi
import pulumi.runtime
from typing import Union
from . import utilities, tables

class StackScript(pulumi.CustomResource):
    created: pulumi.Output[str]
    """
    The date this StackScript was created.
    """
    deployments_active: pulumi.Output[float]
    """
    Count of currently active, deployed Linodes created from this StackScript.
    """
    deployments_total: pulumi.Output[float]
    """
    The total number of times this StackScript has been deployed.
    """
    description: pulumi.Output[str]
    """
    A description for the StackScript.
    """
    images: pulumi.Output[list]
    """
    An array of Image IDs representing the Images that this StackScript is compatible for deploying with.
    """
    is_public: pulumi.Output[bool]
    """
    This determines whether other users can use your StackScript. Once a StackScript is made public, it cannot be made private. *Changing `is_public` forces the creation of a new StackScript*
    """
    label: pulumi.Output[str]
    """
    The StackScript's label is for display purposes only.
    """
    rev_note: pulumi.Output[str]
    """
    This field allows you to add notes for the set of revisions made to this StackScript.
    """
    script: pulumi.Output[str]
    """
    The script to execute when provisioning a new Linode with this StackScript.
    """
    updated: pulumi.Output[str]
    """
    The date this StackScript was updated.
    """
    user_defined_fields: pulumi.Output[list]
    """
    This is a list of fields defined with a special syntax inside this StackScript that allow for supplying customized
    parameters during deployment.

      * `default` (`str`)
      * `example` (`str`)
      * `label` (`str`) - The StackScript's label is for display purposes only.
      * `manyOf` (`str`)
      * `name` (`str`)
      * `oneOf` (`str`)
    """
    user_gravatar_id: pulumi.Output[str]
    """
    The Gravatar ID for the User who created the StackScript.
    """
    username: pulumi.Output[str]
    """
    The User who created the StackScript.
    """
    def __init__(__self__, resource_name, opts=None, description=None, images=None, is_public=None, label=None, rev_note=None, script=None, user_defined_fields=None, __props__=None, __name__=None, __opts__=None):
        """
        Provides a Linode StackScript resource.  This can be used to create, modify, and delete Linode StackScripts.  StackScripts are private or public managed scripts which run within an instance during startup.  StackScripts can include variables whose values are specified when the Instance is created.  

        For more information, see [Automate Deployment with StackScripts](https://www.linode.com/docs/platform/stackscripts/) and the [Linode APIv4 docs](https://developers.linode.com/api/v4#tag/StackScripts).

        ## Example Usage



        ```python
        import pulumi
        import pulumi_linode as linode

        foo_stack_script = linode.StackScript("fooStackScript",
            description="Installs a Package",
            images=[
                "linode/ubuntu18.04",
                "linode/ubuntu16.04lts",
            ],
            label="foo",
            rev_note="initial version",
            script=\"\"\"#!/bin/bash
        # <UDF name="package" label="System Package to Install" example="nginx" default="">
        apt-get -q update && apt-get -q -y install $$PACKAGE

        \"\"\")
        foo_instance = linode.Instance("fooInstance",
            authorized_keys=["..."],
            image="linode/ubuntu18.04",
            label="foo",
            region="us-east",
            root_pass="...",
            stackscript_data={
                "package": "nginx",
            },
            stackscript_id=linode_stackscript["install-nginx"]["id"],
            type="g6-nanode-1")
        ```

        ## Attributes

        This resource exports the following attributes:

        * `deployments_active` - Count of currently active, deployed Linodes created from this StackScript.

        * `user_gravatar_id` - The Gravatar ID for the User who created the StackScript.

        * `deployments_total` - The total number of times this StackScript has been deployed.

        * `username` - The User who created the StackScript.

        * `created` - The date this StackScript was created.

        * `updated` - The date this StackScript was updated.

        * `user_defined_fields` - This is a list of fields defined with a special syntax inside this StackScript that allow for supplying customized parameters during deployment.

          * `label` - A human-readable label for the field that will serve as the input prompt for entering the value during deployment.

          * `name` - The name of the field.

          * `example` - An example value for the field.

          * `one_of` - A list of acceptable single values for the field.

          * `many_of` - A list of acceptable values for the field in any quantity, combination or order.

          * `default` - The default value. If not specified, this value will be used.

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] description: A description for the StackScript.
        :param pulumi.Input[list] images: An array of Image IDs representing the Images that this StackScript is compatible for deploying with.
        :param pulumi.Input[bool] is_public: This determines whether other users can use your StackScript. Once a StackScript is made public, it cannot be made private. *Changing `is_public` forces the creation of a new StackScript*
        :param pulumi.Input[str] label: The StackScript's label is for display purposes only.
        :param pulumi.Input[str] rev_note: This field allows you to add notes for the set of revisions made to this StackScript.
        :param pulumi.Input[str] script: The script to execute when provisioning a new Linode with this StackScript.
        :param pulumi.Input[list] user_defined_fields: This is a list of fields defined with a special syntax inside this StackScript that allow for supplying customized
               parameters during deployment.

        The **user_defined_fields** object supports the following:

          * `default` (`pulumi.Input[str]`)
          * `example` (`pulumi.Input[str]`)
          * `label` (`pulumi.Input[str]`) - The StackScript's label is for display purposes only.
          * `manyOf` (`pulumi.Input[str]`)
          * `name` (`pulumi.Input[str]`)
          * `oneOf` (`pulumi.Input[str]`)
        """
        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()

            if description is None:
                raise TypeError("Missing required property 'description'")
            __props__['description'] = description
            if images is None:
                raise TypeError("Missing required property 'images'")
            __props__['images'] = images
            __props__['is_public'] = is_public
            if label is None:
                raise TypeError("Missing required property 'label'")
            __props__['label'] = label
            __props__['rev_note'] = rev_note
            if script is None:
                raise TypeError("Missing required property 'script'")
            __props__['script'] = script
            __props__['user_defined_fields'] = user_defined_fields
            __props__['created'] = None
            __props__['deployments_active'] = None
            __props__['deployments_total'] = None
            __props__['updated'] = None
            __props__['user_gravatar_id'] = None
            __props__['username'] = None
        super(StackScript, __self__).__init__(
            'linode:index/stackScript:StackScript',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name, id, opts=None, created=None, deployments_active=None, deployments_total=None, description=None, images=None, is_public=None, label=None, rev_note=None, script=None, updated=None, user_defined_fields=None, user_gravatar_id=None, username=None):
        """
        Get an existing StackScript 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 str id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] created: The date this StackScript was created.
        :param pulumi.Input[float] deployments_active: Count of currently active, deployed Linodes created from this StackScript.
        :param pulumi.Input[float] deployments_total: The total number of times this StackScript has been deployed.
        :param pulumi.Input[str] description: A description for the StackScript.
        :param pulumi.Input[list] images: An array of Image IDs representing the Images that this StackScript is compatible for deploying with.
        :param pulumi.Input[bool] is_public: This determines whether other users can use your StackScript. Once a StackScript is made public, it cannot be made private. *Changing `is_public` forces the creation of a new StackScript*
        :param pulumi.Input[str] label: The StackScript's label is for display purposes only.
        :param pulumi.Input[str] rev_note: This field allows you to add notes for the set of revisions made to this StackScript.
        :param pulumi.Input[str] script: The script to execute when provisioning a new Linode with this StackScript.
        :param pulumi.Input[str] updated: The date this StackScript was updated.
        :param pulumi.Input[list] user_defined_fields: This is a list of fields defined with a special syntax inside this StackScript that allow for supplying customized
               parameters during deployment.
        :param pulumi.Input[str] user_gravatar_id: The Gravatar ID for the User who created the StackScript.
        :param pulumi.Input[str] username: The User who created the StackScript.

        The **user_defined_fields** object supports the following:

          * `default` (`pulumi.Input[str]`)
          * `example` (`pulumi.Input[str]`)
          * `label` (`pulumi.Input[str]`) - The StackScript's label is for display purposes only.
          * `manyOf` (`pulumi.Input[str]`)
          * `name` (`pulumi.Input[str]`)
          * `oneOf` (`pulumi.Input[str]`)
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["created"] = created
        __props__["deployments_active"] = deployments_active
        __props__["deployments_total"] = deployments_total
        __props__["description"] = description
        __props__["images"] = images
        __props__["is_public"] = is_public
        __props__["label"] = label
        __props__["rev_note"] = rev_note
        __props__["script"] = script
        __props__["updated"] = updated
        __props__["user_defined_fields"] = user_defined_fields
        __props__["user_gravatar_id"] = user_gravatar_id
        __props__["username"] = username
        return StackScript(resource_name, opts=opts, __props__=__props__)
    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

