Aliyun.Oss.Bucket.Website (aliyun_oss v2.0.0)

Bucket operations - Static websites.

Link to this section Summary

Functions

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

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

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

Link to this section Types

@type error() ::
  %Aliyun.Oss.Client.Error{
    body: String.t(),
    parsed_details: map(),
    status_code: integer()
  }
  | atom()

Link to this section Functions

Link to this function

delete(config, bucket)

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

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

examples

Examples

iex> Aliyun.Oss.Bucket.Website.delete("some-bucket")
{:ok,
%Aliyun.Oss.Client.Response{
  data: "",
  headers: [
    {"Server", "AliyunOSS"},
    {"Date", "Fri, 11 Jan 2019 05:19:45 GMT"},
    {"Content-Length", "0"},
    {"Connection", "keep-alive"},
    {"x-oss-request-id", "5C3000000000000000000000"},
    {"x-oss-server-time", "90"}
  ]
}}
iex> Aliyun.Oss.Bucket.Website.delete("unknown-bucket")
{:error,
%Aliyun.Oss.Client.Error{
  parsed_details: %{
    "BucketName" => "unknown-bucket",
    "Code" => "NoSuchBucket",
    "HostId" => "unknown-bucket.oss-cn-shenzhen.aliyuncs.com",
    "Message" => "The specified bucket does not exist.",
    "RequestId" => "5C38283EC84D1C4471F2F48A"
  },
  body: "<?xml version="1.0" encoding="UTF-8"?>...</xml>",
  status_code: 404
}}
Link to this function

get(config, bucket)

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

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

examples

Examples

iex> Aliyun.Oss.Bucket.Website.get("some-bucket")
{:ok, %Aliyun.Oss.Client.Response{
  data: %{
    "WebsiteConfiguration" => %{"IndexDocument" => %{"Suffix" => "index.html"}}
  },
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}

iex> Aliyun.Oss.Bucket.Website.get("unkown-bucket")
{:error,
  %Aliyun.Oss.Client.Error{
    status_code: 404,
    parsed_details: %{
      "BucketName" => "unkown-bucket",
      "Code" => "NoSuchBucket",
      "HostId" => "unkown-bucket.oss-cn-shenzhen.aliyuncs.com",
      "Message" => "The specified bucket does not exist.",
      "RequestId" => "5C0000000000000000000000"
    },
    body: "<?xml version="1.0" encoding="UTF-8"?>...</xml>"
  }
}
Link to this function

put(config, bucket, xml_body)

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

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

examples

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("some-bucket", xml_body)
{:ok,
%Aliyun.Oss.Client.Response{
  data: "",
  headers: [
    {"Server", "AliyunOSS"},
    {"Date", "Fri, 11 Jan 2019 05:05:50 GMT"},
    {"Content-Length", "0"},
    {"Connection", "keep-alive"},
    {"x-oss-request-id", "5C0000000000000000000000"},
    {"x-oss-server-time", "63"}
  ]
}}