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