# `Aliyun.Oss.Bucket.Website`

Bucket operations - Static websites.

# `delete`

```elixir
@spec delete(Aliyun.Oss.Config.t(), String.t()) ::
  {:error, Exception.t()} | {:ok, Aliyun.Oss.Client.Response.t()}
```

DeleteBucketWebsite - disables the static website hosting mode and clears the redirection rules for a bucket.

## Examples

    iex> Aliyun.Oss.Bucket.Website.delete(config, "some-bucket")
    {:ok,
    %Aliyun.Oss.Client.Response{
      data: "",
      headers: %{
        "connection" => ["keep-alive"],
        "content-length" => ["0"],
        "date" => ["Wed, 09 Jul 2025 02:58:10 GMT"],
        "server" => ["AliyunOSS"],
        "x-oss-request-id" => ["686DDAC222DB************"],
        "x-oss-server-time" => ["38"]
      }
    }}
    iex> Aliyun.Oss.Bucket.Website.delete(config, "unknown-bucket")
    {:error,
    %Aliyun.Oss.Client.Error{
      status: 404,
      code: "NoSuchBucket",
      message: "The specified bucket does not exist.",
      details: %{
        "BucketName" => "unknown-bucket",
        "Code" => "NoSuchBucket",
        "EC" => "0015-00000101",
        "HostId" => "unknown-bucket.oss-cn-shenzhen.aliyuncs.com",
        "Message" => "The specified bucket does not exist.",
        "RecommendDoc" => "https://api.aliyun.com/troubleshoot?q=0015-00000101",
        "RequestId" => "5C38283EC84D1C4471F2F48A"
      }
    }}

# `get`

```elixir
@spec get(Aliyun.Oss.Config.t(), String.t()) ::
  {:error, Exception.t()} | {:ok, Aliyun.Oss.Client.Response.t()}
```

GetBucketWebsite - gets the static website hosting status and redirection rules configured for a bucket.

## Examples

    iex> Aliyun.Oss.Bucket.Website.get(config, "some-bucket")
    {:ok, %Aliyun.Oss.Client.Response{
      data: %{
        "WebsiteConfiguration" => %{
          "ErrorDocument" => %{"HttpStatus" => "404", "Key" => "error.html"},
          "IndexDocument" => %{
            "Suffix" => "index.html",
            "SupportSubDir" => "true",
            "Type" => "0"
          }
        }
      },
      headers: %{
        "connection" => ["keep-alive"],
        ...
      }
    }}

    iex> Aliyun.Oss.Bucket.Website.get(config, "unkown-bucket")
    {:error,
      %Aliyun.Oss.Client.Error{
        status: 404,
        code: "NoSuchBucket",
        message: "The specified bucket does not exist.",
        details: %{
          "BucketName" => "unkown-bucket",
          "Code" => "NoSuchBucket",
          "EC" => "0015-00000101",
          "HostId" => "unkown-bucket.oss-cn-shenzhen.aliyuncs.com",
          "Message" => "The specified bucket does not exist.",
          "RecommendDoc" => "https://api.aliyun.com/troubleshoot?q=0015-00000101",
          "RequestId" => "5C0000000000000000000000"
        }
      }
    }

# `put`

```elixir
@spec put(Aliyun.Oss.Config.t(), String.t(), String.t()) ::
  {:error, Exception.t()} | {:ok, Aliyun.Oss.Client.Response.t()}
```

PutBucketWebsite - sets a bucket to the static website hosting mode and configures redirection rules.

## Examples

    iex> xml_body = """
    ...> <?xml version="1.0" encoding="UTF-8"?>
    ...> <WebsiteConfiguration>
    ...> <IndexDocument>
    ...>   <Suffix>index.html</Suffix>
    ...> </IndexDocument>
    ...> ...
    ...> ...
    ...> </WebsiteConfiguration>
    ...>  """
    iex> Aliyun.Oss.Bucket.Website.put(config, "some-bucket", xml_body)
    {:ok,
    %Aliyun.Oss.Client.Response{
      data: "",
      headers: %{
        "connection" => ["keep-alive"],
        "content-length" => ["0"],
        "date" => ["Wed, 09 Jul 2025 02:56:31 GMT"],
        "server" => ["AliyunOSS"],
        "x-oss-request-id" => ["686DDA5F22D*************"],
        "x-oss-server-time" => ["113"]
      }
    }}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
