diff --git a/.changeset/famous-lemons-smile.md b/.changeset/famous-lemons-smile.md new file mode 100644 index 000000000..43792f587 --- /dev/null +++ b/.changeset/famous-lemons-smile.md @@ -0,0 +1,5 @@ +--- +'@siafoundation/renterd-js': patch +--- + +Fixed a typo in the naming of the config method. diff --git a/.changeset/nine-crabs-try.md b/.changeset/nine-crabs-try.md new file mode 100644 index 000000000..e63f1bd33 --- /dev/null +++ b/.changeset/nine-crabs-try.md @@ -0,0 +1,7 @@ +--- +'@siafoundation/renterd-js': minor +'@siafoundation/renterd-react': minor +'@siafoundation/renterd-types': minor +--- + +Added support for autopilot config evaluation. diff --git a/libs/renterd-js/src/autopilot.ts b/libs/renterd-js/src/autopilot.ts index 40e063482..bde26e561 100644 --- a/libs/renterd-js/src/autopilot.ts +++ b/libs/renterd-js/src/autopilot.ts @@ -1,4 +1,7 @@ import { + AutopilotConfigEvaluateParams, + AutopilotConfigEvaluatePayload, + AutopilotConfigEvaluateResponse, AutopilotConfigParams, AutopilotConfigPayload, AutopilotConfigResponse, @@ -36,7 +39,7 @@ export function Autopilot({ AutopilotStatePayload, AutopilotStateResponse >(axios, 'get', autopilotStateRoute), - confg: buildRequestHandler< + config: buildRequestHandler< AutopilotConfigParams, AutopilotConfigPayload, AutopilotConfigResponse @@ -46,6 +49,11 @@ export function Autopilot({ AutopilotConfigUpdatePayload, AutopilotConfigUpdateResponse >(axios, 'put', autopilotConfigRoute), + configEvaluate: buildRequestHandler< + AutopilotConfigEvaluateParams, + AutopilotConfigEvaluatePayload, + AutopilotConfigEvaluateResponse + >(axios, 'post', autopilotConfigRoute), hostsSearch: buildRequestHandler< AutopilotHostsSearchParams, AutopilotHostsSearchPayload, diff --git a/libs/renterd-js/src/bus.ts b/libs/renterd-js/src/bus.ts index 659b2088f..248a505b3 100644 --- a/libs/renterd-js/src/bus.ts +++ b/libs/renterd-js/src/bus.ts @@ -537,7 +537,7 @@ export function Bus({ api, password }: { api: string; password?: string }) { setting: buildRequestHandler< SettingParams, SettingPayload, - SettingResponse + SettingResponse >(axios, 'get', busSettingKeyRoute), settingUpdate: buildRequestHandler< SettingUpdateParams, diff --git a/libs/renterd-react/src/autopilot.ts b/libs/renterd-react/src/autopilot.ts index 61cf62432..2759c6de4 100644 --- a/libs/renterd-react/src/autopilot.ts +++ b/libs/renterd-react/src/autopilot.ts @@ -14,6 +14,9 @@ import { AutopilotConfigUpdateParams, AutopilotConfigUpdatePayload, AutopilotConfigUpdateResponse, + AutopilotConfigEvaluateParams, + AutopilotConfigEvaluatePayload, + AutopilotConfigEvaluateResponse, AutopilotHostsSearchParams, AutopilotHostsSearchPayload, AutopilotHostsSearchResponse, @@ -68,6 +71,16 @@ export function useAutopilotConfigUpdate( ) } +export function useAutopilotConfigEvaluate( + args?: HookArgsCallback< + AutopilotConfigEvaluateParams, + AutopilotConfigEvaluatePayload, + AutopilotConfigEvaluateResponse + > +) { + return usePostFunc({ ...args, route: autopilotConfigRoute }) +} + export function useAutopilotHostsSearch( args?: HookArgsWithPayloadSwr< AutopilotHostsSearchParams, diff --git a/libs/renterd-types/src/autopilot.ts b/libs/renterd-types/src/autopilot.ts index 31b674428..de2c1d5b6 100644 --- a/libs/renterd-types/src/autopilot.ts +++ b/libs/renterd-types/src/autopilot.ts @@ -1,4 +1,9 @@ -import { AutopilotConfig, Host } from './types' +import { + AutopilotConfig, + GougingSettings, + Host, + RedundancySettings, +} from './types' import { HostsSearchPayload, BusStateResponse } from './bus' export const autopilotStateRoute = '/autopilot/state' @@ -30,6 +35,34 @@ export type AutopilotConfigUpdateParams = void export type AutopilotConfigUpdatePayload = AutopilotConfig export type AutopilotConfigUpdateResponse = void +export type ConfigRecommendation = { + gougingSettings: GougingSettings +} + +export type AutopilotConfigEvaluateParams = void +export type AutopilotConfigEvaluatePayload = { + autopilotConfig: AutopilotConfig + gougingSettings: GougingSettings + redundancySettings: RedundancySettings +} +export type AutopilotConfigEvaluateResponse = { + hosts: number + usable: number + unusable: { + blocked: number + gouging: { + contract: number + download: number + gouging: number + pruning: number + upload: number + } + notAcceptingContracts: number + notScanned: number + } + recommendation?: ConfigRecommendation +} + export type AutopilotHost = { host: Host checks?: { diff --git a/libs/renterd-types/src/bus.ts b/libs/renterd-types/src/bus.ts index 3444c81e0..1c5864aff 100644 --- a/libs/renterd-types/src/bus.ts +++ b/libs/renterd-types/src/bus.ts @@ -487,7 +487,7 @@ export type SettingsResponse = string[] export type SettingParams = { key: string } export type SettingPayload = void -export type SettingResponse = T +export type SettingResponse = Setting export type SettingUpdateParams = { key: string } export type SettingUpdatePayload = Setting