aws-sdk-resources 2.0.6.pre → 2.0.7.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1836c23ab216964624f76b4e9d5897c005cdb922
4
- data.tar.gz: a4c93137ebb9ed5f7a2a5b241e934602f5212a94
3
+ metadata.gz: d5e78644cbc27978c51cd6615a58fc773be80a38
4
+ data.tar.gz: 9a99500defb2563b7069aadbcadb7e7300ecb8ed
5
5
  SHA512:
6
- metadata.gz: 62c9ab0d1fac25872ddbbc823f8f4c770886fb589c201142a63063e45402eb3b23cce44aea07c082366ce1f5d5175ee2d2ed86a5833b53059b3e326f589cf1c0
7
- data.tar.gz: 58b60ec8a12570d5c087e0c7a4bd0593deb7a0dc80cb4a8726aed4ec48fcefd33ea693a3829d47fdb54cf399dbdcfd292dcbccc72b69b3e967e3ec45648ef4b2
6
+ metadata.gz: 135e7a7f1d5b9433a0c513775cb12e7dc8f35a42680329af082c853b8a3fc484c6cf04a3a5d8b9dcfd5f837d4768ea4e80b9c8197243c93df557533950f658c1
7
+ data.tar.gz: 3869b525d250dc45c62498567cc47ab3c2c29a62994c968d22dfe0b4501a79c0eb44e82b32f5065ee5e5acc7b0f7cb0ef72e37924b68938132b866dc2a40a275
@@ -32,7 +32,7 @@ module Aws
32
32
  #
33
33
  # Batches provide operations that operate on the entire batch. These
34
34
  # operations are only defined for resources where the AWS API accepts
35
- # multiple inputs. This means a batch operation for n elements will
35
+ # multiple inputs. This means a batch operation for n resources will
36
36
  # only make one request.
37
37
  #
38
38
  # Resource classes document each of their own batch operations.
@@ -41,7 +41,6 @@ module Aws
41
41
  class Batch
42
42
 
43
43
  include Enumerable
44
- extend OperationMethods
45
44
 
46
45
  # @param [Array<Resource>] resources
47
46
  # @option options [Seahorse::Client::Response] :response
@@ -95,6 +94,40 @@ module Aws
95
94
  "#<#{self.class.name} resources=#{@resources}>"
96
95
  end
97
96
 
97
+ # @api private
98
+ def respond_to?(method_name, *args)
99
+ if !empty? && batch_method?(method_name)
100
+ true
101
+ else
102
+ super
103
+ end
104
+ end
105
+
106
+
107
+ # @api private
108
+ def method_missing(method_name, *args, &block)
109
+ if respond_to?(method_name)
110
+ invoke_batch_operation(method_name, args, block) unless empty?
111
+ else
112
+ super
113
+ end
114
+ end
115
+
116
+ private
117
+
118
+ def batch_method?(method_name)
119
+ resource_class.batch_operation_names.include?(method_name.to_sym)
120
+ end
121
+
122
+ def resource_class
123
+ @resources.first.class
124
+ end
125
+
126
+ def invoke_batch_operation(method_name, args, block)
127
+ operation = resource_class.batch_operation(method_name)
128
+ operation.call(resource:self, args:args, block:block)
129
+ end
130
+
98
131
  end
99
132
  end
100
133
  end
@@ -56,7 +56,7 @@ module Aws
56
56
  yield(resource) if block_given?
57
57
  resource
58
58
  end
59
- resource_class::Batch.new(resources, options)
59
+ Batch.new(resources, options)
60
60
  end
61
61
 
62
62
  def build_one(identifiers, options)
@@ -4,8 +4,8 @@ module Aws
4
4
 
5
5
  include Enumerable
6
6
 
7
- # @param [EnumerateResourceOperation] operation
8
- # @option (see EnumerateResourceOperation#call)
7
+ # @param [HasManyOperation] operation
8
+ # @option (see HasManyOperation#call)
9
9
  # @api private
