View Source SCF - Tencent Cloud SCF Elixir SDK
Use signature v3 and
POST
only.
installation
Installation
The package can be installed by adding tencent_cloud_scf
to your list of dependencies in mix.exs
:
def deps do
[
{:tencent_cloud_scf, "~> 0.1.0"}
]
end
configuration
Configuration
config :tencent_cloud_scf,
secret_id: "secret_id",
secret_key: "secret_key",
region: "your-region",
# Optional
http_client: [adapter: Tesla.Hackney],
language: "your-language",
api_host: "your-api_host"
request-api
Request API
Take this api ListFunctions as an example. There are 3 ways to request it.
1-shortcut-functions
1. shortcut functions
There are 3 shortcut functions:
SCF.API.Function.list_functions/0
- with default common parameters.SCF.API.Function.list_functions/1
- with default common parameters and body parameters.SCF.API.Function.list_functions/2
- with default common parameters & body parameters & http client options.
If the api has required parameters other than the common parameters, the shortcut function with
/0
is invalid.
2-scf-http-auth_post-parameters-opts
2. SCF.HTTP.auth_post(parameters, opts \\ [])
Build the parameters by referring the document. opts
is http client options.
# don't add "X-TC-" prefix to common parameters
params = %{"Action" => "ListFunctions"}
SCF.HTTP.auth_post(params)
3-scf-http-request-parameters-headers-opts-not-recommended
3. SCF.HTTP.request(parameters, headers, opts)
(not recommended)
Build parameters and headers manually.
headers = [{"X-TC-Action", "ListFunctions"}]
SCF.HTTP.request(%{}, headers, [])