agent-list-http.service.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Injectable } from '@nestjs/common'
  2. import { ServiceResponse } from '@/response/response.interface'
  3. import { HttpClientService } from '@/shared/http-client/http-client.service'
  4. @Injectable()
  5. export class AgentListHttpService {
  6. private readonly baseUrl = 'http://192.168.206.189:8083/api'
  7. constructor(private readonly httpClientService: HttpClientService) {}
  8. private async makeRequest<T>(
  9. endpoint: string,
  10. params?: Record<string, any>
  11. ): Promise<ServiceResponse<T>> {
  12. const url = `${this.baseUrl}/${endpoint}`
  13. return this.httpClientService.get<T>(url, params)
  14. }
  15. async makeRequestPost<T>(
  16. endpoint: string,
  17. params?: Record<string, any>
  18. ): Promise<ServiceResponse<T>> {
  19. const url = `${this.baseUrl}/${endpoint}`
  20. return this.httpClientService.post<T>(url, params)
  21. }
  22. async getNativeAgentList(
  23. params: Record<string, any>
  24. ): Promise<ServiceResponse<AgentListType[]>> {
  25. return this.makeRequest<AgentListType[]>('getNativeAgentList', params)
  26. }
  27. async getNativeAgentConfiguration(
  28. agent_id: string
  29. ): Promise<ServiceResponse<AgentConfigurationType[]>> {
  30. return this.makeRequest<AgentConfigurationType[]>(
  31. 'getNativeAgentConfiguration',
  32. { agent_id }
  33. )
  34. }
  35. async saveNativeAgentConfiguration(
  36. params: SaveAgentConfigurationType
  37. ): Promise<ServiceResponse<SaveAgentConfigurationType>> {
  38. console.log(params)
  39. return this.makeRequestPost<SaveAgentConfigurationType>(
  40. 'saveNativeAgentConfiguration',
  41. params
  42. )
  43. }
  44. async getToolList(): Promise<ServiceResponse<any>> {
  45. return this.makeRequest<any>('getToolList')
  46. }
  47. }