Fix edge gateway unit contracts
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
const EDGE_GATEWAY_ERROR_MESSAGES = {
|
||||
EDGE_GATEWAY_OFFLINE: {
|
||||
title: "Gateway offline",
|
||||
description: "The gateway is not sending a heartbeat. Check the service and the network path.",
|
||||
description: "Gatewayen sender ikke heartbeat. Kontrollér service og netværk, og prøv igen.",
|
||||
},
|
||||
EDGE_GATEWAY_STALE_HEARTBEAT: {
|
||||
title: "Stale heartbeat",
|
||||
description: "The gateway is responding too slowly to trust new work right now.",
|
||||
title: "Forældet heartbeat",
|
||||
description: "Gatewayen svarer langsomt eller ustabilt. Kontrollér forbindelsen, og prøv igen.",
|
||||
},
|
||||
EDGE_GATEWAY_INVALID_TOKEN: {
|
||||
title: "Invalid credentials",
|
||||
description: "The control plane rejected the stored agent token. Rotate the credentials and restart the stack.",
|
||||
title: "Ugyldige legitimationsoplysninger",
|
||||
description: "Gateway-token blev afvist. Rotér credentials, og genstart agenten.",
|
||||
},
|
||||
EDGE_GATEWAY_OPERATION_TIMEOUT: {
|
||||
title: "Operation timed out",
|
||||
description: "The gateway did not finish the operation within the lease window.",
|
||||
description: "Gatewayoperationen tog for lang tid. Gennemgå logs og forsøg igen.",
|
||||
},
|
||||
EDGE_GATEWAY_UNSUPPORTED_VERSION: {
|
||||
title: "Unsupported version",
|
||||
description: "The requested version or artifact set is not supported by the current gateway stack.",
|
||||
title: "Version ikke understøttet",
|
||||
description: "Målversionen eller artefaktet understøttes ikke af den installerede gateway.",
|
||||
},
|
||||
EDGE_GATEWAY_CONFLICT: {
|
||||
title: "Operation conflict",
|
||||
description: "Another gateway operation is already active for this gateway.",
|
||||
title: "Operation i konflikt",
|
||||
description: "En anden gatewayoperation kører allerede. Vent til den er afsluttet eller fejlet.",
|
||||
},
|
||||
EDGE_GATEWAY_VALIDATION_FAILED: {
|
||||
title: "Invalid request",
|
||||
description: "Review the request payload and try again.",
|
||||
title: "Ugyldig anmodning",
|
||||
description: "Kontrollér input og prøv igen.",
|
||||
},
|
||||
EDGE_GATEWAY_CANCELLED: {
|
||||
title: "Operation cancelled",
|
||||
|
||||
@@ -2,7 +2,6 @@ import { authenticatedRequest } from "@/components/session/authenticatedRequest.
|
||||
|
||||
export const EDGE_GATEWAY_WORKSPACE_CACHE_KEY = "truckwash.edgeGatewayWorkspace.cache.v1";
|
||||
|
||||
const EDGE_GATEWAY_BASE = "/edge-gateways";
|
||||
const EDGE_GATEWAY_CONFIG_BASE = "/edgegateway/config";
|
||||
|
||||
const listRequestsInFlight = new Map();
|
||||
@@ -363,7 +362,7 @@ export const listEdgeGateways = async ({ departmentId = null, view = "summary",
|
||||
return listRequestsInFlight.get(requestKey);
|
||||
}
|
||||
|
||||
const request = authenticatedRequest(EDGE_GATEWAY_BASE, "GET", {
|
||||
const request = authenticatedRequest("/edge-gateways", "GET", {
|
||||
...(departmentId ? { department_id: departmentId } : {}),
|
||||
...(view ? { view } : {}),
|
||||
}).then((response) => {
|
||||
@@ -395,7 +394,7 @@ export const getEdgeGateway = async (gatewayId, { forceRefresh = false } = {}) =
|
||||
return detailRequestsInFlight.get(normalizedGatewayId);
|
||||
}
|
||||
|
||||
const request = authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}`, "GET", {}).then((response) => {
|
||||
const request = authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}`, "GET", {}).then((response) => {
|
||||
const gateway = response?.data?.data;
|
||||
if (gateway?.id) {
|
||||
cacheGatewaySnapshot(gateway);
|
||||
@@ -413,25 +412,25 @@ export const getEdgeGateway = async (gatewayId, { forceRefresh = false } = {}) =
|
||||
};
|
||||
|
||||
export const listEdgeGatewayOperations = async (gatewayId) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/operations`, "GET", {});
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}/operations`, "GET", {});
|
||||
|
||||
export const createEdgeGatewayOperation = async (gatewayId, typeOrPayload, request = {}) =>
|
||||
authenticatedRequest(
|
||||
`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/operations`,
|
||||
`/edge-gateways/${encodeURIComponent(gatewayId)}/operations`,
|
||||
"POST",
|
||||
buildOperationPayload(typeOrPayload, request)
|
||||
).then(cacheGatewayFromNestedResponse);
|
||||
|
||||
export const cancelEdgeGatewayOperation = async (gatewayId, operationId) =>
|
||||
authenticatedRequest(
|
||||
`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/operations/${encodeURIComponent(String(operationId))}/cancel`,
|
||||
`/edge-gateways/${encodeURIComponent(gatewayId)}/operations/${encodeURIComponent(String(operationId))}/cancel`,
|
||||
"POST",
|
||||
{}
|
||||
).then(cacheGatewayFromNestedResponse);
|
||||
|
||||
export const getEdgeGatewayOperationEvents = async (gatewayId, operationId) =>
|
||||
authenticatedRequest(
|
||||
`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/operations/${encodeURIComponent(String(operationId))}/events`,
|
||||
`/edge-gateways/${encodeURIComponent(gatewayId)}/operations/${encodeURIComponent(String(operationId))}/events`,
|
||||
"GET",
|
||||
{}
|
||||
);
|
||||
@@ -439,24 +438,24 @@ export const getEdgeGatewayOperationEvents = async (gatewayId, operationId) =>
|
||||
export const listEdgeGatewayOperationEvents = getEdgeGatewayOperationEvents;
|
||||
|
||||
export const rotateEdgeGatewayCredentials = async (gatewayId) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/rotate-credentials`, "POST", {});
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}/rotate-credentials`, "POST", {});
|
||||
|
||||
export const createEdgeGatewayInstallToken = async ({ department_id, label }) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/install-token`, "POST", { department_id, label });
|
||||
authenticatedRequest("/edge-gateways/install-token", "POST", { department_id, label });
|
||||
|
||||
export const updateEdgeGateway = async (gatewayId, payload) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}`, "PUT", payload).then(cacheGatewayFromResponse);
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}`, "PUT", payload).then(cacheGatewayFromResponse);
|
||||
|
||||
export const triggerEdgeGatewayDiscovery = async (gatewayId) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/discovery`, "POST", {}).then(cacheGatewayFromResponse);
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}/discovery`, "POST", {}).then(cacheGatewayFromResponse);
|
||||
|
||||
export const saveEdgeGatewayBindings = async (gatewayId, bindings) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}/bindings`, "PUT", { bindings }).then(
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}/bindings`, "PUT", { bindings }).then(
|
||||
cacheGatewayFromResponse
|
||||
);
|
||||
|
||||
export const deleteEdgeGateway = async (gatewayId) =>
|
||||
authenticatedRequest(`${EDGE_GATEWAY_BASE}/${encodeURIComponent(gatewayId)}`, "DELETE", {}).then((response) => {
|
||||
authenticatedRequest(`/edge-gateways/${encodeURIComponent(gatewayId)}`, "DELETE", {}).then((response) => {
|
||||
removeEdgeGatewayCache(gatewayId);
|
||||
return response;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user