diff options
Diffstat (limited to 'src/api/routes')
| -rw-r--r-- | src/api/routes/datacenters.js | 26 | ||||
| -rw-r--r-- | src/api/routes/paths.js | 30 | ||||
| -rw-r--r-- | src/api/routes/room-types.js | 9 | ||||
| -rw-r--r-- | src/api/routes/rooms.js | 45 | ||||
| -rw-r--r-- | src/api/routes/sections.js | 5 | ||||
| -rw-r--r-- | src/api/routes/simulations.js | 47 | ||||
| -rw-r--r-- | src/api/routes/specifications.js | 57 | ||||
| -rw-r--r-- | src/api/routes/tiles.js | 146 | ||||
| -rw-r--r-- | src/api/routes/token-signin.js (renamed from src/api/routes/auth.js) | 0 | ||||
| -rw-r--r-- | src/api/routes/users.js | 25 | ||||
| -rw-r--r-- | src/api/routes/util.js | 37 |
11 files changed, 369 insertions, 58 deletions
diff --git a/src/api/routes/datacenters.js b/src/api/routes/datacenters.js new file mode 100644 index 00000000..df621a62 --- /dev/null +++ b/src/api/routes/datacenters.js @@ -0,0 +1,26 @@ +import {sendRequest} from "../index"; +import {getById} from "./util"; + +export function getDatacenter(datacenterId) { + return getById("/datacenters/{datacenterId}", {datacenterId}); +} + +export function getRoomsOfDatacenter(datacenterId) { + return getById("/datacenters/{datacenterId}/rooms", {datacenterId}); +} + +export function addRoomToDatacenter(room) { + return sendRequest({ + path: "/datacenters/{datacenterId}/rooms", + method: "POST", + parameters: { + body: { + room + }, + path: { + datacenterId: room.datacenterId + }, + query: {} + } + }); +} diff --git a/src/api/routes/paths.js b/src/api/routes/paths.js new file mode 100644 index 00000000..073cbe7e --- /dev/null +++ b/src/api/routes/paths.js @@ -0,0 +1,30 @@ +import {sendRequest} from "../index"; +import {getById} from "./util"; + +export function getPath(pathId) { + return getById("/paths/{pathId}", {pathId}); +} + +export function getBranchesOfPath(pathId) { + return getById("/paths/{pathId}/branches", {pathId}); +} + +export function branchFromPath(pathId, section) { + return sendRequest({ + path: "/paths/{pathId}/branches", + method: "POST", + parameters: { + body: { + section + }, + path: { + pathId + }, + query: {} + } + }); +} + +export function getSectionsOfPath(pathId) { + return getById("/paths/{pathId}/sections", {pathId}); +} diff --git a/src/api/routes/room-types.js b/src/api/routes/room-types.js new file mode 100644 index 00000000..339896d2 --- /dev/null +++ b/src/api/routes/room-types.js @@ -0,0 +1,9 @@ +import {getAll, getById} from "./util"; + +export function getAvailableRoomTypes() { + return getAll("/room-types"); +} + +export function getAllowedObjectsOfRoomType(name) { + return getById("/room-types/{name}/allowed-objects", {name}); +} diff --git a/src/api/routes/rooms.js b/src/api/routes/rooms.js new file mode 100644 index 00000000..e08cc6e7 --- /dev/null +++ b/src/api/routes/rooms.js @@ -0,0 +1,45 @@ +import {sendRequest} from "../index"; + +export function getRoom(roomId) { + return getById("/rooms/{roomId}", {roomId}); +} + +export function updateRoom(room) { + return sendRequest({ + path: "/rooms/{roomId}", + method: "PUT", + parameters: { + body: { + room + }, + path: { + roomId: room.id + }, + query: {} + } + }); +} + +export function deleteRoom(roomId) { + return deleteById("/rooms/{roomId}", {roomId}); +} + +export function getTilesOfRoom(roomId) { + return getById("/rooms/{roomId}/tiles", {roomId}); +} + +export function addTileToRoom(tile) { + return sendRequest({ + path: "/rooms/{roomId}/tiles", + method: "POST", + parameters: { + body: { + tile + }, + path: { + roomId: tile.roomId + }, + query: {} + } + }); +} diff --git a/src/api/routes/sections.js b/src/api/routes/sections.js new file mode 100644 index 00000000..8d71d768 --- /dev/null +++ b/src/api/routes/sections.js @@ -0,0 +1,5 @@ +import {getById} from "./util"; + +export function getSection(sectionId) { + return getById("/sections/{sectionId}", {sectionId}); +} diff --git a/src/api/routes/simulations.js b/src/api/routes/simulations.js index 3c7c748e..d65460ee 100644 --- a/src/api/routes/simulations.js +++ b/src/api/routes/simulations.js @@ -1,4 +1,9 @@ import {sendRequest} from "../index"; +import {deleteById, getById} from "./util"; + +export function getSimulation(simulationId) { + return getById("/simulations/{simulationId}", {simulationId}); +} export function addSimulation(simulation) { return sendRequest({ @@ -14,20 +19,6 @@ export function addSimulation(simulation) { }); } -export function getSimulation(simulationId) { - return sendRequest({ - path: "/simulations/{simulationId}", - method: "GET", - parameters: { - body: {}, - path: { - simulationId - }, - query: {} - } - }); -} - export function updateSimulation(simulation) { return sendRequest({ path: "/simulations/{simulationId}", @@ -45,29 +36,13 @@ export function updateSimulation(simulation) { } export function deleteSimulation(simulationId) { - return sendRequest({ - path: "/simulations/{simulationId}", - method: "DELETE", - parameters: { - body: {}, - path: { - simulationId - }, - query: {} - } - }); + return deleteById("/simulations/{simulationId}", {simulationId}); } export function getAuthorizationsBySimulation(simulationId) { - return sendRequest({ - path: "/simulations/{simulationId}/authorizations", - method: "GET", - parameters: { - body: {}, - path: { - simulationId - }, - query: {} - } - }) + return getById("/simulations/{simulationId}/authorizations", {simulationId}); +} + +export function getPathsOfSimulation(simulationId) { + return getById("/simulations/{simulationId}/paths", {simulationId}); } diff --git a/src/api/routes/specifications.js b/src/api/routes/specifications.js new file mode 100644 index 00000000..676d9441 --- /dev/null +++ b/src/api/routes/specifications.js @@ -0,0 +1,57 @@ +import {getAll, getById} from "./util"; + +export function getAllCoolingItems() { + return getAll("/specifications/cooling-items"); +} + +export function getCoolingItem(id) { + return getById("/specifications/cooling-items/{id}", {id}); +} + +export function getAllCPUs() { + return getAll("/specifications/cpus"); +} + +export function getCPU(id) { + return getById("/specifications/cpus/{id}", {id}); +} + +export function getAllFailureModels() { + return getAll("/specifications/failure-models"); +} + +export function getFailureModel(id) { + return getById("/specifications/failure-models/{id}", {id}); +} + +export function getAllGPUs() { + return getAll("/specifications/gpus"); +} + +export function getGPU(id) { + return getById("/specifications/gpus/{id}", {id}); +} + +export function getAllMemories() { + return getAll("/specifications/memories"); +} + +export function getMemory(id) { + return getById("/specifications/memories/{id}", {id}); +} + +export function getAllPSUs() { + return getAll("/specifications/psus"); +} + +export function getPSU(id) { + return getById("/specifications/psus/{id}", {id}); +} + +export function getAllStorages() { + return getAll("/specifications/storages"); +} + +export function getStorage(id) { + return getById("/specifications/storages/{id}", {id}); +} diff --git a/src/api/routes/tiles.js b/src/api/routes/tiles.js new file mode 100644 index 00000000..927a074b --- /dev/null +++ b/src/api/routes/tiles.js @@ -0,0 +1,146 @@ +import {sendRequest} from "../index"; +import {deleteById, getById} from "./util"; + +export function getTile(tileId) { + return getById("/tiles/{tileId}", {tileId}); +} + +export function deleteTile(tileId) { + return deleteById("/tiles/{tileId}", {tileId}); +} + +export function getRackByTile(tileId) { + return getTileObject(tileId, "/rack"); +} + +export function addRackToTile(tileId, rack) { + return addTileObject(tileId, {rack}, "/rack"); +} + +export function updateRackOnTile(tileId, rack) { + return updateTileObject(tileId, {rack}, "/rack"); +} + +export function deleteRackFromTile(tileId) { + return deleteTileObject(tileId, "/rack"); +} + +export function getMachinesOfRackByTile(tileId) { + return getById("/tiles/{tileId}/rack/machines", {tileId}); +} + +export function addMachineToRackOnTile(tileId, machine) { + return sendRequest({ + path: "/tiles/{tileId}/rack/machines", + method: "GET", + parameters: { + body: { + machine + }, + path: { + tileId + }, + query: {} + } + }); +} + +export function updateMachineInRackOnTile(tileId, position, machine) { + return sendRequest({ + path: "/tiles/{tileId}/rack/machines/{position}", + method: "PUT", + parameters: { + body: { + machine + }, + path: { + tileId, + position + }, + query: {} + } + }); +} + +export function deleteMachineInRackOnTile(tileId, position) { + return sendRequest({ + path: "/tiles/{tileId}/rack/machines/{position}", + method: "DELETE", + parameters: { + body: {}, + path: { + tileId, + position + }, + query: {} + } + }); +} + +export function getCoolingItemByTile(tileId) { + return getTileObject(tileId, "/cooling-item"); +} + +export function addCoolingItemToTile(tileId, coolingItemId) { + return addTileObject(tileId, {coolingItemId}, "/cooling-item"); +} + +export function updateCoolingItemOnTile(tileId, coolingItemId) { + return updateTileObject(tileId, {coolingItemId}, "/cooling-item"); +} + +export function deleteCoolingItemFromTile(tileId) { + return deleteTileObject(tileId, "/cooling-item"); +} + +export function getPSUByTile(tileId) { + return getTileObject(tileId, "/psu"); +} + +export function addPSUToTile(tileId, psuId) { + return addTileObject(tileId, {psuId}, "/psu"); +} + +export function updatePSUOnTile(tileId, psuId) { + return updateTileObject(tileId, {psuId}, "/psu"); +} + +export function deletePSUFromTile(tileId) { + return deleteTileObject(tileId, "/psu"); +} + +function getTileObject(tileId, endpoint) { + return getById("/tiles/{tileId}" + endpoint, {tileId}); +} + +function addTileObject(tileId, objectBody, endpoint) { + return sendRequest({ + path: "/tiles/{tileId}" + endpoint, + method: "POST", + parameters: { + body: objectBody, + path: { + tileId + }, + query: {} + } + }); +} + +function updateTileObject(tileId, objectBody, endpoint) { + return sendRequest({ + path: "/tiles/{tileId}" + endpoint, + method: "PUT", + parameters: { + body: objectBody, + path: { + tileId + }, + query: {} + } + }); +} + +function deleteTileObject(tileId, endpoint) { + return deleteById("/tiles/{tileId}" + endpoint, {tileId}); +} diff --git a/src/api/routes/auth.js b/src/api/routes/token-signin.js index 76a39572..76a39572 100644 --- a/src/api/routes/auth.js +++ b/src/api/routes/token-signin.js diff --git a/src/api/routes/users.js b/src/api/routes/users.js index c91e07b2..7b931d66 100644 --- a/src/api/routes/users.js +++ b/src/api/routes/users.js @@ -1,4 +1,5 @@ import {sendRequest} from "../index"; +import {deleteById, getById} from "./util"; export function getUserByEmail(email) { return sendRequest({ @@ -62,29 +63,9 @@ export function updateUser(userId, user) { } export function deleteUser(userId) { - return sendRequest({ - path: "/users/{userId}", - method: "DELETE", - parameters: { - body: {}, - path: { - userId - }, - query: {} - } - }); + return deleteById("/users/{userId}", {userId}); } export function getAuthorizationsByUser(userId) { - return sendRequest({ - path: "/users/{userId}/authorizations", - method: "GET", - parameters: { - body: {}, - path: { - userId - }, - query: {} - } - }); + return getById("/users/{userId}/authorizations", {userId}); } diff --git a/src/api/routes/util.js b/src/api/routes/util.js new file mode 100644 index 00000000..ff21d4f4 --- /dev/null +++ b/src/api/routes/util.js @@ -0,0 +1,37 @@ +import {sendRequest} from "../index"; + +export function getAll(path) { + return sendRequest({ + path, + method: "GET", + parameters: { + body: {}, + path: {}, + query: {} + } + }); +} + +export function getById(path, pathObject) { + return sendRequest({ + path, + method: "GET", + parameters: { + body: {}, + path: pathObject, + query: {} + } + }); +} + +export function deleteById(path, pathObject) { + return sendRequest({ + path, + method: "DELETE", + parameters: { + body: {}, + path: pathObject, + query: {} + } + }); +} |
