summaryrefslogtreecommitdiff
path: root/app/services/clusters/gcp/fetch_operation_service.rb
blob: 02c96a1e28642b0e18877c9560ad1beb916eb681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module Clusters
  module Gcp
    class FetchOperationService
      def execute(provider)
        operation = provider.api_client.projects_zones_operations(
          provider.gcp_project_id,
          provider.zone,
          provider.operation_id)

        yield(operation) if block_given?
      rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
        provider.make_errored!("Failed to request to CloudPlatform; #{e.message}")
      end
    end
  end
end