@@ -7,6 +7,12 @@ import type {
|
||||
LogFilters,
|
||||
InsertLogRequest,
|
||||
InsertLogsRequest,
|
||||
TokenUpdate,
|
||||
TokenUpdatePermissions,
|
||||
TokenPasswordReset,
|
||||
RegistrationRequest,
|
||||
DeployAgentsRequest,
|
||||
DeployResponse,
|
||||
} from "../types/agent.types";
|
||||
|
||||
class AgentApiService {
|
||||
@@ -20,7 +26,9 @@ class AgentApiService {
|
||||
}
|
||||
|
||||
async getUsers(): Promise<TokenUser[]> {
|
||||
const response = await apiClient.get<TokenUser[]>(`${this.authBasePath}/tokens`);
|
||||
const response = await apiClient.get<TokenUser[]>(
|
||||
`${this.authBasePath}/tokens`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
@@ -60,17 +68,85 @@ class AgentApiService {
|
||||
}
|
||||
|
||||
async getDistinctAgents(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/agents`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/agents`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getDistinctLevels(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/levels`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/levels`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getDistinctServices(): Promise<string[]> {
|
||||
const response = await apiClient.get<string[]>(`${this.logsBasePath}/services`);
|
||||
const response = await apiClient.get<string[]>(
|
||||
`${this.logsBasePath}/services`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// User management methods
|
||||
async getUserByLogin(login: string): Promise<TokenUser> {
|
||||
const response = await apiClient.get<TokenUser>(
|
||||
`${this.authBasePath}/users/${login}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getInactiveUsers(): Promise<TokenUser[]> {
|
||||
const response = await apiClient.get<TokenUser[]>(
|
||||
`${this.authBasePath}/users/inactive`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async updateUser(login: string, data: TokenUpdate): Promise<void> {
|
||||
await apiClient.put(`${this.authBasePath}/users/${login}`, data);
|
||||
}
|
||||
|
||||
async updateUserPermissions(
|
||||
login: string,
|
||||
data: TokenUpdatePermissions,
|
||||
): Promise<void> {
|
||||
await apiClient.put(
|
||||
`${this.authBasePath}/users/${login}/permissions`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
async resetUserPassword(
|
||||
login: string,
|
||||
data: TokenPasswordReset,
|
||||
): Promise<void> {
|
||||
await apiClient.put(`${this.authBasePath}/users/${login}/password`, data);
|
||||
}
|
||||
|
||||
async activateUser(login: string): Promise<void> {
|
||||
await apiClient.post(`${this.authBasePath}/users/${login}/activate`);
|
||||
}
|
||||
|
||||
async deactivateUser(login: string): Promise<void> {
|
||||
await apiClient.post(`${this.authBasePath}/users/${login}/deactivate`);
|
||||
}
|
||||
|
||||
async createRegistrationToken(
|
||||
data: RegistrationRequest,
|
||||
): Promise<Record<string, string>> {
|
||||
const response = await apiClient.post<Record<string, string>>(
|
||||
`${this.basePath}/register-token`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async deployAgents(data: DeployAgentsRequest): Promise<DeployResponse> {
|
||||
const response = await apiClient.post<DeployResponse>(
|
||||
`${this.basePath}/deploy`,
|
||||
data,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,3 +74,51 @@ export interface LogFilters {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface TokenUpdate {
|
||||
name?: string;
|
||||
last_name?: string;
|
||||
}
|
||||
|
||||
export interface TokenUpdatePermissions {
|
||||
is_active?: boolean;
|
||||
permission_admin?: boolean;
|
||||
permission_manage_agent?: boolean;
|
||||
permission_view?: boolean;
|
||||
}
|
||||
|
||||
export interface TokenPasswordReset {
|
||||
new_password: string;
|
||||
}
|
||||
|
||||
export interface RegistrationRequest {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface DeployResult {
|
||||
agent_label: string;
|
||||
error?: string;
|
||||
ip: string;
|
||||
success: boolean;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface DeployAgentsRequest {
|
||||
servers: AgentDeployConfig[];
|
||||
}
|
||||
|
||||
export interface AgentDeployConfig {
|
||||
agentLabel: string;
|
||||
authMethod: "key" | "password";
|
||||
deployType: "docker" | "binary";
|
||||
ip: string;
|
||||
password?: string;
|
||||
port?: number;
|
||||
sshKey?: string;
|
||||
user: string;
|
||||
}
|
||||
|
||||
export interface DeployResponse {
|
||||
message?: string;
|
||||
results: DeployResult[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user