Namespace
pytruenas.namespace.Namespace(client, *name)
Source code in src/pytruenas/namespace.py
165 166 167 168 169 170 171 172 | |
__call__(*args, _tries=1, _method=None, _ioerror=False, _filetransfer=False, _timeout=_UNSET, **kwds)
Invoke this namespace's middleware method.
_tries is the number of reconnect retries after a dropped
connection (ECONNABORTED); 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 (used by core.job_wait for long jobs). _method
appends a leaf method name, _ioerror maps a middleware error to the
matching OSError, and _filetransfer routes through
upload/download.
Source code in src/pytruenas/namespace.py
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 | |
__getattr__(name)
Source code in src/pytruenas/namespace.py
261 | |
__getitem__(name)
Source code in src/pytruenas/namespace.py
263 264 265 266 267 268 269 | |
__repr__()
Source code in src/pytruenas/namespace.py
174 175 | |
__str__()
Source code in src/pytruenas/namespace.py
177 178 | |
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
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 | |
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
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 | |