summaryrefslogtreecommitdiff
path: root/opendc/api
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/api')
-rw-r--r--opendc/api/v1/datacenters/datacenterId/endpoint.py5
-rw-r--r--opendc/api/v1/datacenters/datacenterId/rooms/endpoint.py14
-rw-r--r--opendc/api/v1/experiments/experimentId/endpoint.py13
-rw-r--r--opendc/api/v1/experiments/experimentId/last-simulated-tick/endpoint.py7
-rw-r--r--opendc/api/v1/experiments/experimentId/machine-states/endpoint.py7
-rw-r--r--opendc/api/v1/experiments/experimentId/rack-states/endpoint.py7
-rw-r--r--opendc/api/v1/experiments/experimentId/room-states/endpoint.py7
-rw-r--r--opendc/api/v1/experiments/experimentId/statistics/task-durations/endpoint.py7
-rw-r--r--opendc/api/v1/experiments/experimentId/task-states/endpoint.py5
-rw-r--r--opendc/api/v1/jobs/jobId/endpoint.py3
-rw-r--r--opendc/api/v1/jobs/jobId/tasks/endpoint.py5
-rw-r--r--opendc/api/v1/paths.json102
-rw-r--r--opendc/api/v1/paths/pathId/branches/endpoint.py27
-rw-r--r--opendc/api/v1/paths/pathId/endpoint.py6
-rw-r--r--opendc/api/v1/paths/pathId/sections/endpoint.py7
-rw-r--r--opendc/api/v1/room-types/endpoint.py1
-rw-r--r--opendc/api/v1/room-types/name/allowed-objects/endpoint.py5
-rw-r--r--opendc/api/v1/rooms/roomId/endpoint.py19
-rw-r--r--opendc/api/v1/rooms/roomId/tiles/endpoint.py14
-rw-r--r--opendc/api/v1/schedulers/endpoint.py1
-rw-r--r--opendc/api/v1/sections/sectionId/endpoint.py8
-rw-r--r--opendc/api/v1/simulations/endpoint.py23
-rw-r--r--opendc/api/v1/simulations/simulationId/authorizations/endpoint.py5
-rw-r--r--opendc/api/v1/simulations/simulationId/authorizations/userId/endpoint.py32
-rw-r--r--opendc/api/v1/simulations/simulationId/datacenters/endpoint.py7
-rw-r--r--opendc/api/v1/simulations/simulationId/endpoint.py19
-rw-r--r--opendc/api/v1/simulations/simulationId/experiments/endpoint.py15
-rw-r--r--opendc/api/v1/simulations/simulationId/paths/endpoint.py5
-rw-r--r--opendc/api/v1/specifications/cpus/endpoint.py1
-rw-r--r--opendc/api/v1/specifications/cpus/id/endpoint.py3
-rw-r--r--opendc/api/v1/specifications/failure-models/endpoint.py1
-rw-r--r--opendc/api/v1/specifications/failure-models/id/endpoint.py3
-rw-r--r--opendc/api/v1/specifications/gpus/endpoint.py1
-rw-r--r--opendc/api/v1/specifications/gpus/id/endpoint.py3
-rw-r--r--opendc/api/v1/specifications/memories/endpoint.py1
-rw-r--r--opendc/api/v1/specifications/memories/id/endpoint.py3
-rw-r--r--opendc/api/v1/specifications/storages/endpoint.py1
-rw-r--r--opendc/api/v1/specifications/storages/id/endpoint.py3
-rw-r--r--opendc/api/v1/tiles/tileId/endpoint.py8
-rw-r--r--opendc/api/v1/tiles/tileId/rack/endpoint.py32
-rw-r--r--opendc/api/v1/tiles/tileId/rack/machines/endpoint.py16
-rw-r--r--opendc/api/v1/tiles/tileId/rack/machines/position/endpoint.py17
-rw-r--r--opendc/api/v1/traces/endpoint.py1
-rw-r--r--opendc/api/v1/traces/traceId/endpoint.py3
-rw-r--r--opendc/api/v1/traces/traceId/jobs/endpoint.py7
-rw-r--r--opendc/api/v1/users/endpoint.py20
-rw-r--r--opendc/api/v1/users/userId/authorizations/endpoint.py5
-rw-r--r--opendc/api/v1/users/userId/endpoint.py20
48 files changed, 293 insertions, 232 deletions
diff --git a/opendc/api/v1/datacenters/datacenterId/endpoint.py b/opendc/api/v1/datacenters/datacenterId/endpoint.py
index 75d0a9cf..9444fb80 100644
--- a/opendc/api/v1/datacenters/datacenterId/endpoint.py
+++ b/opendc/api/v1/datacenters/datacenterId/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.datacenter import Datacenter
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Datacenter."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'datacenterId': 'int'
}
)
diff --git a/opendc/api/v1/datacenters/datacenterId/rooms/endpoint.py b/opendc/api/v1/datacenters/datacenterId/rooms/endpoint.py
index 31545a1e..cd96f97f 100644
--- a/opendc/api/v1/datacenters/datacenterId/rooms/endpoint.py
+++ b/opendc/api/v1/datacenters/datacenterId/rooms/endpoint.py
@@ -1,8 +1,9 @@
-from opendc.models.room import Room
from opendc.models.datacenter import Datacenter
-from opendc.util import database, exceptions
+from opendc.models.room import Room
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Datacenter's Rooms."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'datacenterId': 'int'
}
)
@@ -41,6 +42,7 @@ def GET(request):
[x.to_JSON() for x in rooms]
)
+
def POST(request):
"""Add a Room."""
@@ -48,10 +50,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'datacenterId': 'int'
},
- body = {
+ body={
'room': {
'id': 'int',
'datacenterId': 'int',
@@ -61,7 +63,7 @@ def POST(request):
)
except exceptions.ParameterError as e:
return Response(400, e.message)
-
+
# Make sure the passed object's datacenter id matches the path datacenter id
if request.params_path['datacenterId'] != request.params_body['room']['datacenterId']:
diff --git a/opendc/api/v1/experiments/experimentId/endpoint.py b/opendc/api/v1/experiments/experimentId/endpoint.py
index 3bdd30d2..59e0e0fe 100644
--- a/opendc/api/v1/experiments/experimentId/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/endpoint.py
@@ -1,13 +1,14 @@
from opendc.models.experiment import Experiment
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment."""
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -39,6 +40,7 @@ def GET(request):
experiment.to_JSON()
)
+
def PUT(request):
"""Update this Experiment's Path, Trace, Scheduler, and/or name."""
@@ -46,10 +48,10 @@ def PUT(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
},
- body = {
+ body={
'experiment': {
'pathId': 'int',
'traceId': 'int',
@@ -97,6 +99,7 @@ def PUT(request):
experiment.to_JSON()
)
+
def DELETE(request):
"""Delete this Experiment."""
@@ -104,7 +107,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
diff --git a/opendc/api/v1/experiments/experimentId/last-simulated-tick/endpoint.py b/opendc/api/v1/experiments/experimentId/last-simulated-tick/endpoint.py
index 24eb8932..b4b19f59 100644
--- a/opendc/api/v1/experiments/experimentId/last-simulated-tick/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/last-simulated-tick/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.experiment import Experiment
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's last simulated tick."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -21,7 +22,7 @@ def GET(request):
experiment = Experiment.from_primary_key((request.params_path['experimentId'],))
- # Make sure this Experiment exisits
+ # Make sure this Experiment exists
if not experiment.exists():
return Response(404, '{} not found.'.format(experiment))
diff --git a/opendc/api/v1/experiments/experimentId/machine-states/endpoint.py b/opendc/api/v1/experiments/experimentId/machine-states/endpoint.py
index 97113e4a..8ad588d2 100644
--- a/opendc/api/v1/experiments/experimentId/machine-states/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/machine-states/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.experiment import Experiment
from opendc.models.machine_state import MachineState
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's Machine States."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -22,7 +23,7 @@ def GET(request):
experiment = Experiment.from_primary_key((request.params_path['experimentId'],))
- # Make sure this Experiment exisits
+ # Make sure this Experiment exists
if not experiment.exists():
return Response(404, '{} not found.'.format(experiment))
diff --git a/opendc/api/v1/experiments/experimentId/rack-states/endpoint.py b/opendc/api/v1/experiments/experimentId/rack-states/endpoint.py
index daed45c5..03570039 100644
--- a/opendc/api/v1/experiments/experimentId/rack-states/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/rack-states/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.experiment import Experiment
from opendc.models.rack_state import RackState
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's Tack States."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -22,7 +23,7 @@ def GET(request):
experiment = Experiment.from_primary_key((request.params_path['experimentId'],))
- # Make sure this Experiment exisits
+ # Make sure this Experiment exists
if not experiment.exists():
return Response(404, '{} not found.'.format(experiment))
diff --git a/opendc/api/v1/experiments/experimentId/room-states/endpoint.py b/opendc/api/v1/experiments/experimentId/room-states/endpoint.py
index 9e283d34..2693dc89 100644
--- a/opendc/api/v1/experiments/experimentId/room-states/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/room-states/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.experiment import Experiment
from opendc.models.room_state import RoomState
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's Room States."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -22,7 +23,7 @@ def GET(request):
experiment = Experiment.from_primary_key((request.params_path['experimentId'],))
- # Make sure this Experiment exisits
+ # Make sure this Experiment exists
if not experiment.exists():
return Response(404, '{} not found.'.format(experiment))
diff --git a/opendc/api/v1/experiments/experimentId/statistics/task-durations/endpoint.py b/opendc/api/v1/experiments/experimentId/statistics/task-durations/endpoint.py
index ad73daa7..b8311f08 100644
--- a/opendc/api/v1/experiments/experimentId/statistics/task-durations/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/statistics/task-durations/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.experiment import Experiment
from opendc.models.task_duration import TaskDuration
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's Task Durations."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
@@ -22,7 +23,7 @@ def GET(request):
experiment = Experiment.from_primary_key((request.params_path['experimentId'],))
- # Make sure this Experiment exisits
+ # Make sure this Experiment exists
if not experiment.exists():
return Response(404, '{} not found.'.format(experiment))
diff --git a/opendc/api/v1/experiments/experimentId/task-states/endpoint.py b/opendc/api/v1/experiments/experimentId/task-states/endpoint.py
index 805d86fb..0c3fae89 100644
--- a/opendc/api/v1/experiments/experimentId/task-states/endpoint.py
+++ b/opendc/api/v1/experiments/experimentId/task-states/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.experiment import Experiment
from opendc.models.task_state import TaskState
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Experiment's Task States."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'experimentId': 'int'
}
)
diff --git a/opendc/api/v1/jobs/jobId/endpoint.py b/opendc/api/v1/jobs/jobId/endpoint.py
index 84b8f3c4..da4dcd9d 100644
--- a/opendc/api/v1/jobs/jobId/endpoint.py
+++ b/opendc/api/v1/jobs/jobId/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.job import Job
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Job."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'jobId': 'int'
}
)
diff --git a/opendc/api/v1/jobs/jobId/tasks/endpoint.py b/opendc/api/v1/jobs/jobId/tasks/endpoint.py
index 9b6a1cab..04ac5b8c 100644
--- a/opendc/api/v1/jobs/jobId/tasks/endpoint.py
+++ b/opendc/api/v1/jobs/jobId/tasks/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.job import Job
from opendc.models.task import Task
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Job's Tasks."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'jobId': 'int'
}
)
diff --git a/opendc/api/v1/paths.json b/opendc/api/v1/paths.json
index 79133968..bac7fc71 100644
--- a/opendc/api/v1/paths.json
+++ b/opendc/api/v1/paths.json
@@ -1,53 +1,53 @@
[
- "/users",
- "/users/{userId}",
- "/users/{userId}/authorizations",
- "/simulations",
- "/simulations/{simulationId}",
- "/simulations/{simulationId}/authorizations",
- "/simulations/{simulationId}/authorizations/{userId}",
- "/datacenters/{datacenterId}",
- "/datacenters/{datacenterId}/rooms",
- "/rooms/{roomId}",
- "/rooms/{roomId}/tiles",
- "/tiles/{tileId}",
- "/tiles/{tileId}/cooling-item",
- "/tiles/{tileId}/psu",
- "/tiles/{tileId}/rack",
- "/tiles/{tileId}/rack/machines",
- "/tiles/{tileId}/rack/machines/{position}",
- "/simulations/{simulationId}/experiments",
- "/experiments/{experimentId}",
- "/experiments/{experimentId}/last-simulated-tick",
- "/experiments/{experimentId}/machine-states",
- "/experiments/{experimentId}/rack-states",
- "/experiments/{experimentId}/room-states",
- "/experiments/{experimentId}/task-states",
- "/simulations/{simulationId}/paths",
- "/paths/{pathId}",
- "/paths/{pathId}/branches",
- "/paths/{pathId}/sections",
- "/sections/{sectionId}",
- "/schedulers",
- "/traces",
- "/traces/{traceId}",
- "/traces/{traceId}/jobs",
- "/jobs/{jobId}",
- "/jobs/{jobId}/tasks",
- "/room-types",
- "/room-types/{name}/allowed-objects",
- "/specifications/cooling-items",
- "/specifications/cooling-items/{id}",
- "/specifications/cpus",
- "/specifications/cpus/{id}",
- "/specifications/failure-models",
- "/specifications/failure-models/{id}",
- "/specifications/gpus",
- "/specifications/gpus/{id}",
- "/specifications/memories",
- "/specifications/memories/{id}",
- "/specifications/psus",
- "/specifications/psus/{id}",
- "/specifications/storages",
- "/specifications/storages/{id}"
+ "/users",
+ "/users/{userId}",
+ "/users/{userId}/authorizations",
+ "/simulations",
+ "/simulations/{simulationId}",
+ "/simulations/{simulationId}/authorizations",
+ "/simulations/{simulationId}/authorizations/{userId}",
+ "/datacenters/{datacenterId}",
+ "/datacenters/{datacenterId}/rooms",
+ "/rooms/{roomId}",
+ "/rooms/{roomId}/tiles",
+ "/tiles/{tileId}",
+ "/tiles/{tileId}/cooling-item",
+ "/tiles/{tileId}/psu",
+ "/tiles/{tileId}/rack",
+ "/tiles/{tileId}/rack/machines",
+ "/tiles/{tileId}/rack/machines/{position}",
+ "/simulations/{simulationId}/experiments",
+ "/experiments/{experimentId}",
+ "/experiments/{experimentId}/last-simulated-tick",
+ "/experiments/{experimentId}/machine-states",
+ "/experiments/{experimentId}/rack-states",
+ "/experiments/{experimentId}/room-states",
+ "/experiments/{experimentId}/task-states",
+ "/simulations/{simulationId}/paths",
+ "/paths/{pathId}",
+ "/paths/{pathId}/branches",
+ "/paths/{pathId}/sections",
+ "/sections/{sectionId}",
+ "/schedulers",
+ "/traces",
+ "/traces/{traceId}",
+ "/traces/{traceId}/jobs",
+ "/jobs/{jobId}",
+ "/jobs/{jobId}/tasks",
+ "/room-types",
+ "/room-types/{name}/allowed-objects",
+ "/specifications/cooling-items",
+ "/specifications/cooling-items/{id}",
+ "/specifications/cpus",
+ "/specifications/cpus/{id}",
+ "/specifications/failure-models",
+ "/specifications/failure-models/{id}",
+ "/specifications/gpus",
+ "/specifications/gpus/{id}",
+ "/specifications/memories",
+ "/specifications/memories/{id}",
+ "/specifications/psus",
+ "/specifications/psus/{id}",
+ "/specifications/storages",
+ "/specifications/storages/{id}"
] \ No newline at end of file
diff --git a/opendc/api/v1/paths/pathId/branches/endpoint.py b/opendc/api/v1/paths/pathId/branches/endpoint.py
index 2ac4236a..1f330472 100644
--- a/opendc/api/v1/paths/pathId/branches/endpoint.py
+++ b/opendc/api/v1/paths/pathId/branches/endpoint.py
@@ -11,6 +11,7 @@ from opendc.models.tile import Tile
from opendc.util import database, exceptions
from opendc.util.rest import Request, Response
+
def POST(request):
"""Create a new Path that branches off of this Path at the specified tick."""
@@ -18,10 +19,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'pathId': 'int'
},
- body = {
+ body={
'section': {
'startTick': 'int'
}
@@ -48,8 +49,8 @@ def POST(request):
# Create the new Path
new_path = Path(
- simulation_id = current_path.simulation_id,
- datetime_created = database.datetime_to_string(datetime.now())
+ simulation_id=current_path.simulation_id,
+ datetime_created=database.datetime_to_string(datetime.now())
)
new_path.insert()
@@ -62,11 +63,10 @@ def POST(request):
for current_section in current_sections:
if current_section.start_tick < request.params_body['section']['startTick'] or current_section.start_tick == 0:
-
new_section = Section(
- path_id = new_path.id,
- datacenter_id = current_section.datacenter_id,
- start_tick = current_section.start_tick
+ path_id=new_path.id,
+ datacenter_id=current_section.datacenter_id,
+ start_tick=current_section.start_tick
)
new_section.insert()
@@ -92,9 +92,9 @@ def POST(request):
if last_section.start_tick != 0:
new_section = Section(
- path_id = new_path.id,
- datacenter_id = path_parameters['datacenterId'],
- start_tick = request.params_body['section']['startTick']
+ path_id=new_path.id,
+ datacenter_id=path_parameters['datacenterId'],
+ start_tick=request.params_body['section']['startTick']
)
new_section.insert()
@@ -113,7 +113,7 @@ def POST(request):
message = old_room.generate_api_call(path_parameters, request.token)
response = Request(message).process()
-
+
path_parameters['roomId'] = response.content['id']
# ... then the Tiles, ...
@@ -147,10 +147,9 @@ def POST(request):
old_machines = Machine.query('rack_id', old_rack.id)
for old_machine in old_machines:
-
old_machine.read()
old_machine.rack_id = path_parameters['rackId']
-
+
message = old_machine.generate_api_call(path_parameters, request.token)
response = Request(message).process()
diff --git a/opendc/api/v1/paths/pathId/endpoint.py b/opendc/api/v1/paths/pathId/endpoint.py
index 470063d2..7ade19ce 100644
--- a/opendc/api/v1/paths/pathId/endpoint.py
+++ b/opendc/api/v1/paths/pathId/endpoint.py
@@ -1,8 +1,8 @@
from opendc.models.path import Path
-from opendc.models.simulation import Simulation
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Path."""
@@ -10,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'pathId': 'int'
}
)
diff --git a/opendc/api/v1/paths/pathId/sections/endpoint.py b/opendc/api/v1/paths/pathId/sections/endpoint.py
index 5b08863b..d4161839 100644
--- a/opendc/api/v1/paths/pathId/sections/endpoint.py
+++ b/opendc/api/v1/paths/pathId/sections/endpoint.py
@@ -1,8 +1,9 @@
-from opendc.models.section import Section
from opendc.models.path import Path
-from opendc.util import database, exceptions
+from opendc.models.section import Section
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Path's Sections."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'pathId': 'int'
}
)
diff --git a/opendc/api/v1/room-types/endpoint.py b/opendc/api/v1/room-types/endpoint.py
index 2030b538..fe00f226 100644
--- a/opendc/api/v1/room-types/endpoint.py
+++ b/opendc/api/v1/room-types/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.room_type import RoomType
from opendc.util.rest import Response
+
def GET(request):
"""Get all available room types."""
diff --git a/opendc/api/v1/room-types/name/allowed-objects/endpoint.py b/opendc/api/v1/room-types/name/allowed-objects/endpoint.py
index 76b863f1..a574591c 100644
--- a/opendc/api/v1/room-types/name/allowed-objects/endpoint.py
+++ b/opendc/api/v1/room-types/name/allowed-objects/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.allowed_object import AllowedObject
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this room's allowed objects."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'name': 'string'
}
)
@@ -27,4 +28,4 @@ def GET(request):
200,
'Successfully retrieved AllowedObjects.',
[x.to_JSON() for x in allowed_objects]
- )
+ )
diff --git a/opendc/api/v1/rooms/roomId/endpoint.py b/opendc/api/v1/rooms/roomId/endpoint.py
index 6d7ab261..1dfc32cc 100644
--- a/opendc/api/v1/rooms/roomId/endpoint.py
+++ b/opendc/api/v1/rooms/roomId/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.room import Room
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Room."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'roomId': 'int'
}
)
@@ -41,24 +42,25 @@ def GET(request):
room.to_JSON()
)
+
def PUT(request):
"""Update this Room's name and type."""
# Make sure required parameters are there
-
+
try:
request.check_required_parameters(
- path = {
+ path={
'roomId': 'int'
},
- body = {
+ body={
'room': {
'name': 'string',
'roomType': 'string'
}
}
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -94,6 +96,7 @@ def PUT(request):
room.to_JSON()
)
+
def DELETE(request):
"""Delete this Room."""
@@ -101,7 +104,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'roomId': 'int'
}
)
@@ -129,6 +132,6 @@ def DELETE(request):
return Response(
200,
- 'Sucessfully deleted {}.'.format(room),
+ 'Successfully deleted {}.'.format(room),
room.to_JSON()
)
diff --git a/opendc/api/v1/rooms/roomId/tiles/endpoint.py b/opendc/api/v1/rooms/roomId/tiles/endpoint.py
index 9d17c644..a4ef51e7 100644
--- a/opendc/api/v1/rooms/roomId/tiles/endpoint.py
+++ b/opendc/api/v1/rooms/roomId/tiles/endpoint.py
@@ -1,8 +1,9 @@
-from opendc.models.tile import Tile
from opendc.models.room import Room
-from opendc.util import database, exceptions
+from opendc.models.tile import Tile
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Room's Tiles."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'roomId': 'int'
}
)
@@ -45,6 +46,7 @@ def GET(request):
[x.to_JSON() for x in tiles]
)
+
def POST(request):
"""Add a Tile."""
@@ -52,10 +54,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'roomId': 'int'
},
- body = {
+ body={
'tile': {
'roomId': 'int',
'positionX': 'int',
@@ -104,7 +106,7 @@ def POST(request):
if e.message == 'OccupiedTilePosition':
return Response(409, 'Tile position occupied.')
-
+
elif e.message == 'InvalidTilePosition':
return Response(400, 'Invalid Tile position (new Tiles must neighbor existing Tiles).')
diff --git a/opendc/api/v1/schedulers/endpoint.py b/opendc/api/v1/schedulers/endpoint.py
index 206c7cb9..36537764 100644
--- a/opendc/api/v1/schedulers/endpoint.py
+++ b/opendc/api/v1/schedulers/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.scheduler import Scheduler
from opendc.util.rest import Response
+
def GET(request):
"""Get all available Schedulers."""
diff --git a/opendc/api/v1/sections/sectionId/endpoint.py b/opendc/api/v1/sections/sectionId/endpoint.py
index 48e724bd..94c81d37 100644
--- a/opendc/api/v1/sections/sectionId/endpoint.py
+++ b/opendc/api/v1/sections/sectionId/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.section import Section
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Path's Sections."""
@@ -9,14 +10,13 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'sectionId': 'int'
}
)
except exceptions.ParameterError as e:
return Response(400, e.message)
-
# Instantiate a Section from the database
section = Section.from_primary_key((request.params_path['sectionId'],))
@@ -34,7 +34,7 @@ def GET(request):
# Return the Section
section.read()
-
+
return Response(
200,
'Successfully retrieved {}.'.format(section),
diff --git a/opendc/api/v1/simulations/endpoint.py b/opendc/api/v1/simulations/endpoint.py
index ff669290..a8637728 100644
--- a/opendc/api/v1/simulations/endpoint.py
+++ b/opendc/api/v1/simulations/endpoint.py
@@ -9,6 +9,7 @@ from opendc.models.user import User
from opendc.util import database, exceptions
from opendc.util.rest import Response
+
def POST(request):
"""Create a new simulation, and return that new simulation."""
@@ -16,7 +17,7 @@ def POST(request):
try:
request.check_required_parameters(
- body = {
+ body={
'simulation': {
'name': 'string'
}
@@ -42,9 +43,9 @@ def POST(request):
# Instantiate an Authorization and insert it into the database
authorization = Authorization(
- user_id = User.from_google_id(request.google_id).id,
- simulation_id = simulation.id,
- authorization_level = 'OWN'
+ user_id=User.from_google_id(request.google_id).id,
+ simulation_id=simulation.id,
+ authorization_level='OWN'
)
authorization.insert()
@@ -52,8 +53,8 @@ def POST(request):
# Instantiate a Path and insert it into the database
path = Path(
- simulation_id = simulation.id,
- datetime_created = database.datetime_to_string(datetime.now())
+ simulation_id=simulation.id,
+ datetime_created=database.datetime_to_string(datetime.now())
)
path.insert()
@@ -61,8 +62,8 @@ def POST(request):
# Instantiate a Datacenter and insert it into the database
datacenter = Datacenter(
- starred = 0,
- simulation_id = simulation.id
+ starred=0,
+ simulation_id=simulation.id
)
datacenter.insert()
@@ -70,9 +71,9 @@ def POST(request):
# Instantiate a Section and insert it into the database
section = Section(
- path_id = path.id,
- datacenter_id = datacenter.id,
- start_tick = 0
+ path_id=path.id,
+ datacenter_id=datacenter.id,
+ start_tick=0
)
section.insert()
diff --git a/opendc/api/v1/simulations/simulationId/authorizations/endpoint.py b/opendc/api/v1/simulations/simulationId/authorizations/endpoint.py
index d880564e..1d6b494e 100644
--- a/opendc/api/v1/simulations/simulationId/authorizations/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/authorizations/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.authorization import Authorization
from opendc.models.simulation import Simulation
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Find all authorizations for a Simulation."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
}
)
diff --git a/opendc/api/v1/simulations/simulationId/authorizations/userId/endpoint.py b/opendc/api/v1/simulations/simulationId/authorizations/userId/endpoint.py
index c3e599cf..46458ffc 100644
--- a/opendc/api/v1/simulations/simulationId/authorizations/userId/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/authorizations/userId/endpoint.py
@@ -1,9 +1,10 @@
from opendc.models.authorization import Authorization
from opendc.models.simulation import Simulation
from opendc.models.user import User
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def DELETE(request):
"""Delete a user's authorization level over a simulation."""
@@ -11,7 +12,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int',
'userId': 'int'
}
@@ -21,7 +22,7 @@ def DELETE(request):
return Response(400, e.message)
# Instantiate an Authorization
-
+
authorization = Authorization.from_primary_key((
request.params_path['userId'],
request.params_path['simulationId']
@@ -30,7 +31,7 @@ def DELETE(request):
# Make sure this Authorization exists in the database
if not authorization.exists():
- return Response (404, '{} not found.'.format(authorization))
+ return Response(404, '{} not found.'.format(authorization))
# Make sure this User is allowed to delete this Authorization
@@ -47,14 +48,15 @@ def DELETE(request):
authorization.to_JSON()
)
+
def GET(request):
"""Get this User's Authorization over this Simulation."""
-
+
# Make sure required parameters are there
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int',
'userId': 'int'
}
@@ -62,7 +64,7 @@ def GET(request):
except exceptions.ParameterError as e:
return Response(400, e.message)
-
+
# Instantiate an Authorization
authorization = Authorization.from_primary_key((
@@ -87,6 +89,7 @@ def GET(request):
authorization.to_JSON()
)
+
def POST(request):
"""Add an authorization for a user's access to a simulation."""
@@ -94,11 +97,11 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'userId': 'int',
'simulationId': 'int'
},
- body = {
+ body={
'authorization': {
'authorizationLevel': 'string'
}
@@ -143,7 +146,7 @@ def POST(request):
except exceptions.ForeignKeyError:
return Response(400, 'Invalid authorizationLevel')
-
+
# Return this Authorization
return Response(
@@ -152,6 +155,7 @@ def POST(request):
authorization.to_JSON()
)
+
def PUT(request):
"""Change a user's authorization level over a simulation."""
@@ -159,11 +163,11 @@ def PUT(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int',
'userId': 'int'
},
- body = {
+ body={
'authorization': {
'authorizationLevel': 'string'
}
@@ -192,7 +196,7 @@ def PUT(request):
return Response(403, 'Forbidden from updating {}.'.format(authorization))
# Try to update this Authorization
-
+
try:
authorization.update()
@@ -200,7 +204,7 @@ def PUT(request):
return Response(400, 'Invalid authorization level.')
# Return this Authorization
-
+
return Response(
200,
'Successfully updated {}.'.format(authorization),
diff --git a/opendc/api/v1/simulations/simulationId/datacenters/endpoint.py b/opendc/api/v1/simulations/simulationId/datacenters/endpoint.py
index d53cd1c8..e28402e4 100644
--- a/opendc/api/v1/simulations/simulationId/datacenters/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/datacenters/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.datacenter import Datacenter
from opendc.models.simulation import Simulation
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def POST(request):
"""Add a new Datacenter to this Simulation."""
@@ -10,10 +11,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
},
- body = {
+ body={
'datacenter': {
'starred': 'int',
'simulationId': 'int'
diff --git a/opendc/api/v1/simulations/simulationId/endpoint.py b/opendc/api/v1/simulations/simulationId/endpoint.py
index 01623973..5e595740 100644
--- a/opendc/api/v1/simulations/simulationId/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/endpoint.py
@@ -1,11 +1,10 @@
from datetime import datetime
-from opendc.models.authorization import Authorization
from opendc.models.simulation import Simulation
-from opendc.models.user import User
from opendc.util import database, exceptions
from opendc.util.rest import Response
+
def DELETE(request):
"""Delete this Simulation."""
@@ -13,14 +12,14 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
}
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
-
+
# Instantiate a Simulation and make sure it exists
simulation = Simulation.from_primary_key((request.params_path['simulationId'],))
@@ -45,6 +44,7 @@ def DELETE(request):
simulation.to_JSON()
)
+
def GET(request):
"""Get this Simulation."""
@@ -52,7 +52,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
}
)
@@ -82,6 +82,7 @@ def GET(request):
simulation.to_JSON()
)
+
def PUT(request):
"""Update a simulation's name."""
@@ -89,12 +90,12 @@ def PUT(request):
try:
request.check_required_parameters(
- body = {
+ body={
'simulation': {
'name': 'name'
}
},
- path = {
+ path={
'simulationId': 'int'
}
)
@@ -115,7 +116,7 @@ def PUT(request):
return Response(403, 'Forbidden from editing {}.'.format(simulation))
# Update this Simulation in the database
-
+
simulation.read()
simulation.name = request.params_body['simulation']['name']
diff --git a/opendc/api/v1/simulations/simulationId/experiments/endpoint.py b/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
index 034e82a1..86fadb24 100644
--- a/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/experiments/endpoint.py
@@ -1,9 +1,9 @@
from opendc.models.experiment import Experiment
-from opendc.models.queued_experiment import QueuedExperiment
from opendc.models.simulation import Simulation
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Simulation's Experiments."""
@@ -11,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
}
)
@@ -43,6 +43,7 @@ def GET(request):
[x.to_JSON() for x in experiments]
)
+
def POST(request):
"""Add a new Experiment for this Simulation."""
@@ -50,10 +51,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
},
- body = {
+ body={
'experiment': {
'simulationId': 'int',
'pathId': 'int',
@@ -96,12 +97,12 @@ def POST(request):
try:
experiment.insert()
-
+
except exceptions.ForeignKeyError as e:
return Response(400, 'Foreign key constraint not met.' + e.message)
# Return this Experiment
-
+
experiment.read()
return Response(
diff --git a/opendc/api/v1/simulations/simulationId/paths/endpoint.py b/opendc/api/v1/simulations/simulationId/paths/endpoint.py
index e74c8d22..e4aab427 100644
--- a/opendc/api/v1/simulations/simulationId/paths/endpoint.py
+++ b/opendc/api/v1/simulations/simulationId/paths/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.path import Path
from opendc.models.simulation import Simulation
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Simulation's Paths."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'simulationId': 'int'
}
)
diff --git a/opendc/api/v1/specifications/cpus/endpoint.py b/opendc/api/v1/specifications/cpus/endpoint.py
index 5c856255..5cdbb9ec 100644
--- a/opendc/api/v1/specifications/cpus/endpoint.py
+++ b/opendc/api/v1/specifications/cpus/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.cpu import CPU
from opendc.util.rest import Response
+
def GET(request):
"""Get a list of the specifications of all CPUs."""
diff --git a/opendc/api/v1/specifications/cpus/id/endpoint.py b/opendc/api/v1/specifications/cpus/id/endpoint.py
index 158576cb..c2453e51 100644
--- a/opendc/api/v1/specifications/cpus/id/endpoint.py
+++ b/opendc/api/v1/specifications/cpus/id/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.cpu import CPU
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get the specs of a CPU."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'id': 'int'
}
)
diff --git a/opendc/api/v1/specifications/failure-models/endpoint.py b/opendc/api/v1/specifications/failure-models/endpoint.py
index 2530d032..fff668c0 100644
--- a/opendc/api/v1/specifications/failure-models/endpoint.py
+++ b/opendc/api/v1/specifications/failure-models/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.failure_model import FailureModel
from opendc.util.rest import Response
+
def GET(request):
"""Get all Failure Models."""
diff --git a/opendc/api/v1/specifications/failure-models/id/endpoint.py b/opendc/api/v1/specifications/failure-models/id/endpoint.py
index 8a7d2e1d..0797c9c9 100644
--- a/opendc/api/v1/specifications/failure-models/id/endpoint.py
+++ b/opendc/api/v1/specifications/failure-models/id/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.failure_model import FailureModel
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Failure Model."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'id': 'int'
}
)
diff --git a/opendc/api/v1/specifications/gpus/endpoint.py b/opendc/api/v1/specifications/gpus/endpoint.py
index 8728d203..5676f62b 100644
--- a/opendc/api/v1/specifications/gpus/endpoint.py
+++ b/opendc/api/v1/specifications/gpus/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.gpu import GPU
from opendc.util.rest import Response
+
def GET(request):
"""Get a list of the specifications of all GPUs."""
diff --git a/opendc/api/v1/specifications/gpus/id/endpoint.py b/opendc/api/v1/specifications/gpus/id/endpoint.py
index 41b5a9e4..81113dc3 100644
--- a/opendc/api/v1/specifications/gpus/id/endpoint.py
+++ b/opendc/api/v1/specifications/gpus/id/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.gpu import GPU
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get the specs of a GPU."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'id': 'int'
}
)
diff --git a/opendc/api/v1/specifications/memories/endpoint.py b/opendc/api/v1/specifications/memories/endpoint.py
index b275b6f0..271824b3 100644
--- a/opendc/api/v1/specifications/memories/endpoint.py
+++ b/opendc/api/v1/specifications/memories/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.memory import Memory
from opendc.util.rest import Response
+
def GET(request):
"""Get a list of the specifications of all Memories."""
diff --git a/opendc/api/v1/specifications/memories/id/endpoint.py b/opendc/api/v1/specifications/memories/id/endpoint.py
index 3132efab..863099ca 100644
--- a/opendc/api/v1/specifications/memories/id/endpoint.py
+++ b/opendc/api/v1/specifications/memories/id/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.memory import Memory
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get the specs of a Memory."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'id': 'int'
}
)
diff --git a/opendc/api/v1/specifications/storages/endpoint.py b/opendc/api/v1/specifications/storages/endpoint.py
index 875ed987..28f33177 100644
--- a/opendc/api/v1/specifications/storages/endpoint.py
+++ b/opendc/api/v1/specifications/storages/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.storage import Storage
from opendc.util.rest import Response
+
def GET(request):
"""Get a list of the specifications of all Storages."""
diff --git a/opendc/api/v1/specifications/storages/id/endpoint.py b/opendc/api/v1/specifications/storages/id/endpoint.py
index b0d254a4..ebe65857 100644
--- a/opendc/api/v1/specifications/storages/id/endpoint.py
+++ b/opendc/api/v1/specifications/storages/id/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.storage import Storage
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get the specs of a Storage."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'id': 'int'
}
)
diff --git a/opendc/api/v1/tiles/tileId/endpoint.py b/opendc/api/v1/tiles/tileId/endpoint.py
index deb76195..5ccc9cd7 100644
--- a/opendc/api/v1/tiles/tileId/endpoint.py
+++ b/opendc/api/v1/tiles/tileId/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.tile import Tile
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Tile."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
}
)
@@ -41,6 +42,7 @@ def GET(request):
tile.to_JSON()
)
+
def DELETE(request):
"""Delete this Tile."""
@@ -48,7 +50,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
}
)
diff --git a/opendc/api/v1/tiles/tileId/rack/endpoint.py b/opendc/api/v1/tiles/tileId/rack/endpoint.py
index 59338e9a..64245856 100644
--- a/opendc/api/v1/tiles/tileId/rack/endpoint.py
+++ b/opendc/api/v1/tiles/tileId/rack/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.rack import Rack
from opendc.models.tile import Tile
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Tile's Rack."""
@@ -10,11 +11,11 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
},
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -51,6 +52,7 @@ def GET(request):
rack.to_JSON()
)
+
def POST(request):
"""Add a Rack to this Tile if it is empty."""
@@ -58,10 +60,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
},
- body = {
+ body={
'rack': {
'name': 'string',
'capacity': 'int',
@@ -69,7 +71,7 @@ def POST(request):
}
}
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -93,7 +95,7 @@ def POST(request):
return Response(409, '{} occupied.'.format(tile))
# Instantiate a Rack and insert it into the database
-
+
rack = Rack.from_JSON(request.params_body['rack'])
rack.insert()
@@ -112,7 +114,8 @@ def POST(request):
'Successfully added {}.'.format(rack),
rack.to_JSON()
)
-
+
+
def PUT(request):
"""Update the Rack on this Tile."""
@@ -120,10 +123,10 @@ def PUT(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
},
- body = {
+ body={
'rack': {
'name': 'string',
'capacity': 'int',
@@ -131,7 +134,7 @@ def PUT(request):
}
}
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -175,6 +178,7 @@ def PUT(request):
rack.to_JSON()
)
+
def DELETE(request):
"""Delete this Tile's Rack."""
@@ -182,11 +186,11 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
},
)
-
+
except exceptions.ParameterError as e:
return Response(400, e.message)
@@ -217,7 +221,7 @@ def DELETE(request):
tile.object_id = None
tile.object_type = None
-
+
tile.update()
# Delete this Rack
diff --git a/opendc/api/v1/tiles/tileId/rack/machines/endpoint.py b/opendc/api/v1/tiles/tileId/rack/machines/endpoint.py
index 2d160713..5272c117 100644
--- a/opendc/api/v1/tiles/tileId/rack/machines/endpoint.py
+++ b/opendc/api/v1/tiles/tileId/rack/machines/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.machine import Machine
from opendc.models.rack import Rack
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Rack's Machines."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
}
)
@@ -45,6 +46,7 @@ def GET(request):
[x.to_JSON() for x in machines]
)
+
def POST(request):
"""Add a Machine to this rack."""
@@ -52,10 +54,10 @@ def POST(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int'
},
- body = {
+ body={
'machine': {
'rackId': 'int',
'position': 'int',
@@ -91,14 +93,14 @@ def POST(request):
return Response(403, 'Forbidden from viewing {}.'.format(rack))
# Instantiate a Machine
-
+
machine = Machine.from_JSON(request.params_body['machine'])
-
+
# Try to insert this Machine
try:
machine.insert()
-
+
except exceptions.ForeignKeyError:
return Response(409, 'Rack position occupied.')
diff --git a/opendc/api/v1/tiles/tileId/rack/machines/position/endpoint.py b/opendc/api/v1/tiles/tileId/rack/machines/position/endpoint.py
index 15e6cf96..99011fa4 100644
--- a/opendc/api/v1/tiles/tileId/rack/machines/position/endpoint.py
+++ b/opendc/api/v1/tiles/tileId/rack/machines/position/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.machine import Machine
from opendc.models.rack import Rack
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get the Machine at this location in this Rack."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int',
'position': 'int'
}
@@ -43,16 +44,17 @@ def GET(request):
machine.to_JSON()
)
+
def PUT(request):
"""Update the Machine at this location in this Rack."""
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int',
'position': 'int'
},
- body = {
+ body={
'machine': {
'rackId': 'int',
'position': 'int',
@@ -91,7 +93,7 @@ def PUT(request):
# Update this Machine
- machine.positoin = request.params_body['machine']['position']
+ machine.position = request.params_body['machine']['position']
machine.tags = request.params_body['machine']['tags']
machine.cpu_ids = request.params_body['machine']['cpuIds']
machine.gpu_ids = request.params_body['machine']['gpuIds']
@@ -100,7 +102,7 @@ def PUT(request):
try:
machine.update()
-
+
except exceptions.ForeignKeyError:
return Response(409, 'Rack position occupied.')
@@ -118,6 +120,7 @@ def PUT(request):
machine.to_JSON()
)
+
def DELETE(request):
"""Delete the Machine at this location in this Rack."""
@@ -125,7 +128,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'tileId': 'int',
'position': 'int'
}
diff --git a/opendc/api/v1/traces/endpoint.py b/opendc/api/v1/traces/endpoint.py
index 05d6fd48..78930b0f 100644
--- a/opendc/api/v1/traces/endpoint.py
+++ b/opendc/api/v1/traces/endpoint.py
@@ -1,6 +1,7 @@
from opendc.models.trace import Trace
from opendc.util.rest import Response
+
def GET(request):
"""Get all available Traces."""
diff --git a/opendc/api/v1/traces/traceId/endpoint.py b/opendc/api/v1/traces/traceId/endpoint.py
index eabb23a4..50993c41 100644
--- a/opendc/api/v1/traces/traceId/endpoint.py
+++ b/opendc/api/v1/traces/traceId/endpoint.py
@@ -2,6 +2,7 @@ from opendc.models.trace import Trace
from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Trace."""
@@ -9,7 +10,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'traceId': 'int'
}
)
diff --git a/opendc/api/v1/traces/traceId/jobs/endpoint.py b/opendc/api/v1/traces/traceId/jobs/endpoint.py
index 2f271c9e..bd2c6eb0 100644
--- a/opendc/api/v1/traces/traceId/jobs/endpoint.py
+++ b/opendc/api/v1/traces/traceId/jobs/endpoint.py
@@ -1,8 +1,9 @@
-from opendc.models.trace import Trace
from opendc.models.job import Job
-from opendc.util import database, exceptions
+from opendc.models.trace import Trace
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this Trace's Jobs."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'traceId': 'int'
}
)
diff --git a/opendc/api/v1/users/endpoint.py b/opendc/api/v1/users/endpoint.py
index 1c971b56..abd54f27 100644
--- a/opendc/api/v1/users/endpoint.py
+++ b/opendc/api/v1/users/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.user import User
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Search for a User using their email address."""
@@ -9,14 +10,14 @@ def GET(request):
try:
request.check_required_parameters(
- query = {
+ query={
'email': 'string'
}
)
except exceptions.ParameterError as e:
return Response(400, e.message)
-
+
# Instantiate and read a User from the database
user = User.from_email(request.params_query['email'])
@@ -34,6 +35,7 @@ def GET(request):
user.to_JSON()
)
+
def POST(request):
"""Add a new User."""
@@ -41,7 +43,7 @@ def POST(request):
try:
request.check_required_parameters(
- body = {
+ body={
'user': {
'email': 'string'
}
@@ -52,12 +54,12 @@ def POST(request):
return Response(400, e.message)
# Instantiate a User
-
+
request.params_body['user']['googleId'] = request.google_id
user = User.from_JSON(request.params_body['user'])
# Make sure a User with this Google ID does not already exist
-
+
if user.exists('google_id'):
user = user.from_google_id(user.google_id)
return Response(409, '{} already exists.'.format(user))
@@ -65,7 +67,7 @@ def POST(request):
# Make sure this User is authorized to create this User
if not request.google_id == user.google_id:
- return Response(403, 'Fobidden from creating this User.')
+ return Response(403, 'Forbidden from creating this User.')
# Insert the User
@@ -74,7 +76,7 @@ def POST(request):
# Return a JSON representation of the User
return Response(
- 200,
- 'Successfully created {}'.format(user),
+ 200,
+ 'Successfully created {}'.format(user),
user.to_JSON()
)
diff --git a/opendc/api/v1/users/userId/authorizations/endpoint.py b/opendc/api/v1/users/userId/authorizations/endpoint.py
index 2320456f..46ca12ba 100644
--- a/opendc/api/v1/users/userId/authorizations/endpoint.py
+++ b/opendc/api/v1/users/userId/authorizations/endpoint.py
@@ -1,8 +1,9 @@
from opendc.models.authorization import Authorization
from opendc.models.user import User
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def GET(request):
"""Get this User's Authorizations."""
@@ -10,7 +11,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'userId': 'int'
}
)
diff --git a/opendc/api/v1/users/userId/endpoint.py b/opendc/api/v1/users/userId/endpoint.py
index e4edc107..767c5d13 100644
--- a/opendc/api/v1/users/userId/endpoint.py
+++ b/opendc/api/v1/users/userId/endpoint.py
@@ -1,7 +1,8 @@
from opendc.models.user import User
-from opendc.util import database, exceptions
+from opendc.util import exceptions
from opendc.util.rest import Response
+
def DELETE(request):
"""Delete this user."""
@@ -9,7 +10,7 @@ def DELETE(request):
try:
request.check_required_parameters(
- path = {
+ path={
'userId': 'int'
}
)
@@ -37,10 +38,11 @@ def DELETE(request):
return Response(
200,
- 'Succesfully deleted {}'.format(user),
+ 'Successfully deleted {}'.format(user),
user.to_JSON()
)
+
def GET(request):
"""Get this User."""
@@ -48,7 +50,7 @@ def GET(request):
try:
request.check_required_parameters(
- path = {
+ path={
'userId': 'int'
}
)
@@ -71,6 +73,7 @@ def GET(request):
user.to_JSON(),
)
+
def PUT(request):
"""Update this User's given name and/ or family name."""
@@ -78,13 +81,13 @@ def PUT(request):
try:
request.check_required_parameters(
- body = {
+ body={
'user': {
'givenName': 'string',
'familyName': 'string'
}
},
- path = {
+ path={
'userId': 'int'
}
)
@@ -103,9 +106,9 @@ def PUT(request):
if not user.google_id_has_at_least(request.google_id, 'OWN'):
return Response(403, 'Forbidden from editing {}.'.format(user))
-
+
# Update this User
-
+
user.given_name = request.params_body['user']['givenName']
user.family_name = request.params_body['user']['familyName']
@@ -118,4 +121,3 @@ def PUT(request):
'Successfully updated {}.'.format(user),
user.to_JSON()
)
-