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

Bucket operations - Replication.

Link to this section Summary

Functions

DeleteBucketReplication - disables data replication for a bucket and delete the data replication rule configured for the bucket.

GetBucketReplication - gets cross-region replication (CRR) rules configured for a bucket.

GetBucketReplicationLocation - gets the region in which the destination bucket can be located.

GetBucketReplicationProgress - gets the progress of a data replication task configured for a bucket.

PutBucketReplication - configures data replication rules for a bucket.

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, rule_id)

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

DeleteBucketReplication - disables data replication for a bucket and delete the data replication rule configured for the bucket.

examples

Examples

iex> Aliyun.Oss.Bucket.Replication.delete("some-bucket", "rule1")
{: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"}
  ]
}}
Link to this function

get(config, bucket)

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

GetBucketReplication - gets cross-region replication (CRR) rules configured for a bucket.

examples

Examples

iex> Aliyun.Oss.Bucket.Replication.get("some-bucket")
{:ok, %Aliyun.Oss.Client.Response{
  data: %{
    "ReplicationConfiguration" => %{
      "Rule" => %{
        "Action" => "ALL",
        "Destination" => %{
          "Bucket" => "replication-test",
          "Location" => "oss-cn-beijing"
        },
        "HistoricalObjectReplication" => "disabled",
        "ID" => "test_replication_1",
        "Status" => "starting"
      }
    }
  },
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}
Link to this function

get_location(config, bucket)

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

GetBucketReplicationLocation - gets the region in which the destination bucket can be located.

examples

Examples

iex> Aliyun.Oss.Bucket.Replication.get_location("some-bucket")
{:ok, %Aliyun.Oss.Client.Response{
  data: %{
    "ReplicationLocation" => %{
      "Location" => ["oss-ap-northeast-1", "oss-ap-south-1",
        "oss-ap-southeast-1", "oss-ap-southeast-2", "oss-ap-southeast-3",
        "oss-ap-southeast-5", "oss-cn-beijing", "oss-cn-chengdu",
        "oss-cn-guangzhou", "oss-cn-hangzhou", "oss-cn-heyuan",
        "oss-cn-hongkong", "oss-cn-huhehaote", "oss-cn-qingdao",
        "oss-cn-shanghai", "oss-cn-wulanchabu", "oss-cn-zhangjiakou",
        "oss-eu-central-1", "oss-eu-west-1", "oss-me-east-1", "oss-rus-west-1",
        "oss-us-east-1", "oss-us-west-1"],
      "LocationTransferTypeConstraint" => %{
        "LocationTransferType" => [
          %{
            "Location" => "oss-cn-hongkong",
            "TransferTypes" => %{"Type" => "oss_acc"}
          },
          # ...
        ]
      }
    }
  },
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}
Link to this function

get_progress(config, bucket, rule_id)

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

GetBucketReplicationProgress - gets the progress of a data replication task configured for a bucket.

examples

Examples

iex> Aliyun.Oss.Bucket.Replication.get_progress("some-bucket", "replication_rule_id_1")
{:ok, %Aliyun.Oss.Client.Response{
  data: %{
    "ReplicationProgress" => %{
      "Rule" => %{
        "Action" => "ALL",
        "Destination" => %{
          "Bucket" => "replication-test",
          "Location" => "oss-cn-beijing"
        },
        "HistoricalObjectReplication" => "disabled",
        "ID" => "replication_rule_id_1",
        "Progress" => %{"NewObject" => "2021-01-19T05:53:07.000Z"},
        "Status" => "doing"
      }
    }
  },
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}
Link to this function

put(config, bucket, config)

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

PutBucketReplication - configures data replication rules for a bucket.

examples

Examples

iex> config_json = %{
  "ReplicationConfiguration" => %{
    "Rule" => %{
      "Action" => "ALL",
      "Destination" => %{
        "Bucket" => "replication-test",
        "Location" => "oss-cn-beijing",
        "TransferType" => "internal"
      },
      "HistoricalObjectReplication" => "disabled"
    }
  }
}
iex> Aliyun.Oss.Bucket.Replication.put("some-bucket", config_json)
{:ok, %Aliyun.Oss.Client.Response{
  data: "",
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}
iex> config_xml = ~S[
  <?xml version="1.0" encoding="UTF-8"?>
  <ReplicationConfiguration>
    <Rule>
      <Action>ALL</Action>
      <Destination>
          <Bucket>replication-test</Bucket>
          <Location>oss-cn-beijing</Location>
          <TransferType>internal</TransferType>
      </Destination>
      <HistoricalObjectReplication>disabled</HistoricalObjectReplication>
    </Rule>
  </ReplicationConfiguration>
]
iex> Aliyun.Oss.Bucket.Inventory.put("some-bucket", "inventory_id", config_xml)
{:ok, %Aliyun.Oss.Client.Response{
  data: "",
  headers: [
    {"Date", "Wed, 05 Dec 2018 02:34:57 GMT"},
    ...
  ]
}}