# 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, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables
from . import outputs
from ._inputs import *

__all__ = ['Bucket']


class Bucket(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 acl: Optional[pulumi.Input[str]] = None,
                 bucket: Optional[pulumi.Input[str]] = None,
                 cors_rules: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketCorsRuleArgs']]]]] = None,
                 force_destroy: Optional[pulumi.Input[bool]] = None,
                 lifecycle_rules: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketLifecycleRuleArgs']]]]] = None,
                 logging: Optional[pulumi.Input[pulumi.InputType['BucketLoggingArgs']]] = None,
                 logging_isenable: Optional[pulumi.Input[bool]] = None,
                 policy: Optional[pulumi.Input[str]] = None,
                 redundancy_type: Optional[pulumi.Input[str]] = None,
                 referer_config: Optional[pulumi.Input[pulumi.InputType['BucketRefererConfigArgs']]] = None,
                 server_side_encryption_rule: Optional[pulumi.Input[pulumi.InputType['BucketServerSideEncryptionRuleArgs']]] = None,
                 storage_class: Optional[pulumi.Input[str]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, Any]]] = None,
                 versioning: Optional[pulumi.Input[pulumi.InputType['BucketVersioningArgs']]] = None,
                 website: Optional[pulumi.Input[pulumi.InputType['BucketWebsiteArgs']]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides a resource to create a oss bucket and set its attribution.

        > **NOTE:** The bucket namespace is shared by all users of the OSS system. Please set bucket name as unique as possible.

        ## Example Usage

        Private Bucket

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_acl = alicloud.oss.Bucket("bucket-acl",
            acl="private",
            bucket="bucket-170309-acl")
        ```

        Static Website

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_website = alicloud.oss.Bucket("bucket-website",
            bucket="bucket-170309-website",
            website=alicloud.oss.BucketWebsiteArgs(
                error_document="error.html",
                index_document="index.html",
            ))
        ```

        Enable Logging

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_target = alicloud.oss.Bucket("bucket-target",
            bucket="bucket-170309-acl",
            acl="public-read")
        bucket_logging = alicloud.oss.Bucket("bucket-logging",
            bucket="bucket-170309-logging",
            logging=alicloud.oss.BucketLoggingArgs(
                target_bucket=bucket_target.id,
                target_prefix="log/",
            ))
        ```

        Referer configuration

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_referer = alicloud.oss.Bucket("bucket-referer",
            acl="private",
            bucket="bucket-170309-referer",
            referer_config=alicloud.oss.BucketRefererConfigArgs(
                allow_empty=False,
                referers=[
                    "http://www.aliyun.com",
                    "https://www.aliyun.com",
                ],
            ))
        ```

        Set lifecycle rule

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_lifecycle = alicloud.oss.Bucket("bucket-lifecycle",
            acl="public-read",
            bucket="bucket-170309-lifecycle",
            lifecycle_rules=[alicloud.oss.BucketLifecycleRuleArgs(
                enabled=True,
                id="rule-days-transition",
                prefix="path3/",
                transitions=[
                    alicloud.oss.BucketLifecycleRuleTransitionArgs(
                        created_before_date="2020-11-11",
                        storage_class="IA",
                    ),
                    alicloud.oss.BucketLifecycleRuleTransitionArgs(
                        created_before_date="2021-11-11",
                        storage_class="Archive",
                    ),
                ],
            )])
        ```

        Set bucket policy

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_policy = alicloud.oss.Bucket("bucket-policy",
            acl="private",
            bucket="bucket-170309-policy",
            policy=\"\"\"  {"Statement":
              [{"Action":
                  ["oss:PutObject", "oss:GetObject", "oss:DeleteBucket"],
                "Effect":"Allow",
                "Resource":
                    ["acs:oss:*:*:*"]}],
           "Version":"1"}
          
        \"\"\")
        ```

        IA Bucket

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_storageclass = alicloud.oss.Bucket("bucket-storageclass",
            bucket="bucket-170309-storageclass",
            storage_class="IA")
        ```

        Set bucket server-side encryption rule

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_sserule = alicloud.oss.Bucket("bucket-sserule",
            acl="private",
            bucket="bucket-170309-sserule",
            server_side_encryption_rule=alicloud.oss.BucketServerSideEncryptionRuleArgs(
                kms_master_key_id="your kms key id",
                sse_algorithm="KMS",
            ))
        ```

        Set bucket tags

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_tags = alicloud.oss.Bucket("bucket-tags",
            acl="private",
            bucket="bucket-170309-tags",
            tags={
                "key1": "value1",
                "key2": "value2",
            })
        ```

        Enable bucket versioning

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_versioning = alicloud.oss.Bucket("bucket-versioning",
            acl="private",
            bucket="bucket-170309-versioning",
            versioning=alicloud.oss.BucketVersioningArgs(
                status="Enabled",
            ))
        ```

        Set bucket redundancy type

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        bucket_redundancytype = alicloud.oss.Bucket("bucket-redundancytype",
            bucket="bucket_name",
            redundancy_type="ZRS")
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] acl: The [canned ACL](https://www.alibabacloud.com/help/doc-detail/31898.htm) to apply. Can be "private", "public-read" and "public-read-write". Defaults to "private".
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketCorsRuleArgs']]]] cors_rules: A rule of [Cross-Origin Resource Sharing](https://www.alibabacloud.com/help/doc-detail/31903.htm) (documented below). The items of core rule are no more than 10 for every OSS bucket.
        :param pulumi.Input[bool] force_destroy: A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. Defaults to "false".
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketLifecycleRuleArgs']]]] lifecycle_rules: A configuration of [object lifecycle management](https://www.alibabacloud.com/help/doc-detail/31904.htm) (documented below).
        :param pulumi.Input[pulumi.InputType['BucketLoggingArgs']] logging: A Settings of [bucket logging](https://www.alibabacloud.com/help/doc-detail/31900.htm) (documented below).
        :param pulumi.Input[bool] logging_isenable: The flag of using logging enable container. Defaults true.
        :param pulumi.Input[str] policy: Json format text of bucket policy [bucket policy management](https://www.alibabacloud.com/help/doc-detail/100680.htm).
        :param pulumi.Input[str] redundancy_type: The [redundancy type](https://www.alibabacloud.com/help/doc-detail/90589.htm) to enable. Can be "LRS", and "ZRS". Defaults to "LRS".
        :param pulumi.Input[pulumi.InputType['BucketRefererConfigArgs']] referer_config: The configuration of [referer](https://www.alibabacloud.com/help/doc-detail/31901.htm) (documented below).
        :param pulumi.Input[pulumi.InputType['BucketServerSideEncryptionRuleArgs']] server_side_encryption_rule: A configuration of server-side encryption (documented below).
        :param pulumi.Input[str] storage_class: Specifies the storage class that objects that conform to the rule are converted into. The storage class of the objects in a bucket of the IA storage class can be converted into Archive but cannot be converted into Standard. Values: `IA`, `Archive`.
        :param pulumi.Input[Mapping[str, Any]] tags: A mapping of tags to assign to the bucket. The items are no more than 10 for a bucket.
        :param pulumi.Input[pulumi.InputType['BucketVersioningArgs']] versioning: A state of versioning (documented below).
        :param pulumi.Input[pulumi.InputType['BucketWebsiteArgs']] website: A website object(documented below).
        """
        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__['acl'] = acl
            __props__['bucket'] = bucket
            __props__['cors_rules'] = cors_rules
            __props__['force_destroy'] = force_destroy
            __props__['lifecycle_rules'] = lifecycle_rules
            __props__['logging'] = logging
            if logging_isenable is not None:
                warnings.warn("Deprecated from 1.37.0. When `logging` is set, the bucket logging will be able.", DeprecationWarning)
                pulumi.log.warn("logging_isenable is deprecated: Deprecated from 1.37.0. When `logging` is set, the bucket logging will be able.")
            __props__['logging_isenable'] = logging_isenable
            __props__['policy'] = policy
            __props__['redundancy_type'] = redundancy_type
            __props__['referer_config'] = referer_config
            __props__['server_side_encryption_rule'] = server_side_encryption_rule
            __props__['storage_class'] = storage_class
            __props__['tags'] = tags
            __props__['versioning'] = versioning
            __props__['website'] = website
            __props__['creation_date'] = None
            __props__['extranet_endpoint'] = None
            __props__['intranet_endpoint'] = None
            __props__['location'] = None
            __props__['owner'] = None
        super(Bucket, __self__).__init__(
            'alicloud:oss/bucket:Bucket',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            acl: Optional[pulumi.Input[str]] = None,
            bucket: Optional[pulumi.Input[str]] = None,
            cors_rules: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketCorsRuleArgs']]]]] = None,
            creation_date: Optional[pulumi.Input[str]] = None,
            extranet_endpoint: Optional[pulumi.Input[str]] = None,
            force_destroy: Optional[pulumi.Input[bool]] = None,
            intranet_endpoint: Optional[pulumi.Input[str]] = None,
            lifecycle_rules: Optional[pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketLifecycleRuleArgs']]]]] = None,
            location: Optional[pulumi.Input[str]] = None,
            logging: Optional[pulumi.Input[pulumi.InputType['BucketLoggingArgs']]] = None,
            logging_isenable: Optional[pulumi.Input[bool]] = None,
            owner: Optional[pulumi.Input[str]] = None,
            policy: Optional[pulumi.Input[str]] = None,
            redundancy_type: Optional[pulumi.Input[str]] = None,
            referer_config: Optional[pulumi.Input[pulumi.InputType['BucketRefererConfigArgs']]] = None,
            server_side_encryption_rule: Optional[pulumi.Input[pulumi.InputType['BucketServerSideEncryptionRuleArgs']]] = None,
            storage_class: Optional[pulumi.Input[str]] = None,
            tags: Optional[pulumi.Input[Mapping[str, Any]]] = None,
            versioning: Optional[pulumi.Input[pulumi.InputType['BucketVersioningArgs']]] = None,
            website: Optional[pulumi.Input[pulumi.InputType['BucketWebsiteArgs']]] = None) -> 'Bucket':
        """
        Get an existing Bucket 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] acl: The [canned ACL](https://www.alibabacloud.com/help/doc-detail/31898.htm) to apply. Can be "private", "public-read" and "public-read-write". Defaults to "private".
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketCorsRuleArgs']]]] cors_rules: A rule of [Cross-Origin Resource Sharing](https://www.alibabacloud.com/help/doc-detail/31903.htm) (documented below). The items of core rule are no more than 10 for every OSS bucket.
        :param pulumi.Input[str] creation_date: The creation date of the bucket.
        :param pulumi.Input[str] extranet_endpoint: The extranet access endpoint of the bucket.
        :param pulumi.Input[bool] force_destroy: A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. Defaults to "false".
        :param pulumi.Input[str] intranet_endpoint: The intranet access endpoint of the bucket.
        :param pulumi.Input[List[pulumi.Input[pulumi.InputType['BucketLifecycleRuleArgs']]]] lifecycle_rules: A configuration of [object lifecycle management](https://www.alibabacloud.com/help/doc-detail/31904.htm) (documented below).
        :param pulumi.Input[str] location: The location of the bucket.
        :param pulumi.Input[pulumi.InputType['BucketLoggingArgs']] logging: A Settings of [bucket logging](https://www.alibabacloud.com/help/doc-detail/31900.htm) (documented below).
        :param pulumi.Input[bool] logging_isenable: The flag of using logging enable container. Defaults true.
        :param pulumi.Input[str] owner: The bucket owner.
        :param pulumi.Input[str] policy: Json format text of bucket policy [bucket policy management](https://www.alibabacloud.com/help/doc-detail/100680.htm).
        :param pulumi.Input[str] redundancy_type: The [redundancy type](https://www.alibabacloud.com/help/doc-detail/90589.htm) to enable. Can be "LRS", and "ZRS". Defaults to "LRS".
        :param pulumi.Input[pulumi.InputType['BucketRefererConfigArgs']] referer_config: The configuration of [referer](https://www.alibabacloud.com/help/doc-detail/31901.htm) (documented below).
        :param pulumi.Input[pulumi.InputType['BucketServerSideEncryptionRuleArgs']] server_side_encryption_rule: A configuration of server-side encryption (documented below).
        :param pulumi.Input[str] storage_class: Specifies the storage class that objects that conform to the rule are converted into. The storage class of the objects in a bucket of the IA storage class can be converted into Archive but cannot be converted into Standard. Values: `IA`, `Archive`.
        :param pulumi.Input[Mapping[str, Any]] tags: A mapping of tags to assign to the bucket. The items are no more than 10 for a bucket.
        :param pulumi.Input[pulumi.InputType['BucketVersioningArgs']] versioning: A state of versioning (documented below).
        :param pulumi.Input[pulumi.InputType['BucketWebsiteArgs']] website: A website object(documented below).
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["acl"] = acl
        __props__["bucket"] = bucket
        __props__["cors_rules"] = cors_rules
        __props__["creation_date"] = creation_date
        __props__["extranet_endpoint"] = extranet_endpoint
        __props__["force_destroy"] = force_destroy
        __props__["intranet_endpoint"] = intranet_endpoint
        __props__["lifecycle_rules"] = lifecycle_rules
        __props__["location"] = location
        __props__["logging"] = logging
        __props__["logging_isenable"] = logging_isenable
        __props__["owner"] = owner
        __props__["policy"] = policy
        __props__["redundancy_type"] = redundancy_type
        __props__["referer_config"] = referer_config
        __props__["server_side_encryption_rule"] = server_side_encryption_rule
        __props__["storage_class"] = storage_class
        __props__["tags"] = tags
        __props__["versioning"] = versioning
        __props__["website"] = website
        return Bucket(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def acl(self) -> pulumi.Output[Optional[str]]:
        """
        The [canned ACL](https://www.alibabacloud.com/help/doc-detail/31898.htm) to apply. Can be "private", "public-read" and "public-read-write". Defaults to "private".
        """
        return pulumi.get(self, "acl")

    @property
    @pulumi.getter
    def bucket(self) -> pulumi.Output[Optional[str]]:
        return pulumi.get(self, "bucket")

    @property
    @pulumi.getter(name="corsRules")
    def cors_rules(self) -> pulumi.Output[Optional[List['outputs.BucketCorsRule']]]:
        """
        A rule of [Cross-Origin Resource Sharing](https://www.alibabacloud.com/help/doc-detail/31903.htm) (documented below). The items of core rule are no more than 10 for every OSS bucket.
        """
        return pulumi.get(self, "cors_rules")

    @property
    @pulumi.getter(name="creationDate")
    def creation_date(self) -> pulumi.Output[str]:
        """
        The creation date of the bucket.
        """
        return pulumi.get(self, "creation_date")

    @property
    @pulumi.getter(name="extranetEndpoint")
    def extranet_endpoint(self) -> pulumi.Output[str]:
        """
        The extranet access endpoint of the bucket.
        """
        return pulumi.get(self, "extranet_endpoint")

    @property
    @pulumi.getter(name="forceDestroy")
    def force_destroy(self) -> pulumi.Output[Optional[bool]]:
        """
        A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. Defaults to "false".
        """
        return pulumi.get(self, "force_destroy")

    @property
    @pulumi.getter(name="intranetEndpoint")
    def intranet_endpoint(self) -> pulumi.Output[str]:
        """
        The intranet access endpoint of the bucket.
        """
        return pulumi.get(self, "intranet_endpoint")

    @property
    @pulumi.getter(name="lifecycleRules")
    def lifecycle_rules(self) -> pulumi.Output[Optional[List['outputs.BucketLifecycleRule']]]:
        """
        A configuration of [object lifecycle management](https://www.alibabacloud.com/help/doc-detail/31904.htm) (documented below).
        """
        return pulumi.get(self, "lifecycle_rules")

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

    @property
    @pulumi.getter
    def logging(self) -> pulumi.Output[Optional['outputs.BucketLogging']]:
        """
        A Settings of [bucket logging](https://www.alibabacloud.com/help/doc-detail/31900.htm) (documented below).
        """
        return pulumi.get(self, "logging")

    @property
    @pulumi.getter(name="loggingIsenable")
    def logging_isenable(self) -> pulumi.Output[Optional[bool]]:
        """
        The flag of using logging enable container. Defaults true.
        """
        return pulumi.get(self, "logging_isenable")

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

    @property
    @pulumi.getter
    def policy(self) -> pulumi.Output[Optional[str]]:
        """
        Json format text of bucket policy [bucket policy management](https://www.alibabacloud.com/help/doc-detail/100680.htm).
        """
        return pulumi.get(self, "policy")

    @property
    @pulumi.getter(name="redundancyType")
    def redundancy_type(self) -> pulumi.Output[Optional[str]]:
        """
        The [redundancy type](https://www.alibabacloud.com/help/doc-detail/90589.htm) to enable. Can be "LRS", and "ZRS". Defaults to "LRS".
        """
        return pulumi.get(self, "redundancy_type")

    @property
    @pulumi.getter(name="refererConfig")
    def referer_config(self) -> pulumi.Output[Optional['outputs.BucketRefererConfig']]:
        """
        The configuration of [referer](https://www.alibabacloud.com/help/doc-detail/31901.htm) (documented below).
        """
        return pulumi.get(self, "referer_config")

    @property
    @pulumi.getter(name="serverSideEncryptionRule")
    def server_side_encryption_rule(self) -> pulumi.Output[Optional['outputs.BucketServerSideEncryptionRule']]:
        """
        A configuration of server-side encryption (documented below).
        """
        return pulumi.get(self, "server_side_encryption_rule")

    @property
    @pulumi.getter(name="storageClass")
    def storage_class(self) -> pulumi.Output[Optional[str]]:
        """
        Specifies the storage class that objects that conform to the rule are converted into. The storage class of the objects in a bucket of the IA storage class can be converted into Archive but cannot be converted into Standard. Values: `IA`, `Archive`.
        """
        return pulumi.get(self, "storage_class")

    @property
    @pulumi.getter
    def tags(self) -> pulumi.Output[Optional[Mapping[str, Any]]]:
        """
        A mapping of tags to assign to the bucket. The items are no more than 10 for a bucket.
        """
        return pulumi.get(self, "tags")

    @property
    @pulumi.getter
    def versioning(self) -> pulumi.Output[Optional['outputs.BucketVersioning']]:
        """
        A state of versioning (documented below).
        """
        return pulumi.get(self, "versioning")

    @property
    @pulumi.getter
    def website(self) -> pulumi.Output[Optional['outputs.BucketWebsite']]:
        """
        A website object(documented below).
        """
        return pulumi.get(self, "website")

    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

