Class: Grpc::Client::ORiN3::Provider::ORiN3RootObject

Inherits:
ORiN3BaseObject show all
Includes:
ORiN3ChildCreator
Defined in:
lib/grpc/client/orin3/provider/orin3_root_object.rb

Defined Under Namespace

Classes: RootObjectInformation

Instance Attribute Summary

Attributes inherited from ORiN3BaseObject

#created_datetime, #name, #option, #orin3_object_type, #type_name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ORiN3ChildCreator

#create_file, #create_job, #create_module, #create_stream, #create_variable

Methods inherited from ORiN3BaseObject

#execute, #get_status, #get_tag, #get_tag_keys, #id, #remove_tag, #set_tag

Class Method Details

.attach(channel) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/grpc/client/orin3/provider/orin3_root_object.rb', line 37

def self.attach(channel)
  begin
    root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: channel)
    request = O3::GetRootObjectIdRequest.new(common: O3P::CommonRequest.new)
    response = root.get_root_object_id(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return ORiN3RootObject.new(channel, response.root_object_id)
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

Instance Method Details

#create_controller(name, type_name, option) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/grpc/client/orin3/provider/orin3_root_object.rb', line 84

def create_controller(name, type_name, option)
  begin
    root = O3::ControllerCreatorService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::CreateControllerRequest.new(common: O3P::CommonRequest.new, parent_id: @internal_id, name: name, type_name: type_name, option: option)
    response = root.create_controller(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return ORiN3Controller.new(@channel, response.id, response.created_datetime)
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

#get_informationObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/grpc/client/orin3/provider/orin3_root_object.rb', line 53

def get_information
  begin
    root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::GetInformationRequest.new(common: O3P::CommonRequest.new)
    response = root.get_information(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return RootObjectInformation.new(response.orin3_provider_config, response.connection_count)
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

#shutdownObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/grpc/client/orin3/provider/orin3_root_object.rb', line 69

def shutdown
  begin
    root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::ShutdownRequest.new(common: O3P::CommonRequest.new)
    response = root.shutdown(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end