Ruby SDK 示例

安装 SDK

Ruby SDK 使用说明:https://github.com/aliyun/openapi-core-ruby-sdk/blob/master/README-CN.md?spm=a2c1g.8271268.10000.179.5f4ddf25O8YAn9&file=README-CN.md

调用 Codeup API

以 CreateRepository 为例:

# gem install aliyunsdkcore

require 'aliyunsdkcore'

client = ROAClient.new(
  access_key_id: '<accessKeyId>',
  access_key_secret: '<accessSecret>',
  endpoint: 'https://codeup.cn-hangzhou.aliyuncs.com',
  api_version: '2020-04-14'
)

response = client.request(
  method: 'POST',
  uri: '/api/v3/projects',
  queries: {
    "RegionId": "cn-hangzhou",
    "OrganizationId": "<OrganizationId>"
  },
  headers: {
    "Content-Type": "application/json"
  },
  body: `{
    "name": "<RepoName>",
    "path": "<RepoPath>",
    "visibility_level": 10,
    "namespace_id": 123
  }`,
  options: {}
)

print response