Skip to content

Commit 3429242

Browse files
committed
Implemented get all files sdk
1 parent 531dcba commit 3429242

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

‎src/internal/apis/FileBucketApi.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export interface FileBucketControllerDeleteFileBucketRequest {
3131
deleteFileBucketModel: DeleteFileBucketModel;
3232
}
3333

34+
export interface FileBucketControllerGetAllFilesRequest {
35+
configId: string;
36+
}
37+
3438
export interface FileBucketControllerGetBucketsByConfigIdAndEnvRequest {
3539
configId: string;
3640
}
@@ -103,6 +107,62 @@ export class FileBucketApi extends runtime.BaseAPI {
103107
return await response.value();
104108
}
105109

110+
/**
111+
* Get all files from all buckets for a config.
112+
*/
113+
async fileBucketControllerGetAllFilesRaw(
114+
requestParameters: FileBucketControllerGetAllFilesRequest,
115+
initOverrides?: RequestInit | runtime.InitOverrideFunction
116+
): Promise<runtime.ApiResponse<Array<object>>> {
117+
if (requestParameters['configId'] == null) {
118+
throw new runtime.RequiredError(
119+
'configId',
120+
'Required parameter "configId" was null or undefined when calling fileBucketControllerGetAllFiles().'
121+
);
122+
}
123+
124+
const queryParameters: any = {};
125+
126+
const headerParameters: runtime.HTTPHeaders = {};
127+
128+
if (this.configuration && this.configuration.accessToken) {
129+
const token = this.configuration.accessToken;
130+
const tokenString = await token('API_Key', []);
131+
132+
if (tokenString) {
133+
headerParameters['Authorization'] = `Bearer ${tokenString}`;
134+
}
135+
}
136+
const response = await this.request(
137+
{
138+
path: `/file/all/{configId}`.replace(
139+
`{${'configId'}}`,
140+
encodeURIComponent(String(requestParameters['configId']))
141+
),
142+
method: 'GET',
143+
headers: headerParameters,
144+
query: queryParameters,
145+
},
146+
initOverrides
147+
);
148+
149+
return new runtime.JSONApiResponse<any>(response);
150+
}
151+
152+
/**
153+
* Get all files from all buckets for a config.
154+
*/
155+
async fileBucketControllerGetAllFiles(
156+
requestParameters: FileBucketControllerGetAllFilesRequest,
157+
initOverrides?: RequestInit | runtime.InitOverrideFunction
158+
): Promise<Array<object>> {
159+
const response = await this.fileBucketControllerGetAllFilesRaw(
160+
requestParameters,
161+
initOverrides
162+
);
163+
return await response.value();
164+
}
165+
106166
/**
107167
* Get File Buckets by Config Id and Config Env.
108168
*/

‎src/lib/file.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,26 @@ export class FileAPI {
270270
);
271271
}
272272

273+
async getAllFiles(
274+
configId: string,
275+
credentials?: ApiCredentials
276+
): Promise<Array<object>> {
277+
const headers: Record<string, string> = {};
278+
if (credentials?.userJwt) {
279+
headers['X-User-JWT'] = credentials.userJwt;
280+
}
281+
if (credentials?.projectId !== undefined) {
282+
headers['X-Project-Id'] = String(credentials.projectId);
283+
}
284+
285+
return await this.bucketApi.fileBucketControllerGetAllFiles(
286+
{ configId },
287+
async ({ init }) => ({
288+
headers: { ...(init.headers as Record<string, string>), ...headers },
289+
})
290+
);
291+
}
292+
273293
async uploadFile(options: {
274294
fileName: string;
275295
bucketName: string;

0 commit comments

Comments
 (0)