ucloud_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/lib/ucloud_api/version.rb +3 -0
- data/lib/ucloud_api.rb +60 -0
- data/ucloud_api.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3052176cb9deeaa227f4deb2cb608aa82890def0
|
4
|
+
data.tar.gz: 6ee4bbd11c7e5558af5d55e89f6b2e961581a20f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e8258d1ed52c369effcde4b166a45389d75da860907a1399fe019b9188038020e22dd6bd44a708047c49b979245282d85b46f1034a88540bee4c7a6bf140ffb
|
7
|
+
data.tar.gz: 5a32a8dad199bb591601df6d31e38c08e48ac83b91ce5ba3ca9bb57076dc9e30e657658368fdb3292329df19ebc7d0b0d31840ac2bedcd4a92a6ea7696a6ecd9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Beom Jae Kim
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/ucloud_api.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require "ucloud_api/version"
|
2
|
+
require 'addressable/uri'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
module UcloudApi
|
6
|
+
|
7
|
+
class Client
|
8
|
+
include HTTParty
|
9
|
+
base_uri 'https://api.ucloudbiz.olleh.com/server/v1/client'
|
10
|
+
format :json # spechify resonse format
|
11
|
+
|
12
|
+
# debug_output $stderr
|
13
|
+
|
14
|
+
def initialize(apikey=nil, secretkey=nil)
|
15
|
+
@apikey = apikey || ENV["UCLOUDAPIKEY"]
|
16
|
+
@secretkey = secretkey || ENV["UCLOUDSECRET"]
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def raw_cmd options={}
|
21
|
+
uri = Addressable::URI.new
|
22
|
+
hashable_opt = options.merge( {:apiKey => @apikey, :response=>"json"} )
|
23
|
+
uri.query_values = hashable_opt.sort
|
24
|
+
hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), uri.query.downcase, @secretkey)
|
25
|
+
signature = Base64.encode64("#{OpenSSL::HMAC.digest('sha1', @secretkey, uri.query.downcase)}")[0..-2]
|
26
|
+
query = options.merge( {:response=>"json", :apiKey=>@apikey, :signature => signature } )
|
27
|
+
self.class.get "/api" , :query => query
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.list_styled command, listname
|
31
|
+
class_eval <<"EOD"
|
32
|
+
def #{command}(*args, &block)
|
33
|
+
h = Hash[*args]
|
34
|
+
h[:command] = "#{command}"
|
35
|
+
response = raw_cmd(h)
|
36
|
+
list = response.parsed_response["#{command.to_s.downcase}response"]["#{listname}"]
|
37
|
+
yield(list) if block_given?
|
38
|
+
list
|
39
|
+
end
|
40
|
+
EOD
|
41
|
+
end
|
42
|
+
|
43
|
+
list_styled "listAvailableProductTypes", "producttypes"
|
44
|
+
list_styled "listVirtualMacines", "virtualmachine"
|
45
|
+
list_styled "listTemplates", "template"
|
46
|
+
list_styled "listZones", "zone"
|
47
|
+
list_styled "listNetworks", "network"
|
48
|
+
|
49
|
+
def method_missing m, *args, &block
|
50
|
+
h = Hash[*args]
|
51
|
+
h[:command] = m.to_s
|
52
|
+
response = raw_cmd(h)
|
53
|
+
r = response.parsed_response["#{m.to_s.downcase}response"]
|
54
|
+
yield(r) if block_given?
|
55
|
+
r
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/ucloud_api.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ucloud_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ucloud_api"
|
8
|
+
spec.version = UcloudApi::VERSION
|
9
|
+
spec.authors = ["Beom Jae Kim"]
|
10
|
+
spec.email = ["burnssun@gmail.com"]
|
11
|
+
spec.summary = %q{KT ucloud biz api}
|
12
|
+
spec.description = %q{KT ucloud biz api}
|
13
|
+
spec.homepage = 'https://github.com/burnsssun/ucloud_api'
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ucloud_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Beom Jae Kim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: KT ucloud biz api
|
42
|
+
email:
|
43
|
+
- burnssun@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/ucloud_api.rb
|
54
|
+
- lib/ucloud_api/version.rb
|
55
|
+
- ucloud_api.gemspec
|
56
|
+
homepage: https://github.com/burnsssun/ucloud_api
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.0.14
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: KT ucloud biz api
|
80
|
+
test_files: []
|