Skip to content
Snippets Groups Projects

Add Google Cloud Compute services

Merged Pedro Pombeiro requested to merge pedropombeiro/438315/add-services into master
All threads resolved!
Compare and Show latest version
3 files
+ 49
19
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -3,6 +3,8 @@
@@ -3,6 +3,8 @@
module GoogleCloudPlatform
module GoogleCloudPlatform
module Compute
module Compute
class ListMachineTypesService < ::GoogleCloudPlatform::Compute::BaseService
class ListMachineTypesService < ::GoogleCloudPlatform::Compute::BaseService
 
extend ::Gitlab::Utils::Override
 
MAX_RESULTS_LIMIT = 500
MAX_RESULTS_LIMIT = 500
MISSING_ZONE_ERROR_MESSAGE = 'Zone value must be provided'
MISSING_ZONE_ERROR_MESSAGE = 'Zone value must be provided'
@@ -23,13 +25,6 @@ def initialize(project:, current_user:, zone:, filter: nil, max_results: nil, pa
@@ -23,13 +25,6 @@ def initialize(project:, current_user:, zone:, filter: nil, max_results: nil, pa
def execute
def execute
return before_execute if before_execute.error?
return before_execute if before_execute.error?
return ServiceResponse.error(message: MISSING_ZONE_ERROR_MESSAGE) if zone.blank?
return ServiceResponse.error(message: INVALID_ORDER_BY_ERROR_MESSAGE) unless valid_order_by?(order_by)
unless (1..MAX_RESULTS_LIMIT).cover?(max_results)
return ServiceResponse.error(message: MAX_RESULTS_OUT_OF_BOUNDS)
end
handling_client_errors do
handling_client_errors do
machine_types = client.machine_types(
machine_types = client.machine_types(
zone: zone,
zone: zone,
@@ -44,6 +39,21 @@ def execute
@@ -44,6 +39,21 @@ def execute
})
})
end
end
end
end
 
 
private
 
 
override :before_execute
 
def before_execute
 
return super if super.error?
 
return ServiceResponse.error(message: MISSING_ZONE_ERROR_MESSAGE) if zone.blank?
 
return ServiceResponse.error(message: INVALID_ORDER_BY_ERROR_MESSAGE) unless valid_order_by?(order_by)
 
 
unless (1..MAX_RESULTS_LIMIT).cover?(max_results)
 
return ServiceResponse.error(message: MAX_RESULTS_OUT_OF_BOUNDS)
 
end
 
 
ServiceResponse.success
 
end
end
end
end
end
end
end
Loading