Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Akito Ueno
committed
Jun 16, 2016
0 parents
commit ab587d0
Showing
66 changed files
with
2,200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/.env | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--format documentation | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.3 | ||
Exclude: | ||
- "Gemfile" | ||
- "*.gemspec" | ||
DisplayCopNames: true | ||
|
||
Documentation: | ||
Enabled: false | ||
|
||
Lint/AssignmentInCondition: | ||
Enabled: false | ||
|
||
Lint/HandleExceptions: | ||
Enabled: false | ||
|
||
Lint/UnderscorePrefixedVariableName: | ||
Enabled: false | ||
|
||
Lint/UnusedBlockArgument: | ||
Enabled: false | ||
|
||
Lint/UnusedMethodArgument: | ||
Enabled: false | ||
|
||
Metrics/AbcSize: | ||
Max: 20 | ||
|
||
Metrics/CyclomaticComplexity: | ||
Max: 6 | ||
|
||
Metrics/LineLength: | ||
Max: 100 | ||
|
||
Metrics/MethodLength: | ||
Max: 20 | ||
|
||
Metrics/PerceivedComplexity: | ||
Max: 7 | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
Style/AccessorMethodName: | ||
Enabled: false | ||
|
||
Style/AsciiComments: | ||
Enabled: false | ||
|
||
Style/Documentation: | ||
Enabled: false | ||
|
||
Style/DoubleNegation: | ||
Enabled: false | ||
|
||
Style/FormatString: | ||
EnforcedStyle: percent | ||
|
||
Style/GuardClause: | ||
MinBodyLength: 4 | ||
|
||
Style/IfUnlessModifier: | ||
Enabled: false | ||
|
||
Style/MultilineBlockChain: | ||
Enabled: false | ||
|
||
Style/NumericLiterals: | ||
MinDigits: 7 | ||
|
||
Style/PredicateName: | ||
NamePrefixBlacklist: | ||
- "is_" | ||
- "have_" | ||
|
||
Style/SignalException: | ||
EnforcedStyle: only_raise | ||
|
||
Style/SingleLineBlockParams: | ||
Enabled: false | ||
|
||
Style/SpaceAroundOperators: | ||
AllowForAlignment: true | ||
|
||
Style/SpaceBeforeComma: | ||
Enabled: false | ||
|
||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/TrailingCommaInLiteral: | ||
Enabled: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: ruby | ||
rvm: | ||
- 2.1 | ||
- 2.2 | ||
before_install: gem install bundler -v 1.11.2 | ||
env: | ||
global: | ||
- secure: "GYnbgGX4ELD31qLfeXmaVAcEZeLSXV4VmQPi7GHBSLckrEfUlc2jJrdwcYY0t4+kfL1HPHkCVb61u7/KizD3fbjo9B+RjIKDCzOnRt0qf4TMnieJDLLaWhGvEPQZpqSSX9skvqbY1eMipFn+PgN9CEFRqnnVANp8PxY3TxGh5zi0hTaxZIh918/FxH0gCiTQOGpkjInSadY8bI9tDlKAV8g+EDolAerWz7WDq3+d/GM/VhpQyprqQkd76cyQ2HkBEvngJYAm1RpsJfnSPuqE0rP6C82onV4kVoREI0l0Y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b44I=" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Contributor Code of Conduct | ||
|
||
As contributors and maintainers of this project, and in the interest of | ||
fostering an open and welcoming community, we pledge to respect all people who | ||
contribute through reporting issues, posting feature requests, updating | ||
documentation, submitting pull requests or patches, and other activities. | ||
|
||
We are committed to making participation in this project a harassment-free | ||
experience for everyone, regardless of level of experience, gender, gender | ||
identity and expression, sexual orientation, disability, personal appearance, | ||
body size, race, ethnicity, age, religion, or nationality. | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery | ||
* Personal attacks | ||
* Trolling or insulting/derogatory comments | ||
* Public or private harassment | ||
* Publishing other's private information, such as physical or electronic | ||
addresses, without explicit permission | ||
* Other unethical or unprofessional conduct | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
By adopting this Code of Conduct, project maintainers commit themselves to | ||
fairly and consistently applying these principles to every aspect of managing | ||
this project. Project maintainers who do not follow or enforce the Code of | ||
Conduct may be permanently removed from the project team. | ||
|
||
This code of conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting a project maintainer at kasugai@dropsystem.co.jp. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. Maintainers are | ||
obligated to maintain confidentiality with regard to the reporter of an | ||
incident. | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], | ||
version 1.3.0, available at | ||
[http://contributor-covenant.org/version/1/3/0/][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/3/0/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in idcf-ilb.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 IDC Frontier Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Idcf::Ilb | ||
[![Gem Version](https://badge.fury.io/rb/idcf-ilb.svg)](http://badge.fury.io/rb/idcf-ilb) | ||
[![Build Status](https://travis-ci.org/idcf/idcf-ilb-ruby.svg?branch=master)](https://travis-ci.org/idcf/idcf-ilb-ruby) | ||
[![Code Climate](https://codeclimate.com/github/idcf/idcf-ilb-ruby/badges/gpa.svg)](https://codeclimate.com/github/idcf/idcf-ilb-ruby) | ||
[![Test Coverage](https://codeclimate.com/github/idcf/idcf-ilb-ruby/badges/coverage.svg)](https://codeclimate.com/github/idcf/idcf-ilb-ruby/coverage) | ||
|
||
A Ruby client for [IDCF Cloud ILB service](https://console.jp-east.idcfcloud.com/ilb/). | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'idcf-ilb' | ||
``` | ||
|
||
And then execute: | ||
|
||
$ bundle | ||
|
||
Or install it yourself as: | ||
|
||
$ gem install idcf-ilb | ||
|
||
## Usage | ||
### Basic usage | ||
#### Client | ||
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](https://console.idcfcloud.com/user/apikey). | ||
|
||
```ruby | ||
require "idcf/ilb" | ||
|
||
client = | ||
Idcf::Ilb::Client.new( | ||
api_key: ENV["IDCF_API_KEY"], | ||
secret_key: ENV["IDCF_SECRET_KEY"] | ||
) | ||
|
||
# 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 | ||
``` | ||
|
||
#### Servers | ||
##### Add server | ||
```ruby | ||
# 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 | ||
``` | ||
|
||
##### Get servers | ||
```ruby | ||
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 | ||
``` | ||
|
||
##### Delete server | ||
```ruby | ||
# 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 | ||
``` | ||
|
||
## Contributing | ||
|
||
1. Fork it ( https://github.com/idcf/idcf-ilb-ruby/fork ) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "bundler/setup" | ||
require "idcf/ilb/ruby" | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
# (If you use this, don't forget to add pry to your Gemfile!) | ||
# require "pry" | ||
# Pry.start | ||
|
||
require "irb" | ||
IRB.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'idcf/ilb/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "idcf-ilb" | ||
spec.version = Idcf::Ilb::VERSION | ||
spec.authors = ["Akito Ueno"] | ||
spec.email = ["aueno@idcf.jp"] | ||
|
||
spec.summary = %q{A Ruby client for IDCF Cloud ILB Service.} | ||
spec.homepage = "http://www.idcf.jp/cloud/" | ||
|
||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
spec.bindir = "exe" | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_development_dependency "bundler", "~> 1.11" | ||
spec.add_development_dependency "codeclimate-test-reporter" | ||
spec.add_development_dependency "dotenv" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
spec.add_development_dependency "rspec", "~> 3.0" | ||
spec.add_development_dependency "simplecov" | ||
|
||
spec.add_dependency "activesupport", "~> 4.2.3" | ||
spec.add_dependency "faraday", "~> 0.9.1" | ||
spec.add_dependency "faraday_middleware", "~> 0.10.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "idcf/ilb/errors" | ||
|
||
# IDCF Cloud SDK | ||
module Idcf | ||
module Ilb | ||
autoload :Client , "idcf/ilb/client" | ||
autoload :ClientExtensions, "idcf/ilb/client_extensions" | ||
autoload :Request , "idcf/ilb/request" | ||
autoload :Resources , "idcf/ilb/resources" | ||
autoload :Response , "idcf/ilb/response" | ||
autoload :Validators , "idcf/ilb/validators" | ||
end | ||
end |
Oops, something went wrong.