miasma 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a74043b0719d34f3ad9967c6345ad9f26175336
4
- data.tar.gz: f58390eaca85d115434f260d6db8cf47869942f2
3
+ metadata.gz: 039c6245899398e6105945fa52ea6b60a6f8b496
4
+ data.tar.gz: a50c93103661c9d7919ea9453b095d13d7cbe272
5
5
  SHA512:
6
- metadata.gz: 25776c602dc8f1b1d2b8815fe8cb2b313ba1a7eada1f64918888a9668b309cc6853ea31de11932159f13ff9782b090c14558425d85bdd0e97a598198e69a3596
7
- data.tar.gz: 3c9e161d83a4c092e9fc62bd401245509013bf1c29dd47ca8840f1fe947ec6c9995d3fc175e2182f748f8d1cfc463546b0ca7b71337d32d5322aa4197d94acf3
6
+ metadata.gz: 30654c515d23a58a58355b7b61ba4fc15179b0cb212dbeaa17bf27879bbba0494516efb1570bb45df29d5d157a6c7f243fdc57c02a0537847524ac651b734528
7
+ data.tar.gz: e609e7a4a63d73df54f783ee6d33854b1dee23506a25aeaeeac66e14cf2e85a5d4e2ccae0918be602825511c55f12e1b7951e113585dafe7c059c6c6393874eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # V0.2.10
2
+ * Add auto-follow to paginated results on aws
3
+ * Speed up stack list building on aws
4
+
1
5
  # v0.2.8
2
6
  * Allow multiple expected response codes
3
7
  * Fix API type provided when building server instance from ASG
@@ -29,8 +29,9 @@ module Miasma
29
29
  else
30
30
  list << content
31
31
  end
32
- if(token = result.get(:body, 'NextToken'))
33
- list += all_result_pages(token, *result_key, &block)
32
+ set = result.get(*result_key.slice(0, 3))
33
+ if(set && set['NextToken'])
34
+ list += all_result_pages(set['NextToken'], *result_key, &block)
34
35
  end
35
36
  list.compact
36
37
  end
@@ -49,11 +49,12 @@ module Miasma
49
49
  if(group)
50
50
  params.merge('AutoScalingGroupNames.member.1' => group.id || group.name)
51
51
  end