10
10
  def initialize(operation, options)
11
11
  @operation = operation
@@ -78,13 +78,13 @@ module Aws
78
78
  if count == 1
79
79
  limit(1).to_a.first
80
80
  else
81
- resource_class::Batch.new(limit(count).to_a)
81
+ Batch.new(limit(count).to_a)
82
82
  end
83
83
  end
84
84
 
85
85
  # @api private
86
86
  def respond_to?(method_name, *args)
87
- if resource_class::Batch.instance_methods.include?(method_name.to_sym)
87
+ if resource_class.batch_operation_names.include?(method_name.to_sym)
88
88
  true
89
89
  else
90
90
  super
@@ -24,8 +24,7 @@ module Aws
24
24
  define_batch_actions(namespace, resource, definition['batchActions'] || {})
25
25
  define_waiters(namespace, resource, definition['waiters'] || {})
26
26
  define_has_many(namespace, resource, definition['hasMany'] || {})
27
- define_has_some(namespace, resource, definition['hasSome'] || {})
28
- define_has_one(namespace, resource, definition['hasOne'] || {})
27
+ define_belongs_to(namespace, resource, definition['belongsTo'] || {})
29
28
  define_data_attributes(namespace, resource, definition)
30
29
  define_subresources(namespace, resource, definition['subResources'] || {})
31
30
  end
@@ -43,9 +42,6 @@ module Aws
43
42
  resource_class.add_identifier(underscore(identifier['name']))
44
43
  end
45
44
  namespace.const_set(name, resource_class)
46
- unless name == 'Resource'
47
- resource_class.const_set(:Batch, Class.new(Batch))
48
- end
49
45
  end
50
46
  end
51
47
 
@@ -72,7 +68,7 @@ module Aws
72
68
  end
73
69
 
74
70
  def subresource(namespace, type, identifiers)
