Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/internal/apis/FileBucketApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export interface FileBucketControllerDeleteFileBucketRequest {
deleteFileBucketModel: DeleteFileBucketModel;
}

export interface FileBucketControllerGetAllFilesRequest {
configId: string;
}

export interface FileBucketControllerGetBucketsByConfigIdAndEnvRequest {
configId: string;
}
Expand Down Expand Up @@ -103,6 +107,62 @@ export class FileBucketApi extends runtime.BaseAPI {
return await response.value();
}

/**
* Get all files from all buckets for a config.
*/
async fileBucketControllerGetAllFilesRaw(
requestParameters: FileBucketControllerGetAllFilesRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction
): Promise<runtime.ApiResponse<Array<object>>> {
Comment thread
llam36 marked this conversation as resolved.
if (requestParameters['configId'] == null) {
throw new runtime.RequiredError(
'configId',
'Required parameter "configId" was null or undefined when calling fileBucketControllerGetAllFiles().'
);
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token('API_Key', []);

if (tokenString) {
headerParameters['Authorization'] = `Bearer ${tokenString}`;
}
}
const response = await this.request(
{
path: `/file/all/{configId}`.replace(
`{${'configId'}}`,
encodeURIComponent(String(requestParameters['configId']))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);

return new runtime.JSONApiResponse<any>(response);
Comment thread
llam36 marked this conversation as resolved.
}

/**
* Get all files from all buckets for a config.
*/
async fileBucketControllerGetAllFiles(
requestParameters: FileBucketControllerGetAllFilesRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction
): Promise<Array<object>> {
const response = await this.fileBucketControllerGetAllFilesRaw(
requestParameters,
initOverrides
);
return await response.value();
}

/**
* Get File Buckets by Config Id and Config Env.
*/
Expand Down
20 changes: 20 additions & 0 deletions src/lib/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,26 @@ export class FileAPI {
);
}

async getAllFiles(
configId: string,
credentials?: ApiCredentials
): Promise<Array<object>> {
Comment thread
llam36 marked this conversation as resolved.
const headers: Record<string, string> = {};
if (credentials?.userJwt) {
headers['X-User-JWT'] = credentials.userJwt;
}
if (credentials?.projectId !== undefined) {
headers['X-Project-Id'] = String(credentials.projectId);
}

return await this.bucketApi.fileBucketControllerGetAllFiles(
{ configId },
async ({ init }) => ({
headers: { ...(init.headers as Record<string, string>), ...headers },
})
);
}

async uploadFile(options: {
fileName: string;
bucketName: string;
Expand Down
Loading