-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from textileio/asutula/new-api
New Powergate API
- Loading branch information
Showing
40 changed files
with
1,876 additions
and
1,818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { Config } from "../types" | ||
import { createProfiles, Profiles } from "./profiles" | ||
import { createStorageJobs, StorageJobs } from "./storage-jobs" | ||
import { createWallet, Wallet } from "./wallet" | ||
export { Profiles, StorageJobs, Wallet } | ||
|
||
export interface Admin { | ||
/** | ||
* The admin Profiles API. | ||
*/ | ||
profiles: Profiles | ||
|
||
/** | ||
* The admin Wallet API. | ||
*/ | ||
wallet: Wallet | ||
|
||
/** | ||
* The admin Storage Jobs API. | ||
*/ | ||
storageJobs: StorageJobs | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createAdmin = (config: Config, getMeta: () => grpc.Metadata): Admin => { | ||
return { | ||
profiles: createProfiles(config, getMeta), | ||
wallet: createWallet(config, getMeta), | ||
storageJobs: createStorageJobs(config, getMeta), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { | ||
CreateStorageProfileRequest, | ||
CreateStorageProfileResponse, | ||
StorageProfilesRequest, | ||
StorageProfilesResponse, | ||
} from "@textile/grpc-powergate-client/dist/proto/admin/v1/powergate_admin_pb" | ||
import { PowergateAdminServiceClient } from "@textile/grpc-powergate-client/dist/proto/admin/v1/powergate_admin_pb_service" | ||
import { Config } from "../types" | ||
import { promise } from "../util" | ||
|
||
export interface Profiles { | ||
/** | ||
* Create a new storage profile. | ||
* @returns Information about the new storage profile. | ||
*/ | ||
createStorageProfile: () => Promise<CreateStorageProfileResponse.AsObject> | ||
|
||
/** | ||
* List all storage profiles. | ||
* @returns A list of all storage profiles. | ||
*/ | ||
storageProfiles: () => Promise<StorageProfilesResponse.AsObject> | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createProfiles = (config: Config, getMeta: () => grpc.Metadata): Profiles => { | ||
const client = new PowergateAdminServiceClient(config.host, config) | ||
return { | ||
createStorageProfile: () => { | ||
return promise( | ||
(cb) => client.createStorageProfile(new CreateStorageProfileRequest(), getMeta(), cb), | ||
(resp: CreateStorageProfileResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
storageProfiles: () => | ||
promise( | ||
(cb) => client.storageProfiles(new StorageProfilesRequest(), getMeta(), cb), | ||
(resp: StorageProfilesResponse) => resp.toObject(), | ||
), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { grpc } from "@improbable-eng/grpc-web" | ||
import { | ||
ExecutingStorageJobsRequest, | ||
ExecutingStorageJobsResponse, | ||
LatestFinalStorageJobsRequest, | ||
LatestFinalStorageJobsResponse, | ||
LatestSuccessfulStorageJobsRequest, | ||
LatestSuccessfulStorageJobsResponse, | ||
QueuedStorageJobsRequest, | ||
QueuedStorageJobsResponse, | ||
StorageJobsSummaryRequest, | ||
StorageJobsSummaryResponse, | ||
} from "@textile/grpc-powergate-client/dist/proto/admin/v1/powergate_admin_pb" | ||
import { PowergateAdminServiceClient } from "@textile/grpc-powergate-client/dist/proto/admin/v1/powergate_admin_pb_service" | ||
import { Config } from "../types" | ||
import { promise } from "../util" | ||
|
||
export interface StorageJobs { | ||
/** | ||
* List queued storgae jobs. | ||
* @param profileId The storage profile id to query or an empty string for all storage profiles. | ||
* @param cids An optional list of data cids to fileter the results with. | ||
* @returns A list of queued storage jobs. | ||
*/ | ||
queued: (profileId: string, ...cids: string[]) => Promise<QueuedStorageJobsResponse.AsObject> | ||
|
||
/** | ||
* List executing storgae jobs. | ||
* @param profileId The storage profile id to query or an empty string for all storage profiles. | ||
* @param cids An optional list of data cids to fileter the results with. | ||
* @returns A list of executing storage jobs. | ||
*/ | ||
executing: ( | ||
profileId: string, | ||
...cids: string[] | ||
) => Promise<ExecutingStorageJobsResponse.AsObject> | ||
|
||
/** | ||
* List the latest final storgae jobs. | ||
* @param profileId The storage profile id to query or an empty string for all storage profiles. | ||
* @param cids An optional list of data cids to fileter the results with. | ||
* @returns A list of the latest final storage jobs. | ||
*/ | ||
latestFinal: ( | ||
profileId: string, | ||
...cids: string[] | ||
) => Promise<LatestFinalStorageJobsResponse.AsObject> | ||
|
||
/** | ||
* List the latest successful storgae jobs. | ||
* @param profileId The storage profile id to query or an empty string for all storage profiles. | ||
* @param cids An optional list of data cids to fileter the results with. | ||
* @returns A list of the latest successful storage jobs. | ||
*/ | ||
latestSuccessful: ( | ||
profileId: string, | ||
...cids: string[] | ||
) => Promise<LatestSuccessfulStorageJobsResponse.AsObject> | ||
|
||
/** | ||
* Get a summary of all jobs. | ||
* @param profileId The storage profile id to query or an empty string for all storage profiles. | ||
* @param cids An optional list of data cids to fileter the results with. | ||
* @returns A summary of all jobs. | ||
*/ | ||
summary: (profileId: string, ...cids: string[]) => Promise<StorageJobsSummaryResponse.AsObject> | ||
} | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const createStorageJobs = (config: Config, getMeta: () => grpc.Metadata): StorageJobs => { | ||
const client = new PowergateAdminServiceClient(config.host, config) | ||
return { | ||
queued: (profileId: string, ...cids: string[]) => { | ||
const req = new QueuedStorageJobsRequest() | ||
req.setCidsList(cids) | ||
req.setProfileId(profileId) | ||
return promise( | ||
(cb) => client.queuedStorageJobs(req, getMeta(), cb), | ||
(resp: QueuedStorageJobsResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
executing: (profileId: string, ...cids: string[]) => { | ||
const req = new ExecutingStorageJobsRequest() | ||
req.setCidsList(cids) | ||
req.setProfileId(profileId) | ||
return promise( | ||
(cb) => client.executingStorageJobs(req, getMeta(), cb), | ||
(resp: ExecutingStorageJobsResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
latestFinal: (profileId: string, ...cids: string[]) => { | ||
const req = new LatestFinalStorageJobsRequest() | ||
req.setCidsList(cids) | ||
req.setProfileId(profileId) | ||
return promise( | ||
(cb) => client.latestFinalStorageJobs(req, getMeta(), cb), | ||
(resp: LatestFinalStorageJobsResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
latestSuccessful: (profileId: string, ...cids: string[]) => { | ||
const req = new LatestSuccessfulStorageJobsRequest() | ||
req.setCidsList(cids) | ||
req.setProfileId(profileId) | ||
return promise( | ||
(cb) => client.latestSuccessfulStorageJobs(req, getMeta(), cb), | ||
(resp: LatestSuccessfulStorageJobsResponse) => resp.toObject(), | ||
) | ||
}, | ||
|
||
summary: (profileId: string, ...cids: string[]) => { | ||
const req = new StorageJobsSummaryRequest() | ||
req.setCidsList(cids) | ||
req.setProfileId(profileId) | ||
return promise( | ||
(cb) => client.storageJobsSummary(req, getMeta(), cb), | ||
(resp: StorageJobsSummaryResponse) => resp.toObject(), | ||
) | ||
}, | ||
} | ||
} |
Oops, something went wrong.