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 (172 lines) | stat: -rw-r--r-- 5,689 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
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2022 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.

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

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


# interface
class DiagLogSettings(Interface):
    idlType = "diag.DiagLogSettings:1.0.0"

    # enumeration
    class LogLevel(Enumeration):
        idlType = "diag.DiagLogSettings.LogLevel:1.0.0"
        values = ["LOG_LEVEL_NONE", "LOG_LEVEL_ERR", "LOG_LEVEL_WARN", "LOG_LEVEL_INFO", "LOG_LEVEL_DEBUG", "LOG_LEVEL_TRACE"]

    LogLevel.LOG_LEVEL_NONE = LogLevel(0)
    LogLevel.LOG_LEVEL_ERR = LogLevel(1)
    LogLevel.LOG_LEVEL_WARN = LogLevel(2)
    LogLevel.LOG_LEVEL_INFO = LogLevel(3)
    LogLevel.LOG_LEVEL_DEBUG = LogLevel(4)
    LogLevel.LOG_LEVEL_TRACE = LogLevel(5)

    # structure
    class LogLevelEntry(Structure):
        idlType = "diag.DiagLogSettings.LogLevelEntry:1.0.0"
        elements = ["ctxName", "logLevel"]

        def __init__(self, ctxName, logLevel):
            typecheck.is_string(ctxName, AssertionError)
            typecheck.is_enum(logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError)

            self.ctxName = ctxName
            self.logLevel = logLevel

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                ctxName = json['ctxName'],
                logLevel = raritan.rpc.diag.DiagLogSettings.LogLevel.decode(json['logLevel']),
            )
            return obj

        def encode(self):
            json = {}
            json['ctxName'] = self.ctxName
            json['logLevel'] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(self.logLevel)
            return json

    ERR_NONE = 0

    ERR_UNKNOWN_LOG_CONTEXT_NAME = 1

    ERR_UNKNOWN_LOG_LEVEL = 2

    class _resetLogLevelsForAllCtxNames(Interface.Method):
        name = 'resetLogLevelsForAllCtxNames'

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

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

    class _getLogLevelsForAllCtxNames(Interface.Method):
        name = 'getLogLevelsForAllCtxNames'

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

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [raritan.rpc.diag.DiagLogSettings.LogLevelEntry.decode(x0, agent) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_struct(x0, raritan.rpc.diag.DiagLogSettings.LogLevelEntry, DecodeException)
            return _ret_

    class _setLogLevelForAllCtxNames(Interface.Method):
        name = 'setLogLevelForAllCtxNames'

        @staticmethod
        def encode(logLevel):
            typecheck.is_enum(logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError)
            args = {}
            args['logLevel'] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(logLevel)
            return args

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

    class _getLogLevelByCtxName(Interface.Method):
        name = 'getLogLevelByCtxName'

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

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            logLevel = raritan.rpc.diag.DiagLogSettings.LogLevel.decode(rsp['logLevel'])
            typecheck.is_int(_ret_, DecodeException)
            typecheck.is_enum(logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, DecodeException)
            return (_ret_, logLevel)

    class _setLogLevelByCtxName(Interface.Method):
        name = 'setLogLevelByCtxName'

        @staticmethod
        def encode(ctxName, logLevel):
            typecheck.is_string(ctxName, AssertionError)
            typecheck.is_enum(logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError)
            args = {}
            args['ctxName'] = ctxName
            args['logLevel'] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(logLevel)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(DiagLogSettings, self).__init__(target, agent)
        self.resetLogLevelsForAllCtxNames = DiagLogSettings._resetLogLevelsForAllCtxNames(self)
        self.getLogLevelsForAllCtxNames = DiagLogSettings._getLogLevelsForAllCtxNames(self)
        self.setLogLevelForAllCtxNames = DiagLogSettings._setLogLevelForAllCtxNames(self)
        self.getLogLevelByCtxName = DiagLogSettings._getLogLevelByCtxName(self)
        self.setLogLevelByCtxName = DiagLogSettings._setLogLevelByCtxName(self)

# from raritan/rpc/diag/__extend__.py
def download(agent):
    """
    Method to download the diagnostic data

    **parameters**

    :param agent: An agent instance from the device where the diagnostic file should be downloaded
    :return: returns the diagnostic data

    **Example**
        :Example:

        from raritan import rpc
        from raritan.rpc import diag

        agent = rpc.Agent("https", "my-pdu.example.com", "admin", "raritan")
        # download
        diag = diag.download(agent)
        print(diag)
    """
    target = "cgi-bin/diag-data.cgi"
    return agent.get(target)