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, #error, #execute, #process_response, #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



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

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:



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

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