summaryrefslogtreecommitdiff
path: root/lib/google_api
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-01 00:54:22 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-01 00:54:22 +0900
commite499c1c39dbea505858874ee47436641df3d93d4 (patch)
treebce2333e86abfbdba7e55d15bb1fe8e432657832 /lib/google_api
parentc30546f4aa073f44e97b49f47c57a9a89062c3c6 (diff)
downloadgitlab-ce-e499c1c39dbea505858874ee47436641df3d93d4.tar.gz
Replace reactive_cache by multipel sidekiq workers
Diffstat (limited to 'lib/google_api')
-rw-r--r--lib/google_api/auth.rb (renamed from lib/google_api/authentication.rb)2
-rw-r--r--lib/google_api/cloud_platform/client.rb28
2 files changed, 11 insertions, 19 deletions
diff --git a/lib/google_api/authentication.rb b/lib/google_api/auth.rb
index 4c9016e1085..92787b87ac6 100644
--- a/lib/google_api/authentication.rb
+++ b/lib/google_api/auth.rb
@@ -1,5 +1,5 @@
module GoogleApi
- class Authentication
+ class Auth
attr_reader :access_token, :redirect_uri, :state
ConfigMissingError = Class.new(StandardError)
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index 0bc306a24e6..74ae5e16ab2 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -2,9 +2,9 @@ require 'google/apis/container_v1'
module GoogleApi
module CloudPlatform
- class Client < GoogleApi::Authentication
+ class Client < GoogleApi::Auth
class << self
- def token_in_session
+ def session_key_for_token
:cloud_platform_access_token
end
end
@@ -13,20 +13,14 @@ module GoogleApi
'https://www.googleapis.com/auth/cloud-platform'
end
- ##
- # Exception
- # Google::Apis::ClientError:
- # Google::Apis::AuthorizationError:
- ##
-
def projects_zones_clusters_get(project_id, zone, cluster_id)
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
begin
cluster = service.get_zone_cluster(project_id, zone, cluster_id)
- rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
- return nil
+ rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
+ return e
end
puts "#{self.class.name} - #{__callee__}: cluster: #{cluster.inspect}"
@@ -35,7 +29,7 @@ module GoogleApi
# Responce exmaple
# TODO: machine_type : Defailt 3.75 GB
- def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size:, machine_type:)
+ def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:)
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
@@ -50,8 +44,8 @@ module GoogleApi
begin
operation = service.create_cluster(project_id, zone, request_body)
- rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
- return nil
+ rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
+ return e
end
puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}"
@@ -65,17 +59,15 @@ module GoogleApi
begin
operation = service.get_zone_operation(project_id, zone, operation_id)
rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
- return nil
+ return e
end
puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}"
operation
end
- def parse_self_link(self_link)
- ret = self_link.match(/projects\/(.*)\/zones\/(.*)\/operations\/(.*)/)
-
- return ret[1], ret[2], ret[3] # project_id, zone, operation_id
+ def parse_operation_id(self_link)
+ self_link.match(/projects\/.*\/zones\/.*\/operations\/(.*)/)[1]
end
end
end