class Google::Cloud::Storage::Service
def initialize project, credentials, retries: nil,
Creates a new Service instance.
#
def initialize project, credentials, retries: nil, timeout: nil, open_timeout: nil, read_timeout: nil, send_timeout: nil, host: nil, quota_project: nil, max_elapsed_time: nil, base_interval: nil, max_interval: nil, multiplier: nil, upload_chunk_size: nil, universe_domain: nil host ||= Google::Cloud::Storage.configure.endpoint @project = project @credentials = credentials @service = API::StorageService.new @service.client_options.application_name = "gcloud-ruby" @service.client_options.application_version = Google::Cloud::Storage::VERSION @service.client_options.open_timeout_sec = (open_timeout || timeout) @service.client_options.read_timeout_sec = (read_timeout || timeout) @service.client_options.send_timeout_sec = (send_timeout || timeout) @service.client_options.transparent_gzip_decompression = false @service.request_options.retries = retries || 3 @service.request_options.header ||= {} @service.request_options.header["x-goog-api-client"] = "gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Storage::VERSION}" @service.request_options.header["Accept-Encoding"] = "gzip" @service.request_options.quota_project = quota_project if quota_project @service.request_options.max_elapsed_time = max_elapsed_time if max_elapsed_time @service.request_options.base_interval = base_interval if base_interval @service.request_options.max_interval = max_interval if max_interval @service.request_options.multiplier = multiplier if multiplier @service.request_options.add_invocation_id_header = true @service.request_options.upload_chunk_size = upload_chunk_size if upload_chunk_size @service.authorization = @credentials.client if @credentials @service.root_url = host if host @service.universe_domain = universe_domain || Google::Cloud::Storage.configure.universe_domain begin @service.verify_universe_domain! rescue Google::Apis::UniverseDomainError => e # TODO: Create a Google::Cloud::Error subclass for this. raise Google::Cloud::Error, e.message end end