Skip to content

Commit 3308002

Browse files
authored
Merge pull request #57 from Terraform-GUI/feature/web/allowingBlobResponse
fix(front): #49 - allowing blob response
2 parents e88acfb + 7d1d739 commit 3308002

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

web/src/api/ApiClient.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface IApiClient {
77
): Promise<TResponse>;
88
put<TRequest, TResponse>(path: string, object: TRequest): Promise<TResponse>;
99
get<TResponse>(path: string): Promise<TResponse>;
10+
getBlob<BlobPart>(path: string): Promise<BlobPart>;
1011
delete<TResponse>(path: string): Promise<TResponse>;
1112
patch<TRequest, TResponse>(path: string, object: TRequest): Promise<TResponse>;
1213
}
@@ -69,6 +70,19 @@ export default class ApiClient implements IApiClient {
6970
}
7071
return {} as TResponse;
7172
}
73+
74+
75+
async getBlob<BlobPart>(path: string): Promise<BlobPart> {
76+
try {
77+
const response = await this.client.get<BlobPart>(path, {
78+
responseType: 'blob',
79+
});
80+
return response.data;
81+
} catch (error) {
82+
console.log(error);
83+
}
84+
return {} as BlobPart;
85+
}
7286

7387
async delete<TResponse>(path: string): Promise<TResponse> {
7488
try {

web/src/api/ProjectService.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface IProjectApiClient {
99
createProject: (name: string, nodes: Node<ISavedNodeData>[], edges: Edge[]) => Promise<ISavedProject | undefined>
1010
updateProject: (id: string, name: string, nodes: Node<ISavedNodeData>[], edges: Edge[]) => Promise<ISavedProject | undefined>
1111
deleteProject: (id: string) => Promise<IDeleteProjectResponse | undefined>
12+
getArchive: (id: string) => Promise<BlobPart | undefined>
1213
}
1314

1415
export class ProjectApiClient implements IProjectApiClient {
@@ -58,6 +59,15 @@ export class ProjectApiClient implements IProjectApiClient {
5859
console.log(error);
5960
}
6061
};
62+
63+
async getArchive(id: string): Promise<BlobPart | undefined> {
64+
try {
65+
const response: BlobPart = await this.apiClient.getBlob(`/api/projects/${id}/terraform-archive`);
66+
return response;
67+
} catch (error) {
68+
console.log(error);
69+
}
70+
};
6171
}
6272

6373
export default class ProjectService {
@@ -82,4 +92,8 @@ export default class ProjectService {
8292
async deleteProject(id: string): Promise<IDeleteProjectResponse | undefined> {
8393
return this.projectApiClient.deleteProject(id);
8494
}
95+
96+
async getArchive(id: string): Promise<BlobPart | undefined> {
97+
return this.projectApiClient.getArchive(id);
98+
}
8599
}

0 commit comments

Comments
 (0)