File: __init__.py

package info (click to toggle)
raritan-json-rpc-sdk 3.6.1%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 41,748 kB
  • sloc: cs: 162,629; perl: 85,818; python: 24,275; javascript: 5,937; makefile: 21
file content (364 lines) | stat: -rw-r--r-- 12,598 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.

#
# Section generated by IdlC from "PortFuse.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.idl

import raritan.rpc.portsmodel


# interface
class PortFuse(Interface):
    idlType = "portsmodel.PortFuse:1.0.0"

    # enumeration
    class Status(Enumeration):
        idlType = "portsmodel.PortFuse.Status:1.0.0"
        values = ["UNKNOWN", "TRIPPED", "GOOD"]

    Status.UNKNOWN = Status(0)
    Status.TRIPPED = Status(1)
    Status.GOOD = Status(2)

    # value object
    class StatusChangedEvent(raritan.rpc.idl.Event):
        idlType = "portsmodel.PortFuse.StatusChangedEvent:1.0.0"

        def __init__(self, oldStatus, newStatus, source):
            super(raritan.rpc.portsmodel.PortFuse.StatusChangedEvent, self).__init__(source)
            typecheck.is_enum(oldStatus, raritan.rpc.portsmodel.PortFuse.Status, AssertionError)
            typecheck.is_enum(newStatus, raritan.rpc.portsmodel.PortFuse.Status, AssertionError)

            self.oldStatus = oldStatus
            self.newStatus = newStatus

        def encode(self):
            json = super(raritan.rpc.portsmodel.PortFuse.StatusChangedEvent, self).encode()
            json['oldStatus'] = raritan.rpc.portsmodel.PortFuse.Status.encode(self.oldStatus)
            json['newStatus'] = raritan.rpc.portsmodel.PortFuse.Status.encode(self.newStatus)
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                oldStatus = raritan.rpc.portsmodel.PortFuse.Status.decode(json['oldStatus']),
                newStatus = raritan.rpc.portsmodel.PortFuse.Status.decode(json['newStatus']),
                # for idl.Event
                source = Interface.decode(json['source'], agent),
            )
            return obj

        def listElements(self):
            elements = ["oldStatus", "newStatus"]
            elements = elements + super(raritan.rpc.portsmodel.PortFuse.StatusChangedEvent, self).listElements()
            return elements

    class _getStatus(Interface.Method):
        name = 'getStatus'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.portsmodel.PortFuse.Status.decode(rsp['_ret_'])
            typecheck.is_enum(_ret_, raritan.rpc.portsmodel.PortFuse.Status, DecodeException)
            return _ret_

    class _reset(Interface.Method):
        name = 'reset'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            return None
    def __init__(self, target, agent):
        super(PortFuse, self).__init__(target, agent)
        self.getStatus = PortFuse._getStatus(self)
        self.reset = PortFuse._reset(self)

#
# Section generated by IdlC from "Port.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.idl

import raritan.rpc.portsmodel


