@oystehr/sdk
Version:
Oystehr SDK
98 lines (95 loc) • 4.41 kB
text/typescript
// AUTOGENERATED -- DO NOT EDIT
import {
OystehrClientRequest,
Z3CreateBucketParams,
Z3CreateBucketResponse,
Z3DeleteBucketParams,
Z3DeleteObjectParams,
Z3GetPresignedUrlParams,
Z3GetPresignedUrlResponse,
Z3ListBucketsResponse,
Z3ListObjectsParams,
Z3ListObjectsResponse,
} from '../..';
import { SDKResource } from '../../client/client';
import { OystehrConfig } from '../../config';
import * as ext from './z3-ext';
export class Z3 extends SDKResource {
constructor(config: OystehrConfig) {
super(config);
}
#baseUrlThunk(): string {
return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1';
}
/**
* Uploads a file to the bucket and key. Files should be Blobs.
* @param params upload file params
*/
uploadFile = ext.uploadFile;
/**
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
* @param params download file params
*/
downloadFile = ext.downloadFile;
/**
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
* instead of the standard SDK `Z3GetPresignedUrlParams`.
* @param params url and action
*/
getPresignedUrlForZ3Url = ext.getPresignedUrlForZ3Url;
/**
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:ListBuckets`
* Access Policy Resource: `Z3:BucketName`
*/
listBuckets(request?: OystehrClientRequest): Promise<Z3ListBucketsResponse> {
return this.request('/z3', 'get', this.#baseUrlThunk.bind(this))(request);
}
/**
* Create a Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:CreateBucket`
* Access Policy Resource: `Z3:*`
*/
createBucket(params: Z3CreateBucketParams, request?: OystehrClientRequest): Promise<Z3CreateBucketResponse> {
return this.request('/z3/{bucketName}', 'put', this.#baseUrlThunk.bind(this))(params, request);
}
/**
* Delete the Z3 Bucket with the provided name. [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:DeleteBucket`
* Access Policy Resource: `Z3:BucketName`
*/
deleteBucket(params: Z3DeleteBucketParams, request?: OystehrClientRequest): Promise<void> {
return this.request('/z3/{bucketName}', 'delete', this.#baseUrlThunk.bind(this))(params, request);
}
/**
* List all Z3 Objects at the provided path in the Bucket with the provided name [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:ListObjects`
* Access Policy Resource: `Z3:BucketName:ObjectPath`
*/
listObjects(params: Z3ListObjectsParams, request?: OystehrClientRequest): Promise<Z3ListObjectsResponse> {
return this.request('/z3/{bucketName}/{objectPath+}', 'get', this.#baseUrlThunk.bind(this))(params, request);
}
/**
* Get a link for downloading or uploading a Z3 Object to the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:PutObject` or `Z3:GetObject`
* Access Policy Resource: `Z3:BucketName:ObjectPath`
*/
getPresignedUrl(params: Z3GetPresignedUrlParams, request?: OystehrClientRequest): Promise<Z3GetPresignedUrlResponse> {
return this.request('/z3/{bucketName}/{objectPath+}', 'post', this.#baseUrlThunk.bind(this))(params, request);
}
/**
* Delete the Z3 Object at the provided path in the Bucket with the provided name. [Z3](https://docs.oystehr.com/oystehr/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
*
* Access Policy Action: `Z3:DeleteObject`
* Access Policy Resource: `Z3:BucketName:ObjectPath`
*/
deleteObject(params: Z3DeleteObjectParams, request?: OystehrClientRequest): Promise<void> {
return this.request('/z3/{bucketName}/{objectPath+}', 'delete', this.#baseUrlThunk.bind(this))(params, request);
}
}