require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb' require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_job_pb' require_relative '../message_client_error' module O3P include Message::ORiN3::Provider::V1::AutoGenerated end module O3 include Design::ORiN3::Common::V1::AutoGenerated include Message::ORiN3::Provider::V1::AutoGenerated::Job end module Grpc module Client module ORiN3 module Provider class ORiN3Job < ORiN3BaseObject attr_reader :created_datetime include ORiN3ResourceOpener def initialize(channel, internal_id, created_datetime) @created_datetime = created_datetime super(channel, internal_id) end def start(argument = nil) open(argument.nil? ? {} : argument) end def stop(argument = nil) close(argument.nil? ? {} : argument) end def get_standard_output begin job = O3::JobService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel) request = O3::GetStandardOutputRequest.new(common: O3P::CommonRequest.new, id: @internal_id) response = job.get_standard_output(request) if (response.common.result_code != :SUCCEEDED) raise MessageClientError.new(response.common.result_code, response.common.detail) end response.output rescue MessageClientError => ee raise rescue StandardError => e raise MessageClientError.new(e) end end def get_standard_error begin job = O3::JobService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel) request = O3::GetStandardErrorRequest.new(common: O3P::CommonRequest.new, id: @internal_id) response = job.get_standard_error(request) if (response.common.result_code != :SUCCEEDED) raise MessageClientError.new(response.common.result_code, response.common.detail) end response.error rescue MessageClientError => ee raise rescue StandardError => e raise MessageClientError.new(e) end end def get_result begin job = O3::JobService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel) request = O3::GetResultRequest.new(common: O3P::CommonRequest.new, id: @internal_id) response = job.get_result(request) if (response.common.result_code != :SUCCEEDED) raise MessageClientError.new(response.common.result_code, response.common.detail) end response.is_null_result ? nil : ORiN3BinaryConverter.deserialize(response.result) rescue MessageClientError => ee raise rescue StandardError => e raise MessageClientError.new(e) end end end end end end end