Essentially aliyun-openapi is DSL definition + code generator. It generate the code based on openapi-meta JSON files.
Before everything, make sure you run rake codegen:generate_code to build generated code and test!
You need to configure the openapi before using it.
Aliyun::Openapi.configure do |config|
config.ssl_required = true
config.access_key_id = YOU_KEY_ID
config.access_key_secret = YOUR_KEY_SECRET
config.region = 'cn-hangzhou'
endrequire necessary lib files
require 'aliyun/openapi/all'if you want to call particular product, just go with
require 'aliyun/openapi/ecs'Here is the example:
Aliyun::Openapi::Client.ecs(version:'2014-05-26').describe_regions do |response|
p response
endThe basic calling name convention is :
Aliyun::Openapi::Client.[product](version: [version]).[api_end_point]([param_key]: [param_value] ...) do |resposne|
# response is a Faraday response object
end