Skip to content

Commit 55e8648

Browse files
rkorsakkeithrfung
authored andcommitted
✨ Add new endpoint for Election constants (#56)
1 parent 975b443 commit 55e8648

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

app/api/v1/endpoints/election.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from electionguard.election import ElectionDescription
1+
from electionguard.election import ElectionDescription, ElectionConstants
22
from fastapi import APIRouter, HTTPException
33
from os.path import realpath, join
44
from typing import Any
5+
from app.utils.serialize import write_json_object
56

67

78
router = APIRouter()
@@ -11,6 +12,15 @@
1112
READ = "r"
1213

1314

15+
@router.get("/constants")
16+
def get_election_constants() -> Any:
17+
"""
18+
Return the constants defined for an election
19+
"""
20+
constants = ElectionConstants()
21+
return write_json_object(constants)
22+
23+
1424
@router.get("/description")
1525
def get_default_election_description() -> Any:
1626
"""

tests/ElectionGuard Web Api.postman_collection.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@
117117
}
118118
},
119119
"response": []
120+
},
121+
{
122+
"name": "Get Election Constants",
123+
"request": {
124+
"method": "GET",
125+
"header": [],
126+
"url": {
127+
"raw": "{{url}}/api/{{version}}/election/constants",
128+
"host": [
129+
"{{url}}"
130+
],
131+
"path": [
132+
"api",
133+
"{{version}}",
134+
"election",
135+
"constants"
136+
]
137+
}
138+
},
139+
"response": []
120140
}
121141
],
122142
"protocolProfileBehavior": {}

0 commit comments

Comments
 (0)