Index
frequenz.client.dispatch ¤
Dispatch API client for Python.
Classes¤
frequenz.client.dispatch.Client ¤
Dispatch API client.
Source code in frequenz/client/dispatch/_client.py
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 |
|
Functions¤
__init__ ¤
Initialize the client.
PARAMETER | DESCRIPTION |
---|---|
grpc_channel |
gRPC channel to use for communication with the API.
TYPE:
|
svc_addr |
Address of the service to connect to.
TYPE:
|
Source code in frequenz/client/dispatch/_client.py
create
async
¤
create(
microgrid_id: int,
_type: str,
start_time: datetime,
duration: timedelta,
selector: ComponentSelector,
active: bool = True,
dry_run: bool = False,
payload: dict[str, Any] | None = None,
recurrence: RecurrenceRule | None = None,
) -> Dispatch
Create a dispatch.
Will try to return the created dispatch, identifying it by the same fields as the request.
PARAMETER | DESCRIPTION |
---|---|
microgrid_id |
The microgrid_id to create the dispatch for.
TYPE:
|
_type |
User defined string to identify the dispatch type.
TYPE:
|
start_time |
The start time of the dispatch.
TYPE:
|
duration |
The duration of the dispatch.
TYPE:
|
selector |
The component selector for the dispatch.
TYPE:
|
active |
The active status of the dispatch.
TYPE:
|
dry_run |
The dry_run status of the dispatch.
TYPE:
|
payload |
The payload of the dispatch. |
recurrence |
The recurrence rule of the dispatch.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dispatch
|
The created dispatch
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If start_time is in the past. |
ValueError
|
If the created dispatch could not be found. |
Source code in frequenz/client/dispatch/_client.py
delete
async
¤
delete(dispatch_id: int) -> None
Delete a dispatch.
PARAMETER | DESCRIPTION |
---|---|
dispatch_id |
The dispatch_id to delete.
TYPE:
|
Source code in frequenz/client/dispatch/_client.py
get
async
¤
Get a dispatch.
PARAMETER | DESCRIPTION |
---|---|
dispatch_id |
The dispatch_id to get.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dispatch
|
The dispatch.
TYPE:
|
Source code in frequenz/client/dispatch/_client.py
list
async
¤
list(
microgrid_id: int,
component_selectors: Iterator[ComponentSelector] = iter(
()
),
start_from: datetime | None = None,
start_to: datetime | None = None,
end_from: datetime | None = None,
end_to: datetime | None = None,
active: bool | None = None,
dry_run: bool | None = None,
) -> AsyncIterator[Dispatch]
List dispatches.
Example usage:
grpc_channel = grpc.aio.insecure_channel("example")
client = Client(grpc_channel, "localhost:50051")
async for dispatch in client.list(microgrid_id=1):
print(dispatch)
YIELDS | DESCRIPTION |
---|---|
Dispatch
|
The dispatches.
TYPE::
|
PARAMETER | DESCRIPTION |
---|---|
microgrid_id |
The microgrid_id to list dispatches for.
TYPE:
|
component_selectors |
optional, list of component ids or categories to filter by.
TYPE:
|
start_from |
optional, filter by start_time >= start_from.
TYPE:
|
start_to |
optional, filter by start_time < start_to.
TYPE:
|
end_from |
optional, filter by end_time >= end_from.
TYPE:
|
end_to |
optional, filter by end_time < end_to.
TYPE:
|
active |
optional, filter by active status.
TYPE:
|
dry_run |
optional, filter by dry_run status.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AsyncIterator[Dispatch]
|
An async iterator of dispatches. |
Source code in frequenz/client/dispatch/_client.py
update
async
¤
Update a dispatch.
The new_fields
argument is a dictionary of fields to update. The keys are
the field names, and the values are the new values for the fields.
For recurrence fields, the keys are preceeded by "recurrence.".
Note that updating type
and dry_run
is not supported.
PARAMETER | DESCRIPTION |
---|---|
dispatch_id |
The dispatch_id to update.
TYPE:
|
new_fields |
The fields to update. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If updating |