Class: Grpc::Client::ORiN3::Provider::ORiN3BaseObject

Inherits:
Object
  • Object
show all
Defined in:
lib/grpc/client/orin3/provider/orin3_base_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, internal_id) ⇒ ORiN3BaseObject

Returns a new instance of ORiN3BaseObject.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 22

def initialize(channel, internal_id)
  begin
    @channel = channel
    @internal_id = internal_id

    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::GetObjectInfoRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
    response = sut.get_object_info(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end

    @name = response.name
    @type_name = response.type_name
    @option = response.option
    @created_datetime = Grpc::ORiN3::Provider::DateTimeConverter.from_int64(response.created_datetime)
    @orin3_object_type = response.object_type
    @extra = response.extra
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

Instance Attribute Details

#created_datetimeObject (readonly)

Returns the value of attribute created_datetime.



20
21
22
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 20

def created_datetime
  @created_datetime
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 20

def name
  @name
end

#optionObject (readonly)

Returns the value of attribute option.



20
21
22
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 20

def option
  @option
end

#orin3_object_typeObject (readonly)

Returns the value of attribute orin3_object_type.



20
21
22
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 20

def orin3_object_type
  @orin3_object_type
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



20
21
22
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 20

def type_name
  @type_name
end

Instance Method Details

#execute(command_name, argument) ⇒ Object



133
134
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 133

def execute(command_name)
end

#get_statusObject



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 117

def get_status
  begin
    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::GetStatusRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
    response = sut.get_status(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return response.status
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

#get_tag(key) ⇒ Object



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

def get_tag(key)
  begin
    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::GetTagRequest.new(common: O3P::CommonRequest.new, id: @internal_id, key: key)
    response = sut.get_tag(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return ORiN3BinaryConverter.deserialize(response.tag)
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise
    raise MessageClientError.new(e)
  end
end

#get_tag_keysObject



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

def get_tag_keys
  begin
    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::GetTagKeysRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
    response = sut.get_tag_keys(request)
    if (response.common.result_code != :SUCCEEDED)
      raise MessageClientError.new(response.common.result_code, response.common.detail)
    end
    return response.keys
  rescue MessageClientError
    raise
  rescue StandardError => e
    raise MessageClientError.new(e)
  end
end

#idObject



47
48
49
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 47

def id
  @internal_id.unpack('H*').first.gsub(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '\1-\2-\3-\4-\5')
end

#remove_tag(key) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/grpc/client/orin3/provider/orin3_base_object.rb', line 102

def remove_tag(key)
  begin
    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    request = O3::RemoveTagRequest.new(common: O3P::CommonRequest.new, id: @internal_id, key: key)
    response = sut.remove_tag(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

#set_tag(key, tag, type = nil) ⇒ Object



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

def set_tag(key, tag, type = nil)
  begin
    sut = O3::BaseObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
    if type == ORiN3BinaryConverter::DataType::StringArray
      puts ORiN3BinaryConverter.serialize(tag, type).unpack('H*')[0].scan(/../).join(' ')
    end
    request = O3::SetTagRequest.new(common: O3P::CommonRequest.new, id: @internal_id, key: key, tag: ORiN3BinaryConverter.serialize(tag, type))
    response = sut.set_tag(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