Class: Google::Apis::Core::BatchCommand

Inherits:
HttpCommand show all
Defined in:
lib/google/apis/core/batch.rb

Overview

Wrapper request for batching multiple calls in a single server request

Direct Known Subclasses

BatchUploadCommand

Constant Summary collapse

MULTIPART_MIXED =
'multipart/mixed'

Constants inherited from HttpCommand

HttpCommand::RETRIABLE_ERRORS

Instance Attribute Summary

Attributes inherited from HttpCommand

#body, #connection, #header, #method, #options, #params, #query, #url

Instance Method Summary collapse

Methods inherited from HttpCommand

#allow_form_encoding?, #apply_request_options, #authorization_refreshable?, #check_status, #do_retry, #error, #execute, #process_response, #set_api_version_header, #success

Methods included from Logging

#logger

Constructor Details

#initialize(method, url) ⇒ BatchCommand

Returns a new instance of BatchCommand.

Parameters:

  • method (symbol)

    HTTP method

  • url (String, Addressable::URI, Addressable::Template)

    HTTP URL or template



48
49
50
51
52
# File 'lib/google/apis/core/batch.rb', line 48

def initialize(method, url)
  super(method, url)
  @calls = []
  @base_id = SecureRandom.uuid
end

Instance Method Details

#add(call) {|result, err| ... } ⇒ Google::Apis::Core::BatchCommand

Add a new call to the batch request.

Parameters:

Yields:

  • (result, err)

    Result & error when response available

Returns:



60
61
62
63
64
# File 'lib/google/apis/core/batch.rb', line 60

def add(call, &block)
  ensure_valid_command(call)
  @calls << [call, block]
  self
end