Skip to content

Commit

Permalink
fix: renterd add contract prunable and size APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Jul 8, 2024
1 parent 9b01557 commit bc051e0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/calm-hounds-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Added the contracts prunable API.
7 changes: 7 additions & 0 deletions .changeset/friendly-drinks-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Added the contract size API.
18 changes: 18 additions & 0 deletions libs/renterd-js/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ import {
ContractSetsParams,
ContractSetsPayload,
ContractSetsResponse,
ContractSizeParams,
ContractSizePayload,
ContractSizeResponse,
ContractsAddParams,
ContractsAddPayload,
ContractsAddResponse,
ContractsParams,
ContractsPayload,
ContractsPrunableParams,
ContractsPrunablePayload,
ContractsPrunableResponse,
ContractsReleaseParams,
ContractsReleasePayload,
ContractsReleaseResponse,
Expand Down Expand Up @@ -221,6 +227,8 @@ import {
busContractIdReleaseRoute,
busContractIdRenewedRoute,
busContractIdRoute,
busContractIdSize,
busContractsPrunableRoute,
busContractsRoute,
busContractsSetsRoute,
busContractsSetsSetRoute,
Expand Down Expand Up @@ -459,6 +467,11 @@ export function Bus({ api, password }: { api: string; password?: string }) {
ContractDeletePayload,
ContractDeleteResponse
>(axios, 'delete', busContractIdRoute),
contractSize: buildRequestHandler<
ContractSizeParams,
ContractSizePayload,
ContractSizeResponse
>(axios, 'get', busContractIdSize),
contractSets: buildRequestHandler<
ContractSetsParams,
ContractSetsPayload,
Expand All @@ -469,6 +482,11 @@ export function Bus({ api, password }: { api: string; password?: string }) {
ContractSetUpdatePayload,
ContractSetUpdateResponse
>(axios, 'put', busContractsSetsSetRoute),
contractsPrunable: buildRequestHandler<
ContractsPrunableParams,
ContractsPrunablePayload,
ContractsPrunableResponse
>(axios, 'get', busContractsPrunableRoute),
buckets: buildRequestHandler<
BucketsParams,
BucketsPayload,
Expand Down
18 changes: 18 additions & 0 deletions libs/renterd-react/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ import {
RedundancySettings,
S3AuthenticationSettings,
UploadPackingSettings,
ContractsPrunableParams,
ContractsPrunableResponse,
busContractsPrunableRoute,
ContractSizeParams,
ContractSizeResponse,
busContractIdSize,
} from '@siafoundation/renterd-types'

// state
Expand Down Expand Up @@ -666,6 +672,12 @@ export function useContractDelete(
)
}

export function useContractSize(
args?: HookArgsSwr<ContractSizeParams, ContractSizeResponse>
) {
return useGetSwr({ ...args, route: busContractIdSize })
}

export function useContractSets(
args?: HookArgsSwr<ContractSetsParams, ContractSetsResponse>
) {
Expand All @@ -682,6 +694,12 @@ export function useContractSetUpdate(
return usePutFunc({ ...args, route: busContractsSetsSetRoute })
}

export function useContractsPrunable(
args?: HookArgsSwr<ContractsPrunableParams, ContractsPrunableResponse>
) {
return useGetSwr({ ...args, route: busContractsPrunableRoute })
}

// objects

export function useBuckets(args?: HookArgsSwr<BucketsParams, BucketsResponse>) {
Expand Down
23 changes: 23 additions & 0 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export const busContractRoute = '/bus/contract'
export const busContractIdRoute = '/bus/contract/:id'
export const busContractIdNewRoute = '/bus/contract/:id/new'
export const busContractIdRenewedRoute = '/bus/contract/:id/renewed'
export const busContractIdSize = '/bus/contract/:id/size'
export const busContractsSetsRoute = '/bus/contracts/sets'
export const busContractsSetsSetRoute = '/bus/contracts/sets/:set'
export const busContractsPrunableRoute = '/bus/contracts/prunable'
export const busBucketRoute = '/bus/bucket'
export const busBucketsRoute = '/bus/buckets'
export const busBucketNameRoute = '/bus/bucket/:name'
Expand Down Expand Up @@ -362,6 +364,27 @@ export type ContractSetUpdateParams = {
export type ContractSetUpdatePayload = string[]
export type ContractSetUpdateResponse = void

export type ContractSizeParams = {
id: string
}
export type ContractSizePayload = void
export type ContractSizeResponse = {
prunable: number
size: number
}

export type ContractsPrunableParams = void
export type ContractsPrunablePayload = void
export type ContractsPrunableResponse = {
contracts: {
id: string
prunable: number
size: number
}[]
totalPrunable: number
totalSize: number
}

// objects

export type Bucket = {
Expand Down

0 comments on commit bc051e0

Please sign in to comment.