Class: Google::Apis::StorageV1::StorageService

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/storage/service.rb

Instance Method Summary collapse

Instance Method Details

#execute_or_queue_command_with_response(command, &callback) ⇒ Object

Returns a two-element array containing:

  • The result that is the usual return type of #execute_or_queue_command.
  • The http_resp from DownloadCommand#execute_once.


602
603
604
605
606
607
608
609
610
611
# File 'lib/google/cloud/storage/service.rb', line 602

def execute_or_queue_command_with_response(command, &callback)
  batch_command = current_batch
  if batch_command
    raise "Can not combine services in a batch" if Thread.current[:google_api_batch_service] != self
    batch_command.add(command, &callback)
    nil
  else
    command.execute_with_response(client, &callback)
  end
end

#get_object_with_response(bucket, object, generation: nil, if_generation_match: nil, if_generation_not_match: nil, if_metageneration_match: nil, if_metageneration_not_match: nil, projection: nil, user_project: nil, fields: nil, quota_user: nil, user_ip: nil, download_dest: nil, options: nil, &block) ⇒ Object

Returns a two-element array containing:

  • The result that is the usual return type of #get_object.
  • The http_resp from DownloadCommand#execute_once.


575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/google/cloud/storage/service.rb', line 575

def get_object_with_response(bucket, object, generation: nil, if_generation_match: nil, if_generation_not_match: nil, if_metageneration_match: nil, if_metageneration_not_match: nil, projection: nil, user_project: nil, fields: nil, quota_user: nil, user_ip: nil, download_dest: nil, options: nil, &block)
  if download_dest.nil?
    command =  make_simple_command(:get, 'b/{bucket}/o/{object}', options)
  else
    command = make_download_command(:get, 'b/{bucket}/o/{object}', options)
    command.download_dest = download_dest
  end
  command.response_representation = Google::Apis::StorageV1::Object::Representation
  command.response_class = Google::Apis::StorageV1::Object
  command.params['bucket'] = bucket unless bucket.nil?
  command.params['object'] = object unless object.nil?
  command.query['generation'] = generation unless generation.nil?
  command.query['ifGenerationMatch'] = if_generation_match unless if_generation_match.nil?
  command.query['ifGenerationNotMatch'] = if_generation_not_match unless if_generation_not_match.nil?
  command.query['ifMetagenerationMatch'] = if_metageneration_match unless if_metageneration_match.nil?
  command.query['ifMetagenerationNotMatch'] = if_metageneration_not_match unless if_metageneration_not_match.nil?
  command.query['projection'] = projection unless projection.nil?
  command.query['userProject'] = user_project unless user_project.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  command.query['userIp'] = user_ip unless user_ip.nil?
  execute_or_queue_command_with_response(command, &block)
end