# interface
class Port(Interface):
    idlType = "portsmodel.Port:2.0.2"

    NO_ERROR = 0

    ERR_INVALID_PARAM = 1

    ERR_DEVICE_BUSY = 2

    # enumeration
    class DetectionType(Enumeration):
        idlType = "portsmodel.Port_2_0_2.DetectionType:1.0.0"
        values = ["AUTO", "PINNED", "DISABLED"]

    DetectionType.AUTO = DetectionType(0)
    DetectionType.PINNED = DetectionType(1)
    DetectionType.DISABLED = DetectionType(2)

    # structure
    class DetectionMode(Structure):
        idlType = "portsmodel.Port_2_0_2.DetectionMode:1.0.0"
        elements = ["type", "pinnedDeviceType"]

        def __init__(self, type, pinnedDeviceType):
            typecheck.is_enum(type, raritan.rpc.portsmodel.Port.DetectionType, AssertionError)
            typecheck.is_string(pinnedDeviceType, AssertionError)

            self.type = type
            self.pinnedDeviceType = pinnedDeviceType

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                type = raritan.rpc.portsmodel.Port.DetectionType.decode(json['type']),
                pinnedDeviceType = json['pinnedDeviceType'],
            )
            return obj

        def encode(self):
            json = {}
            json['type'] = raritan.rpc.portsmodel.Port.DetectionType.encode(self.type)
            json['pinnedDeviceType'] = self.pinnedDeviceType
            return json

    # structure
    class Properties(Structure):
        idlType = "portsmodel.Port_2_0_2.Properties:1.0.0"
        elements = ["name", "label", "mode", "detectedDeviceType", "detectedDeviceName"]

        def __init__(self, name, label, mode, detectedDeviceType, detectedDeviceName):
            typecheck.is_string(name, AssertionError)
            typecheck.is_string(label, AssertionError)
            typecheck.is_struct(mode, raritan.rpc.portsmodel.Port.DetectionMode, AssertionError)
            typecheck.is_string(detectedDeviceType, AssertionError)
            typecheck.is_string(detectedDeviceName, AssertionError)

            self.name = name
            self.label = label
            self.mode = mode
            self.detectedDeviceType = detectedDeviceType
            self.detectedDeviceName = detectedDeviceName

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                name = json['name'],
                label = json['label'],
                mode = raritan.rpc.portsmodel.Port.DetectionMode.decode(json['mode'], agent),
                detectedDeviceType = json['detectedDeviceType'],
                detectedDeviceName = json['detectedDeviceName'],
            )
            return obj

        def encode(self):
            json = {}
            json['name'] = self.name
            json['label'] = self.label
            json['mode'] = raritan.rpc.portsmodel.Port.DetectionMode.encode(self.mode)
            json['detectedDeviceType'] = self.detectedDeviceType
            json['detectedDeviceName'] = self.detectedDeviceName
            return json

    # value object
    class PropertiesChangedEvent(raritan.rpc.idl.Event):
        idlType = "portsmodel.Port_2_0_2.PropertiesChangedEvent:1.0.0"

        def __init__(self, oldProperties, newProperties, source):
            super(raritan.rpc.portsmodel.Port.PropertiesChangedEvent, self).__init__(source)
            typecheck.is_struct(oldProperties, raritan.rpc.portsmodel.Port.Properties, AssertionError)
            typecheck.is_struct(newProperties, raritan.rpc.portsmodel.Port.Properties, AssertionError)

            self.oldProperties = oldProperties
            self.newProperties = newProperties

        def encode(self):
            json = super(raritan.rpc.portsmodel.Port.PropertiesChangedEvent, self).encode()
            json['oldProperties'] = raritan.rpc.portsmodel.Port.Properties.encode(self.oldProperties)
            json['newProperties'] = raritan.rpc.portsmodel.Port.Properties.encode(self.newProperties)
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                oldProperties = raritan.rpc.portsmodel.Port.Properties.decode(json['oldProperties'], agent),
                newProperties = raritan.rpc.portsmodel.Port.Properties.decode(json['newProperties'], agent),
                # for idl.Event
                source = Interface.decode(json['source'], agent),
            )
            return obj

        def listElements(self):
            elements = ["oldProperties", "newProperties"]
            elements = elements + super(raritan.rpc.portsmodel.Port.PropertiesChangedEvent, self).listElements()
            return elements

    # value object
    class DeviceChangedEvent(raritan.rpc.idl.Event):
        idlType = "portsmodel.Port_2_0_2.DeviceChangedEvent:1.0.0"

        def __init__(self, oldDevice, newDevice, source):
            super(raritan.rpc.portsmodel.Port.DeviceChangedEvent, self).__init__(source)
            typecheck.is_remote_obj(oldDevice, AssertionError)
            typecheck.is_remote_obj(newDevice, AssertionError)

            self.oldDevice = oldDevice
            self.newDevice = newDevice

        def encode(self):
            json = super(raritan.rpc.portsmodel.Port.DeviceChangedEvent, self).encode()
            json['oldDevice'] = Interface.encode(self.oldDevice)
            json['newDevice'] = Interface.encode(self.newDevice)
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                oldDevice = Interface.decode(json['oldDevice'], agent),
                newDevice = Interface.decode(json['newDevice'], agent),
                # for idl.Event
                source = Interface.decode(json['source'], agent),
            )
            return obj

        def listElements(self):
            elements = ["oldDevice", "newDevice"]
            elements = elements + super(raritan.rpc.portsmodel.Port.DeviceChangedEvent, self).listElements()
            return elements

    class _getProperties(Interface.Method):
        name = 'getProperties'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.portsmodel.Port.Properties.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.portsmodel.Port.Properties, DecodeException)
            return _ret_

    class _setName(Interface.Method):
        name = 'setName'

        @staticmethod
        def encode(name):
            typecheck.is_string(name, AssertionError)
            args = {}
            args['name'] = name
            return args

        @staticmethod
        def decode(rsp, agent):
            return None

    class _setDetectionMode(Interface.Method):
        name = 'setDetectionMode'

        @staticmethod
        def encode(mode):
            typecheck.is_struct(mode, raritan.rpc.portsmodel.Port.DetectionMode, AssertionError)
            args = {}
            args['mode'] = raritan.rpc.portsmodel.Port.DetectionMode.encode(mode)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getDetectableDevices(Interface.Method):
        name = 'getDetectableDevices'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [x0 for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_string(x0, DecodeException)
            return _ret_

    class _getDevice(Interface.Method):
        name = 'getDevice'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = Interface.decode(rsp['_ret_'], agent)
            typecheck.is_remote_obj(_ret_, DecodeException)
            return _ret_

    class _getDeviceConfig(Interface.Method):
        name = 'getDeviceConfig'

        @staticmethod
        def encode(deviceType):
            typecheck.is_string(deviceType, AssertionError)
            args = {}
            args['deviceType'] = deviceType
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = Interface.decode(rsp['_ret_'], agent)
            typecheck.is_remote_obj(_ret_, DecodeException)
            return _ret_

    class _getFuse(Interface.Method):
        name = 'getFuse'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = Interface.decode(rsp['_ret_'], agent)
            typecheck.is_interface(_ret_, raritan.rpc.portsmodel.PortFuse, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(Port, self).__init__(target, agent)
        self.getProperties = Port._getProperties(self)
        self.setName = Port._setName(self)
        self.setDetectionMode = Port._setDetectionMode(self)
        self.getDetectableDevices = Port._getDetectableDevices(self)
        self.getDevice = Port._getDevice(self)
        self.getDeviceConfig = Port._getDeviceConfig(self)
        self.getFuse = Port._getFuse(self)