75
- Operations::ReferenceOperation.new(builder: define_builder(namespace, {
71
+ Operations::BelongsToOperation.new(builder: define_builder(namespace, {
76
72
  'type' => type,
77
73
  'identifiers' => identifiers.map { |source, target|
78
74
  {
@@ -87,7 +83,7 @@ module Aws
87
83
  def define_top_level_references(namespace)
88
84
  top_level = Set.new(resource_definitions.keys)
89
85
  each_resource_class(namespace) do |resource, definition|
90
- unless resource.identifiers.count == 1
86
+ unless resource.identifiers.count <= 1
91
87
  top_level.delete(resource.resource_name)
92
88
  end
93
89
  ((definition['subResources'] || {})['resources'] || {}).each do |child|
@@ -105,7 +101,7 @@ module Aws
105
101
  batch_actions.each do |name, definition|
106
102
  method_name = underscore(name)
107
103
  operation = build_operation(namespace, resource, definition)
108
- resource::Batch.add_operation(method_name, operation)
104
+ resource.add_batch_operation(method_name, operation)
109
105
  end
110
106
  end
111
107
 
@@ -131,7 +127,7 @@ module Aws
131
127
 
132
128
  def define_load(namespace, resource, definition)
133
129
  return unless definition
134
- resource.load_operation = Operations::DataOperation.new(
130
+ resource.load_operation = Operations::LoadOperation.new(
135
131
  request: define_request(definition['request']),
136
132
  path: underscore(definition['path']),
137
133
  source: source(definition),
@@ -164,28 +160,9 @@ module Aws
164
160
  )
165
161
  end
166
162
 
167
- def build_data_operation(namespace, resource, definition)
168
- plural = definition['path'].include?('[')
169
- source = source(definition)
170
- if plural
171
- Operations::EnumerateDataOperation.new(
172
- request: define_request(definition['request']),
173
- path: underscore(definition['path']),
174
- source: source,
175
- limit_key: limit_key(resource, definition)
176
- )
177
- else
178
- Operations::DataOperation.new(
179
- request: define_request(definition['request']),
180
- path: underscore(definition['path']),
181
- source: source
182
- )
183
- end
184
- end
185
-
186
163
  def build_resource_operation(namespace, resource, definition)
187
164
  builder = define_builder(namespace, definition['resource'])
188
- if path = definition['path']
165
+ if path = definition['resource']['path']
189
166
  source = underscore(path)
190
167
  builder.sources << BuilderSources::ResponsePath.new(source, :data)
191
168
  end
@@ -198,11 +175,11 @@ module Aws
198
175
 
199
176
  def build_enumerate_resource_operation(namespace, resource, definition)
200
177
  builder = define_builder(namespace, definition['resource'])
201
- if path = definition['path']
178
+ if path = definition['resource']['path']
202
179
  source = underscore(path)
203
180
  builder.sources << BuilderSources::ResponsePath.new(source, :data)
204
181
  end
205
- Operations::EnumerateResourceOperation.new(
182
+ Operations::HasManyOperation.new(
206
183
  request: define_request(definition['request']),
207
184
  builder: builder,
208
185
  source: source(definition),
@@ -258,25 +235,19 @@ module Aws
258
235
  end
259
236
  end
260
237
 
261
- def define_has_some(namespace, resource, has_some)
238
+ def define_belongs_to(namespace, resource, has_some)
262
239
  has_some.each do |name, definition|
263
240
  define_reference(namespace, resource, name, definition)
264
241
  end
265
242
  end
266
243
 
267
- def define_has_one(namespace, resource, has_one)
268
- has_one.each do |name, definition|
269
- define_reference(namespace, resource, name, definition)
270
- end
271
- end
272
-
273
244
  def define_reference(namespace, resource, name, definition)
274
245
  builder = define_builder(namespace, definition['resource'])
275
- if path = definition['path']
246
+ if path = definition['resource']['path']
276
247
  source = underscore(path)
277
248
  builder.sources << BuilderSources::DataMember.new(source, :data)
278
249
  end
279
- operation = Operations::ReferenceOperation.new(
250
+ operation = Operations::BelongsToOperation.new(
280
251
  builder: builder,
281
252
  source: source(definition))
282
253
  resource.add_operation(underscore(name), operation)
@@ -5,11 +5,9 @@ module Aws
5
5
  class Documenter
6
6
 
7
7
  autoload :BaseOperationDocumenter, 'aws-sdk-resources/documenter/base_operation_documenter'
8
- autoload :DataOperationDocumenter, 'aws-sdk-resources/documenter/data_operation_documenter'
9
- autoload :EnumerateDataOperationDocumenter, 'aws-sdk-resources/documenter/enumerate_data_operation_documenter'
10
- autoload :EnumerateResourceOperationDocumenter, 'aws-sdk-resources/documenter/enumerate_resource_operation_documenter'
8
+ autoload :BelongsToOperationDocumenter, 'aws-sdk-resources/documenter/belongs_to_operation_documenter'
9
+ autoload :HasManyOperationDocumenter, 'aws-sdk-resources/documenter/has_many_operation_documenter'
11
10
  autoload :OperationDocumenter, 'aws-sdk-resources/documenter/operation_documenter'
12
- autoload :ReferenceOperationDocumenter, 'aws-sdk-resources/documenter/reference_operation_documenter'
13
11
  autoload :ResourceOperationDocumenter, 'aws-sdk-resources/documenter/resource_operation_documenter'
14
12
  autoload :WaiterOperationDocumenter, 'aws-sdk-resources/documenter/waiter_operation_documenter'
15
13
 
@@ -62,7 +62,7 @@ module Aws
62
62
  # API operation called. Returns `nil` if this operation does not make
63
63
  # any API requests.
64
64
  attr_reader :api_request
65
-
65
+
66
66
  # @return [Array<Resources::RequestParams::Base>, nil] Returns the
67
67
  # parameters this operation binds to the made request. Returns `nil`
68
68
  # if this operation does not make a request.
@@ -83,10 +83,13 @@ module Aws
83
83
  # Constructs and returns a new YARD method object for this operation.
84
84
  # @return [YARD::CodeObject::MethodObject]
85
85
  def method_object
86
- m = YARD::CodeObjects::MethodObject.new(yard_class, operation_name)
86
+ if m = YARD::Registry[@resource_class.name + "##{operation_name}"]
87
+ else
88
+ m = YARD::CodeObjects::MethodObject.new(yard_class, operation_name)
89
+ m.docstring = docstring
90
+ m.parameters = parameters
91
+ end
87
92
  m.scope = :instance
88
- m.parameters = parameters
89
- m.docstring = docstring
90
93
  if source
91
94
  m.source_type = :json
92
95
  m.source = source.format
@@ -106,7 +109,7 @@ module Aws
106
109
  if option_tags.empty?
107
110
  []
108
111
  else
109
- [['params', '{}']]
112
+ [['options', '{}']]
110
113
  end
111
114
  end
112
115
 
@@ -137,7 +140,7 @@ module Aws
137
140
  end
138
141
  docstring = member_shape.documentation
139
142
  req = ' **`required`** &mdash; ' if required.include?(member_name)
140
- tags << "@option params [#{param_type(member_shape)}] :#{member_name} #{req}#{docstring}"
143
+ tags << "@option options [#{param_type(member_shape)}] :#{member_name} #{req}#{docstring}"
141
144
  end
142
145
  tags = tags.join("\n")
143
146
  YARD::DocstringParser.new.parse(tags).to_docstring.tags
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Resources
3
3
  class Documenter
4
- class ReferenceOperationDocumenter < BaseOperationDocumenter
4
+ class BelongsToOperationDocumenter < BaseOperationDocumenter
5
5
 
6
6
  def docstring
7
7
  docs = []
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Resources
3
3
  class Documenter
4
- class EnumerateResourceOperationDocumenter < BaseOperationDocumenter
4
+ class HasManyOperationDocumenter < BaseOperationDocumenter
5
5
 
6
6
  def docstring
7
7
  super + ' ' +<<-DOCSTRING.lstrip
@@ -40,7 +40,7 @@ module Aws
40
40
  idv = target_resource_class_name.downcase + '-' + id.gsub('_', '-')
41
41
  tag = []
42
42
  tag << "@example Basic usage"
43
- tag << " #{resp_variable} = #{variable_name}.#{operation_name}(params)"
43
+ tag << " #{resp_variable} = #{variable_name}.#{operation_name}(options)"
44
44
  if plural?
45
45
  tag << " #{resp_variable}.map(&:#{id})"
46
46
  tag << " #=> [#{idv.inspect}, ...]"
@@ -31,9 +31,36 @@ module Aws
31
31
  @operations.keys
32
32
  end
33
33
 
34
+ # @param [Symbol] name
35
+ # @return [Operation] Returns the named batch operation.
36
+ # @raise [Errors::UnknownOperationError]
37
+ def batch_operation(name)
38
+ @batch_operations[name.to_sym] or
39
+ raise Errors::UnknownOperationError.new(name)
40
+ end
41
+
42
+ # @param [Symbol] method_name
43
+ # @param [Operation] operation
44
+ # @return [void]
45
+ def add_batch_operation(method_name, operation = nil, &definition)
46
+ operation = definition if block_given?
47
+ @batch_operations[method_name.to_sym] = operation
48
+ end
49
+
50
+ # @return [Hash]
51
+ def batch_operations(&block)
52
+ @batch_operations.dup
53
+ end
54
+
55
+ # @return [Array<Symbol>]
56
+ def batch_operation_names
57
+ @batch_operations.keys
58
+ end
59
+
34
60
  # @api private
35
61
  def inherited(subclass)
36
62
  subclass.send(:instance_variable_set, "@operations", {})
63
+ subclass.send(:instance_variable_set, "@batch_operations", {})
37
64
  end
38
65
 
39
66
  private
@@ -22,14 +22,6 @@ module Aws
22
22
  # @return [Source, nil]
23
23
  attr_reader :source
24
24
 
25
- # @option options[required,Resource] :resource
26
- # @option options[required,Array<Mixed>] :args
27
- # @option options[Proc] :block
28
- # @return [Mixed]
29
- def call(options = {})
30
- raise NotImplementedError
31
- end
32
-
33
25
  end
34
26
 
35
27
  # Makes an API request using the resource client, returning the client
@@ -53,7 +45,7 @@ module Aws
53
45
 
54
46
  end
55
47
 
56
- class DataOperation < Operation
48
+ class LoadOperation < Operation
57
49
 
58
50
  # @option options [required, Request] :request
59
51
  # @option options [required, String<JMESPath>] :path
@@ -79,46 +71,6 @@ module Aws
79
71
 
80
72
  end
81
73
 
82
- class EnumerateDataOperation < DataOperation
83
-
84
- # @option options [required, Request] :request
85
- # @option options [required, String<JMESPath>] :path
86
- # @option options [Symbol] :limit_key
87
- def initialize(options = {})
88
- @limit_key = options[:limit_key]
89
- super
90
- end
91
-
92
- # @option (see Base#call)
93
- # @option options [Integer] :limit (nil)
94
- # @return [Enumerator]
95
- def call(options)
96
- if options[:limit]
97
- enum_for(:limited_each, options[:limit], options)
98
- else
99
- enum_for(:each, options)
100
- end
101
- end
102
-
103
- private
104
-
105
- def each(options, &block)
106
- @request.call(options).each do |response|
107
- extract(response).each(&block)
108
- end
109
- end
110
-
111
- def limited_each(limit, options, &block)
112
- yielded = 0
113
- each(options) do |value|
114
- yield(value)
115
- yielded += 1
116
- break if yielded == limit
117
- end
118
- end
119
-
120
- end
121
-
122
74
  class ResourceOperation < Operation
123
75
 
124
76
  # @option options [required, Request] :request
@@ -139,7 +91,7 @@ module Aws
139
91
 
140
92
  end
141
93
 
142
- class EnumerateResourceOperation < ResourceOperation
94
+ class HasManyOperation < ResourceOperation
143
95
 
144
96
  # @option options [required, Request] :request
145
97
  # @option options [required, Builder] :builder
@@ -204,7 +156,7 @@ module Aws
204
156
 
205
157
  end
206
158
 
207
- class ReferenceOperation < Base
159
+ class BelongsToOperation < Base
208
160
 
209
161
  # @option options [required, Builder] :builder
210
162
  def initialize(options = {})
@@ -91,7 +91,7 @@ module Aws
91
91
  # this class.
92
92
  attr_accessor :client_class
93
93
 
94
- # @return [Operations::DataOperation, nil]
94
+ # @return [Operations::LoadOperation, nil]
95
95
  attr_accessor :load_operation
96
96
 
97
97
  # @return [Array<Symbol>]
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module Aws
2
4
  module S3
3
5
  class Bucket
@@ -26,6 +28,23 @@ module Aws
26
28
  delete
27
29
  end
28
30
 
31
+ # @return [String] the URL for this bucket.
32
+ def url
33
+ url = URI.parse(client.config.endpoint.to_s)
34
+ if dns_compatible?(url.scheme) && !client.config.force_path_style
35
+ url.host = "#{name}.#{url.host}"
36
+ else
37
+ url.path = "/#{name}"
38
+ end
39
+ url.to_s
40
+ end
41
+
42
+ private
43
+
44
+ def dns_compatible?(scheme)
45
+ Plugins::S3BucketDns.dns_compatible?(name, scheme == 'https')
46
+ end
47
+
29
48
  end
30
49
  end
31
50
  end
@@ -4,15 +4,17 @@ module Aws
4
4
 
5
5
  alias_method :basic_complete, :complete
6
6
 
7
- # Completes the MultipartUpload.
7
+ # Completes the upload, requires a list of completed parts. You can
8
+ # provide the list of parts with `:part_number` and `:etag` values.
8
9
  #
9
- # To complete a multipart upload, a list of part numbers and their
10
- # ETags is required.
10
+ # upload.complete(multipart_upload: { parts: [
11
+ # { part_number: 1, etag:'etag1' },
12
+ # { part_number: 2, etag:'etag2' },
13
+ # ...
14
+ # ]})
11
15
  #
12
- # upload.complete(multipart_upload: { parts: part_list })
13
- #
14
- # You can pass `:compute_parts => true` and the {Client#list_parts}
15
- # method will be called to generate the part list.
16
+ # Alternatively, you can pass **`compute_parts: true`** and the part
17
+ # list will be computed by calling {Client#list_parts}.
16
18
  #
17
19
  # upload.complete(compute_parts: true)
18
20
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6.pre
4
+ version: 2.0.7.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.6
19
+ version: 2.0.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.6
26
+ version: 2.0.7
27
27
  description: Provides resource-oriented abstractions for AWS.
28
28
  email:
29
29
  executables: []
@@ -36,11 +36,10 @@ files:
36
36
  - lib/aws-sdk-resources/collection.rb
37
37
  - lib/aws-sdk-resources/definition.rb
38
38
  - lib/aws-sdk-resources/documenter/base_operation_documenter.rb
39
+ - lib/aws-sdk-resources/documenter/belongs_to_operation_documenter.rb
39
40
  - lib/aws-sdk-resources/documenter/data_operation_documenter.rb
40
- - lib/aws-sdk-resources/documenter/enumerate_data_operation_documenter.rb
41
- - lib/aws-sdk-resources/documenter/enumerate_resource_operation_documenter.rb
41
+ - lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb
42
42
  - lib/aws-sdk-resources/documenter/operation_documenter.rb
43
- - lib/aws-sdk-resources/documenter/reference_operation_documenter.rb
44
43
  - lib/aws-sdk-resources/documenter/resource_operation_documenter.rb
45
44
  - lib/aws-sdk-resources/documenter/waiter_operation_documenter.rb
46
45
  - lib/aws-sdk-resources/documenter.rb
@@ -1,50 +0,0 @@
1
- module Aws
2
- module Resources
3
- class Documenter
4
- class EnumerateDataOperationDocumenter < BaseOperationDocumenter
5
-
6
- def docstring
7
- super + ' ' + <<-DOCSTRING.lstrip
8
- Returns an enumerator that yields #{operation_name.gsub('_', ' ')}.
9
- No API requests are made until you call an enumerable method.
10
- {#{called_operation}} will be called multiple times until all results
11
- have been yielded.
12
- DOCSTRING
13
- end
14
-
15
- def return_type
16
- ["Enumerator<#{path_type}>"]
17
- end
18
-
19
- def return_message
20
- msg = "Returns an enumerator that yields #{operation_name.gsub('_', ' ')}."
21
- msg << data_members
22
- msg
23
- end
24
-
25
- def data_members
26
- if path_shape.type == 'structure'
27
- msg = "\nEnumerated values have the following properties:\n"
28
- path_shape.member_names.each do |name|
29
- msg << "\n* `#{name}`"
30
- end
31
- msg
32
- else
33
- ''
34
- end
35
- end
36
-
37
- def example_tags
38
- tag = <<-EXAMPLE.strip
39
- @example Enumerate all #{operation_name}
40
- #{variable_name}.#{operation_name}.each do |data|
41
- # ...
42
- end
43
- EXAMPLE
44
- YARD::DocstringParser.new.parse(tag).to_docstring.tags
45
- end
46
-
47
- end
48
- end
49
- end
50
- end