Namespace
pytruenas.namespace.Namespace(client, *name)
Source code in src/pytruenas/namespace.py
221 222 223 224 225 226 227 228 | |
__call__(*args, _retries=1, _method=None, _ioerror=False, _filetransfer=False, _timeout=_UNSET, **kwds)
Invoke this namespace's middleware method.
_retries is the number of retries on a new connection after a
dropped one, made only when the request was never sent
(:class:~pytruenas.ConnectionClosed with sent=False); with the
default 1 the call is attempted up to twice. _timeout is
the per-call timeout in seconds; the default sentinel uses the
client's configured timeout, None waits indefinitely. _method
appends a leaf method name, _ioerror maps a middleware error to the
matching OSError, and _filetransfer routes through
upload/download.
job=True, as in the upstream client, waits for the job the method
starts and returns the job's result (:meth:TrueNASClient.wait): a
failed job raises :class:~pytruenas.JobFailed. The wait has no
deadline unless _timeout is given. job="RETURN" returns the
job id. Any other keyword raises TypeError: middleware methods take
positional parameters.
Source code in src/pytruenas/namespace.py
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 | |
__getattr__(name)
Source code in src/pytruenas/namespace.py
360 | |
__getitem__(name)
Source code in src/pytruenas/namespace.py
362 363 364 365 366 367 368 | |
__repr__()
Source code in src/pytruenas/namespace.py
230 231 232 233 234 | |
__str__()
Source code in src/pytruenas/namespace.py
236 237 | |
subscribe(__callback=None, *, event=None, maxsize=_connection.DEFAULT_EVENT_QUEUE_SIZE)
Subscribe to this namespace's collection events.
client.api.alert.list.subscribe() subscribes to the alert.list
event -- the event name defaults to this namespace's dotted path.
Returns a :class:~pytruenas.connection.Subscription; consume it via its
events() iterator and/or the optional __callback (invoked inline
on the reader thread -- keep it fast).
Pass event= to subscribe to a different event name than the
namespace path (e.g. from client.api root). This is a real method,
so it shadows any middleware method literally named subscribe; reach
such a method via ns(_method="subscribe", ...) if ever needed.
Source code in src/pytruenas/namespace.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
pytruenas.namespace.DBAction
Bases: str, Enum
The database mutation an _upsert/_update/_create resolves to.
A str enum (StrEnum is 3.11+, so this uses the 3.9-compatible
(str, Enum) form) whose members double as the action name.
CREATE = 'create'
class-attribute
instance-attribute
UPDATE = 'update'
class-attribute
instance-attribute
UPSERT = 'upsert'
class-attribute
instance-attribute
execute(__action, __namespace, __selector=None, *__opts, **__fields)
Source code in src/pytruenas/namespace.py
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 | |