conoha_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.md +8 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/conoha_api.gemspec +26 -0
- data/example/example.rb +26 -0
- data/lib/conoha_api/authentication.rb +28 -0
- data/lib/conoha_api/client/account.rb +0 -0
- data/lib/conoha_api/client/block_strage.rb +0 -0
- data/lib/conoha_api/client/compute.rb +172 -0
- data/lib/conoha_api/client/database_hosting.rb +0 -0
- data/lib/conoha_api/client/dns.rb +0 -0
- data/lib/conoha_api/client/identity.rb +25 -0
- data/lib/conoha_api/client/image.rb +0 -0
- data/lib/conoha_api/client/mail_hosting.rb +0 -0
- data/lib/conoha_api/client/network.rb +0 -0
- data/lib/conoha_api/client/object_strage.rb +0 -0
- data/lib/conoha_api/client.rb +53 -0
- data/lib/conoha_api/configurable.rb +37 -0
- data/lib/conoha_api/connection.rb +72 -0
- data/lib/conoha_api/error.rb +0 -0
- data/lib/conoha_api/version.rb +3 -0
- data/lib/conoha_api.rb +2 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f942d877c96caa81b3bbe32683d6caaba1256621
|
4
|
+
data.tar.gz: 1494b7cfc327806d6997596e0dc78da671387b06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fe2445b1442de779a383519811534d0e2fc40578f758173d89966f3e1651ede36755d93dd30b90824fdb91ec395cfe9f8f0f83909f0729eb8c361699499c902a
|
7
|
+
data.tar.gz: 3873bc2b99a8225507e85aa56f8a442011dc080c79b36e0d70908e7dcd709b668686e557137b9bba4d4beda56de4fbc8895b690ad46a7679bf5e078f78c90cf4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
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, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2015 Yasuhiro.Kinoshita
|
3
|
+
|
4
|
+
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:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
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.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# ConoHaAPI
|
2
|
+
|
3
|
+
ConoHaAPI is api client for ConoHa
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'conoha_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install conoha_api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
see example/example.rb
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/conoha_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
ConoHaAPI is released under the [MIT License](http://www.opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
data/conoha_api.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'conoha_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "conoha_api"
|
8
|
+
spec.version = ConohaApi::VERSION
|
9
|
+
spec.authors = ["Kinoshita.Yasuhiro"]
|
10
|
+
spec.email = ["WhoIsDissolvedGirl+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ConoHa API Client}
|
13
|
+
spec.description = %q{ConoHa API Client}
|
14
|
+
spec.homepage = "https://github.com/kinoppyd/conoha-api"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "sawyer", "~> 0.6"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
data/example/example.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'conoha_api'
|
2
|
+
|
3
|
+
client = ConohaApi::Client.new(
|
4
|
+
login: '',
|
5
|
+
password: '',
|
6
|
+
tenant_id: '',
|
7
|
+
api_endpoint: 'https://identity.tyo1.conoha.io/v2.0'
|
8
|
+
)
|
9
|
+
|
10
|
+
# gather infomations to create server
|
11
|
+
key = client.keypairs.keypairs.first
|
12
|
+
flavor = client.flavors.flavors.first
|
13
|
+
image = client.images.images.first
|
14
|
+
|
15
|
+
# create new server
|
16
|
+
puts client.add_server(image.id, flavor.id, key_name: key.keypair.name)
|
17
|
+
|
18
|
+
# force stop all servers
|
19
|
+
client.servers.servers.each do |server|
|
20
|
+
puts client.force_stop_server(server.id)
|
21
|
+
end
|
22
|
+
|
23
|
+
# delete all servers
|
24
|
+
client.servers.servers.each do |server|
|
25
|
+
puts client.delete_server(server.id)
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'conoha_api/connection'
|
3
|
+
|
4
|
+
module ConohaApi
|
5
|
+
module Authentication
|
6
|
+
attr_reader :token_expire_time
|
7
|
+
|
8
|
+
def ready_for_authentication?
|
9
|
+
!! (@login && @password)
|
10
|
+
end
|
11
|
+
|
12
|
+
def token_expired?
|
13
|
+
return true unless token_expire_time
|
14
|
+
token_expire_time < Time.now
|
15
|
+
end
|
16
|
+
|
17
|
+
def token_expires(expire_time)
|
18
|
+
@token_expire_time = case expire_time
|
19
|
+
when String
|
20
|
+
Time.iso8601(expire_time)
|
21
|
+
when Date
|
22
|
+
expire_time
|
23
|
+
else
|
24
|
+
raise
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'conoha_api/client/base'
|
2
|
+
|
3
|
+
module ConohaApi
|
4
|
+
class Client
|
5
|
+
module Compute
|
6
|
+
SERVICE = 'compute'
|
7
|
+
|
8
|
+
def flavors
|
9
|
+
get "flavors"
|
10
|
+
end
|
11
|
+
|
12
|
+
def flavors_detail
|
13
|
+
get "flavors/detail"
|
14
|
+
end
|
15
|
+
|
16
|
+
def flavor(id)
|
17
|
+
get "flavors/#{id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def servers
|
21
|
+
get "servers"
|
22
|
+
end
|
23
|
+
|
24
|
+
def servers_detail
|
25
|
+
get "servers/detail"
|
26
|
+
end
|
27
|
+
|
28
|
+
def server(id)
|
29
|
+
get "servers/#{id}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_server(image_ref, flavor_ref, options = {})
|
33
|
+
request_json = {
|
34
|
+
server: {
|
35
|
+
imageRef: image_ref,
|
36
|
+
flavorRef: flavor_ref
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
request_json[:server][:adminPass] = options[:admin_pass] if options[:admin_pass]
|
41
|
+
request_json[:server][:keyName] = options[:key_name] if options[:key_name]
|
42
|
+
post "servers", request_json, options
|
43
|
+
end
|
44
|
+
|
45
|
+
def delete_server(id)
|
46
|
+
delete "servers/#{id}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_server(id)
|
50
|
+
action(id, :"os-start" => nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def reboot_server(id, type = 'SOFT')
|
54
|
+
raise ArgumentError.new("#{type} is not valid") unless ['SOFT', 'HARD'].include?(type.upcase)
|
55
|
+
action(id, reboot: { type: type.upcase })
|
56
|
+
end
|
57
|
+
|
58
|
+
def force_stop_server(id, force = true)
|
59
|
+
action(id, :"os-stop" => { force_shutdown: force })
|
60
|
+
end
|
61
|
+
|
62
|
+
def stop_server(id)
|
63
|
+
action(id, :"os-stop" => nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
def rebuild_server(id, image_ref, options = {})
|
67
|
+
request_json = {
|
68
|
+
rebuild: {
|
69
|
+
imageRef: image_ref
|
70
|
+
}
|
71
|
+
}
|
72
|
+
request_json[:rebuild][:adminPass] = options[:admin_pass] if options[:admin_pass]
|
73
|
+
request_json[:rebuild][:keyName] = options[:key_name] if options[:key_name]
|
74
|
+
action(id, request_json)
|
75
|
+
end
|
76
|
+
|
77
|
+
def resize(id, flavor_ref)
|
78
|
+
action(id, resize: { flavorRef: flavor_ref })
|
79
|
+
end
|
80
|
+
|
81
|
+
def confirm_resize(id)
|
82
|
+
action(id, confirmResize: nil)
|
83
|
+
end
|
84
|
+
|
85
|
+
def revert_resize(id)
|
86
|
+
action(id, revertResize: nil)
|
87
|
+
end
|
88
|
+
|
89
|
+
def vnc(id)
|
90
|
+
action(id, :"os-getVNCConsole" => { type: :novnc })
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_image(id, name)
|
94
|
+
action(id, createImage: { name: name })
|
95
|
+
end
|
96
|
+
|
97
|
+
def change_strage_controller(id, hardware_disk_bus)
|
98
|
+
raise ArgumentError.new("#{hardware_disk_bus} is not valid") unless ['virtio', 'scsi', 'ide'].include?(hardware_disk_bus)
|
99
|
+
action(id, hwDiskBus: hardware_disk_bus)
|
100
|
+
end
|
101
|
+
|
102
|
+
def change_network_adapter(id, hardware_virtualinterface_model)
|
103
|
+
raise ArgumentError.new("#{hardware_virtualinterface_model} is not valid") unless ['e1000', 'virtio', 'rtl8139'].include?(hardware_virtualinterface_model)
|
104
|
+
action(id, hwVifModel: hardware_virtualinterface_model)
|
105
|
+
end
|
106
|
+
|
107
|
+
def change_video_device(id, hardware_video_model)
|
108
|
+
raise ArgumentError.new("#{hardware_video_model} is not valid") unless ['qxl', 'vga', 'cirrus'].include?(hardware_video_model)
|
109
|
+
action(id, hwVideoModel: hardware_video_model)
|
110
|
+
end
|
111
|
+
|
112
|
+
def change_console_keymap(id, vnc_keymap)
|
113
|
+
raise ArgumentError.new("#{vnc_keymap} is not valid") unless ['us-en', 'jp'].include?(vnc_keymap)
|
114
|
+
action(id, vncKeymap: vnc_keymap)
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_web_console(id, type = 'nova')
|
118
|
+
raise ArgumentError.new("#{type} is not valid") unless ['nova', 'http'].include?(type)
|
119
|
+
request_json = {}
|
120
|
+
type == 'nova' ? request_json[:"os-getSerialConsole"] = {type: :serial} : request_json[:"os-getWebConsole"] = {type: :serial}
|
121
|
+
action(id, request_json)
|
122
|
+
end
|
123
|
+
|
124
|
+
def mount_iso_image(id, file_path)
|
125
|
+
action(id, mountImage: file_path)
|
126
|
+
end
|
127
|
+
|
128
|
+
def unmount_iso_image(id)
|
129
|
+
action(id, unmountImage: nil)
|
130
|
+
end
|
131
|
+
|
132
|
+
def action(id, query)
|
133
|
+
post "servers/#{id}/action", query
|
134
|
+
end
|
135
|
+
private :action
|
136
|
+
|
137
|
+
def keypairs
|
138
|
+
get "os-keypairs"
|
139
|
+
end
|
140
|
+
|
141
|
+
def keypair(name)
|
142
|
+
get "os-keypairs/#{name}"
|
143
|
+
end
|
144
|
+
|
145
|
+
def add_keypair(name, public_key = nil)
|
146
|
+
request_json = {
|
147
|
+
keypair: {
|
148
|
+
name: name
|
149
|
+
}
|
150
|
+
}
|
151
|
+
request_json[:keypair][:public_key] = public_key if public_key
|
152
|
+
post "os-keypairs", request_json
|
153
|
+
end
|
154
|
+
|
155
|
+
def delete_keypair(name)
|
156
|
+
delete "os-keypairs/#{name}"
|
157
|
+
end
|
158
|
+
|
159
|
+
def images
|
160
|
+
get "images"
|
161
|
+
end
|
162
|
+
|
163
|
+
def images_detail(options = {})
|
164
|
+
get "images/detail", options
|
165
|
+
end
|
166
|
+
|
167
|
+
def image(id)
|
168
|
+
get "images/#{id}"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ConohaApi
|
2
|
+
class Client
|
3
|
+
module Identity
|
4
|
+
SERVICE = "identity"
|
5
|
+
|
6
|
+
def identity_version
|
7
|
+
get "", no_auth: true
|
8
|
+
end
|
9
|
+
|
10
|
+
def tokens
|
11
|
+
request_json = {
|
12
|
+
auth: {
|
13
|
+
passwordCredentials: {
|
14
|
+
username: @login,
|
15
|
+
password: @password
|
16
|
+
},
|
17
|
+
tenantId: @tenant_id
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
post "tokens", request_json, no_auth: true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "sawyer"
|
2
|
+
|
3
|
+
require "conoha_api/connection"
|
4
|
+
require "conoha_api/configurable"
|
5
|
+
require "conoha_api/authentication"
|
6
|
+
|
7
|
+
require "conoha_api/client/compute"
|
8
|
+
require "conoha_api/client/identity"
|
9
|
+
|
10
|
+
module ConohaApi
|
11
|
+
class Client
|
12
|
+
class_variable_set(:@@endpoints, {})
|
13
|
+
|
14
|
+
include ConohaApi::Connection
|
15
|
+
include ConohaApi::Configurable
|
16
|
+
include ConohaApi::Authentication
|
17
|
+
|
18
|
+
include ConohaApi::Client::Compute
|
19
|
+
include ConohaApi::Client::Identity
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
Configurable.keys.each do |key|
|
23
|
+
instance_variable_set(:"@#{key}", options[key] || ConohaApi.instance_variable_get(:"@#{key}"))
|
24
|
+
end
|
25
|
+
credential
|
26
|
+
end
|
27
|
+
|
28
|
+
def endpoints
|
29
|
+
@@endpoints
|
30
|
+
end
|
31
|
+
|
32
|
+
def credential
|
33
|
+
@credential = nil if token_expired?
|
34
|
+
@credential ||= auth
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def auth
|
40
|
+
raise unless ready_for_authentication?
|
41
|
+
auth_infomations = tokens
|
42
|
+
token_expires(auth_infomations.access.token.expires)
|
43
|
+
authed_endpoints(auth_infomations)
|
44
|
+
auth_infomations
|
45
|
+
end
|
46
|
+
|
47
|
+
def authed_endpoints(auth_infomations)
|
48
|
+
auth_infomations.access.serviceCatalog.each do |endpoint|
|
49
|
+
@@endpoints[endpoint.type] = endpoint.endpoints.find { |e| e.region = 'tyo1' }.publicURL
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ConohaApi
|
2
|
+
module Configurable
|
3
|
+
|
4
|
+
attr_reader :api_endpoint
|
5
|
+
attr_reader :tenant_id
|
6
|
+
attr_reader :login
|
7
|
+
attr_reader :password
|
8
|
+
attr_reader :connection_options
|
9
|
+
attr_reader :middleware
|
10
|
+
attr_reader :proxy
|
11
|
+
attr_reader :raise_error
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def keys
|
15
|
+
@keys || [
|
16
|
+
:api_endpoint,
|
17
|
+
:tenant_id,
|
18
|
+
:login,
|
19
|
+
:password,
|
20
|
+
:connection_options,
|
21
|
+
:middleware,
|
22
|
+
:proxy,
|
23
|
+
:raise_error,
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure
|
29
|
+
yield
|
30
|
+
end
|
31
|
+
|
32
|
+
def api_endpoint
|
33
|
+
File.join(@api_endpoint, "")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "conoha_api/authentication"
|
2
|
+
require "conoha_api/configurable"
|
3
|
+
|
4
|
+
module ConohaApi
|
5
|
+
module Connection
|
6
|
+
attr_reader :current_connection
|
7
|
+
|
8
|
+
include ConohaApi::Authentication
|
9
|
+
include ConohaApi::Configurable
|
10
|
+
|
11
|
+
def get(path, options = {})
|
12
|
+
request(:get, path, nil, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def put(path, data, options = {})
|
16
|
+
request(:put, path, data, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(path, options = {})
|
20
|
+
request(:delete, path, nil, options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def post(path, data, options = {})
|
24
|
+
request(:post, path, data, options)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def agent
|
30
|
+
endpoint = @connection_stack.last
|
31
|
+
(@connections ||= {})[endpoint] ||= Sawyer::Agent.new(endpoint, sawyer_options) do |http|
|
32
|
+
http.headers['content-type'] = 'application/json'
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def request(method, path, data, options = {})
|
38
|
+
# find module original method defined and add endpoint to connection stack
|
39
|
+
origin = search_caller(caller(0..2))
|
40
|
+
endpoint = URI.parse(endpoints[origin::SERVICE] || @api_endpoint)
|
41
|
+
(@connection_stack ||= []).push("#{endpoint.scheme}://#{endpoint.host}")
|
42
|
+
|
43
|
+
unless options[:no_auth]
|
44
|
+
options = options.dup
|
45
|
+
(options[:headers] ||= {})["X-Auth-Token"] = credential.access.token.id
|
46
|
+
end
|
47
|
+
|
48
|
+
path = File.join(endpoint.path, path)
|
49
|
+
res = agent.call(method, URI::Parser.new.escape(path), data, options)
|
50
|
+
|
51
|
+
@connection_stack.pop
|
52
|
+
res.data
|
53
|
+
end
|
54
|
+
|
55
|
+
def search_caller(call_stack)
|
56
|
+
res = call_stack[2].match(/`(?<method>.*)'/)
|
57
|
+
self.method(res[:method]).owner
|
58
|
+
end
|
59
|
+
|
60
|
+
def sawyer_options
|
61
|
+
opts = {
|
62
|
+
:links_parser => Sawyer::LinkParsers::Simple.new
|
63
|
+
}
|
64
|
+
conn_ops = @connection_options
|
65
|
+
conn_ops[:builder] = @middleware if @middleware
|
66
|
+
conn_ops[:proxy] = @proxy if @proxy
|
67
|
+
opts[:faraday] = Faraday.new(conn_ops)
|
68
|
+
|
69
|
+
opts
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
File without changes
|
data/lib/conoha_api.rb
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conoha_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kinoshita.Yasuhiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sawyer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ConoHa API Client
|
84
|
+
email:
|
85
|
+
- WhoIsDissolvedGirl+github@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- .travis.yml
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.md
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- conoha_api.gemspec
|
99
|
+
- example/example.rb
|
100
|
+
- lib/conoha_api.rb
|
101
|
+
- lib/conoha_api/authentication.rb
|
102
|
+
- lib/conoha_api/client.rb
|
103
|
+
- lib/conoha_api/client/account.rb
|
104
|
+
- lib/conoha_api/client/block_strage.rb
|
105
|
+
- lib/conoha_api/client/compute.rb
|
106
|
+
- lib/conoha_api/client/database_hosting.rb
|
107
|
+
- lib/conoha_api/client/dns.rb
|
108
|
+
- lib/conoha_api/client/identity.rb
|
109
|
+
- lib/conoha_api/client/image.rb
|
110
|
+
- lib/conoha_api/client/mail_hosting.rb
|
111
|
+
- lib/conoha_api/client/network.rb
|
112
|
+
- lib/conoha_api/client/object_strage.rb
|
113
|
+
- lib/conoha_api/configurable.rb
|
114
|
+
- lib/conoha_api/connection.rb
|
115
|
+
- lib/conoha_api/error.rb
|
116
|
+
- lib/conoha_api/version.rb
|
117
|
+
homepage: https://github.com/kinoppyd/conoha-api
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 2.0.14
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: ConoHa API Client
|
141
|
+
test_files: []
|