grpc-orin3-provider 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -1
  3. data/README.md +18 -21
  4. data/Rakefile +42 -0
  5. data/gen/Design.ORiN3.Common/V1/orin3_common_pb.rb +23 -0
  6. data/gen/Design.ORiN3.Common/V1/orin3_common_remote_engine_pb.rb +25 -0
  7. data/gen/Design.ORiN3.Provider/V1/orin3_object_type_pb.rb +23 -0
  8. data/gen/Design.ORiN3.Provider/V1/orin3_value_type_pb.rb +23 -0
  9. data/gen/Message.ORiN3.Provider/V1/orin3_base_object_pb.rb +39 -0
  10. data/gen/Message.ORiN3.Provider/V1/{orin3baseobject_services_pb.rb → orin3_base_object_services_pb.rb} +3 -3
  11. data/gen/Message.ORiN3.Provider/V1/orin3_child_creator_pb.rb +39 -0
  12. data/gen/Message.ORiN3.Provider/V1/{orin3childcreator_services_pb.rb → orin3_child_creator_services_pb.rb} +3 -3
  13. data/gen/Message.ORiN3.Provider/V1/orin3_child_pb.rb +28 -0
  14. data/gen/Message.ORiN3.Provider/V1/{orin3child_services_pb.rb → orin3_child_services_pb.rb} +3 -3
  15. data/gen/Message.ORiN3.Provider/V1/orin3_common_type_pb.rb +79 -0
  16. data/gen/Message.ORiN3.Provider/V1/orin3_controller_creator_pb.rb +28 -0
  17. data/gen/Message.ORiN3.Provider/V1/{orin3controllercreator_services_pb.rb → orin3_controller_creator_services_pb.rb} +3 -3
  18. data/gen/Message.ORiN3.Provider/V1/orin3_executable_pb.rb +28 -0
  19. data/gen/Message.ORiN3.Provider/V1/{orin3executable_services_pb.rb → orin3_executable_services_pb.rb} +3 -3
  20. data/gen/Message.ORiN3.Provider/V1/orin3_file_pb.rb +41 -0
  21. data/gen/Message.ORiN3.Provider/V1/{orin3file_services_pb.rb → orin3_file_services_pb.rb} +3 -3
  22. data/gen/Message.ORiN3.Provider/V1/orin3_job_pb.rb +32 -0
  23. data/gen/Message.ORiN3.Provider/V1/{orin3job_services_pb.rb → orin3_job_services_pb.rb} +3 -3
  24. data/gen/Message.ORiN3.Provider/V1/orin3_parent_pb.rb +31 -0
  25. data/gen/Message.ORiN3.Provider/V1/{orin3parent_services_pb.rb → orin3_parent_services_pb.rb} +3 -3
  26. data/gen/Message.ORiN3.Provider/V1/orin3_resource_opener_pb.rb +30 -0
  27. data/gen/Message.ORiN3.Provider/V1/{orin3resourceopener_services_pb.rb → orin3_resource_opener_services_pb.rb} +3 -3
  28. data/gen/Message.ORiN3.Provider/V1/orin3_root_object_pb.rb +44 -0
  29. data/gen/Message.ORiN3.Provider/V1/{orin3rootobject_services_pb.rb → orin3_root_object_services_pb.rb} +3 -3
  30. data/gen/Message.ORiN3.Provider/V1/orin3_stream_pb.rb +28 -0
  31. data/gen/Message.ORiN3.Provider/V1/{orin3stream_services_pb.rb → orin3_stream_services_pb.rb} +3 -3
  32. data/gen/Message.ORiN3.Provider/V1/orin3_variable_pb.rb +31 -0
  33. data/gen/Message.ORiN3.Provider/V1/{orin3variable_services_pb.rb → orin3_variable_services_pb.rb} +3 -3
  34. data/gen/Message.ORiN3.RemoteEngine/V1/orin3_remote_engine_pb.rb +40 -0
  35. data/gen/Message.ORiN3.RemoteEngine/V1/orin3_remote_engine_services_pb.rb +32 -0
  36. data/lib/grpc/client/orin3/message_client_error.rb +23 -0
  37. data/lib/grpc/client/orin3/provider/orin3_base_object.rb +145 -0
  38. data/lib/grpc/client/orin3/provider/orin3_child_creator.rb +104 -0
  39. data/lib/grpc/client/orin3/provider/orin3_controller.rb +68 -0
  40. data/lib/grpc/client/orin3/provider/orin3_file.rb +146 -0
  41. data/lib/grpc/client/orin3/provider/orin3_job.rb +86 -0
  42. data/lib/grpc/client/orin3/provider/orin3_module.rb +30 -0
  43. data/lib/grpc/client/orin3/provider/orin3_resource_opener.rb +50 -0
  44. data/lib/grpc/client/orin3/provider/orin3_root_object.rb +108 -0
  45. data/lib/grpc/client/orin3/provider/orin3_stream.rb +48 -0
  46. data/lib/grpc/client/orin3/provider/orin3_variable.rb +500 -0
  47. data/lib/grpc/client/orin3/remoteengine/orin3_remote_engine.rb +158 -0
  48. data/lib/grpc/orin3/provider/date_time_converter.rb +25 -0
  49. data/lib/grpc/orin3/provider/orin3_binary_converter.rb +686 -0
  50. data/lib/grpc/orin3/provider/version.rb +1 -1
  51. data/lib/grpc/orin3/provider.rb +160 -99
  52. data/testsemiauto/test_with_mock_provider.rb +908 -0
  53. data/testsemiauto/test_with_test_provider.rb +200 -0
  54. data/testsemiauto/testdata/file.txt +1 -0
  55. metadata +51 -28
  56. data/gen/Message.ORiN3.Common/V1/orin3common_pb.rb +0 -77
  57. data/gen/Message.ORiN3.Provider/V1/orin3baseobject_pb.rb +0 -38
  58. data/gen/Message.ORiN3.Provider/V1/orin3child_pb.rb +0 -28
  59. data/gen/Message.ORiN3.Provider/V1/orin3childcreator_pb.rb +0 -38
  60. data/gen/Message.ORiN3.Provider/V1/orin3controllercreator_pb.rb +0 -28
  61. data/gen/Message.ORiN3.Provider/V1/orin3executable_pb.rb +0 -28
  62. data/gen/Message.ORiN3.Provider/V1/orin3file_pb.rb +0 -41
  63. data/gen/Message.ORiN3.Provider/V1/orin3job_pb.rb +0 -32
  64. data/gen/Message.ORiN3.Provider/V1/orin3parent_pb.rb +0 -31
  65. data/gen/Message.ORiN3.Provider/V1/orin3resourceopener_pb.rb +0 -30
  66. data/gen/Message.ORiN3.Provider/V1/orin3rootobject_pb.rb +0 -44
  67. data/gen/Message.ORiN3.Provider/V1/orin3stream_pb.rb +0 -28
  68. data/gen/Message.ORiN3.Provider/V1/orin3variable_pb.rb +0 -30
