fog-google 1.29.4 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/integration-compute-core.yml +1 -1
- data/.github/workflows/integration-compute-instance_groups.yml +1 -1
- data/.github/workflows/integration-compute-loadbalancing.yml +1 -1
- data/.github/workflows/integration-compute-networking.yml +1 -1
- data/.github/workflows/integration-monitoring.yml +1 -1
- data/.github/workflows/integration-pubsub.yml +1 -1
- data/.github/workflows/integration-sql.yml +1 -1
- data/.github/workflows/integration-storage.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/CHANGELOG.md +17 -0
- data/README.md +19 -0
- data/examples/create_instance_and_attach_disk_later.rb +1 -1
- data/examples/get_list_images.rb +4 -0
- data/examples/get_list_snapshots.rb +2 -0
- data/examples/image_create.rb +7 -5
- data/examples/load-balance.rb +9 -9
- data/fog-google.gemspec +8 -8
- data/lib/fog/google/compute/models/operation.rb +54 -14
- data/lib/fog/google/compute/models/server.rb +11 -0
- data/lib/fog/google/shared.rb +62 -3
- data/lib/fog/google/storage/storage_json/models/files.rb +2 -1
- data/lib/fog/google/storage/storage_json/real.rb +2 -4
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/google.rb +11 -11
- metadata +830 -783
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5707c2bd16c0b9a132ecb218caa372be41d15798747099789b8db1d660e67bea
|
|
4
|
+
data.tar.gz: ee7584a9655e9031130109d598dd06a247734b03348f8b114b94dffbe5882802
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 08e52b304fc2d4ba285272c99be0f86781c2c4a242d51a7da3ba2b650164afeda25ab148ed0b7ae8223f72214b71726631c29611d85a792070ab3e2823a9862c
|
|
7
|
+
data.tar.gz: 9e28c95456d9bc6a49ba68f663d921f81c2bb3c7bdc3b61c7262babccde8fc770aafdf2979b6528622610c9e671110e4194134bf5266f293227b168ebd7801d5
|
data/.github/workflows/unit.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1
|
|
|
4
4
|
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 1.30.0
|
|
8
|
+
|
|
9
|
+
### User-facing
|
|
10
|
+
|
|
11
|
+
- #663 Apply `connection_options` timeouts (`connect_timeout`, `read_timeout`, `write_timeout`) to storage and IAM requests, and to OAuth2 token requests for credentials fog creates
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- #660 Keep options given to `StorageJSON::Files#all` for subsequent pages
|
|
16
|
+
- #661 Raise an exception if errors occur during server creation
|
|
17
|
+
|
|
18
|
+
### Development changes
|
|
19
|
+
|
|
20
|
+
- #662 Update pry requirement to 0.16.1
|
|
21
|
+
- #659 Bump actions/checkout from 6 to 7
|
|
22
|
+
- Fix RuboCop offenses in lib, gemspec, examples and tests
|
|
23
|
+
|
|
7
24
|
## 1.29.4
|
|
8
25
|
|
|
9
26
|
- #657 Fix handling of universe domains with service key
|
data/README.md
CHANGED
|
@@ -155,6 +155,25 @@ development:
|
|
|
155
155
|
google_cloud_storage_bucket_name: your-bucket-name
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
+
#### Timeouts
|
|
159
|
+
|
|
160
|
+
By default, storage requests use the HTTP client's timeouts (60 seconds to connect, for example). To fail faster, set timeouts in seconds with `connection_options`, which uses the same keys as other fog providers:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
Fog::Storage.new(
|
|
164
|
+
provider: 'Google',
|
|
165
|
+
google_project: 'my-project',
|
|
166
|
+
google_json_key_location: '/path/to/key.json',
|
|
167
|
+
connection_options: { connect_timeout: 10, read_timeout: 30, write_timeout: 60 }
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`open_timeout_sec`, `read_timeout_sec` and `send_timeout_sec` also work and take precedence. The timeouts also apply to OAuth2 token requests for credentials that fog creates. They don't apply to:
|
|
172
|
+
|
|
173
|
+
- Credentials passed in with `google_auth`.
|
|
174
|
+
- Tokens from the GCE metadata server.
|
|
175
|
+
- External account credentials (Workload Identity Federation) and impersonated service account credentials from application default credentials. googleauth builds these without the connection fog configures and has no public way to set it afterwards.
|
|
176
|
+
|
|
158
177
|
#### SSH-ing into instances
|
|
159
178
|
|
|
160
179
|
If you want to be able to bootstrap SSH-able instances, (using `servers.bootstrap`,) be sure you have a key in `~/.ssh/id_rsa` and `~/.ssh/id_rsa.pub`
|
|
@@ -74,7 +74,7 @@ def example
|
|
|
74
74
|
|
|
75
75
|
p "Waiting for second disk to be destroyed"
|
|
76
76
|
begin
|
|
77
|
-
|
|
77
|
+
attached_disk.wait_for { status.nil? || status == "DELETING" }
|
|
78
78
|
rescue StandardError => e
|
|
79
79
|
if e.message !~ /not found/ && e.message !~ /notFound/
|
|
80
80
|
raise e
|
data/examples/get_list_images.rb
CHANGED
|
@@ -13,18 +13,21 @@ def test
|
|
|
13
13
|
puts "---------------------------------"
|
|
14
14
|
images = connection.images.all
|
|
15
15
|
raise "Could not LIST the images" unless images
|
|
16
|
+
|
|
16
17
|
puts images.inspect
|
|
17
18
|
|
|
18
19
|
puts "Listing current (non-deprecated) images in all projects..."
|
|
19
20
|
puts "----------------------------------------------------------"
|
|
20
21
|
images = connection.images.current
|
|
21
22
|
raise "Could not LIST current images" unless images
|
|
23
|
+
|
|
22
24
|
puts images.inspect
|
|
23
25
|
|
|
24
26
|
puts "Fetching a single image from a global project..."
|
|
25
27
|
puts "------------------------------------------------"
|
|
26
28
|
img = connection.images.get("debian-11-bullseye-v20220920")
|
|
27
29
|
raise "Could not GET the image" unless img
|
|
30
|
+
|
|
28
31
|
puts img.inspect
|
|
29
32
|
|
|
30
33
|
# First, get the name of an image that is in the users 'project' (not global)
|
|
@@ -35,6 +38,7 @@ def test
|
|
|
35
38
|
puts "----------------------------------------------"
|
|
36
39
|
img = connection.images.get(custom_img_name.name)
|
|
37
40
|
raise "Could not GET the (custom) image" unless img
|
|
41
|
+
|
|
38
42
|
puts img.inspect
|
|
39
43
|
end
|
|
40
44
|
end
|
|
@@ -13,6 +13,7 @@ def test
|
|
|
13
13
|
puts "---------------------------------"
|
|
14
14
|
snapshots = connection.snapshots.all
|
|
15
15
|
raise "Could not LIST the snapshots" unless snapshots
|
|
16
|
+
|
|
16
17
|
puts snapshots.inspect
|
|
17
18
|
|
|
18
19
|
puts "Fetching a single snapshot..."
|
|
@@ -21,6 +22,7 @@ def test
|
|
|
21
22
|
unless snap.nil?
|
|
22
23
|
snap = connection.snapshots.get(snap)
|
|
23
24
|
raise "Could not GET the snapshot" unless snap
|
|
25
|
+
|
|
24
26
|
puts snap.inspect
|
|
25
27
|
end
|
|
26
28
|
end
|
data/examples/image_create.rb
CHANGED
|
@@ -2,16 +2,18 @@ def test
|
|
|
2
2
|
connection = Fog::Compute.new(:provider => "Google")
|
|
3
3
|
|
|
4
4
|
rawdisk = {
|
|
5
|
-
|
|
5
|
+
# Google Cloud Storage URL pointing to the disk image. (e.g. http://storage.googleapis.com/test/test.tar.gz)
|
|
6
|
+
:source => nil,
|
|
6
7
|
:container_type => "TAR"
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
# Can't test this unless the 'source' points to a valid URL
|
|
10
11
|
return if rawdisk[:source].nil?
|
|
11
12
|
|
|
12
|
-
img = connection.images.create(:name
|
|
13
|
-
:description
|
|
14
|
-
:raw_disk
|
|
13
|
+
img = connection.images.create(:name => "test-image",
|
|
14
|
+
:description => "Test image (via fog)",
|
|
15
|
+
:raw_disk => rawdisk)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
# will raise if image was not saved correctly
|
|
18
|
+
img.reload
|
|
17
19
|
end
|
data/examples/load-balance.rb
CHANGED
|
@@ -27,7 +27,7 @@ def test
|
|
|
27
27
|
:source_image => "debian-11-bullseye-v20220920"
|
|
28
28
|
)
|
|
29
29
|
disk.wait_for { disk.ready? }
|
|
30
|
-
rescue
|
|
30
|
+
rescue StandardError
|
|
31
31
|
puts "Failed to create disk #{name}-#{i}"
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -39,7 +39,7 @@ def test
|
|
|
39
39
|
:zone_name => zone
|
|
40
40
|
)
|
|
41
41
|
servers << server
|
|
42
|
-
rescue
|
|
42
|
+
rescue StandardError
|
|
43
43
|
puts "Failed to create instance #{name}-#{i}"
|
|
44
44
|
end
|
|
45
45
|
end
|
|
@@ -49,7 +49,7 @@ def test
|
|
|
49
49
|
begin
|
|
50
50
|
health = gce.http_health_checks.new(:name => name)
|
|
51
51
|
health.save
|
|
52
|
-
rescue
|
|
52
|
+
rescue StandardError
|
|
53
53
|
puts "Failed to create health check #{name}"
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -63,7 +63,7 @@ def test
|
|
|
63
63
|
:instances => servers.map(&:self_link)
|
|
64
64
|
)
|
|
65
65
|
pool.save
|
|
66
|
-
rescue
|
|
66
|
+
rescue StandardError
|
|
67
67
|
puts "Failed to create target pool #{name}"
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -78,7 +78,7 @@ def test
|
|
|
78
78
|
:target => pool.self_link
|
|
79
79
|
)
|
|
80
80
|
rule.save
|
|
81
|
-
rescue
|
|
81
|
+
rescue StandardError
|
|
82
82
|
puts "Failed to create forwarding rule #{name}"
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -90,25 +90,25 @@ def test
|
|
|
90
90
|
puts "--------------------------------"
|
|
91
91
|
begin
|
|
92
92
|
rule.destroy
|
|
93
|
-
rescue
|
|
93
|
+
rescue StandardError
|
|
94
94
|
puts "Failed to clean up forwarding rule."
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
begin
|
|
98
98
|
pool.destroy
|
|
99
|
-
rescue
|
|
99
|
+
rescue StandardError
|
|
100
100
|
puts "Failed to clean up target pool."
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
begin
|
|
104
104
|
health.destroy
|
|
105
|
-
rescue
|
|
105
|
+
rescue StandardError
|
|
106
106
|
puts "Failed to clean up health check."
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
begin
|
|
110
110
|
servers.each(&:destroy)
|
|
111
|
-
rescue
|
|
111
|
+
rescue StandardError
|
|
112
112
|
puts "Failed to clean up instances."
|
|
113
113
|
end
|
|
114
114
|
end
|
data/fog-google.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lib = File.expand_path("
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require "fog/google/version"
|
|
4
4
|
|
|
@@ -17,19 +17,19 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.require_paths = ["lib"]
|
|
18
18
|
|
|
19
19
|
# As of 0.1.1
|
|
20
|
-
spec.required_ruby_version = ">= 2.
|
|
20
|
+
spec.required_ruby_version = ">= 2.3"
|
|
21
21
|
|
|
22
22
|
spec.add_dependency "fog-core", "~> 2.5"
|
|
23
23
|
spec.add_dependency "fog-json", "~> 1.2"
|
|
24
24
|
spec.add_dependency "fog-xml", "~> 0.1.0"
|
|
25
25
|
|
|
26
|
-
spec.add_dependency "google-apis-storage_v1", [">= 0.19", "< 1"]
|
|
27
|
-
spec.add_dependency "google-apis-iamcredentials_v1", "~> 0.15"
|
|
28
26
|
spec.add_dependency "google-apis-compute_v1", "~> 0.53"
|
|
29
|
-
spec.add_dependency "google-apis-monitoring_v3", "~> 0.37"
|
|
30
27
|
spec.add_dependency "google-apis-dns_v1", "~> 0.28"
|
|
28
|
+
spec.add_dependency "google-apis-iamcredentials_v1", "~> 0.15"
|
|
29
|
+
spec.add_dependency "google-apis-monitoring_v3", "~> 0.37"
|
|
31
30
|
spec.add_dependency "google-apis-pubsub_v1", "~> 0.30"
|
|
32
31
|
spec.add_dependency "google-apis-sqladmin_v1beta4", "~> 0.38"
|
|
32
|
+
spec.add_dependency "google-apis-storage_v1", [">= 0.19", "< 1"]
|
|
33
33
|
|
|
34
34
|
spec.add_dependency "google-cloud-env", ">= 1.2", "< 3.0"
|
|
35
35
|
|
|
@@ -38,14 +38,14 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
# Debugger
|
|
39
39
|
# Locked because pry-byebug is broken with 13+
|
|
40
40
|
# see: https://github.com/deivid-rodriguez/pry-byebug/issues/343
|
|
41
|
-
spec.add_development_dependency "pry", "= 0.16.
|
|
41
|
+
spec.add_development_dependency "pry", "= 0.16.1"
|
|
42
42
|
|
|
43
43
|
# Testing gems
|
|
44
|
-
spec.add_development_dependency "retriable"
|
|
45
|
-
spec.add_development_dependency "rake"
|
|
46
44
|
spec.add_development_dependency "minitest"
|
|
47
45
|
spec.add_development_dependency "minitest-mock"
|
|
48
46
|
spec.add_development_dependency "minitest-reporters"
|
|
47
|
+
spec.add_development_dependency "rake"
|
|
48
|
+
spec.add_development_dependency "retriable"
|
|
49
49
|
spec.add_development_dependency "shindo"
|
|
50
50
|
spec.add_development_dependency "vcr"
|
|
51
51
|
spec.add_development_dependency "webmock"
|
|
@@ -27,17 +27,6 @@ module Fog
|
|
|
27
27
|
attribute :zone
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
# {:errors=>
|
|
31
|
-
# [{:code=>"QUOTA_EXCEEDED",
|
|
32
|
-
# :error_details=>
|
|
33
|
-
# [{:quota_info=>
|
|
34
|
-
# {:dimensions=>{:region=>"us-east4"},
|
|
35
|
-
# :limit=>500,
|
|
36
|
-
# :limit_name=>"SSD-TOTAL-GB-per-project-region",
|
|
37
|
-
# :metric_name=>"compute.googleapis.com/ssd_total_storage"}}],
|
|
38
|
-
# :message=>"Quota 'SSD_TOTAL_GB' exceeded. Limit: 500.0 in region us-east4."}
|
|
39
|
-
# ]
|
|
40
|
-
# }
|
|
41
30
|
class ErrorInfo
|
|
42
31
|
attr_accessor :code
|
|
43
32
|
attr_accessor :error_details
|
|
@@ -56,6 +45,20 @@ module Fog
|
|
|
56
45
|
end
|
|
57
46
|
end # ErrorInfo
|
|
58
47
|
|
|
48
|
+
# {:errors => [
|
|
49
|
+
# {:code => "QUOTA_EXCEEDED",
|
|
50
|
+
# :error_details => [
|
|
51
|
+
# {:quota_info=>
|
|
52
|
+
# {:dimensions=>{:region=>"us-east4"},
|
|
53
|
+
# :limit=>500,
|
|
54
|
+
# :limit_name=>"SSD-TOTAL-GB-per-project-region",
|
|
55
|
+
# :metric_name=>"compute.googleapis.com/ssd_total_storage"
|
|
56
|
+
# }
|
|
57
|
+
# }
|
|
58
|
+
# ],
|
|
59
|
+
# :message=>"Quota 'SSD_TOTAL_GB' exceeded. Limit: 500.0 in region us-east4."
|
|
60
|
+
# }
|
|
61
|
+
# ]}
|
|
59
62
|
class QuotaInfo < ErrorInfo
|
|
60
63
|
def initialize(attributes = {})
|
|
61
64
|
code = attributes[:code]
|
|
@@ -93,6 +96,36 @@ module Fog
|
|
|
93
96
|
end
|
|
94
97
|
end # QuotaInfo
|
|
95
98
|
|
|
99
|
+
# {:errors => [
|
|
100
|
+
# {:code => "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS",
|
|
101
|
+
# :error_details => [
|
|
102
|
+
# {:help => {:links=>[{:description=>"Troubleshooting documentation", :url=>"https://cloud.google.com/compute/docs/resource-error"}]}},
|
|
103
|
+
# {:localized_message => {
|
|
104
|
+
# :locale=>"en-US",
|
|
105
|
+
# :message=> "A c3d-highmem-4 VM instance is currently unavailable in the us-east4-b zone. Try requesting the VM in another zone. For more information, view the troubleshooting documentation."
|
|
106
|
+
# }},
|
|
107
|
+
# {:error_info => {
|
|
108
|
+
# :domain=>"compute.googleapis.com",
|
|
109
|
+
# :metadatas=>{:attachment=>"", :vmType=>"c3d-highmem-4", :zone=>"us-east4-b", :zonesAvailable=>""},
|
|
110
|
+
# :reason=>"stockout"
|
|
111
|
+
# }}
|
|
112
|
+
# ],
|
|
113
|
+
# :message => "The zone 'projects/projname/zones/us-east4-b' does not have enough resources available to fulfill the request. '(resource type:compute)'."
|
|
114
|
+
# }
|
|
115
|
+
# ]}
|
|
116
|
+
class ResourcePoolInfo < ErrorInfo
|
|
117
|
+
def initialize(attributes = {})
|
|
118
|
+
code = attributes[:code]
|
|
119
|
+
raise Fog::Errors::Error.new("Invalid error code: #{code}") if code !~ /RESOURCE_POOL_EXHAUSTED/
|
|
120
|
+
|
|
121
|
+
super(attributes)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Placeholder in case there is a need for future message formatting
|
|
125
|
+
# def message_pretty
|
|
126
|
+
# end
|
|
127
|
+
end
|
|
128
|
+
|
|
96
129
|
|
|
97
130
|
def error?
|
|
98
131
|
! error.nil?
|
|
@@ -118,11 +151,18 @@ module Fog
|
|
|
118
151
|
zone.nil? ? nil : zone.split("/")[-1]
|
|
119
152
|
end
|
|
120
153
|
|
|
154
|
+
# https://docs.cloud.google.com/compute/docs/reference/rest/v1/errors
|
|
121
155
|
def error_info_class(code)
|
|
122
156
|
case code
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
157
|
+
when "QUOTA_EXCEEDED" then QuotaInfo
|
|
158
|
+
|
|
159
|
+
when "REGION_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS" then ResourcePoolInfo
|
|
160
|
+
when "RESOURCE_POOL_EXHAUSTED" then ResourcePoolInfo
|
|
161
|
+
when "ZONE_RESOURCE_POOL_EXHAUSTED" then ResourcePoolInfo
|
|
162
|
+
when "ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS" then ResourcePoolInfo
|
|
163
|
+
|
|
164
|
+
else
|
|
165
|
+
ErrorInfo
|
|
126
166
|
end
|
|
127
167
|
end
|
|
128
168
|
|
|
@@ -563,6 +563,17 @@ module Fog
|
|
|
563
563
|
.new(:service => service)
|
|
564
564
|
.get(data.name, data.zone)
|
|
565
565
|
operation.wait_for { ready? }
|
|
566
|
+
|
|
567
|
+
# Handle errors
|
|
568
|
+
if operation.error?
|
|
569
|
+
msg = "Error creating server #{name}."
|
|
570
|
+
|
|
571
|
+
err = operation.primary_error
|
|
572
|
+
msg = "#{msg} #{err.message_pretty}" unless err.nil?
|
|
573
|
+
|
|
574
|
+
raise Fog::Errors::Error.new(msg)
|
|
575
|
+
end
|
|
576
|
+
|
|
566
577
|
reload
|
|
567
578
|
end
|
|
568
579
|
|
data/lib/fog/google/shared.rb
CHANGED
|
@@ -74,16 +74,75 @@ module Fog
|
|
|
74
74
|
|
|
75
75
|
def initialize_auth(options)
|
|
76
76
|
if options[:google_json_key_location] || options[:google_json_key_string]
|
|
77
|
-
process_key_auth(options)
|
|
77
|
+
configure_auth_connection(process_key_auth(options), options)
|
|
78
78
|
elsif options[:google_auth]
|
|
79
79
|
options[:google_auth]
|
|
80
80
|
elsif options[:google_application_default]
|
|
81
|
-
process_application_default_auth(options)
|
|
81
|
+
configure_auth_connection(process_application_default_auth(options), options)
|
|
82
82
|
else
|
|
83
|
-
process_fallback_auth(options)
|
|
83
|
+
configure_auth_connection(process_fallback_auth(options), options)
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
##
|
|
88
|
+
# Returns the HTTP timeouts to use, in seconds.
|
|
89
|
+
#
|
|
90
|
+
# The :open_timeout_sec, :read_timeout_sec and :send_timeout_sec
|
|
91
|
+
# options take precedence. Otherwise, the Excon-style :connect_timeout,
|
|
92
|
+
# :read_timeout and :write_timeout keys in :connection_options are used,
|
|
93
|
+
# so the same settings work across fog providers.
|
|
94
|
+
#
|
|
95
|
+
# @param [Hash] options client options hash
|
|
96
|
+
# @return [Hash] any of :open_timeout_sec, :read_timeout_sec, :send_timeout_sec
|
|
97
|
+
def timeout_options(options)
|
|
98
|
+
connection_options = options[:connection_options] || {}
|
|
99
|
+
|
|
100
|
+
{
|
|
101
|
+
:open_timeout_sec => options[:open_timeout_sec] || connection_options[:connect_timeout],
|
|
102
|
+
:read_timeout_sec => options[:read_timeout_sec] || connection_options[:read_timeout],
|
|
103
|
+
:send_timeout_sec => options[:send_timeout_sec] || connection_options[:write_timeout]
|
|
104
|
+
}.compact
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Applies the HTTP timeouts to an API service client
|
|
109
|
+
#
|
|
110
|
+
# @param [Google::Apis::Core::BaseService] service API service client instance
|
|
111
|
+
# @param [Hash] options client options hash
|
|
112
|
+
# @return [void]
|
|
113
|
+
def apply_timeout_options(service, options)
|
|
114
|
+
timeout_options(options).each do |option, value|
|
|
115
|
+
service.client_options[option] = value
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
##
|
|
120
|
+
# Applies the HTTP timeouts to OAuth2 token requests made by credentials
|
|
121
|
+
# that fog created. Otherwise, token requests use the default Faraday
|
|
122
|
+
# connection, which ignores these timeouts. Credentials passed in with
|
|
123
|
+
# :google_auth are left as is. External account and impersonated service
|
|
124
|
+
# account credentials don't support configure_connection, so they keep
|
|
125
|
+
# googleauth's connection.
|
|
126
|
+
#
|
|
127
|
+
# @param [Google::Auth::Credentials, Signet::OAuth2::Client] auth credentials
|
|
128
|
+
# @param [Hash] options client options hash
|
|
129
|
+
# @return the credentials
|
|
130
|
+
def configure_auth_connection(auth, options)
|
|
131
|
+
timeouts = timeout_options(options)
|
|
132
|
+
return auth if timeouts.empty? || !auth.respond_to?(:configure_connection)
|
|
133
|
+
|
|
134
|
+
request_options = {
|
|
135
|
+
:open_timeout => timeouts[:open_timeout_sec],
|
|
136
|
+
:read_timeout => timeouts[:read_timeout_sec],
|
|
137
|
+
:write_timeout => timeouts[:send_timeout_sec]
|
|
138
|
+
}.compact
|
|
139
|
+
|
|
140
|
+
auth.configure_connection(
|
|
141
|
+
:connection_builder => -> { ::Faraday.new(:request => request_options) }
|
|
142
|
+
)
|
|
143
|
+
auth
|
|
144
|
+
end
|
|
145
|
+
|
|
87
146
|
##
|
|
88
147
|
# Applies given options to the client instance
|
|
89
148
|
#
|
|
@@ -17,7 +17,8 @@ module Fog
|
|
|
17
17
|
|
|
18
18
|
def all(options = {})
|
|
19
19
|
requires :directory
|
|
20
|
-
|
|
20
|
+
merge_attributes(options)
|
|
21
|
+
parent = service.list_objects(directory.key, attributes)
|
|
21
22
|
attributes[:next_page_token] = parent.next_page_token
|
|
22
23
|
data = parent.to_h[:items] || []
|
|
23
24
|
load(data)
|
|
@@ -24,10 +24,7 @@ module Fog
|
|
|
24
24
|
|
|
25
25
|
@storage_json = ::Google::Apis::StorageV1::StorageService.new
|
|
26
26
|
apply_client_options(@storage_json, options)
|
|
27
|
-
|
|
28
|
-
@storage_json.client_options.open_timeout_sec = options[:open_timeout_sec] if options[:open_timeout_sec]
|
|
29
|
-
@storage_json.client_options.read_timeout_sec = options[:read_timeout_sec] if options[:read_timeout_sec]
|
|
30
|
-
@storage_json.client_options.send_timeout_sec = options[:send_timeout_sec] if options[:send_timeout_sec]
|
|
27
|
+
apply_timeout_options(@storage_json, options)
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
def bucket_base_url
|
|
@@ -157,6 +154,7 @@ DATA
|
|
|
157
154
|
|
|
158
155
|
@iam_service = ::Google::Apis::IamcredentialsV1::IAMCredentialsService.new
|
|
159
156
|
apply_client_options(@iam_service, @options)
|
|
157
|
+
apply_timeout_options(@iam_service, @options)
|
|
160
158
|
iam_options = @options.merge(google_api_scope_url: GOOGLE_STORAGE_JSON_IAM_API_SCOPE_URLS.join(" "))
|
|
161
159
|
@iam_service.authorization = initialize_auth(iam_options)
|
|
162
160
|
@iam_service
|
data/lib/fog/google/version.rb
CHANGED
data/lib/fog/google.rb
CHANGED
|
@@ -5,16 +5,16 @@ require "fog/google/version"
|
|
|
5
5
|
|
|
6
6
|
module Fog
|
|
7
7
|
module Google
|
|
8
|
-
autoload :Compute, File.expand_path("
|
|
9
|
-
autoload :DNS, File.expand_path("
|
|
10
|
-
autoload :Mock, File.expand_path("
|
|
11
|
-
autoload :Monitoring, File.expand_path("
|
|
12
|
-
autoload :Pubsub, File.expand_path("
|
|
13
|
-
autoload :Shared, File.expand_path("
|
|
14
|
-
autoload :SQL, File.expand_path("
|
|
15
|
-
autoload :Storage, File.expand_path("
|
|
16
|
-
autoload :StorageJSON,
|
|
17
|
-
autoload :StorageXML,
|
|
8
|
+
autoload :Compute, File.expand_path("google/compute", __dir__)
|
|
9
|
+
autoload :DNS, File.expand_path("google/dns", __dir__)
|
|
10
|
+
autoload :Mock, File.expand_path("google/mock", __dir__)
|
|
11
|
+
autoload :Monitoring, File.expand_path("google/monitoring", __dir__)
|
|
12
|
+
autoload :Pubsub, File.expand_path("google/pubsub", __dir__)
|
|
13
|
+
autoload :Shared, File.expand_path("google/shared", __dir__)
|
|
14
|
+
autoload :SQL, File.expand_path("google/sql", __dir__)
|
|
15
|
+
autoload :Storage, File.expand_path("google/storage", __dir__)
|
|
16
|
+
autoload :StorageJSON, "fog/google/storage/storage_json"
|
|
17
|
+
autoload :StorageXML, "fog/google/storage/storage_xml"
|
|
18
18
|
|
|
19
19
|
extend Fog::Provider
|
|
20
20
|
|
|
@@ -36,7 +36,7 @@ module Fog
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
module Parsers
|
|
39
|
-
autoload :Storage,
|
|
39
|
+
autoload :Storage, "fog/google/parsers/storage"
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|