File: __init__.py

package info (click to toggle)
raritan-json-rpc-sdk 4.0.20%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,236 kB
  • sloc: cs: 223,121; perl: 117,786; python: 26,872; javascript: 6,544; makefile: 27
file content (91 lines) | stat: -rw-r--r-- 2,405 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
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2022 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.

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

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


# structure
class KeyValue(Structure):
    idlType = "cfg.KeyValue:1.0.0"
    elements = ["key", "value"]

    def __init__(self, key, value):
        typecheck.is_string(key, AssertionError)
        typecheck.is_string(value, AssertionError)

        self.key = key
        self.value = value

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            key = json['key'],
            value = json['value'],
        )
        return obj

    def encode(self):
        json = {}
        json['key'] = self.key
        json['value'] = self.value
        return json

# interface
class Cfg(Interface):
    idlType = "cfg.Cfg:1.0.1"

    ERR_INVALID_KEY = 1

    ERR_INVALID_VALUE = 2

    ERR_NOT_ALLOWED_IN_FIPS_MODE = 3

    class _getValues(Interface.Method):
        name = 'getValues'

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

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

    class _setValues(Interface.Method):
        name = 'setValues'

        @staticmethod
        def encode(keyvaluepairs):
            for x0 in keyvaluepairs:
                typecheck.is_struct(x0, raritan.rpc.cfg.KeyValue, AssertionError)
            args = {}
            args['keyvaluepairs'] = [raritan.rpc.cfg.KeyValue.encode(x0) for x0 in keyvaluepairs]
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(Cfg, self).__init__(target, agent)
        self.getValues = Cfg._getValues(self)
        self.setValues = Cfg._setValues(self)