aws-sdk-resources 2.11.361 → 3.49.0
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 +4 -4
 - data/bin/aws-v3.rb +192 -0
 - data/lib/aws-sdk-resources.rb +189 -87
 - metadata +2594 -69
 - data/lib/aws-sdk-resources/batch.rb +0 -143
 - data/lib/aws-sdk-resources/builder.rb +0 -85
 - data/lib/aws-sdk-resources/builder_sources.rb +0 -105
 - data/lib/aws-sdk-resources/collection.rb +0 -107
 - data/lib/aws-sdk-resources/definition.rb +0 -331
 - data/lib/aws-sdk-resources/documenter.rb +0 -70
 - data/lib/aws-sdk-resources/documenter/base_operation_documenter.rb +0 -279
 - data/lib/aws-sdk-resources/documenter/data_operation_documenter.rb +0 -25
 - data/lib/aws-sdk-resources/documenter/has_many_operation_documenter.rb +0 -69
 - data/lib/aws-sdk-resources/documenter/has_operation_documenter.rb +0 -66
 - data/lib/aws-sdk-resources/documenter/operation_documenter.rb +0 -20
 - data/lib/aws-sdk-resources/documenter/resource_operation_documenter.rb +0 -53
 - data/lib/aws-sdk-resources/documenter/waiter_operation_documenter.rb +0 -77
 - data/lib/aws-sdk-resources/errors.rb +0 -15
 - data/lib/aws-sdk-resources/operation_methods.rb +0 -83
 - data/lib/aws-sdk-resources/operations.rb +0 -280
 - data/lib/aws-sdk-resources/options.rb +0 -17
 - data/lib/aws-sdk-resources/request.rb +0 -39
 - data/lib/aws-sdk-resources/request_params.rb +0 -140
 - data/lib/aws-sdk-resources/resource.rb +0 -243
 - data/lib/aws-sdk-resources/services/ec2.rb +0 -21
 - data/lib/aws-sdk-resources/services/ec2/instance.rb +0 -29
 - data/lib/aws-sdk-resources/services/iam.rb +0 -19
 - data/lib/aws-sdk-resources/services/s3.rb +0 -20
 - data/lib/aws-sdk-resources/services/s3/bucket.rb +0 -127
 - data/lib/aws-sdk-resources/services/s3/encryption.rb +0 -21
 - data/lib/aws-sdk-resources/services/s3/encryption/client.rb +0 -369
 - data/lib/aws-sdk-resources/services/s3/encryption/decrypt_handler.rb +0 -174
 - data/lib/aws-sdk-resources/services/s3/encryption/default_cipher_provider.rb +0 -63
 - data/lib/aws-sdk-resources/services/s3/encryption/default_key_provider.rb +0 -38
 - data/lib/aws-sdk-resources/services/s3/encryption/encrypt_handler.rb +0 -50
 - data/lib/aws-sdk-resources/services/s3/encryption/errors.rb +0 -13
 - data/lib/aws-sdk-resources/services/s3/encryption/io_auth_decrypter.rb +0 -56
 - data/lib/aws-sdk-resources/services/s3/encryption/io_decrypter.rb +0 -29
 - data/lib/aws-sdk-resources/services/s3/encryption/io_encrypter.rb +0 -69
 - data/lib/aws-sdk-resources/services/s3/encryption/key_provider.rb +0 -29
 - data/lib/aws-sdk-resources/services/s3/encryption/kms_cipher_provider.rb +0 -71
 - data/lib/aws-sdk-resources/services/s3/encryption/materials.rb +0 -58
 - data/lib/aws-sdk-resources/services/s3/encryption/utils.rb +0 -79
 - data/lib/aws-sdk-resources/services/s3/file_downloader.rb +0 -169
 - data/lib/aws-sdk-resources/services/s3/file_part.rb +0 -75
 - data/lib/aws-sdk-resources/services/s3/file_uploader.rb +0 -58
 - data/lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb +0 -187
 - data/lib/aws-sdk-resources/services/s3/multipart_upload.rb +0 -42
 - data/lib/aws-sdk-resources/services/s3/multipart_upload_error.rb +0 -16
 - data/lib/aws-sdk-resources/services/s3/object.rb +0 -290
 - data/lib/aws-sdk-resources/services/s3/object_copier.rb +0 -99
 - data/lib/aws-sdk-resources/services/s3/object_multipart_copier.rb +0 -180
 - data/lib/aws-sdk-resources/services/s3/object_summary.rb +0 -73
 - data/lib/aws-sdk-resources/services/s3/presigned_post.rb +0 -647
 - data/lib/aws-sdk-resources/services/sns.rb +0 -7
 - data/lib/aws-sdk-resources/services/sns/message_verifier.rb +0 -171
 - data/lib/aws-sdk-resources/services/sqs.rb +0 -7
 - data/lib/aws-sdk-resources/services/sqs/queue_poller.rb +0 -521
 - data/lib/aws-sdk-resources/source.rb +0 -39
 