52
- result = request(
53
- :path => '/',
54
- :params => params
55
- )
56
- [result.get(:body, 'DescribeAutoScalingGroupsResponse', 'DescribeAutoScalingGroupsResult', 'AutoScalingGroups', 'member')].flatten(1).compact.map do |grp|
52
+ result = all_result_pages(nil, :body, 'DescribeAutoScalingGroupsResponse', 'DescribeAutoScalingGroupsResult', 'AutoScalingGroups', 'member') do |options|
53
+ request(
54
+ :path => '/',
55
+ :params => options.merge(params)
56
+ )
57
+ end.map do |grp|
57
58
  (group || Group.new(self)).load_data(
58
59
  :id => grp['AutoScalingGroupName'],
59
60
  :name => grp['AutoScalingGroupName'],
@@ -105,10 +105,12 @@ module Miasma
105
105
  if(balancer)
106
106
  params.merge('LoadBalancerNames.member.1' => balancer.id || balancer.name)
107
107
  end
108
- result = request(
109
- :path => '/',
110
- :params => params
111
- )
108
+ result = all_result_pages(nil, :body, 'DescribeAutoScalingGroupsResponse', 'DescribeAutoScalingGroupsResult', 'AutoScalingGroups', 'member') do |options|
109
+ request(
110
+ :path => '/',
111
+ :params => options.merge(params)
112
+ )
113
+ end
112
114
  [result.get(:body, 'DescribeLoadBalancersResponse', 'DescribeLoadBalancersResult', 'LoadBalancerDescriptions', 'member')].flatten.compact.map do |blr|
113
115
  (balancer || Balancer.new(self)).load_data(
114
116
  :id => blr['LoadBalancerName'],
@@ -50,19 +50,21 @@ module Miasma
50
50
  end
51
51
  if(stack)
52
52
  d_params['StackName'] = stack.id
53
+ descriptions = all_result_pages(nil, :body, 'DescribeStacksResponse', 'DescribeStacksResult', 'Stacks', 'member') do |options|
54
+ request(
55
+ :path => '/',
56
+ :params => options.merge(d_params)
57
+ )
58
+ end
59
+ else
60
+ descriptions = []
53
61
  end
54
- descriptions = [
55
- request(:path => '/', :params => d_params).get(
56
- :body, 'DescribeStacksResponse', 'DescribeStacksResult', 'Stacks', 'member'
57
- )
58
- ].flatten(1).compact
59
- lists = request(:path => '/', :params => l_params)
60
- [
61
- lists.get(
62
- :body, 'ListStacksResponse', 'ListStacksResult',
63
- 'StackSummaries', 'member'
62
+ lists = all_result_pages(nil, :body, 'ListStacksResponse', 'ListStacksResult', 'StackSummaries', 'member') do |options|
63
+ request(
64
+ :path => '/',
65
+ :params => options.merge(l_params)
64
66
  )
65
- ].flatten(1).compact.map do |stk|
67
+ end.map do |stk|
66
68
  desc = descriptions.detect do |d_stk|
67
69
  d_stk['StackId'] == stk['StackId']
68
70
  end || Smash.new
@@ -79,7 +81,7 @@ module Miasma
79
81
  :created => stk['CreationTime'],
80
82
  :updated => stk['LastUpdatedTime'],
81
83
  :notification_topics => [stk.get('NotificationARNs', 'member')].flatten(1).compact,
82
- :timeout_in_minutes => stk['TimeoutInMinutes'],
84
+ :timeout_in_minutes => stk['TimeoutInMinutes'] ? stk['TimeoutInMinutes'].to_i : nil,
83
85
  :status => stk['StackStatus'],
84
86
  :status_reason => stk['StackStatusReason'],
85
87
  :state => stk['StackStatus'].downcase.to_sym,
@@ -255,20 +257,17 @@ module Miasma
255
257
  # @param stack [Models::Orchestration::Stack]
256
258
  # @return [Array<Models::Orchestration::Stack::Resource>]
257
259
  def resource_all(stack)
258
- result = request(
259
- :path => '/',
260
- :params => Smash.new(
261
- 'Action' => 'DescribeStackResources',
262
- 'StackName' => stack.id
263
- )
264
- )
265
- [
266
- result.fetch(
267
- :body, 'DescribeStackResourcesResponse',
268
- 'DescribeStackResourcesResult',
269
- 'StackResources', 'member', []
260
+ results = all_result_pages(nil, :body, 'DescribeStackResourcesResponse', 'DescribeStackResourcesResult', 'StackResources', 'member') do |options|
261
+ request(
262
+ :path => '/',
263
+ :params => options.merge(
264
+ Smash.new(
265
+ 'Action' => 'DescribeStackResources',
266
+ 'StackName' => stack.id
267
+ )
268
+ )
270
269
  )
271
- ].flatten(1).compact.map do |res|
270
+ end.map do |res|
272
271
  Stack::Resource.new(
273
272
  stack,
274
273
  :id => res['PhysicalResourceId'],
@@ -117,8 +117,13 @@ module Miasma
117
117
  #
118
118
  # @return [Array<Models::Storage::Bucket>]
119
119
  def bucket_all
120
- result = request(:path => '/')
121
- [result.get(:body, 'ListAllMyBucketsResult', 'Buckets', 'Bucket')].flatten.compact.map do |bkt|
120
+ result = all_result_pages(nil, :body, 'ListAllMyBucketsResult', 'Buckets', 'Bucket') do |options|
121
+ request(
122
+ :path => '/',
123
+ :params => options
124
+ )
125
+ end
126
+ result.map do |bkt|
122
127
  Bucket.new(
123
128
  self,
124
129
  :id => bkt['Name'],
@@ -160,11 +165,14 @@ module Miasma
160
165
  # @param bucket [Bucket]
161
166
  # @return [Array<File>]
162
167
  def file_all(bucket)
163
- result = request(
164
- :path => '/',
165
- :endpoint => bucket_endpoint(bucket)
166
- )
167
- [result.get(:body, 'ListBucketResult', 'Contents')].flatten.compact.map do |file|
168
+ result = all_result_pages(nil, :body, 'ListBucketResult', 'Contents') do |options|
169
+ request(
170
+ :path => '/',
171
+ :params => options,
172
+ :endpoint => bucket_endpoint(bucket)
173
+ )
174
+ end
175
+ result.map do |file|
168
176
  File.new(
169
177
  bucket,
170
178
  :id => ::File.join(bucket.name, file['Key']),
@@ -335,7 +343,6 @@ module Miasma
335
343
  'X-Amz-Date' => Contrib::AwsApiCore.time_iso8601,
336
344
  'X-Amz-Expires' => timeout_secs
337
345
  )
338
-
339
346
  )
340
347
  else
341
348
  raise Error::ModelPersistError.new "#{file} has not been saved!"
@@ -1,4 +1,4 @@
1
1
  module Miasma
2
2
  # current library version
3
- VERSION = Gem::Version.new('0.2.8')
3
+ VERSION = Gem::Version.new('0.2.10')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miasma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie