Aliyun openapi tools written in elixir
ExAliyun.OpenAPI supports aliyun openapis:
If available in Hex, the package can be installed
by adding ex_aliyun_openapi
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_aliyun_openapi, "~> 0.8"}
]
end
You should add configs for your services in this way.
config :ex_aliyun_openapi, type,
access_key_id: "YOUR CPS ACCESS KEY ID",
access_key_secret: "YOUR CPS ACCESS KEY SECRET"
type support [:cps, :sts, :sms, :global_sms, :afs, :codeup, :geoip]
You can find the api params in https://help.aliyun.com.
Then you can choose the service, and just put the params to it.
params = %{
"Action" => "AssumeRole",
"RoleArn" => "**YOUR RoleArn**",
"RoleSessionName" => "default",
"DurationSeconds" => 3600,
}
ExAliyun.OpenAPI.call_sts(params)
# or
ExAliyun.OpenAPI.call_sts(params, access_key_id: "ID", access_key_secret: "SECRET")
params = %{
"Action" => "PushNoticeToAndroid",
"AppKey" => "**YOUR AppKey**",
"Target" => "DEVICE",
"TargetValue" => "**YOUR device_id**",
"Title" => "TEST title",
"Body" => "Hello, this is the notice body"
}
ExAliyun.OpenAPI.call_cps(params)
# or
ExAliyun.OpenAPI.call_cps(params, access_key_id: "ID", access_key_secret: "SECRET")
ex_aliyun_openapi.ex
.