Service config. Service logs. Service status.
This commit is contained in:
@@ -3,8 +3,10 @@ import type {
|
||||
ServiceListResponse,
|
||||
Service,
|
||||
ServiceStatus,
|
||||
DetailedServiceStatus,
|
||||
ServiceManifest,
|
||||
ServiceInstallRequest,
|
||||
ServiceConfigUpdateRequest,
|
||||
OperationResponse,
|
||||
} from './types';
|
||||
|
||||
@@ -30,12 +32,30 @@ export const servicesApi = {
|
||||
return apiClient.delete(`/api/v1/instances/${instanceName}/services/${serviceName}`);
|
||||
},
|
||||
|
||||
async getStatus(instanceName: string, serviceName: string): Promise<ServiceStatus> {
|
||||
async getStatus(instanceName: string, serviceName: string): Promise<DetailedServiceStatus> {
|
||||
return apiClient.get(`/api/v1/instances/${instanceName}/services/${serviceName}/status`);
|
||||
},
|
||||
|
||||
async getConfig(instanceName: string, serviceName: string): Promise<Record<string, unknown>> {
|
||||
return apiClient.get(`/api/v1/instances/${instanceName}/services/${serviceName}/config`);
|
||||
const response = await apiClient.get<{ config: Record<string, unknown> }>(
|
||||
`/api/v1/instances/${instanceName}/services/${serviceName}/config`
|
||||
);
|
||||
return response.config;
|
||||
},
|
||||
|
||||
async updateConfig(instanceName: string, serviceName: string, request: ServiceConfigUpdateRequest): Promise<OperationResponse> {
|
||||
return apiClient.patch(`/api/v1/instances/${instanceName}/services/${serviceName}/config`, request);
|
||||
},
|
||||
|
||||
// Service logs
|
||||
getLogsUrl(instanceName: string, serviceName: string, tail?: number, follow?: boolean, container?: string): string {
|
||||
const baseUrl = import.meta.env.VITE_API_BASE_URL || 'http://localhost:5055';
|
||||
const params = new URLSearchParams();
|
||||
if (tail) params.append('tail', tail.toString());
|
||||
if (follow) params.append('follow', 'true');
|
||||
if (container) params.append('container', container);
|
||||
const queryString = params.toString();
|
||||
return `${baseUrl}/api/v1/instances/${instanceName}/services/${serviceName}/logs${queryString ? '?' + queryString : ''}`;
|
||||
},
|
||||
|
||||
// Service lifecycle
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface Service {
|
||||
status?: ServiceStatus | string; // Can be either an object or a string like 'deployed', 'not-deployed'
|
||||
deployed?: boolean;
|
||||
namespace?: string;
|
||||
hasConfig?: boolean; // Whether service has configurable fields
|
||||
}
|
||||
|
||||
export interface ServiceStatus {
|
||||
@@ -14,17 +15,58 @@ export interface ServiceStatus {
|
||||
ready?: boolean;
|
||||
}
|
||||
|
||||
export interface PodStatus {
|
||||
name: string;
|
||||
status: string;
|
||||
ready: string;
|
||||
restarts: number;
|
||||
age: string;
|
||||
node?: string;
|
||||
ip?: string;
|
||||
}
|
||||
|
||||
export interface ReplicaStatus {
|
||||
desired: number;
|
||||
current: number;
|
||||
ready: number;
|
||||
available: number;
|
||||
}
|
||||
|
||||
export interface DetailedServiceStatus {
|
||||
name: string;
|
||||
namespace: string;
|
||||
deploymentStatus: 'Ready' | 'Progressing' | 'Degraded' | 'NotFound';
|
||||
replicas?: ReplicaStatus;
|
||||
pods?: PodStatus[];
|
||||
config?: Record<string, any>;
|
||||
manifest?: ServiceManifest;
|
||||
}
|
||||
|
||||
export interface ServiceListResponse {
|
||||
services: Service[];
|
||||
}
|
||||
|
||||
export interface ConfigDefinition {
|
||||
path: string;
|
||||
prompt: string;
|
||||
default: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface ServiceManifest {
|
||||
name: string;
|
||||
version: string;
|
||||
description: string;
|
||||
config: Record<string, unknown>;
|
||||
namespace?: string;
|
||||
configReferences?: string[];
|
||||
serviceConfig?: Record<string, ConfigDefinition>;
|
||||
}
|
||||
|
||||
export interface ServiceInstallRequest {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ServiceConfigUpdateRequest {
|
||||
config: Record<string, any>;
|
||||
redeploy?: boolean;
|
||||
fetch?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user