aliyun-ess 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Aliyun
3
+ module ESS
4
+ class ScalingGroup < Base
5
+ class << self
6
+ def find(params={}, options={})
7
+ params = {'action' => 'DescribeScalingGroups', 'region_id' => 'cn-hangzhou', 'page_number' => 1}.merge params
8
+ Collection.new get('/', params, options)
9
+ end
10
+
11
+ def find_by(*args)
12
+ c = find(*args)
13
+ c.items.first
14
+ end
15
+ end
16
+
17
+ include SelectiveAttributeProxy
18
+
19
+ def initialize(attributes = {})
20
+ super
21
+ end
22
+
23
+ def id
24
+ attributes['scaling_group_id']
25
+ end
26
+
27
+ def name
28
+ attributes['scaling_group_name']
29
+ end
30
+
31
+ def scaling_rules
32
+ @scaling_rules ||= begin
33
+ build_scaling_rules!
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def build_scaling_rules!
40
+ items = ScalingRule.find(:scaling_group_id => id).items
41
+ items.each {|e| register(e) }
42
+ items
43
+ end
44
+
45
+ def register(object)
46
+ object.scaling_group = self
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,45 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Aliyun
3
+ module ESS
4
+ class ScalingRule < Base
5
+ class << self
6
+ def find(params={}, options={})
7
+ params = {'Action' => 'DescribeScalingRules', 'RegionId' => 'cn-hangzhou', 'PageNumber' => 1}.merge params
8
+ Collection.new get('/', params, options)
9
+ end
10
+
11
+ def find_by(*args)
12
+ c = find(*args)
13
+ c.items.first
14
+ end
15
+
16
+ def execute(params={'ScalingRuleAri' => 'ari:acs:ess:cn-hangzhou:1358641544878377:scalingrule/duK8myelWehmcB5WH9cUTsu7'}, options={})
17
+ params = {'Action' => 'ExecuteScalingRule'}.merge params
18
+ get('/', params, options)
19
+ end
20
+ end
21
+
22
+ include SelectiveAttributeProxy
23
+
24
+ attr_accessor :scaling_group
25
+
26
+ def initialize(attributes = {})
27
+ super
28
+
29
+ end
30
+
31
+ def id
32
+ attributes['scaling_rule_id']
33
+ end
34
+
35
+ def name
36
+ attributes['scaling_rule_name']
37
+ end
38
+
39
+ def execute
40
+ self.class.execute :scaling_rule_ari => scaling_rule_ari
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Aliyun
3
+ module ESS
4
+ # The service lets you find out general information about your account, like what buckets you have.
5
+ #
6
+ class Service < Base
7
+ @@response = nil #:nodoc:
8
+
9
+ class << self
10
+ # Sometimes methods that make requests to the OSS servers return some object, like a Bucket or an OSSObject.
11
+ # Other times they return just <tt>true</tt>. Other times they raise an exception that you may want to rescue. Despite all these
12
+ # possible outcomes, every method that makes a request stores its response object for you in Service.response. You can always
13
+ # get to the last request's response via Service.response.
14
+ #
15
+ # objects = Bucket.objects('jukebox')
16
+ # Service.response.success?
17
+ # # => true
18
+ #
19
+ # This is also useful when an error exception is raised in the console which you weren't expecting. You can
20
+ # root around in the response to get more details of what might have gone wrong.
21
+ def response
22
+ @@response
23
+ end
24
+
25
+ def response=(response) #:nodoc:
26
+ @@response = response
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,14 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Aliyun
3
+ module ESS
4
+ module VERSION #:nodoc:
5
+ MAJOR = '0'
6
+ MINOR = '1'
7
+ TINY = '0'
8
+ BETA = nil
9
+ #BETA = Time.now.to_i.to_s
10
+ end
11
+
12
+ Version = [VERSION::MAJOR, VERSION::MINOR, VERSION::TINY, VERSION::BETA].compact * '.'
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aliyun-ess
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joshua Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-11 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yajl-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ description: Full documentation of the currently supported API can be found at http://www.aliyun.com/product/ess#resources.
56
+ email:
57
+ - sunrisela@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG
63
+ - INSTALL
64
+ - bin/ess
65
+ - bin/setup.rb
66
+ - lib/aliyun/ess.rb
67
+ - lib/aliyun/ess/authentication.rb
68
+ - lib/aliyun/ess/base.rb
69
+ - lib/aliyun/ess/collection.rb
70
+ - lib/aliyun/ess/connection.rb
71
+ - lib/aliyun/ess/error.rb
72
+ - lib/aliyun/ess/exceptions.rb
73
+ - lib/aliyun/ess/extensions.rb
74
+ - lib/aliyun/ess/parsing.rb
75
+ - lib/aliyun/ess/response.rb
76
+ - lib/aliyun/ess/scaling_group.rb
77
+ - lib/aliyun/ess/scaling_rule.rb
78
+ - lib/aliyun/ess/service.rb
79
+ - lib/aliyun/ess/version.rb
80
+ homepage: https://github.com/sunrisela
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.6
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Aliyun::ESS is a Ruby library for Aliyun's Elastic Scaling Service API (http://www.aliyun.com/product/ess)
104
+ test_files: []