@nnsay/dji-terra-api-sdk
Version:
205 lines (204 loc) • 7.62 kB
TypeScript
import { ObtainTokenAPIResponse, UploadCallbackAPIResponse, CreateResourceAPIResponse, GetResourceAPIResponse, ListResourcesAPIResponse, CreateJobAPIResponse, StartJobAPIRequest, ListFilesAPIResponse, GetFileAPIResponse, ListJobAPIResponse } from './dto';
/**
* Terra API
*/
export declare class TerraAPI {
private appKey;
private secretKey;
private apiHost;
private headers;
private algorithm;
private readonly reqClient;
constructor(appKey?: string | undefined, secretKey?: string | undefined, apiHost?: string);
private getFormattedDate;
private calculateDigest;
private generateSignature;
private buildRequestParam;
private traverseDirectory;
/**
* Get token
* @returns STS token
*/
obtainToken(): Promise<ObtainTokenAPIResponse>;
/**
* Upload complete callback
* @param callbackParam string, callback parameter which comes from sts token
* @param uploadedFiles list, the list of uploaded files etag result
* @param resourceUUID string, resource id
* @returns resource file list
*/
uploadCallback(callbackParam: string, uploadedFiles: {
name: string;
etag: string;
checksum: string;
}[], resourceUUID: string): Promise<UploadCallbackAPIResponse[]>;
/**
* Upload file
* @param stsToken STS token, comes from get token api
* @param imageDir local file root directory
* @returns uploaded files etag list
*/
uploadFile(stsToken: ObtainTokenAPIResponse, imageDir: string): Promise<{
name: string;
etag: string;
checksum: string;
}[]>;
/**
* Create resource
* @param payload json, create resource parameters
* - meta?, string, user extension information
* - files?, string[], the file uuid to be added to the resource
* - name, string, resource name
* - type, string, resource type, available values : map
* @returns resource information
*/
createResource(payload: {
meta?: string;
files?: string[];
name: string;
type: 'map';
}): Promise<CreateResourceAPIResponse>;
/**
* Delete resource
* @param resourceUUID string, resource uuid
* @param deleteMode delete mode. 0 - do not delete. 1 - delete files that are not linked to other resource. uint
* @returns execute result
*/
deleteResource(resourceUUID: string, deleteMode?: 0 | 1): Promise<{
code: number;
desc: string;
msg: string;
}>;
/**
* Get resource information
* @param uuid resource uuid
* @return resource information
*/
getResource(uuid: string): Promise<GetResourceAPIResponse>;
/**
* Get resource list
* @param query json, query parameters
* - rows?: page rows. uint
* - page?: page code. Starting from 1. uint
* - search?: search option
* - uuids?: get resource list with specified uuid. The uuids are separated by ",".
* - type?: pecify the resource type to search for, available values : map
* @return resource paged list
*/
listResources(query?: {
rows?: number;
page?: number;
search?: string;
uuids?: string;
type?: 'map';
}): Promise<ListResourcesAPIResponse>;
/**
* Create job
* @param payload json, job parameters
* - meta?, string, User extension information
* - name, string, Job name
* @returns job details
*/
createJob(payload: {
meta?: string;
name: string;
}): Promise<CreateJobAPIResponse>;
/**
* Get job details
* @param uuid string, job ID
* @returns job details
*/
getJob(uuid: string): Promise<CreateJobAPIResponse>;
/**
* Delete job
* @param uuid string, job uuid
* @param deleteMode delete mode. 0 - do not delete. 1 - delete files that are not linked to other resource. uint
* @returns execute result
*/
deleteJob(uuid: string): Promise<{
code: number;
desc: string;
msg: string;
}>;
/**
* Start job
* @param uuid job id
* @param payload json, start job parameters
* - outputResourceUuid?: string, When the type is 4, you can specify the output resource, indicating the merging into that resource.
* - parameters: string, json, reference: https://developer.dji.com/doc/terra_api_tutorial/cn/terra-cloud-algo.html
* - parameters.parameter: json, the configuration of 2D, 3D, and LiDAR reconstruction jobs
* - parameters.predefine_AOI?: json, is an optional parameter, and is at the same level as the parameter. The predefine_AOI parameter only takes effect in 2D and 3D jobs.
* - parameters.export_parameter?: json, is optional and sets the directory structure and content of reconstruction output.
* - resourceUuid: string, Resource uuid
* - type: 13 | 14 | 15, Job type. 14 - 2D reconstruction, 15 - 3D reconstruction, 13 - LiDAR reconstruction
* @returns execute result
*/
startJob<T>(uuid: string, payload: StartJobAPIRequest<T>): Promise<{
code: number;
desc: string;
msg: string;
}>;
/**
* Get file list
* @param query json, query Paramater
* - rows?: number, page rows. uint
* - page?: number, page code. Starting from 1. uint
* - search?: string, search option
* - uuids?: string, get file list with specified uuid. IDs are separated by ",". UUID is a 36-character string, with a maximum support of 1000 UUIDs
* - type?: number, job type. 14 - 2D reconstruction, 15 - 3D reconstruction, 13 - LiDAR reconstruction
* - originResourceUuid?: string, origin resource uuid
* - outputResourceUuid?: string, resource uuid of reconstruction result
* @return file paged list
*/
listJobs(query?: {
rows?: number;
page?: number;
search?: string;
uuids?: string;
type?: number;
originResourceUuid?: string;
outputResourceUuid?: string;
}): Promise<ListJobAPIResponse>;
/**
* Get file list
* @param query json, query Paramater
* - rows?: number, page rows. uint
* - page?: number, page code. Starting from 1. uint
* - search?: string, search option
* - needURL?: boolean
* - name?: string
* - uuids?: string, get file list with specified uuid. IDs are separated by ",". UUID is a 36-character string, with a maximum support of 1000 UUIDs
* - resourceUuid?: string, Linked resource uuid
* - orderAsc?: boolean, The default sorting order for Files is descending based on created_at. When this condition is set to true, the results are returned in ascending order.
* @return file paged list
*/
listFiles(query?: {
rows?: number;
page?: number;
search?: string;
needURL?: boolean;
name?: string;
uuids?: string;
resourceUuid?: string;
orderAsc?: boolean;
}): Promise<ListFilesAPIResponse>;
/**
* Get file information
* @param uuid, string, file id
* @returns file information
*/
getFile(uuid: string): Promise<GetFileAPIResponse>;
/**
* Delete file
* @param uuid, string, file id
* @returns execute result
*/
deleteFile(uuid: string): Promise<undefined>;
/**
* Download files
* @param outputResourceUuid, string, output resource id
* @param rootDir, string, download root directory
* @returns void
*/
downloadFiles(outputResourceUuid: string, rootDir: string): Promise<void>;
}