| 
         @@ -1,20 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Aws
         
     | 
| 
       2 
     | 
    
         
            -
              module Resources
         
     | 
| 
       3 
     | 
    
         
            -
                class Documenter
         
     | 
| 
       4 
     | 
    
         
            -
                  class OperationDocumenter < BaseOperationDocumenter
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                    def docstring
         
     | 
| 
       7 
     | 
    
         
            -
                      @api_request.documentation
         
     | 
| 
       8 
     | 
    
         
            -
                    end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                    def return_tag
         
     | 
| 
       11 
     | 
    
         
            -
                      @yard_client_operation.tags.each do |tag|
         
     | 
| 
       12 
     | 
    
         
            -
                        return tag if tag.tag_name == 'return'
         
     | 
| 
       13 
     | 
    
         
            -
                      end
         
     | 
| 
       14 
     | 
    
         
            -
                      nil
         
     | 
| 
       15 
     | 
    
         
            -
                    end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,53 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Aws
         
     | 
| 
       2 
     | 
    
         
            -
              module Resources
         
     | 
| 
       3 
     | 
    
         
            -
                class Documenter
         
     | 
| 
       4 
     | 
    
         
            -
                  class ResourceOperationDocumenter < BaseOperationDocumenter
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                    def initialize(*args)
         
     | 
| 
       7 
     | 
    
         
            -
                      super
         
     | 
| 
       8 
     | 
    
         
            -
                      @plural = @operation.builder.plural?
         
     | 
| 
       9 
     | 
    
         
            -
                    end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                    # @return [Boolean] Returns `true` if this operation returns an
         
     | 
| 
       12 
     | 
    
         
            -
                    #   array of resource objects. Returns `false` if this method returns
         
     | 
| 
       13 
     | 
    
         
            -
                    #   a single resource object.
         
     | 
| 
       14 
     | 
    
         
            -
                    attr_reader :plural
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                    alias plural? plural
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    def return_tag
         
     | 
| 
       19 
     | 
    
         
            -
                      if plural?
         
     | 
| 
       20 
     | 
    
         
            -
                        tag("@return [Array<#{target_resource_class_name}>]")
         
     | 
| 
       21 
     | 
    
         
            -
                      else
         
     | 
| 
       22 
     | 
    
         
            -
                        tag("@return [#{target_resource_class_name}]")
         
     | 
| 
       23 
     | 
    
         
            -
                      end
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    def example_tags
         
     | 
| 
       27 
     | 
    
         
            -
                      id = target_resource_class.identifiers.last.to_s
         
     | 
| 
       28 
     | 
    
         
            -
                      idv = target_resource_class_name.downcase + '-' + id.gsub('_', '-')
         
     | 
| 
       29 
     | 
    
         
            -
                      example = []
         
     | 
| 
       30 
     | 
    
         
            -
                      example << "@example Basic usage"
         
     | 
| 
       31 
     | 
    
         
            -
                      example << "  #{resp_variable} = #{variable_name}.#{operation_name}(options)"
         
     | 
| 
       32 
     | 
    
         
            -
                      if plural?
         
     | 
| 
       33 
     | 
    
         
            -
                        example << "  #{resp_variable}.map(&:#{id})"
         
     | 
| 
       34 
     | 
    
         
            -
                        example << "  #=> [#{idv.inspect}, ...]"
         
     | 
| 
       35 
     | 
    
         
            -
                      else
         
     | 
