A Ruby client for IDCF Cloud ILB service.
Note: requires Ruby 2.1.0 or higher.
Add this line to your application's Gemfile:
gem 'idcf-ilb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install idcf-ilb
You can create a instance of client by specifying API_KEY and SECRET_KEY.
You can get API_KEY and SECRET_KEY in IDCF Cloud.
You can also specify HOST. If you do not specify HOST, your client send request to "ilb.jp-east.idcfcloud.com".
require "idcf/ilb"
client =
Idcf::Ilb::Client.new(
api_key: ENV["IDCF_API_KEY"],
secret_key: ENV["IDCF_SECRET_KEY"],
host: ENV["IDCF_ILB_HOST"]
)
# Call GET request directly
# returns Response object
response = client.get("loadbalancers")
response.success? #=> true
response.status #=> 200
# Response#body returns HTTP response body as a hash or an array
response.body #=> [loadbalancer1, loadbalancer2, ...]
response.body[0] #=> loadbalancer1
# Response#[] is alias to Response#body[]
response[0] #=> loadbalancer1
# Get target config of loadbalancer
config = client.list_loadbalancers.body.first["configs"].first
# Specify of the adding target server IP address and port
adding_server =
{
ipaddress: "xxx.xxx.xxx.xxx",
port: 80
}
# Add server to config
response =
client.add_server(
config["loadbalancer_id"],
config["id"],
adding_server
)
response #=> server array
loadbalancer = client.loadbalancers.body.first # Get one of the loadbalancer
config = loadbalancer["configs"].first # Get one of the loadbalancer's config hash
response = client.list_servers(loadbalancer["id"], config["id"])
response #=> server array
# Get one of the loadbalancer's config hash
config = client.list_loadbalancers.body.first["configs"].first
# Specify of the deletion target server IP address and port
deletion_server = config["servers"].first
response =
client.delete_server(
config["loadbalancer_id"],
config["id"],
deletion_server["id"]
)
response #=> server array
- Fork it ( https://github.com/idcf/idcf-ilb-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