fog-google 1.7.1 → 1.8.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/.rubocop.yml +3 -0
- data/.travis.yml +0 -3
- data/CHANGELOG.md +45 -1
- data/CONTRIBUTING.md +11 -5
- data/README.md +0 -2
- data/fog-google.gemspec +4 -5
- data/lib/fog/bin/google.rb +4 -0
- data/lib/fog/compute/google/models/addresses.rb +9 -3
- data/lib/fog/compute/google/models/backend_services.rb +3 -2
- data/lib/fog/compute/google/models/disk_types.rb +5 -6
- data/lib/fog/compute/google/models/disks.rb +10 -4
- data/lib/fog/compute/google/models/firewalls.rb +3 -2
- data/lib/fog/compute/google/models/forwarding_rules.rb +8 -12
- data/lib/fog/compute/google/models/global_addresses.rb +3 -2
- data/lib/fog/compute/google/models/global_forwarding_rules.rb +3 -2
- data/lib/fog/compute/google/models/http_health_checks.rb +4 -3
- data/lib/fog/compute/google/models/images.rb +23 -12
- data/lib/fog/compute/google/models/instance_group_managers.rb +10 -7
- data/lib/fog/compute/google/models/instance_groups.rb +21 -15
- data/lib/fog/compute/google/models/instance_templates.rb +3 -2
- data/lib/fog/compute/google/models/machine_types.rb +13 -4
- data/lib/fog/compute/google/models/networks.rb +3 -2
- data/lib/fog/compute/google/models/operations.rb +8 -8
- data/lib/fog/compute/google/models/projects.rb +3 -2
- data/lib/fog/compute/google/models/regions.rb +3 -2
- data/lib/fog/compute/google/models/routes.rb +3 -2
- data/lib/fog/compute/google/models/servers.rb +7 -7
- data/lib/fog/compute/google/models/snapshots.rb +5 -4
- data/lib/fog/compute/google/models/ssl_certificates.rb +4 -3
- data/lib/fog/compute/google/models/subnetworks.rb +13 -7
- data/lib/fog/compute/google/models/target_http_proxies.rb +3 -2
- data/lib/fog/compute/google/models/target_https_proxies.rb +3 -2
- data/lib/fog/compute/google/models/target_instances.rb +8 -8
- data/lib/fog/compute/google/models/target_pools.rb +7 -10
- data/lib/fog/compute/google/models/url_maps.rb +3 -2
- data/lib/fog/compute/google/models/zones.rb +4 -2
- data/lib/fog/compute/google/real.rb +2 -0
- data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +1 -2
- data/lib/fog/dns/google/real.rb +1 -0
- data/lib/fog/google/models/sql/instances.rb +4 -1
- data/lib/fog/google/monitoring/real.rb +1 -0
- data/lib/fog/google/pubsub/real.rb +1 -0
- data/lib/fog/google/shared.rb +15 -1
- data/lib/fog/google/sql/real.rb +1 -0
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/storage/google_json/real.rb +2 -0
- data/test/helpers/integration_test_helper.rb +2 -0
- data/test/helpers/test_collection.rb +26 -3
- data/test/integration/compute/core_compute/test_client_options.rb +12 -0
- data/test/integration/compute/core_compute/test_disk_types.rb +9 -0
- data/test/integration/compute/core_compute/test_images.rb +21 -0
- data/test/integration/compute/core_compute/test_machine_types.rb +13 -0
- data/test/integration/compute/core_compute/test_operations.rb +19 -1
- data/test/integration/compute/instance_groups/test_instance_group_managers.rb +1 -1
- data/test/integration/factories/addresses_factory.rb +4 -0
- data/test/integration/factories/collection_factory.rb +1 -1
- data/test/integration/factories/disks_factory.rb +4 -0
- data/test/integration/factories/forwarding_rules_factory.rb +4 -0
- data/test/integration/factories/images_factory.rb +4 -0
- data/test/integration/factories/instance_group_manager_factory.rb +8 -0
- data/test/integration/factories/instance_groups_factory.rb +4 -0
- data/test/integration/factories/servers_factory.rb +8 -0
- data/test/integration/factories/subnetworks_factory.rb +4 -0
- data/test/integration/factories/target_instances_factory.rb +4 -0
- data/test/integration/factories/target_pools_factory.rb +4 -0
- data/test/unit/compute/test_common_collections.rb +19 -8
- data/test/unit/compute/test_common_models.rb +10 -11
- data/test/unit/compute/test_server.rb +2 -1
- data/test/unit/dns/test_common_collections.rb +43 -0
- data/test/unit/monitoring/test_comon_collections.rb +44 -0
- data/test/unit/pubsub/test_common_collections.rb +35 -0
- data/test/unit/sql/test_common_collections.rb +46 -0
- data/test/unit/storage/test_common_json_collections.rb +38 -0
- data/test/unit/storage/test_common_xml_collections.rb +39 -0
- metadata +33 -27
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
instance_template = service.get_instance_template(identity).to_h
|
15
|
+
return new(instance_template)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -23,10 +23,19 @@ module Fog
|
|
23
23
|
load(data.map(&:to_h) || [])
|
24
24
|
end
|
25
25
|
|
26
|
-
def get(identity, zone)
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def get(identity, zone = nil)
|
27
|
+
if zone
|
28
|
+
machine_type = service.get_machine_type(identity, zone).to_h
|
29
|
+
return new(machine_type)
|
30
|
+
elsif identity
|
31
|
+
# This isn't very functional since it just shows the first available
|
32
|
+
# machine type globally, but needed due to overall compatibility
|
33
|
+
# See: https://github.com/fog/fog-google/issues/352
|
34
|
+
response = all(:filter => "name eq #{identity}",
|
35
|
+
:max_results => 1)
|
36
|
+
machine_type = response.first unless response.empty?
|
37
|
+
return machine_type
|
38
|
+
end
|
30
39
|
rescue ::Google::Apis::ClientError => e
|
31
40
|
raise e unless e.status_code == 404
|
32
41
|
nil
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
network = service.get_network(identity).to_h
|
15
|
+
return new(network)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -16,7 +16,7 @@ module Fog
|
|
16
16
|
if zone
|
17
17
|
data = service.list_zone_operations(zone, opts).to_h[:items]
|
18
18
|
elsif region
|
19
|
-
data = service.list_region_operations(
|
19
|
+
data = service.list_region_operations(region, opts).to_h[:items]
|
20
20
|
else
|
21
21
|
data = service.list_global_operations(opts).to_h[:items]
|
22
22
|
end
|
@@ -26,15 +26,15 @@ module Fog
|
|
26
26
|
|
27
27
|
def get(identity, zone = nil, region = nil)
|
28
28
|
if !zone.nil?
|
29
|
-
|
29
|
+
operation = service.get_zone_operation(zone, identity).to_h
|
30
|
+
return new(operation)
|
30
31
|
elsif !region.nil?
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
operation = service.get_region_operation(region, identity).to_h
|
33
|
+
return new(operation)
|
34
|
+
elsif identity
|
35
|
+
operation = service.get_global_operation(identity).to_h
|
36
|
+
return new(operation)
|
34
37
|
end
|
35
|
-
|
36
|
-
return nil if response.nil?
|
37
|
-
new(response.to_h)
|
38
38
|
rescue ::Google::Apis::ClientError => e
|
39
39
|
raise e unless e.status_code == 404
|
40
40
|
nil
|
@@ -5,8 +5,9 @@ module Fog
|
|
5
5
|
model Fog::Compute::Google::Project
|
6
6
|
|
7
7
|
def get(identity)
|
8
|
-
if
|
9
|
-
|
8
|
+
if identity
|
9
|
+
project = service.get_project(identity).to_h
|
10
|
+
return new(project)
|
10
11
|
end
|
11
12
|
rescue ::Google::Apis::ClientError => e
|
12
13
|
raise e unless e.status_code == 404
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
region = service.get_region(identity).to_h
|
15
|
+
return new(region)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
route = service.get_route(identity).to_h
|
15
|
+
return new(route)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -28,15 +28,15 @@ module Fog
|
|
28
28
|
|
29
29
|
# TODO: This method needs to take self_links as well as names
|
30
30
|
def get(identity, zone = nil)
|
31
|
-
response = nil
|
32
31
|
if zone
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
response =
|
32
|
+
server = service.get_server(identity, zone).to_h
|
33
|
+
return new(server)
|
34
|
+
elsif identity
|
35
|
+
response = all(:filter => "name eq .*#{identity}",
|
36
|
+
:max_results => 1)
|
37
|
+
server = response.first unless response.empty?
|
38
|
+
return server
|
37
39
|
end
|
38
|
-
return nil if response.nil?
|
39
|
-
new(response)
|
40
40
|
rescue ::Google::Apis::ClientError => e
|
41
41
|
raise e unless e.status_code == 404
|
42
42
|
nil
|
@@ -17,10 +17,11 @@ module Fog
|
|
17
17
|
load(items)
|
18
18
|
end
|
19
19
|
|
20
|
-
def get(
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def get(identity)
|
21
|
+
if identity
|
22
|
+
snapshot = service.get_snapshot(identity).to_h
|
23
|
+
return new(snapshot)
|
24
|
+
end
|
24
25
|
rescue ::Google::Apis::ClientError => e
|
25
26
|
raise e unless e.status_code == 404
|
26
27
|
nil
|
@@ -4,9 +4,10 @@ module Fog
|
|
4
4
|
class SslCertificates < Fog::Collection
|
5
5
|
model Fog::Compute::Google::SslCertificate
|
6
6
|
|
7
|
-
def get(
|
8
|
-
if
|
9
|
-
|
7
|
+
def get(identity)
|
8
|
+
if identity
|
9
|
+
ssl_certificate = service.get_ssl_certificate(identity).to_h
|
10
|
+
return new(ssl_certificate)
|
10
11
|
end
|
11
12
|
rescue ::Google::Apis::ClientError => e
|
12
13
|
raise e unless e.status_code == 404
|
@@ -12,20 +12,26 @@ module Fog
|
|
12
12
|
:page_token => page_token
|
13
13
|
}
|
14
14
|
|
15
|
-
if region
|
15
|
+
if region
|
16
|
+
data = service.list_subnetworks(region, filters).to_h[:items] || []
|
17
|
+
else
|
16
18
|
data = []
|
17
19
|
service.list_aggregated_subnetworks(filters).to_h[:items].each_value do |region_obj|
|
18
20
|
data.concat(region_obj[:subnetworks]) if region_obj[:subnetworks]
|
19
21
|
end
|
20
|
-
else
|
21
|
-
data = service.list_subnetworks(region, filters).to_h[:items]
|
22
22
|
end
|
23
|
-
load(data
|
23
|
+
load(data)
|
24
24
|
end
|
25
25
|
|
26
|
-
def get(identity, region)
|
27
|
-
if
|
28
|
-
|
26
|
+
def get(identity, region = nil)
|
27
|
+
if region
|
28
|
+
subnetwork = service.get_subnetwork(identity, region).to_h
|
29
|
+
return new(subnetwork)
|
30
|
+
elsif identity
|
31
|
+
response = all(:filter => "name eq #{identity}",
|
32
|
+
:max_results => 1)
|
33
|
+
subnetwork = response.first unless response.empty?
|
34
|
+
return subnetwork
|
29
35
|
end
|
30
36
|
rescue ::Google::Apis::ClientError => e
|
31
37
|
raise e unless e.status_code == 404
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
target_http_proxy = service.get_target_http_proxy(identity).to_h
|
15
|
+
return new(target_http_proxy)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
target_https_proxy = service.get_target_https_proxy(identity).to_h
|
15
|
+
return new(target_https_proxy)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -26,16 +26,16 @@ module Fog
|
|
26
26
|
load(data)
|
27
27
|
end
|
28
28
|
|
29
|
-
def get(
|
30
|
-
response = nil
|
29
|
+
def get(identity, zone = nil)
|
31
30
|
if zone
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
response =
|
31
|
+
target_instance = service.get_target_instance(target_instance, zone).to_h
|
32
|
+
return new(target_instance)
|
33
|
+
elsif identity
|
34
|
+
response = all(:filter => "name eq #{identity}",
|
35
|
+
:max_results => 1)
|
36
|
+
target_instance = response.first unless response.empty?
|
37
|
+
return target_instance
|
36
38
|
end
|
37
|
-
return nil if response.nil?
|
38
|
-
new(response)
|
39
39
|
rescue ::Google::Apis::ClientError => e
|
40
40
|
raise e unless e.status_code == 404
|
41
41
|
nil
|
@@ -25,17 +25,14 @@ module Fog
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def get(identity, region = nil)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
response = service.get_target_pool(identity, region).to_h
|
28
|
+
if region
|
29
|
+
target_pool = service.get_target_pool(identity, region).to_h
|
30
|
+
return new(target_pool)
|
31
|
+
elsif identity
|
32
|
+
response = all(:filter => "name eq #{identity}")
|
33
|
+
target_pool = response.first unless response.empty?
|
34
|
+
return target_pool
|
36
35
|
end
|
37
|
-
return nil if response.nil?
|
38
|
-
new(response)
|
39
36
|
rescue ::Google::Apis::ClientError => e
|
40
37
|
raise e unless e.status_code = 404
|
41
38
|
nil
|
@@ -10,8 +10,9 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
if
|
14
|
-
|
13
|
+
if identity
|
14
|
+
url_map = service.get_url_map(identity).to_h
|
15
|
+
return new(url_map)
|
15
16
|
end
|
16
17
|
rescue ::Google::Apis::ClientError => e
|
17
18
|
raise e unless e.status_code == 404
|
@@ -10,8 +10,10 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(identity)
|
13
|
-
|
14
|
-
|
13
|
+
if identity
|
14
|
+
zone = service.get_zone(identity).to_h
|
15
|
+
new(zone)
|
16
|
+
end
|
15
17
|
rescue ::Google::Apis::ClientError => e
|
16
18
|
raise e unless e.status_code == 404
|
17
19
|
nil
|
data/lib/fog/dns/google/real.rb
CHANGED
@@ -23,7 +23,10 @@ module Fog
|
|
23
23
|
# @return [Fog::Google::SQL::Instance] Instance resource
|
24
24
|
def get(instance_id)
|
25
25
|
instance = service.get_instance(instance_id).to_h
|
26
|
-
if
|
26
|
+
# XXX if we pass `nil` to get() it returns empty DB object with
|
27
|
+
# kind set to "sql#instancesList"
|
28
|
+
# see https://github.com/google/google-api-ruby-client/issues/699
|
29
|
+
if instance[:kind].eql?("sql#instance")
|
27
30
|
new(instance)
|
28
31
|
end
|
29
32
|
rescue ::Google::Apis::ClientError => e
|
data/lib/fog/google/shared.rb
CHANGED
@@ -30,7 +30,7 @@ module Fog
|
|
30
30
|
# @option options [String] :app_name The app name to set in the user agent
|
31
31
|
# @option options [String] :app_version The app version to set in the user agent
|
32
32
|
# @option options [Google::APIClient] :google_client Existing Google API Client
|
33
|
-
# @option options [Hash] :google_client_options A hash to send
|
33
|
+
# @option options [Hash] :google_client_options A hash to send additional options to Google API Client
|
34
34
|
# @return [Google::APIClient] Google API Client
|
35
35
|
# @raises [ArgumentError] If there is any missing argument
|
36
36
|
def initialize_google_client(options)
|
@@ -119,6 +119,20 @@ module Fog
|
|
119
119
|
auth
|
120
120
|
end
|
121
121
|
|
122
|
+
##
|
123
|
+
# Applies given options to the client instance
|
124
|
+
#
|
125
|
+
# @param [Google::Apis::Core::BaseService] service API service client instance
|
126
|
+
# @param [Hash] google_client_options Service client options to apply
|
127
|
+
# @param [Hash] _ignored Rest of the options (for convenience, ignored)
|
128
|
+
# @return [void]
|
129
|
+
def apply_client_options(service, google_client_options: nil, **_ignored)
|
130
|
+
return if google_client_options.nil? || google_client_options.empty?
|
131
|
+
(service.client_options.members & google_client_options.keys).each do |option|
|
132
|
+
service.client_options[option] = google_client_options[option]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
122
136
|
##
|
123
137
|
# Executes a request and wraps it in a result object
|
124
138
|
#
|
data/lib/fog/google/sql/real.rb
CHANGED
data/lib/fog/google/version.rb
CHANGED
@@ -15,6 +15,8 @@ module Fog
|
|
15
15
|
|
16
16
|
@client = initialize_google_client(options)
|
17
17
|
@storage_json = ::Google::Apis::StorageV1::StorageService.new
|
18
|
+
apply_client_options(@storage_json, options)
|
19
|
+
|
18
20
|
@storage_json.client_options.open_timeout_sec = options[:open_timeout_sec] if options[:open_timeout_sec]
|
19
21
|
@storage_json.client_options.read_timeout_sec = options[:read_timeout_sec] if options[:read_timeout_sec]
|
20
22
|
@storage_json.client_options.send_timeout_sec = options[:send_timeout_sec] if options[:send_timeout_sec]
|
@@ -17,6 +17,8 @@ TEST_REGION = "us-central1".freeze
|
|
17
17
|
TEST_SIZE_GB = 10
|
18
18
|
TEST_MACHINE_TYPE = "n1-standard-1".freeze
|
19
19
|
TEST_IMAGE = "debian-9-stretch-v20180611".freeze
|
20
|
+
TEST_IMAGE_PROJECT = "debian-cloud".freeze
|
21
|
+
TEST_IMAGE_FAMILY = "debian-9".freeze
|
20
22
|
|
21
23
|
# XXX This depends on a public image in gs://fog-test-bucket; there may be a better way to do this
|
22
24
|
# The image was created like so: https://cloud.google.com/compute/docs/images#export_an_image_to_google_cloud_storage
|
@@ -13,8 +13,26 @@ module TestCollection
|
|
13
13
|
assert_includes @subject.all.map(&:identity), one.identity
|
14
14
|
assert_includes @subject.all.map(&:identity), two.identity
|
15
15
|
|
16
|
-
assert_equal one.identity, @
|
17
|
-
assert_equal two.identity, @
|
16
|
+
assert_equal one.identity, @subject.get(one.identity).identity
|
17
|
+
assert_equal two.identity, @subject.get(two.identity).identity
|
18
|
+
|
19
|
+
# Some factories that have scoped parameters (zone, region) have a special
|
20
|
+
# `get` method defined in the factory to pass the correct parameters in
|
21
|
+
if @factory.respond_to?(:get)
|
22
|
+
assert_equal one.identity, @factory.get(one.identity).identity
|
23
|
+
assert_equal two.identity, @factory.get(two.identity).identity
|
24
|
+
end
|
25
|
+
|
26
|
+
# Some factories that have scoped parameters (zone, region) have a special
|
27
|
+
# `all` method defined in the factory to pass the correct parameters in
|
28
|
+
if @factory.respond_to?(:all)
|
29
|
+
subject_list = @subject.all
|
30
|
+
scoped_subject_list = @factory.all
|
31
|
+
|
32
|
+
# Assert that whatever .all(scope) returns is a subset of .all
|
33
|
+
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
34
|
+
"Output of @factory.all must be a subset of @subject.all")
|
35
|
+
end
|
18
36
|
|
19
37
|
one.destroy
|
20
38
|
two.destroy
|
@@ -24,13 +42,18 @@ module TestCollection
|
|
24
42
|
end
|
25
43
|
|
26
44
|
def test_get_returns_nil_if_resource_does_not_exist
|
27
|
-
assert_nil @factory.get("fog-test-fake-identity")
|
45
|
+
assert_nil @factory.get("fog-test-fake-identity") if @factory.respond_to?(:get)
|
46
|
+
assert_nil @subject.get("fog-test-fake-identity")
|
28
47
|
end
|
29
48
|
|
30
49
|
def test_enumerable
|
31
50
|
assert_respond_to @subject, :each
|
32
51
|
end
|
33
52
|
|
53
|
+
def test_nil_get
|
54
|
+
assert_nil @subject.get(nil)
|
55
|
+
end
|
56
|
+
|
34
57
|
def teardown
|
35
58
|
@factory.cleanup
|
36
59
|
end
|