summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/api/routes
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/api/routes')
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/portfolios.js35
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/prefabs.js33
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/projects.js33
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/scenarios.js35
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/schedulers.js4
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/topologies.js35
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/traces.js4
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/users.js41
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/util.js37
9 files changed, 34 insertions, 223 deletions
diff --git a/opendc-web/opendc-web-ui/src/api/routes/portfolios.js b/opendc-web/opendc-web-ui/src/api/routes/portfolios.js
index 7c9ea02a..ba15e828 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/portfolios.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/portfolios.js
@@ -1,42 +1,17 @@
-import { deleteById, getById } from './util'
-import { sendRequest } from '../index'
+import { request } from '../index'
export function addPortfolio(projectId, portfolio) {
- return sendRequest({
- path: '/projects/{projectId}/portfolios',
- method: 'POST',
- parameters: {
- body: {
- portfolio,
- },
- path: {
- projectId,
- },
- query: {},
- },
- })
+ return request(`projects/${projectId}/portfolios`, 'POST', { portfolio })
}
export function getPortfolio(portfolioId) {
- return getById('/portfolios/{portfolioId}', { portfolioId })
+ return request(`portfolios/${portfolioId}`)
}
export function updatePortfolio(portfolioId, portfolio) {
- return sendRequest({
- path: '/portfolios/{projectId}',
- method: 'POST',
- parameters: {
- body: {
- portfolio,
- },
- path: {
- portfolioId,
- },
- query: {},
- },
- })
+ return request(`portfolios/${portfolioId}`, 'PUT', { portfolio })
}
export function deletePortfolio(portfolioId) {
- return deleteById('/portfolios/{portfolioId}', { portfolioId })
+ return request(`portfolios/${portfolioId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/prefabs.js b/opendc-web/opendc-web-ui/src/api/routes/prefabs.js
index 8a1debfa..032e12bc 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/prefabs.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/prefabs.js
@@ -1,40 +1,17 @@
-import { sendRequest } from '../index'
-import { deleteById, getById } from './util'
+import { request } from '../index'
export function getPrefab(prefabId) {
- return getById('/prefabs/{prefabId}', { prefabId })
+ return request(`prefabs/${prefabId}`)
}
export function addPrefab(prefab) {
- return sendRequest({
- path: '/prefabs',
- method: 'POST',
- parameters: {
- body: {
- prefab,
- },
- path: {},
- query: {},
- },
- })
+ return request('prefabs', 'POST', { prefab })
}
export function updatePrefab(prefab) {
- return sendRequest({
- path: '/prefabs/{prefabId}',
- method: 'PUT',
- parameters: {
- body: {
- prefab,
- },
- path: {
- prefabId: prefab._id,
- },
- query: {},
- },
- })
+ return request(`prefabs/${prefab._id}`, 'PUT', { prefab })
}
export function deletePrefab(prefabId) {
- return deleteById('/prefabs/{prefabId}', { prefabId })
+ return request(`prefabs/${prefabId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/projects.js b/opendc-web/opendc-web-ui/src/api/routes/projects.js
index 4109079c..cd46036f 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/projects.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/projects.js
@@ -1,40 +1,17 @@
-import { sendRequest } from '../index'
-import { deleteById, getById } from './util'
+import { request } from '../index'
export function getProject(projectId) {
- return getById('/projects/{projectId}', { projectId })
+ return request(`projects/${projectId}`)
}
export function addProject(project) {
- return sendRequest({
- path: '/projects',
- method: 'POST',
- parameters: {
- body: {
- project,
- },
- path: {},
- query: {},
- },
- })
+ return request('projects', 'POST', { project })
}
export function updateProject(project) {
- return sendRequest({
- path: '/projects/{projectId}',
- method: 'PUT',
- parameters: {
- body: {
- project,
- },
- path: {
- projectId: project._id,
- },
- query: {},
- },
- })
+ return request(`projects/${project._id}`, 'PUT', { project })
}
export function deleteProject(projectId) {
- return deleteById('/projects/{projectId}', { projectId })
+ return request(`projects/${projectId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/scenarios.js b/opendc-web/opendc-web-ui/src/api/routes/scenarios.js
index ab2e8b86..00cc1eb0 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/scenarios.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/scenarios.js
@@ -1,42 +1,17 @@
-import { deleteById, getById } from './util'
-import { sendRequest } from '../index'
+import { request } from '../index'
export function addScenario(portfolioId, scenario) {
- return sendRequest({
- path: '/portfolios/{portfolioId}/scenarios',
- method: 'POST',
- parameters: {
- body: {
- scenario,
- },
- path: {
- portfolioId,
- },
- query: {},
- },
- })
+ return request(`portfolios/${portfolioId}/scenarios`, 'POST', { scenario })
}
export function getScenario(scenarioId) {
- return getById('/scenarios/{scenarioId}', { scenarioId })
+ return request(`scenarios/${scenarioId}`)
}
export function updateScenario(scenarioId, scenario) {
- return sendRequest({
- path: '/scenarios/{projectId}',
- method: 'POST',
- parameters: {
- body: {
- scenario,
- },
- path: {
- scenarioId,
- },
- query: {},
- },
- })
+ return request(`scenarios/${scenarioId}`, 'PUT', { scenario })
}
export function deleteScenario(scenarioId) {
- return deleteById('/scenarios/{scenarioId}', { scenarioId })
+ return request(`scenarios/${scenarioId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/schedulers.js b/opendc-web/opendc-web-ui/src/api/routes/schedulers.js
index 4481fb2a..5e129d33 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/schedulers.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/schedulers.js
@@ -1,5 +1,5 @@
-import { getAll } from './util'
+import { request } from '../index'
export function getAllSchedulers() {
- return getAll('/schedulers')
+ return request('schedulers')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/topologies.js b/opendc-web/opendc-web-ui/src/api/routes/topologies.js
index a8f0d6b1..076895ff 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/topologies.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/topologies.js
@@ -1,42 +1,17 @@
-import { deleteById, getById } from './util'
-import { sendRequest } from '../index'
+import { request } from '../index'
export function addTopology(topology) {
- return sendRequest({
- path: '/projects/{projectId}/topologies',
- method: 'POST',
- parameters: {
- body: {
- topology,
- },
- path: {
- projectId: topology.projectId,
- },
- query: {},
- },
- })
+ return request(`projects/${topology.projectId}/topologies`, 'POST', { topology })
}
export function getTopology(topologyId) {
- return getById('/topologies/{topologyId}', { topologyId })
+ return request(`topologies/${topologyId}`)
}
export function updateTopology(topology) {
- return sendRequest({
- path: '/topologies/{topologyId}',
- method: 'PUT',
- parameters: {
- body: {
- topology,
- },
- path: {
- topologyId: topology._id,
- },
- query: {},
- },
- })
+ return request(`topologies/${topology._id}`, 'PUT', { topology })
}
export function deleteTopology(topologyId) {
- return deleteById('/topologies/{topologyId}', { topologyId })
+ return request(`topologies/${topologyId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/traces.js b/opendc-web/opendc-web-ui/src/api/routes/traces.js
index 67895a87..eb2526ee 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/traces.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/traces.js
@@ -1,5 +1,5 @@
-import { getAll } from './util'
+import { request } from '../index'
export function getAllTraces() {
- return getAll('/traces')
+ return request('traces')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/users.js b/opendc-web/opendc-web-ui/src/api/routes/users.js
index 3028f3f7..619aec1f 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/users.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/users.js
@@ -1,48 +1,17 @@
-import { sendRequest } from '../index'
-import { deleteById } from './util'
+import { request } from '../index'
export function getUserByEmail(email) {
- return sendRequest({
- path: '/users',
- method: 'GET',
- parameters: {
- body: {},
- path: {},
- query: {
- email,
- },
- },
- })
+ return request(`users` + new URLSearchParams({ email }))
}
export function addUser(user) {
- return sendRequest({
- path: '/users',
- method: 'POST',
- parameters: {
- body: {
- user,
- },
- path: {},
- query: {},
- },
- })
+ return request('users', 'POST', { user })
}
export function getUser(userId) {
- return sendRequest({
- path: '/users/{userId}',
- method: 'GET',
- parameters: {
- body: {},
- path: {
- userId,
- },
- query: {},
- },
- })
+ return request(`users/${userId}`)
}
export function deleteUser(userId) {
- return deleteById('/users/{userId}', { userId })
+ return request(`users/${userId}`, 'DELETE')
}
diff --git a/opendc-web/opendc-web-ui/src/api/routes/util.js b/opendc-web/opendc-web-ui/src/api/routes/util.js
deleted file mode 100644
index 67e7173b..00000000
--- a/opendc-web/opendc-web-ui/src/api/routes/util.js
+++ /dev/null
@@ -1,37 +0,0 @@
-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: {},
- },
- })
-}