Code Duplication    Length = 18-18 lines in 2 locations

main.py 2 locations

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