View Source AliyunOpenAPI.Specs.OSS (aliyun_open_api v0.6.0)
Describes an OSS style API.
Read more at:
- Object Storage Service > Developer Reference > Use the RESTful API to initiate requests
- Object Storage Service > Developer Reference > Use the RESTful API to initiate requests (zh-Hans)
About spec_opts
spec_opts
is a plain map for describing a RESTful API request.
Adding signature
This implementation has built-in V4 signature support, and it's controlled
by the :sign_type
option:
:header
- add signature to the headers of request.:url
- add signature to the url of request.
V1 signature is not supported.
Required headers
All necessary headers of requests will be generated automatically. You don't have to specifically set them, unless you want to customize it.
Examples
Send a request for ListBucktets
operation
alias AliyunOpenAPI.Config
alias AliyunOpenAPI.Specs.OSS
alias AliyunOpenAPI.HTTP.Request
alias AliyunOpenAPI.HTTP.Client
config =
Config.new!(
access_key_id: "...",
access_key_secret: "..."
)
OSS.new!(config,
sign_type: :header,
region: "oss-us-west-1",
endpoint: "https://oss-us-west-1.aliyuncs.com/",
method: :get,
path: "/"
)
|> Request.from_spec!()
|> Client.request()
Create a pre-signed url for GetObject
operation
alias AliyunOpenAPI.Config
alias AliyunOpenAPI.Specs.OSS
alias AliyunOpenAPI.HTTP.Request
config =
Config.new!(
access_key_id: "...",
access_key_secret: "..."
)
OSS.new!(config,
sign_type: :url,
region: "oss-us-west-1",
bucket: "example-bucket",
endpoint: "https://example-bucket.oss-us-west-1.aliyuncs.com/",
method: :get,
path: "/example-object",
headers: %{
"x-oss-expires" => 900
}
)
|> Request.from_spec!()
|> Request.url()
Summary
Types
The base url that the request is sent to.
Types
@type body() :: iodata() | nil
@type bucket() :: String.t() | nil
@type endpoint() :: String.t()
The base url that the request is sent to.
Following formats are supported:
- region URL, such as
https://oss-us-west-1.aliyuncs.com
. - virtual-hosted style URL, such as
https://example-bucket.oss-us-west-1.aliyuncs.com
. - custom domain name, such as
https://www.example.com
. - ...
@type method() :: String.t()
@type path() :: String.t()
@type region() :: String.t()
@type sign_type() :: :header | :url
@type spec_opts() :: [spec_opt()]
Functions
@spec new!(AliyunOpenAPI.Config.t(), spec_opts()) :: t()