diff --git a/google-cloud-storage/lib/google/cloud/storage/service.rb b/google-cloud-storage/lib/google/cloud/storage/service.rb index fd87490a5c62..52410e3a3609 100644 --- a/google-cloud-storage/lib/google/cloud/storage/service.rb +++ b/google-cloud-storage/lib/google/cloud/storage/service.rb @@ -72,6 +72,7 @@ def initialize project, credentials, retries: nil, @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.request_options.add_idempotency_token_header = true @service.authorization = @credentials.client if @credentials @service.root_url = host if host @service.universe_domain = universe_domain || Google::Cloud::Storage.configure.universe_domain diff --git a/google-cloud-storage/test/google/cloud/storage/project_test.rb b/google-cloud-storage/test/google/cloud/storage/project_test.rb index c07bff384157..1383a2374cec 100644 --- a/google-cloud-storage/test/google/cloud/storage/project_test.rb +++ b/google-cloud-storage/test/google/cloud/storage/project_test.rb @@ -67,6 +67,13 @@ def creds.is_a? target _(project.universe_domain).must_equal "googleapis.com" end + it "enables invocation id and idempotency token header request options by default" do + service = Google::Cloud::Storage::Service.new "my-project", default_credentials + _(service.service.request_options.add_invocation_id_header).must_equal true + _(service.service.request_options.add_idempotency_token_header).must_equal true + end + + it "supports setting a universe domain argument" do service = Google::Cloud::Storage::Service.new "my-project", default_credentials, universe_domain: "mydomain1.com" _(service.universe_domain).must_equal "mydomain1.com"