-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLakehouseExplorerController.ts
More file actions
47 lines (43 loc) · 1.58 KB
/
LakehouseExplorerController.ts
File metadata and controls
47 lines (43 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { TableMetadata, FileMetadata } from "../models/LakehouseExplorerModel";
export const getTablesInLakehousePath = (baseUrl: string, workspaceObjectId: string, itemObjectId: string) => {
return `${baseUrl}/onelake/${workspaceObjectId}/${itemObjectId}/tables`;
}
export async function getTablesInLakehouse(
tablesPath: string,
token: string): Promise<TableMetadata[]> {
try {
const response: Response = await fetch(tablesPath, { method: `GET`, headers: { 'Authorization': 'Bearer ' + token } });
const responseBody: string = await response.text();
const data = JSON.parse(responseBody);
if (!data.ErrorCode) {
return data;
} else {
return null;
}
}
catch (error) {
console.error(`Error fetching tables: ${error}`);
return null;
}
}
export const getFilesInLakehousePath = (baseUrl: string, workspaceObjectId: string, itemObjectId: string) => {
return `${baseUrl}/onelake/${workspaceObjectId}/${itemObjectId}/files`;
}
export async function getFilesInLakehouse(
filesPath: string,
token: string): Promise<FileMetadata[]> {
try {
const response: Response = await fetch(filesPath, { method: `GET`, headers: { 'Authorization': 'Bearer ' + token } });
const responseBody: string = await response.text();
const data = JSON.parse(responseBody);
if (!data.ErrorCode) {
return data;
} else {
return null;
}
}
catch (error) {
console.error(`Error fetching files: ${error}`);
return null;
}
}