| 
       36 
     | 
    
         
            -
                        example << "  #{resp_variable}.#{id}"
         
     | 
| 
       37 
     | 
    
         
            -
                        example << "  #=> #{idv.inspect}"
         
     | 
| 
       38 
     | 
    
         
            -
                      end
         
     | 
| 
       39 
     | 
    
         
            -
                      super + [tag(example.join("\n"))]
         
     | 
| 
       40 
     | 
    
         
            -
                    end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                    def resp_variable
         
     | 
| 
       43 
     | 
    
         
            -
                      if plural?
         
     | 
| 
       44 
     | 
    
         
            -
                        target_resource_class_name.downcase + 's'
         
     | 
| 
       45 
     | 
    
         
            -
                      else
         
     | 
| 
       46 
     | 
    
         
            -
                        target_resource_class_name.downcase
         
     | 
| 
       47 
     | 
    
         
            -
                      end
         
     | 
| 
       48 
     | 
    
         
            -
                    end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,77 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Aws
         
     | 
| 
       2 
     | 
    
         
            -
              module Resources
         
     | 
| 
       3 
     | 
    
         
            -
                class Documenter
         
     | 
| 
       4 
     | 
    
         
            -
                  class WaiterOperationDocumenter < BaseOperationDocumenter
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                    def docstring
         
     | 
| 
       7 
     | 
    
         
            -
                      super + ' ' + <<-DOCSTRING.lstrip
         
     | 
| 
       8 
     | 
    
         
            -
            Waits until this #{resource_class_name} is #{state}. This method
         
     | 
