|
@@ 431-448 (lines=18) @@
|
| 428 |
|
evc.sync() |
| 429 |
|
return jsonify("Operation successful"), 201 |
| 430 |
|
|
| 431 |
|
@rest("v2/evc/metadata/<key>", methods=["DELETE"]) |
| 432 |
|
@validate_openapi(spec) |
| 433 |
|
def bulk_delete_metadata(self, data, key): |
| 434 |
|
"""Delete metada from a bulk of EVCs""" |
| 435 |
|
circuit_ids = data.pop("circuit_ids") |
| 436 |
|
self.mongo_controller.update_evcs(circuit_ids, {key: ""}, "del") |
| 437 |
|
|
| 438 |
|
fail_evcs = [] |
| 439 |
|
for _id in circuit_ids: |
| 440 |
|
try: |
| 441 |
|
evc = self.circuits[_id] |
| 442 |
|
evc.remove_metadata(key) |
| 443 |
|
except KeyError: |
| 444 |
|
fail_evcs.append(_id) |
| 445 |
|
|
| 446 |
|
if fail_evcs: |
| 447 |
|
return jsonify(fail_evcs), 404 |
| 448 |
|
return jsonify("Operation successful"), 200 |
| 449 |
|
|
| 450 |
|
@rest("v2/evc/<circuit_id>/metadata/<key>", methods=["DELETE"]) |
| 451 |
|
def delete_metadata(self, circuit_id, key): |
|
@@ 381-398 (lines=18) @@
|
| 378 |
|
except KeyError as error: |
| 379 |
|
raise NotFound(f"circuit_id {circuit_id} not found.") from error |
| 380 |
|
|
| 381 |
|
@rest("v2/evc/metadata", methods=["POST"]) |
| 382 |
|
@validate_openapi(spec) |
| 383 |
|
def bulk_add_metadata(self, data): |
| 384 |
|
"""Add metadata to a bulk of EVCs.""" |
| 385 |
|
circuit_ids = data.pop("circuit_ids") |
| 386 |
|
self.mongo_controller.update_evcs(circuit_ids, data, "add") |
| 387 |
|
|
| 388 |
|
fail_evcs = [] |
| 389 |
|
for _id in circuit_ids: |
| 390 |
|
try: |
| 391 |
|
evc = self.circuits[_id] |
| 392 |
|
evc.extend_metadata(data) |
| 393 |
|
except KeyError: |
| 394 |
|
fail_evcs.append(_id) |
| 395 |
|
|
| 396 |
|
if fail_evcs: |
| 397 |
|
return jsonify(fail_evcs), 404 |
| 398 |
|
return jsonify("Operation successful"), 201 |
| 399 |
|
|
| 400 |
|
@rest("v2/evc/<circuit_id>/metadata", methods=["POST"]) |
| 401 |
|
def add_metadata(self, circuit_id): |