Notice: This repository is no longer maintained, please use yunify/qingcloud-sdk-ruby instead.
SDK for QingCloud
$ gem install qingcloud-sdk
Add this line to your application's Gemfile:
gem 'qingcloud-sdk'
or
gem 'qingcloud-sdk', git: 'https://github.com/prettyxw/qingcloud-sdk-ruby'
And then execute:
$ bundle install
Get Code from Github:
$ git clone [email protected]:prettyxw/qingcloud-sdk-ruby.git
Build and Install with Bundle:
$ cd qingcloud-sdk-ruby
$ bundle install
$ bundle exec rake install
Using gem to remove this package:
$ gem uninstall qingcloud-sdk
- All QingCloud API actions are available now.
- API action name is mapped to ruby method.
- API parameter name is mapped to ruby method parameter.
- API optional parameter can be ignored when call ruby method.
Example:
Action: "DescribeInstances" -> "describe_instances"
Parameter: "zone" -> "zone"
Array Parameter: "instances.n" -> "instances_N"
Array Parameter: "statics.n.static_type" -> "statics_N_static_type"
Before your start, please go to QingCloud Console to create a pair of QingCloud API keys.
require 'qingcloud/sdk'
# Create Connection and Service
connector = QingCloud::SDK::IaaS::Connector.init 'qy_access_key_id',
'qy_secret_access_key'
service = QingCloud::SDK::IaaS::Service.new connector
# Describe Instances
service.describe_instances zone: 'ap1'
puts service.response
# Run Instances
service.run_instances image_id: 'centos7x64b',
cpu: 1,
memory: 1024,
login_mode: 'keypair',
login_keypair: 'keypair-id',
zone: 'ap1'
puts service.response
# Terminate Instances
service.describe_instances instances_N: ['instance-id'], zone: 'ap1'
puts service.response
- Fork it ( https://github.com/prettyxw/qingcloud-sdk-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
The MIT License.