@@ -0,0 +1,108 @@
1
+ require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb'
2
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_root_object_pb'
3
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_root_object_services_pb'
4
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_controller_creator_pb'
5
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_controller_creator_services_pb'
6
+ require_relative '../message_client_error'
7
+ require_relative 'orin3_base_object'
8
+ require_relative 'orin3_controller'
9
+ require_relative 'orin3_child_creator'
10
+
11
+ module O3P
12
+ include Message::ORiN3::Provider::V1::AutoGenerated
13
+ end
14
+
15
+ module O3
16
+ include Design::ORiN3::Common::V1::AutoGenerated
17
+ include Message::ORiN3::Provider::V1::AutoGenerated::RootObject
18
+ include Message::ORiN3::Provider::V1::AutoGenerated::ControllerCreator
19
+ end
20
+
21
+ module Grpc
22
+ module Client
23
+ module ORiN3
24
+ module Provider
25
+ class ORiN3RootObject < ORiN3BaseObject
26
+ include ORiN3ChildCreator
27
+
28
+ class RootObjectInformation
29
+ attr_reader :orin3_provider_config, :connection_count
30
+
31
+ def initialize(orin3_provider_config, connection_count)
32
+ @orin3_provider_config = orin3_provider_config
33
+ @connection_count = connection_count
34
+ end
35
+ end
36
+
37
+ def self.attach(channel)
38
+ begin
39
+ root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: channel)
40
+ request = O3::GetRootObjectIdRequest.new(common: O3P::CommonRequest.new)
41
+ response = root.get_root_object_id(request)
42
+ if (response.common.result_code != :SUCCEEDED)
43
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
44
+ end
45
+ return ORiN3RootObject.new(channel, response.root_object_id)
46
+ rescue MessageClientError
47
+ raise
48
+ rescue StandardError => e
49
+ raise MessageClientError.new(e)
50
+ end
51
+ end
52
+
53
+ def get_information
54
+ begin
55
+ root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
56
+ request = O3::GetInformationRequest.new(common: O3P::CommonRequest.new)
57
+ response = root.get_information(request)
58
+ if (response.common.result_code != :SUCCEEDED)
59
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
60
+ end
61
+ return RootObjectInformation.new(response.orin3_provider_config, response.connection_count)
62
+ rescue MessageClientError
63
+ raise
64
+ rescue StandardError => e
65
+ raise MessageClientError.new(e)
66
+ end
67
+ end
68
+
69
+ def shutdown
70
+ begin
71
+ root = O3::RootObjectService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
72
+ request = O3::ShutdownRequest.new(common: O3P::CommonRequest.new)
73
+ response = root.shutdown(request)
74
+ if (response.common.result_code != :SUCCEEDED)
75
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
76
+ end
77
+ rescue MessageClientError
78
+ raise
79
+ rescue StandardError => e
80
+ raise MessageClientError.new(e)
81
+ end
82
+ end
83
+
84
+ def create_controller(name, type_name, option)
85
+ begin
86
+ root = O3::ControllerCreatorService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
87
+ request = O3::CreateControllerRequest.new(common: O3P::CommonRequest.new, parent_id: @internal_id, name: name, type_name: type_name, option: option)
88
+ response = root.create_controller(request)
89
+ if (response.common.result_code != :SUCCEEDED)
90
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
91
+ end
92
+ return ORiN3Controller.new(@channel, response.id, response.created_datetime)
93
+ rescue MessageClientError
94
+ raise
95
+ rescue StandardError => e
96
+ raise MessageClientError.new(e)
97
+ end
98
+ end
99
+
100
+ private
101
+ def initialize(channel, internal_id)
102
+ super(channel, internal_id)
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,48 @@
1
+ require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb'
2
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_stream_pb'
3
+ require_relative '../message_client_error'
4
+
5
+ module O3P
6
+ include Message::ORiN3::Provider::V1::AutoGenerated
7
+ end
8
+
9
+ module O3
10
+ include Design::ORiN3::Common::V1::AutoGenerated
11
+ include Message::ORiN3::Provider::V1::AutoGenerated::Stream
12
+ end
13
+
14
+ module Grpc
15
+ module Client
16
+ module ORiN3
17
+ module Provider
18
+ class ORiN3Stream < ORiN3BaseObject
19
+ attr_reader :created_datetime
20
+ include ORiN3ResourceOpener
21
+
22
+ def initialize(channel, internal_id, created_datetime)
23
+ @created_datetime = created_datetime
24
+ super(channel, internal_id)
25
+ end
26
+
27
+ def read
28
+ begin
29
+ stream = O3::StreamService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
30
+ request = O3::ReadRequest.new(common: O3P::CommonRequest.new, id: @internal_id)
31
+ responses = stream.read(request)
32
+ responses.each do |response|
33
+ if response.common.result_code != :SUCCEEDED
34
+ raise "Read failed: #{response.common.detail}"
35
+ end
36
+ yield response.value if block_given?
37
+ end
38
+ rescue MessageClientError
39
+ raise
40
+ rescue StandardError => e
41
+ raise MessageClientError.new(e)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,500 @@
1
+ require_relative '../../../../../gen/Design.ORiN3.Common/V1/orin3_common_pb'
2
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_variable_pb'
3
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_variable_services_pb'
4
+ require_relative '../../../../../gen/Message.ORiN3.Provider/V1/orin3_common_type_pb'
5
+ require_relative '../message_client_error'
6
+ require_relative 'orin3_base_object'
7
+ require_relative '../../../../grpc/orin3/provider/orin3_binary_converter'
8
+
9
+ module O3P
10
+ include Message::ORiN3::Provider::V1::AutoGenerated
11
+ end
12
+
13
+ module O3
14
+ include Design::ORiN3::Common::V1::AutoGenerated
15
+ include Message::ORiN3::Provider::V1::AutoGenerated::Variable
16
+ end
17
+
18
+ module Grpc
19
+ module Client
20
+ module ORiN3
21
+ module Provider
22
+ class ORiN3Variable < ORiN3BaseObject
23
+ attr_reader :created_datetime, :value_type
24
+
25
+ def initialize(channel, internal_id, created_datetime, value_type)
26
+ @created_datetime = created_datetime
27
+ @value_type = value_type
28
+ super(channel, internal_id)
29
+ end
30
+
31
+ def get_value
32
+ begin
33
+ variable = O3::VariableService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
34
+ request = O3::GetValueRequest.new(common: O3P::CommonRequest.new, id: @internal_id, value_type: @value_type)
35
+ response = variable.get_value(request)
36
+ if (response.common.result_code != :SUCCEEDED)
37
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
38
+ end
39
+ case @value_type
40
+ # BOOL
41
+ when :ORIN3_BOOL
42
+ return response.value.bool.raw_value
43
+ when :ORIN3_BOOL_ARRAY
44
+ return response.value.bool_array.raw_value.map { |it| it }
45
+ when :ORIN3_NULLABLE_BOOL
46
+ return response.value.nullable_bool.is_null == true ? nil : response.value.nullable_bool.raw_value
47
+ when :ORIN3_NULLABLE_BOOL_ARRAY
48
+ return response.value.nullable_bool_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
49
+ # UINT8
50
+ when :ORIN3_UINT8
51
+ return response.value.uint8.raw_value
52
+ when :ORIN3_NULLABLE_UINT8
53
+ return response.value.nullable_uint8.is_null == true ? nil : response.value.nullable_uint8.raw_value
54
+ when :ORIN3_UINT8_ARRAY
55
+ return response.value.uint8_array.raw_value.map { |it| it }
56
+ when :ORIN3_NULLABLE_UINT8_ARRAY
57
+ return response.value.nullable_uint8_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
58
+ # UINT16
59
+ when :ORIN3_UINT16
60
+ return response.value.uint16.raw_value
61
+ when :ORIN3_NULLABLE_UINT16
62
+ return response.value.nullable_uint16.is_null == true ? nil : response.value.nullable_uint16.raw_value
63
+ when :ORIN3_UINT16_ARRAY
64
+ return response.value.uint16_array.raw_value.map { |it| it }
65
+ when :ORIN3_NULLABLE_UINT16_ARRAY
66
+ return response.value.nullable_uint16_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
67
+ # UINT32
68
+ when :ORIN3_UINT32
69
+ return response.value.uint32.raw_value
70
+ when :ORIN3_NULLABLE_UINT32
71
+ return response.value.nullable_uint32.is_null == true ? nil : response.value.nullable_uint32.raw_value
72
+ when :ORIN3_UINT32_ARRAY
73
+ return response.value.uint32_array.raw_value.map { |it| it }
74
+ when :ORIN3_NULLABLE_UINT32_ARRAY
75
+ return response.value.nullable_uint32_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
76
+ # UINT64
77
+ when :ORIN3_UINT64
78
+ return response.value.uint64.raw_value
79
+ when :ORIN3_NULLABLE_UINT64
80
+ return response.value.nullable_uint64.is_null == true ? nil : response.value.nullable_uint64.raw_value
81
+ when :ORIN3_UINT64_ARRAY
82
+ return response.value.uint64_array.raw_value.map { |it| it }
83
+ when :ORIN3_NULLABLE_UINT64_ARRAY
84
+ return response.value.nullable_uint64_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
85
+ # INT8
86
+ when :ORIN3_INT8
87
+ return response.value.int8.raw_value
88
+ when :ORIN3_NULLABLE_INT8
89
+ return response.value.nullable_int8.is_null == true ? nil : response.value.nullable_int8.raw_value
90
+ when :ORIN3_INT8_ARRAY
91
+ return response.value.int8_array.raw_value.map { |it| it }
92
+ when :ORIN3_NULLABLE_INT8_ARRAY
93
+ return response.value.nullable_int8_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
94
+ # INT16
95
+ when :ORIN3_INT16
96
+ return response.value.int16.raw_value
97
+ when :ORIN3_NULLABLE_INT16
98
+ return response.value.nullable_int16.is_null == true ? nil : response.value.nullable_int16.raw_value
99
+ when :ORIN3_INT16_ARRAY
100
+ return response.value.int16_array.raw_value.map { |it| it }
101
+ when :ORIN3_NULLABLE_INT16_ARRAY
102
+ return response.value.nullable_int16_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
103
+ # INT32
104
+ when :ORIN3_INT32
105
+ return response.value.int32.raw_value
106
+ when :ORIN3_NULLABLE_INT32
107
+ return response.value.nullable_int32.is_null == true ? nil : response.value.nullable_int32.raw_value
108
+ when :ORIN3_INT32_ARRAY
109
+ return response.value.int32_array.raw_value.map { |it| it }
110
+ when :ORIN3_NULLABLE_INT32_ARRAY
111
+ return response.value.nullable_int32_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
112
+ # INT64
113
+ when :ORIN3_INT64
114
+ return response.value.int64.raw_value
115
+ when :ORIN3_NULLABLE_INT64
116
+ return response.value.nullable_int64.is_null == true ? nil : response.value.nullable_int64.raw_value
117
+ when :ORIN3_INT64_ARRAY
118
+ return response.value.int64_array.raw_value.map { |it| it }
119
+ when :ORIN3_NULLABLE_INT64_ARRAY
120
+ return response.value.nullable_int64_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
121
+ # FLOAT
122
+ when :ORIN3_FLOAT
123
+ return response.value.float.raw_value
124
+ when :ORIN3_NULLABLE_FLOAT
125
+ return response.value.nullable_float.is_null == true ? nil : response.value.nullable_float.raw_value
126
+ when :ORIN3_FLOAT_ARRAY
127
+ return response.value.float_array.raw_value.map { |it| it }
128
+ when :ORIN3_NULLABLE_FLOAT_ARRAY
129
+ return response.value.nullable_float_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
130
+ # DOUBLE
131
+ when :ORIN3_DOUBLE
132
+ return response.value.double.raw_value
133
+ when :ORIN3_NULLABLE_DOUBLE
134
+ return response.value.nullable_double.is_null == true ? nil : response.value.nullable_double.raw_value
135
+ when :ORIN3_DOUBLE_ARRAY
136
+ return response.value.double_array.raw_value.map { |it| it }
137
+ when :ORIN3_NULLABLE_DOUBLE_ARRAY
138
+ return response.value.nullable_double_array.raw_value.map { |it| it.is_null == true ? nil : it.raw_value }
139
+ # DATETIME
140
+ when :ORIN3_DATETIME
141
+ return Grpc::ORiN3::Provider::DateTimeConverter.from_int64(response.value.datetime.raw_value)
142
+ when :ORIN3_NULLABLE_DATETIME
143
+ return response.value.nullable_datetime.is_null == true ? nil : Grpc::ORiN3::Provider::DateTimeConverter.from_int64(response.value.nullable_datetime.raw_value)
144
+ when :ORIN3_DATETIME_ARRAY
145
+ return response.value.datetime_array.raw_value.map { |it| Grpc::ORiN3::Provider::DateTimeConverter.from_int64(it) }
146
+ when :ORIN3_NULLABLE_DATETIME_ARRAY
147
+ return response.value.nullable_datetime_array.raw_value.map { |it| it.is_null == true ? nil : Grpc::ORiN3::Provider::DateTimeConverter.from_int64(it.raw_value) }
148
+ # STRING
149
+ when :ORIN3_STRING
150
+ if response.value.string.is_null
151
+ return nil
152
+ else
153
+ return response.value.string.raw_value
154
+ end
155
+ when :ORIN3_STRING_ARRAY
156
+ return response.value.string_array.raw_value.map { |it| it.is_null ? nil : it.raw_value }
157
+ else
158
+ return ORiN3BinaryConverter.deserialize(response.value.int32.raw_value)
159
+ end
160
+ rescue MessageClientError
161
+ raise
162
+ rescue StandardError => e
163
+ raise MessageClientError.new(e)
164
+ end
165
+ end
166
+
167
+ def set_value(value)
168
+ begin
169
+ orin3_value = O3P::ORiN3Value.new(type: @value_type)
170
+ case @value_type
171
+ # BOOL
172
+ when :ORIN3_BOOL
173
+ if value.nil?
174
+ raise ArgumentError, "Value is nil."
175
+ elsif !value.is_a?(TrueClass) && !value.is_a?(FalseClass)
176
+ raise ArgumentError, "Value is not Boolean."
177
+ end
178
+ orin3_value.bool = O3P::ORiN3Bool.new(raw_value: value)
179
+ when :ORIN3_BOOL_ARRAY
180
+ if value.nil?
181
+ raise ArgumentError, "Value is nil."
182
+ elsif !value.is_a?(Array)
183
+ raise ArgumentError, "Value is not Array."
184
+ end
185
+ value.each do |item|
186
+ if item.nil?
187
+ raise ArgumentError, "Value contains nil."
188
+ elsif !item.is_a?(TrueClass) && !item.is_a?(FalseClass)
189
+ raise ArgumentError, "Value is not Integer."
190
+ end
191
+ end
192
+ orin3_value.bool_array = O3P::ORiN3BoolArray.new(raw_value: value)
193
+ when :ORIN3_NULLABLE_BOOL
194
+ if !value.nil? && !value.is_a?(TrueClass) && !value.is_a?(FalseClass)
195
+ raise ArgumentError, "Value is not Boolean."
196
+ end
197
+ orin3_value.nullable_bool = O3P::ORiN3NullableBool.new(is_null: value.nil?, raw_value: value)
198
+ when :ORIN3_NULLABLE_BOOL_ARRAY
199
+ if value.nil?
200
+ raise ArgumentError, "Value is nil."
201
+ elsif !value.is_a?(Array)
202
+ raise ArgumentError, "Value is not Array."
203
+ end
204
+ value.each do |item|
205
+ if !item.nil? && !item.is_a?(TrueClass) && !item.is_a?(FalseClass)
206
+ raise ArgumentError, "Value is not Boolean."
207
+ end
208
+ end
209
+ orin3_value.nullable_bool_array = O3P::ORiN3NullableBoolArray.new(raw_value: value.map { |it| O3P::ORiN3NullableBool.new(is_null: it.nil?, raw_value: it) })
210
+ # UINT8
211
+ when :ORIN3_UINT8
212
+ check_integer(value, false, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX)
213
+ orin3_value.uint8 = O3P::ORiN3UInt8.new(raw_value: value)
214
+ when :ORIN3_UINT8_ARRAY
215
+ check_array_integer(value, false, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX)
216
+ orin3_value.uint8_array = O3P::ORiN3UInt8Array.new(raw_value: value)
217
+ when :ORIN3_NULLABLE_UINT8
218
+ check_integer(value, true, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX)
219
+ orin3_value.nullable_uint8 = O3P::ORiN3NullableUInt8.new(is_null: value.nil?, raw_value: value)
220
+ when :ORIN3_NULLABLE_UINT8_ARRAY
221
+ check_array_integer(value, true, ORiN3BinaryConverter::UINT8_MIN, ORiN3BinaryConverter::UINT8_MAX)
222
+ orin3_value.nullable_uint8_array = O3P::ORiN3NullableUInt8Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt8.new(is_null: it.nil?, raw_value: it) })
223
+ # UINT16
224
+ when :ORIN3_UINT16
225
+ check_integer(value, false, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX)
226
+ orin3_value.uint16 = O3P::ORiN3UInt16.new(raw_value: value)
227
+ when :ORIN3_UINT16_ARRAY
228
+ check_array_integer(value, false, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX)
229
+ orin3_value.uint16_array = O3P::ORiN3UInt16Array.new(raw_value: value)
230
+ when :ORIN3_NULLABLE_UINT16
231
+ check_integer(value, true, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX)
232
+ orin3_value.nullable_uint16 = O3P::ORiN3NullableUInt16.new(is_null: value.nil?, raw_value: value)
233
+ when :ORIN3_NULLABLE_UINT16_ARRAY
234
+ check_array_integer(value, true, ORiN3BinaryConverter::UINT16_MIN, ORiN3BinaryConverter::UINT16_MAX)
235
+ orin3_value.nullable_uint16_array = O3P::ORiN3NullableUInt16Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt16.new(is_null: it.nil?, raw_value: it) })
236
+ # UINT32
237
+ when :ORIN3_UINT32
238
+ check_integer(value, false, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX)
239
+ orin3_value.uint32 = O3P::ORiN3UInt32.new(raw_value: value)
240
+ when :ORIN3_UINT32_ARRAY
241
+ check_array_integer(value, false, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX)
242
+ orin3_value.uint32_array = O3P::ORiN3UInt32Array.new(raw_value: value)
243
+ when :ORIN3_NULLABLE_UINT32
244
+ check_integer(value, true, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX)
245
+ orin3_value.nullable_uint32 = O3P::ORiN3NullableUInt32.new(is_null: value.nil?, raw_value: value)
246
+ when :ORIN3_NULLABLE_UINT32_ARRAY
247
+ check_array_integer(value, true, ORiN3BinaryConverter::UINT32_MIN, ORiN3BinaryConverter::UINT32_MAX)
248
+ orin3_value.nullable_uint32_array = O3P::ORiN3NullableUInt32Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt32.new(is_null: it.nil?, raw_value: it) })
249
+ # UINT64
250
+ when :ORIN3_UINT64
251
+ check_integer(value, false, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX)
252
+ orin3_value.uint64 = O3P::ORiN3UInt64.new(raw_value: value)
253
+ when :ORIN3_UINT64_ARRAY
254
+ check_array_integer(value, false, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX)
255
+ orin3_value.uint64_array = O3P::ORiN3UInt64Array.new(raw_value: value)
256
+ when :ORIN3_NULLABLE_UINT64
257
+ check_integer(value, true, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX)
258
+ orin3_value.nullable_uint64 = O3P::ORiN3NullableUInt64.new(is_null: value.nil?, raw_value: value)
259
+ when :ORIN3_NULLABLE_UINT64_ARRAY
260
+ check_array_integer(value, true, ORiN3BinaryConverter::UINT64_MIN, ORiN3BinaryConverter::UINT64_MAX)
261
+ orin3_value.nullable_uint64_array = O3P::ORiN3NullableUInt64Array.new(raw_value: value.map { |it| O3P::ORiN3NullableUInt64.new(is_null: it.nil?, raw_value: it) })
262
+ # INT8
263
+ when :ORIN3_INT8
264
+ check_integer(value, false, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX)
265
+ orin3_value.int8 = O3P::ORiN3Int8.new(raw_value: value)
266
+ when :ORIN3_INT8_ARRAY
267
+ check_array_integer(value, false, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX)
268
+ orin3_value.int8_array = O3P::ORiN3Int8Array.new(raw_value: value)
269
+ when :ORIN3_NULLABLE_INT8
270
+ check_integer(value, true, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX)
271
+ orin3_value.nullable_int8 = O3P::ORiN3NullableInt8.new(is_null: value.nil?, raw_value: value)
272
+ when :ORIN3_NULLABLE_INT8_ARRAY
273
+ check_array_integer(value, true, ORiN3BinaryConverter::INT8_MIN, ORiN3BinaryConverter::INT8_MAX)
274
+ orin3_value.nullable_int8_array = O3P::ORiN3NullableInt8Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt8.new(is_null: it.nil?, raw_value: it) })
275
+ # INT16
276
+ when :ORIN3_INT16
277
+ check_integer(value, false, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX)
278
+ orin3_value.int16 = O3P::ORiN3Int16.new(raw_value: value)
279
+ when :ORIN3_INT16_ARRAY
280
+ check_array_integer(value, false, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX)
281
+ orin3_value.int16_array = O3P::ORiN3Int16Array.new(raw_value: value)
282
+ when :ORIN3_NULLABLE_INT16
283
+ check_integer(value, true, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX)
284
+ orin3_value.nullable_int16 = O3P::ORiN3NullableInt16.new(is_null: value.nil?, raw_value: value)
285
+ when :ORIN3_NULLABLE_INT16_ARRAY
286
+ check_array_integer(value, true, ORiN3BinaryConverter::INT16_MIN, ORiN3BinaryConverter::INT16_MAX)
287
+ orin3_value.nullable_int16_array = O3P::ORiN3NullableInt16Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt16.new(is_null: it.nil?, raw_value: it) })
288
+ # INT32
289
+ when :ORIN3_INT32
290
+ check_integer(value, false, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX)
291
+ orin3_value.int32 = O3P::ORiN3Int32.new(raw_value: value)
292
+ when :ORIN3_INT32_ARRAY
293
+ check_array_integer(value, false, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX)
294
+ orin3_value.int32_array = O3P::ORiN3Int32Array.new(raw_value: value)
295
+ when :ORIN3_NULLABLE_INT32
296
+ check_integer(value, true, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX)
297
+ orin3_value.nullable_int32 = O3P::ORiN3NullableInt32.new(is_null: value.nil?, raw_value: value)
298
+ when :ORIN3_NULLABLE_INT32_ARRAY
299
+ check_array_integer(value, true, ORiN3BinaryConverter::INT32_MIN, ORiN3BinaryConverter::INT32_MAX)
300
+ orin3_value.nullable_int32_array = O3P::ORiN3NullableInt32Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt32.new(is_null: it.nil?, raw_value: it) })
301
+ # INT64
302
+ when :ORIN3_INT64
303
+ check_integer(value, false, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX)
304
+ orin3_value.int64 = O3P::ORiN3Int64.new(raw_value: value)
305
+ when :ORIN3_INT64_ARRAY
306
+ check_array_integer(value, false, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX)
307
+ orin3_value.int64_array = O3P::ORiN3Int64Array.new(raw_value: value)
308
+ when :ORIN3_NULLABLE_INT64
309
+ check_integer(value, true, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX)
310
+ orin3_value.nullable_int64 = O3P::ORiN3NullableInt64.new(is_null: value.nil?, raw_value: value)
311
+ when :ORIN3_NULLABLE_INT64_ARRAY
312
+ check_array_integer(value, true, ORiN3BinaryConverter::INT64_MIN, ORiN3BinaryConverter::INT64_MAX)
313
+ orin3_value.nullable_int64_array = O3P::ORiN3NullableInt64Array.new(raw_value: value.map { |it| O3P::ORiN3NullableInt64.new(is_null: it.nil?, raw_value: it) })
314
+ # FLOAT
315
+ when :ORIN3_FLOAT
316
+ if value.nil?
317
+ raise ArgumentError, "Value is nil."
318
+ elsif !value.is_a?(Float)
319
+ raise ArgumentError, "Value is not Float."
320
+ end
321
+ orin3_value.float = O3P::ORiN3Float.new(raw_value: value)
322
+ when :ORIN3_FLOAT_ARRAY
323
+ if value.nil?
324
+ raise ArgumentError, "Value is nil."
325
+ elsif !value.is_a?(Array)
326
+ raise ArgumentError, "Value is not Array."
327
+ end
328
+ value.each do |item|
329
+ if item.nil?
330
+ raise ArgumentError, "Value contains nil."
331
+ elsif !item.is_a?(Float)
332
+ raise ArgumentError, "Value is not Float."
333
+ end
334
+ end
335
+ orin3_value.float_array = O3P::ORiN3FloatArray.new(raw_value: value)
336
+ when :ORIN3_NULLABLE_FLOAT
337
+ if !value.nil? && !value.is_a?(Float)
338
+ raise ArgumentError, "Value is not Float."
339
+ end
340
+ orin3_value.nullable_float = O3P::ORiN3NullableFloat.new(is_null: value.nil?, raw_value: value)
341
+ when :ORIN3_NULLABLE_FLOAT_ARRAY
342
+ if value.nil?
343
+ raise ArgumentError, "Value is nil."
344
+ elsif !value.is_a?(Array)
345
+ raise ArgumentError, "Value is not Array."
346
+ end
347
+ value.each do |item|
348
+ if !item.nil? && !item.is_a?(Float)
349
+ raise ArgumentError, "Value is not Float."
350
+ end
351
+ end
352
+ orin3_value.nullable_float_array = O3P::ORiN3NullableFloatArray.new(raw_value: value.map { |it| O3P::ORiN3NullableFloat.new(is_null: it.nil?, raw_value: it) })
353
+ # DOUBLE
354
+ when :ORIN3_DOUBLE
355
+ if value.nil?
356
+ raise ArgumentError, "Value is nil."
357
+ elsif !value.is_a?(Float)
358
+ raise ArgumentError, "Value is not Float."
359
+ end
360
+ orin3_value.double = O3P::ORiN3Double.new(raw_value: value)
361
+ when :ORIN3_DOUBLE_ARRAY
362
+ if value.nil?
363
+ raise ArgumentError, "Value is nil."
364
+ elsif !value.is_a?(Array)
365
+ raise ArgumentError, "Value is not Array."
366
+ end
367
+ value.each do |item|
368
+ if item.nil?
369
+ raise ArgumentError, "Value contains nil."
370
+ elsif !item.is_a?(Float)
371
+ raise ArgumentError, "Value is not Float."
372
+ end
373
+ end
374
+ orin3_value.double_array = O3P::ORiN3DoubleArray.new(raw_value: value)
375
+ when :ORIN3_NULLABLE_DOUBLE
376
+ if !value.nil? && !value.is_a?(Float)
377
+ raise ArgumentError, "Value is not Float."
378
+ end
379
+ orin3_value.nullable_double = O3P::ORiN3NullableDouble.new(is_null: value.nil?, raw_value: value)
380
+ when :ORIN3_NULLABLE_DOUBLE_ARRAY
381
+ if value.nil?
382
+ raise ArgumentError, "Value is nil."
383
+ elsif !value.is_a?(Array)
384
+ raise ArgumentError, "Value is not Array."
385
+ end
386
+ value.each do |item|
387
+ if !item.nil? && !item.is_a?(Float)
388
+ raise ArgumentError, "Value is not Float."
389
+ end
390
+ end
391
+ orin3_value.nullable_double_array = O3P::ORiN3NullableDoubleArray.new(raw_value: value.map { |it| O3P::ORiN3NullableDouble.new(is_null: it.nil?, raw_value: it) })
392
+ # DATETIME
393
+ when :ORIN3_DATETIME
394
+ if value.nil?
395
+ raise ArgumentError, "Value is nil."
396
+ elsif !value.is_a?(Time)
397
+ raise ArgumentError, "Value is not Time."
398
+ end
399
+ orin3_value.datetime = O3P::ORiN3DateTime.new(raw_value: Grpc::ORiN3::Provider::DateTimeConverter.to_int64(value))
400
+ when :ORIN3_DATETIME_ARRAY
401
+ if value.nil?
402
+ raise ArgumentError, "Value is nil."
403
+ elsif !value.is_a?(Array)
404
+ raise ArgumentError, "Value is not Array."
405
+ end
406
+ value.each do |item|
407
+ if item.nil?
408
+ raise ArgumentError, "Value contains nil."
409
+ elsif !item.is_a?(Time)
410
+ raise ArgumentError, "Value is not Time."
411
+ end
412
+ end
413
+ orin3_value.datetime_array = O3P::ORiN3DateTimeArray.new(raw_value: value.map { |it| Grpc::ORiN3::Provider::DateTimeConverter.to_int64(it) })
414
+ when :ORIN3_NULLABLE_DATETIME
415
+ if !value.nil? && !value.is_a?(Time)
416
+ raise ArgumentError, "Value is not Time."
417
+ end
418
+ orin3_value.nullable_datetime = O3P::ORiN3NullableDateTime.new(is_null: value.nil?, raw_value: value.nil? ? nil : Grpc::ORiN3::Provider::DateTimeConverter.to_int64(value))
419
+ when :ORIN3_NULLABLE_DATETIME_ARRAY
420
+ if value.nil?
421
+ raise ArgumentError, "Value is nil."
422
+ elsif !value.is_a?(Array)
423
+ raise ArgumentError, "Value is not Array."
424
+ end
425
+ value.each do |item|
426
+ if !item.nil? && !item.is_a?(Time)
427
+ raise ArgumentError, "Value is not Time."
428
+ end
429
+ end
430
+ orin3_value.nullable_datetime_array = O3P::ORiN3NullableDateTimeArray.new(raw_value: value.map { |it| O3P::ORiN3NullableDateTime.new(is_null: it.nil?, raw_value: it.nil? ? nil : Grpc::ORiN3::Provider::DateTimeConverter.to_int64(it)) })
431
+ # STRING
432
+ when :ORIN3_STRING
433
+ if !value.nil? && !value.is_a?(String)
434
+ raise ArgumentError, "Value is not String."
435
+ end
436
+ orin3_value.string = O3P::ORiN3String.new(is_null: value.nil?, raw_value: value)
437
+ when :ORIN3_STRING_ARRAY
438
+ if value.nil?
439
+ raise ArgumentError, "Value is nil."
440
+ elsif !value.is_a?(Array)
441
+ raise ArgumentError, "Value is not Array."
442
+ end
443
+ value.each do |item|
444
+ if !item.nil? && !item.is_a?(String)
445
+ raise ArgumentError, "Value is not String."
446
+ end
447
+ end
448
+ orin3_value.string_array = O3P::ORiN3StringArray.new(raw_value: value.map { |it| O3P::ORiN3String.new(is_null: it.nil?, raw_value: it) })
449
+ else
450
+ raise ArgumentError.new("Not supported.")
451
+ end
452
+ variable = O3::VariableService::Stub.new(nil, :this_channel_is_insecure, channel_override: @channel)
453
+ request = O3::SetValueRequest.new(common: O3P::CommonRequest.new, id: @internal_id, value: orin3_value)
454
+ response = variable.set_value(request)
455
+ if (response.common.result_code != :SUCCEEDED)
456
+ raise MessageClientError.new(response.common.result_code, response.common.detail)
457
+ end
458
+ rescue MessageClientError
459
+ raise
460
+ rescue StandardError => e
461
+ raise MessageClientError.new(e)
462
+ end
463
+ end
464
+
465
+ private
466
+ def check_integer(value, nullable, min, max)
467
+ if !nullable && value.nil?
468
+ raise ArgumentError, "Value is nil."
469
+ elsif !value.nil?
470
+ if !value.is_a?(Integer)
471
+ raise ArgumentError, "Value is not Integer."
472
+ elsif value < min || max < value
473
+ raise ArgumentError, "Value #{value} is out of range. It must be between #{min} and #{max}."
474
+ end
475
+ end
476
+ end
477
+
478
+ def check_array_integer(value, nullable, min, max)
479
+ if value.nil?
480
+ raise ArgumentError, "Value is nil."
481
+ elsif !value.is_a?(Array)
482
+ raise ArgumentError, "Value is not Array."
483
+ end
484
+ value.each do |item|
485
+ if !nullable && item.nil?
486
+ raise ArgumentError, "Value contains nil."
487
+ elsif !item.nil?
488
+ if !item.is_a?(Integer)
489
+ raise ArgumentError, "Value is not Integer."
490
+ elsif item < min || max < item
491
+ raise ArgumentError, "Value #{item} is out of range. It must be between #{min} and #{max}."
492
+ end
493
+ end
494
+ end
495
+ end
496
+ end
497
+ end
498
+ end
499
+ end
500
+ end