Class: Grpc::Client::ORiN3::Provider::ORiN3Controller

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

Instance Attribute Summary collapse

Attributes inherited from ORiN3BaseObject

#name, #option, #orin3_object_type, #type_name

Instance Method Summary collapse

Methods included from ORiN3ResourceOpener

#close, #open

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

Constructor Details

#initialize(channel, internal_id, created_datetime) ⇒ ORiN3Controller

Returns a new instance of ORiN3Controller.



34
35
36
37
# File 'lib/grpc/client/orin3/provider/orin3_controller.rb', line 34

def initialize(channel, internal_id, created_datetime)
  @created_datetime = created_datetime
  super(channel, internal_id)
end

Instance Attribute Details

#created_datetimeObject (readonly)

Returns the value of attribute created_datetime.



32
33
34
# File 'lib/grpc/client/orin3/provider/orin3_controller.rb', line 32

def created_datetime
  @created_datetime
end

Instance Method Details

#connect(argument = nil) ⇒ Object



39
40
41
42
# File 'lib/grpc/client/orin3/provider/orin3_controller.rb', line 39

def connect(argument = nil)
  argument = argument.nil? ? {} : argument
  open(argument)
end

#create_controller(name, type_name, option) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/grpc/client/orin3/provider/orin3_controller.rb', line 49

def create_controller(name, type_name, option)
  begin
    controller = 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 = controller.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

#disconnect(argument = nil) ⇒ Object



44
45
46
47
# File 'lib/grpc/client/orin3/provider/orin3_controller.rb', line 44

def disconnect(argument = nil)
  argument = argument.nil? ? {} : argument
  close(argument)
end