| 
       9 
     | 
    
         
            -
            waits by polling {Client##{api_request_name}} until successful. An error is
         
     | 
| 
       10 
     | 
    
         
            -
            raised after a configurable number of failed checks.
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            This waiter uses the following defaults:
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            | Configuration   | Default                |
         
     | 
| 
       15 
     | 
    
         
            -
            |-----------------|------------------------|
         
     | 
| 
       16 
     | 
    
         
            -
            | `#delay`        | #{waiter.delay}        |
         
     | 
| 
       17 
     | 
    
         
            -
            | `#max_attempts` | #{waiter.max_attempts} |
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            You can modify defaults and register callbacks by passing a block argument.
         
     | 
| 
       20 
     | 
    
         
            -
            @yieldparam [Waiters::Waiter] waiter
         
     | 
| 
       21 
     | 
    
         
            -
            @raise [Waiters::Errors::WaiterFailed]
         
     | 
| 
       22 
     | 
    
         
            -
            @see Client#wait_until
         
     | 
| 
       23 
     | 
    
         
            -
                      DOCSTRING
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    def return_tag
         
     | 
| 
       27 
     | 
    
         
            -
                      tag("@return [#{resource_class_name}] #{return_message}")
         
     | 
| 
       28 
     | 
    
         
            -
                    end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                    def return_message
         
     | 
| 
       31 
     | 
    
         
            -
                      if @operation.path
         
     | 
| 
       32 
     | 
    
         
            -
                        "Returns a copy of this #{resource_class_name} with loaded data."
         
     | 
| 
       33 
     | 
    
         
            -
                      else
         
     | 
| 
       34 
     | 
    
         
            -
                        "Returns a copy of this #{resource_class_name} that is not loaded."
         
     | 
| 
       35 
     | 
    
         
            -
                      end
         
     | 
| 
       36 
     | 
    
         
            -
                    end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                    def state
         
     | 
| 
       39 
     | 
    
         
            -
                      operation_name.to_s.sub('wait_until_', '')
         
     | 
| 
       40 
     | 
    
         
            -
                    end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                    def waiter
         
     | 
| 
       43 
     | 
    
         
            -
                      @resource_class.client_class.waiters.waiter(@operation.waiter_name)
         
     | 
| 
       44 
     | 
    
         
            -
                    end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                    def api_request
         
     | 
| 
       47 
     | 
    
         
            -
                      @resource_class.client_class.api.operation(api_request_name)
         
     | 
| 
       48 
     | 
    
         
            -
                    end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                    def api_request_name
         
     | 
| 
       51 
     | 
    
         
            -
                      waiter.poller.operation_name
         
     | 
| 
       52 
     | 
    
         
            -
                    end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                    def option_tags
         
     | 
| 
       55 
     | 
    
         
            -
                      []
         
     | 
| 
       56 
     | 
    
         
            -
                    end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                    def example_tags
         
     | 
| 
       59 
     | 
    
         
            -
                      example = <<-EXAMPLE.strip
         
     | 
| 
       60 
     | 
    
         
            -
            @example Basic usage
         
     | 
| 
       61 
     | 
    
         
            -
              #{variable_name}.#{operation_name}
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            @example Modify default configuration
         
     | 
| 
       64 
     | 
    
         
            -
              #{variable_name}.#{operation_name} do |w|
         
     | 
| 
       65 
     | 
    
         
            -
                 w.interval = 10
         
     | 
| 
       66 
     | 
    
         
            -
                 w.max_attempts = 100
         
     | 
| 
       67 
     | 
    
         
            -
                 w.before_attempt { |count| ... }
         
     | 
| 
       68 
     | 
    
         
            -
                 w.before_wait do { |count, prev_resp| ... }
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
                      EXAMPLE
         
     | 
| 
       71 
     | 
    
         
            -
                      [tag(example)]
         
     | 
| 
       72 
     | 
    
         
            -
                    end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  end
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
              end
         
     | 
| 
       77 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,83 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Aws
         
     | 
| 
       2 
     | 
    
         
            -
              module Resources
         
     | 
| 
       3 
     | 
    
         
            -
                module OperationMethods
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                  # @param [Symbol] name
         
     | 
| 
       6 
     | 
    
         
            -
                  # @return [Operation] Returns the named operation.
         
     | 
| 
       7 
     | 
    
         
            -
                  # @raise [Errors::UnknownOperationError]
         
     | 
| 
       8 
     | 
    
         
            -
                  def operation(name)
         
     | 
| 
       9 
     | 
    
         
            -
                    @operations[name.to_sym] or
         
     | 
| 
       10 
     | 
    
         
            -
                      raise Errors::UnknownOperationError.new(name)
         
     | 
| 
       11 
     | 
    
         
            -
                  end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                  # @param [Symbol] method_name
         
     | 
| 
       14 
     | 
    
         
            -
                  # @param [Operation] operation
         
     | 
| 
       15 
     | 
    
         
            -
                  # @return [void]
         
     | 
| 
       16 
     | 
    
         
            -
                  def add_operation(method_name, operation = nil, &definition)
         
     | 
| 
       17 
     | 
    
         
            -
                    operation = definition if block_given?
         
     | 
| 
       18 
     | 
    
         
            -
                    safe_define_method(method_name) do |*args, &block|
         
     | 
| 
       19 
     | 
    
         
            -
                      operation.call(resource:self, args:args, block:block)
         
     | 
| 
       20 
     | 
    
         
            -
                    end
         
     | 
| 
       21 
     | 
    
         
            -
                    @operations[method_name.to_sym] = operation
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  # @return [Hash]
         
     | 
| 
       25 
     | 
    
         
            -
                  def operations(&block)
         
     | 
| 
       26 
     | 
    
         
            -
                    @operations.dup
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                  # @return [Array<Symbol>]
         
     | 
| 
       30 
     | 
    
         
            -
                  def operation_names
         
     | 
| 
       31 
     | 
    
         
            -
                    @operations.keys.sort
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
       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.sort
         
     | 
| 
       58 
     | 
    
         
            -
                  end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                  # @api private
         
     | 
| 
       61 
     | 
    
         
            -
                  def inherited(subclass)
         
     | 
| 
       62 
     | 
    
         
            -
                    subclass.send(:instance_variable_set, "@operations", {})
         
     | 
| 
       63 
     | 
    
         
            -
                    subclass.send(:instance_variable_set, "@batch_operations", {})
         
     | 
| 
       64 
     | 
    
         
            -
                  end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                  private
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                  def safe_define_method(method_name, &block)
         
     | 
| 
       69 
     | 
    
         
            -
                    if
         
     | 
| 
       70 
     | 
    
         
            -
                      instance_methods.include?(method_name.to_sym) &&
         
     | 
| 
       71 
     | 
    
         
            -
                      ENV['AWS_SDK_SAFE_DEFINE']
         
     | 
| 
       72 
     | 
    
         
            -
                    then
         
     | 
| 
       73 
     | 
    
         
            -
                      msg = "unable to define method #{name}##{method_name}, "
         
     | 
| 
       74 
     | 
    
         
            -
                      msg << "method already exists"
         
     | 
| 
       75 
     | 
    
         
            -
                      raise Errors::DefinitionError, msg
         
     | 
| 
       76 
     | 
    
         
            -
                    else
         
     | 
| 
       77 
     | 
    
         
            -
                      define_method(method_name, &block)
         
     | 
| 
       78 
     | 
    
         
            -
                    end
         
     | 
| 
       79 
     | 
    
         
            -
                  end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                end
         
     | 
| 
       82 
     | 
    
         
            -
              end
         
     | 
| 
       83 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,280 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Aws
         
     | 
| 
       2 
     | 
    
         
            -
              module Resources
         
     | 
| 
       3 
     | 
    
         
            -
                module Operations
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                  # Base class for operations. An operation is any object that responds
         
     | 
| 
       6 
     | 
    
         
            -
                  # to `#call` receiving a hash of options including:
         
     | 
| 
       7 
     | 
    
         
            -
                  #
         
     | 
| 
       8 
     | 
    
         
            -
                  # * `:resource` - The resource object the operation is invoked against.
         
     | 
| 
       9 
     | 
    
         
            -
                  # * `:args` - An array of arguments given by the caller
         
     | 
| 
       10 
     | 
    
         
            -
                  # * `:block` - An optional block argument
         
     | 
| 
       11 
     | 
    
         
            -
                  #
         
     | 
| 
       12 
     | 
    
         
            -
                  class Base
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                    include Options
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       17 
     | 
    
         
            -
                      @source = options[:source]
         
     | 
| 
       18 
     | 
    
         
            -
                    end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                    # @return [Source, nil]
         
     | 
| 
       21 
     | 
    
         
            -
                    attr_reader :source
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  # Makes an API request using the resource client, returning the client
         
     | 
| 
       26 
     | 
    
         
            -
                  # response.  Most operation classes extend this basic operation.
         
     | 
| 
       27 
     | 
    
         
            -
                  class Operation < Base
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                    # @option options [required, Request] :request
         
     | 
| 
       30 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       31 
     | 
    
         
            -
                      @request = option(:request, options)
         
     | 
| 
       32 
     | 
    
         
            -
                      super
         
     | 
| 
       33 
     | 
    
         
            -
                    end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                    # @return [Request]
         
     | 
| 
       36 
     | 
    
         
            -
                    attr_reader :request
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                    # @option (see Base#call)
         
     | 
| 
       39 
     | 
    
         
            -
                    # @return [Seahorse::Client::Response]
         
     | 
| 
       40 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       41 
     | 
    
         
            -
                      @request.call(options)
         
     | 
| 
       42 
     | 
    
         
            -
                    end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                  class LoadOperation < Operation
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                    # @option options [required, Request] :request
         
     | 
| 
       49 
     | 
    
         
            -
                    # @option options [required, String<JMESPath>] :path
         
     | 
| 
       50 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       51 
     | 
    
         
            -
                      @path = option(:path, options)
         
     | 
| 
       52 
     | 
    
         
            -
                      super
         
     | 
| 
       53 
     | 
    
         
            -
                    end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                    # @return [String<JMESPath>]
         
     | 
| 
       56 
     | 
    
         
            -
                    attr_reader :path
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                    # @option (see Base#call)
         
     | 
| 
       59 
     | 
    
         
            -
                    # @return [Object] Returns the value resolved to by {#path}.
         
     | 
| 
       60 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       61 
     | 
    
         
            -
                      extract(super)
         
     | 
| 
       62 
     | 
    
         
            -
                    end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                    private
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                    def extract(resp)
         
     | 
| 
       67 
     | 
    
         
            -
                      JMESPath.search(@path, resp.data)
         
     | 
| 
       68 
     | 
    
         
            -
                    end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                  end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                  class ResourceOperation < Operation
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                    # @option options [required, Request] :request
         
     | 
| 
       75 
     | 
    
         
            -
                    # @option options [required, Builder] :builder
         
     | 
| 
       76 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       77 
     | 
    
         
            -
                      @builder = option(:builder, options)
         
     | 
| 
       78 
     | 
    
         
            -
                      super
         
     | 
| 
       79 
     | 
    
         
            -
                    end
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                    # @return [Builder]
         
     | 
| 
       82 
     | 
    
         
            -
                    attr_reader :builder
         
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
                    # @option (see Base#call)
         
     | 
| 
       85 
     | 
    
         
            -
                    # @return [Resource, Array<Resource>]
         
     | 
| 
       86 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       87 
     | 
    
         
            -
                      @builder.build(options.merge(response:super))
         
     | 
| 
       88 
     | 
    
         
            -
                    end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
                  end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                  class HasManyOperation < ResourceOperation
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                    # @option options [required, Request] :request
         
     | 
| 
       95 
     | 
    
         
            -
                    # @option options [required, Builder] :builder
         
     | 
| 
       96 
     | 
    
         
            -
                    # @option options [Symbol] :limit_key
         
     | 
| 
       97 
     | 
    
         
            -
                    def initialize(options)
         
     | 
| 
       98 
     | 
    
         
            -
                      @limit_key = options[:limit_key]
         
     | 
| 
       99 
     | 
    
         
            -
                      super
         
     | 
| 
       100 
     | 
    
         
            -
                    end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                    # @return [Builder]
         
     | 
| 
       103 
     | 
    
         
            -
                    attr_reader :builder
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                    # @return [Symbol, nil]
         
     | 
| 
       106 
     | 
    
         
            -
                    attr_reader :limit_key
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                    # @option (see Base#call)
         
     | 
| 
       109 
     | 
    
         
            -
                    # @return [Collection]
         
     | 
| 
       110 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       111 
     | 
    
         
            -
                      validate_args!(options)
         
     | 
| 
       112 
     | 
    
         
            -
                      Collection.new(self, options)
         
     | 
| 
       113 
     | 
    
         
            -
                    end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                    # @api private
         
     | 
| 
       116 
     | 
    
         
            -
                    # @return [Enumerator<Batch>]
         
     | 
| 
       117 
     | 
    
         
            -
                    def batches(options, &block)
         
     | 
| 
       118 
     | 
    
         
            -
                      if options[:limit]
         
     | 
| 
       119 
     | 
    
         
            -
                        enum_for(:limited_batches, options[:limit], options, &block)
         
     | 
| 
       120 
     | 
    
         
            -
                      else
         
     | 
| 
       121 
     | 
    
         
            -
                        enum_for(:all_batches, options, &block)
         
     | 
| 
       122 
     | 
    
         
            -
                      end
         
     | 
| 
       123 
     | 
    
         
            -
                    end
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                    private
         
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                    def validate_args!(options)
         
     | 
| 
       128 
     | 
    
         
            -
                      args = options[:args]
         
     | 
| 
       129 
     | 
    
         
            -
                      unless args.count == 0 || args.count == 1
         
     | 
| 
       130 
     | 
    
         
            -
                        msg = "wrong number of arguments (given #{args.count}, expected 0..1)"
         
     | 
| 
       131 
     | 
    
         
            -
                        raise ArgumentError, msg
         
     | 
| 
       132 
     | 
    
         
            -
                      end
         
     | 
| 
       133 
     | 
    
         
            -
                      unless args[0].nil? || Hash === args[0]
         
     | 
| 
       134 
     | 
    
         
            -
                        raise ArgumentError, "expected Hash, got #{args[0].class}"
         
     | 
| 
       135 
     | 
    
         
            -
                      end
         
     | 
| 
       136 
     | 
    
         
            -
                    end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
                    def all_batches(options, &block)
         
     | 
| 
       139 
     | 
    
         
            -
                      resp = @request.call(options)
         
     | 
| 
       140 
     | 
    
         
            -
                      if resp.respond_to?(:each)
         
     | 
| 
       141 
     | 
    
         
            -
                        resp.each do |response|
         
     | 
| 
       142 
     | 
    
         
            -
                          yield(@builder.build(options.merge(response:response)))
         
     | 
| 
       143 
     | 
    
         
            -
                        end
         
     | 
| 
       144 
     | 
    
         
            -
                      else
         
     | 
| 
       145 
     | 
    
         
            -
                        yield(@builder.build(options.merge(response:resp)))
         
     | 
| 
       146 
     | 
    
         
            -
                      end
         
     | 
| 
       147 
     | 
    
         
            -
                    end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                    def limited_batches(limit, options, &block)
         
     | 
| 
       150 
     | 
    
         
            -
                      remaining = limit
         
     | 
| 
       151 
     | 
    
         
            -
                      all_batches(options) do |batch|
         
     | 
| 
       152 
     | 
    
         
            -
                        if batch.size < remaining
         
     | 
| 
       153 
     | 
    
         
            -
                          yield(batch)
         
     | 
| 
       154 
     | 
    
         
            -
                          remaining -= batch.size
         
     | 
| 
       155 
     | 
    
         
            -
                        else
         
     | 
| 
       156 
     | 
    
         
            -
                          yield(batch.first(remaining))
         
     | 
| 
       157 
     | 
    
         
            -
                          return
         
     | 
| 
       158 
     | 
    
         
            -
                        end
         
     | 
| 
       159 
     | 
    
         
            -
                      end
         
     | 
| 
       160 
     | 
    
         
            -
                    end
         
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
                  end
         
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
                  class HasOperation < Base
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
                    # @option options [required, Builder] :builder
         
     | 
| 
       167 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       168 
     | 
    
         
            -
                      @builder = option(:builder, options)
         
     | 
| 
       169 
     | 
    
         
            -
                      super
         
     | 
| 
       170 
     | 
    
         
            -
                    end
         
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
       172 
     | 
    
         
            -
                    # @return [Builder]
         
     | 
| 
       173 
     | 
    
         
            -
                    attr_reader :builder
         
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
                    # @option (see Base#call)
         
     | 
| 
       176 
     | 
    
         
            -
                    # @return [Resource]
         
     | 
| 
       177 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       178 
     | 
    
         
            -
                      if argc(options) == arity
         
     | 
| 
       179 
     | 
    
         
            -
                        @builder.build(options)
         
     | 
| 
       180 
     | 
    
         
            -
                      else
         
     | 
| 
       181 
     | 
    
         
            -
                        msg = "wrong number of arguments (#{argc(options)} for #{arity})"
         
     | 
| 
       182 
     | 
    
         
            -
                        raise ArgumentError, msg
         
     | 
| 
       183 
     | 
    
         
            -
                      end
         
     | 
| 
       184 
     | 
    
         
            -
                    end
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
                    def arity
         
     | 
| 
       187 
     | 
    
         
            -
                      @builder.sources.count { |s| BuilderSources::Argument === s }
         
     | 
| 
       188 
     | 
    
         
            -
                    end
         
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
                    private
         
     | 
| 
       191 
     | 
    
         
            -
             
     | 
| 
       192 
     | 
    
         
            -
                    def argc(options)
         
     | 
| 
       193 
     | 
    
         
            -
                      (options[:args] || []).count
         
     | 
| 
       194 
     | 
    
         
            -
                    end
         
     | 
| 
       195 
     | 
    
         
            -
             
     | 
| 
       196 
     | 
    
         
            -
                  end
         
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
                  class WaiterOperation < Base
         
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
                    include Options
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       203 
     | 
    
         
            -
                      @waiter_name = option(:waiter_name, options)
         
     | 
| 
       204 
     | 
    
         
            -
                      @waiter_params = option(:waiter_params, options)
         
     | 
| 
       205 
     | 
    
         
            -
                      @path = options[:path]
         
     | 
| 
       206 
     | 
    
         
            -
                      super
         
     | 
| 
       207 
     | 
    
         
            -
                    end
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
                    # @return [Symbol]
         
     | 
| 
       210 
     | 
    
         
            -
                    attr_reader :waiter_name
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
                    # @return [Array<RequestParams::Base>]
         
     | 
| 
       213 
     | 
    
         
            -
                    attr_reader :waiter_params
         
     | 
| 
       214 
     | 
    
         
            -
             
     | 
| 
       215 
     | 
    
         
            -
                    # @return [String<JMESPathExpression>, nil]
         
     | 
| 
       216 
     | 
    
         
            -
                    attr_reader :path
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
                    # @option options [required,Resource] :resource
         
     | 
| 
       219 
     | 
    
         
            -
                    # @option options [required,Array<Mixed>] :args
         
     | 
| 
       220 
     | 
    
         
            -
                    def call(options)
         
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
                      resource = options[:resource]
         
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
       224 
     | 
    
         
            -
                      params_hash = options[:args].first || {}
         
     | 
| 
       225 
     | 
    
         
            -
                      @waiter_params.each do |param|
         
     | 
| 
       226 
     | 
    
         
            -
                        param.apply(params_hash, options)
         
     | 
| 
       227 
     | 
    
         
            -
                      end
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
                      resp = resource.client.wait_until(@waiter_name, params_hash, &options[:block])
         
     | 
| 
       230 
     | 
    
         
            -
             
     | 
| 
       231 
     | 
    
         
            -
                      resource_opts = resource.identifiers.dup
         
     | 
| 
       232 
     | 
    
         
            -
                      if @path && resp.respond_to?(:data)
         
     | 
| 
       233 
     | 
    
         
            -
                        resource_opts[:data] = JMESPath.search(@path, resp.data)
         
     | 
| 
       234 
     | 
    
         
            -
                      end
         
     | 
| 
       235 
     | 
    
         
            -
                      resource_opts[:client] = resource.client
         
     | 
| 
       236 
     | 
    
         
            -
                      resource.class.new(resource_opts)
         
     | 
| 
       237 
     | 
    
         
            -
                    end
         
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
       239 
     | 
    
         
            -
                  end
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
                  # @api private
         
     | 
| 
       242 
     | 
    
         
            -
                  class DeprecatedOperation
         
     | 
| 
       243 
     | 
    
         
            -
             
     | 
| 
       244 
     | 
    
         
            -
                    def initialize(options = {})
         
     | 
| 
       245 
     | 
    
         
            -
                      @name = options[:name]
         
     | 
| 
       246 
     | 
    
         
            -
                      @deprecated_name = options[:deprecated_name]
         
     | 
| 
       247 
     | 
    
         
            -
                      @resource_class = options[:resource_class]
         
     | 
| 
       248 
     | 
    
         
            -
                      @operation = @resource_class.batch_operation(@name)
         
     | 
| 
       249 
     | 
    
         
            -
                      @warned = false
         
     | 
| 
       250 
     | 
    
         
            -
                    end
         
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
                    def call(*args)
         
     | 
| 
       253 
     | 
    
         
            -
                      unless @warned
         
     | 
| 
       254 
     | 
    
         
            -
                        @warned = true
         
     | 
| 
       255 
     | 
    
         
            -
                        warn(deprecation_warning)
         
     | 
| 
       256 
     | 
    
         
            -
                      end
         
     | 
| 
       257 
     | 
    
         
            -
                      @operation.call(*args)
         
     | 
| 
       258 
     | 
    
         
            -
                    end
         
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
                    private
         
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
                    def deprecation_warning
         
     | 
| 
       263 
     | 
    
         
            -
                      "DEPRECATION WARNING: called deprecated batch method " +
         
     | 
| 
       264 
     | 
    
         
            -
                      "`##{@deprecated_name}` on a batch of `#{@resource_class.name}` " +
         
     | 
| 
       265 
     | 
    
         
            -
                      "objects; use `##{@name}` instead"
         
     | 
| 
       266 
     | 
    
         
            -
                    end
         
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
                    class << self
         
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
                      def define(options = {})
         
     | 
| 
       271 
     | 
    
         
            -
                        klass = options[:resource_class]
         
     | 
| 
       272 
     | 
    
         
            -
                        deprecated_name = options[:deprecated_name]
         
     | 
| 
       273 
     | 
    
         
            -
                        klass.add_batch_operation(deprecated_name, new(options))
         
     | 
| 
       274 
     | 
    
         
            -
                      end
         
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
                    end
         
     | 
| 
       277 
     | 
    
         
            -
                  end
         
     | 
| 
       278 
     | 
    
         
            -
                end
         
     | 
| 
       279 
     | 
    
         
            -
              end
         
     | 
| 
       280 
     | 
    
         
            -
            end
         
     |