-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstacklets.ts
More file actions
47 lines (44 loc) · 1.37 KB
/
stacklets.ts
File metadata and controls
47 lines (44 loc) · 1.37 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 { components } from './schema';
import { client } from './session';
import { ObjectMeta } from './meta';
import { delay } from './mock-utils';
export type Stacklet = components['schemas']['Stacklet'];
export type DisplayCondition = components['schemas']['DisplayCondition'];
export async function getStacklets(): Promise<Stacklet[]> {
const { data } = await client().get('/stacklets', {});
if (data === undefined) {
throw new Error('No data returned by API');
} else {
return data;
}
}
export type DiscoveryFieldType = 'url' | 'blob';
interface StackletDiscovery {
metadata: ObjectMeta;
data: { [x: string]: string };
fieldTypes: { [x: string]: DiscoveryFieldType };
}
export async function getStackletDiscovery(
namespace: string,
discoveryConfigMapName: string,
): Promise<StackletDiscovery | undefined> {
await delay(200);
if (namespace == 'default' && discoveryConfigMapName == 'simple-nifi') {
return {
metadata: { namespace, name: discoveryConfigMapName },
data: { NIFI_URL: 'https://foo.com' },
fieldTypes: { NIFI_URL: 'url' },
};
} else if (
namespace == 'default' &&
discoveryConfigMapName == 'simple-hdfs'
) {
return {
metadata: { namespace, name: discoveryConfigMapName },
data: { 'hdfs-config.xml': '<?xml>config goes here' },
fieldTypes: {},
};
} else {
return undefined;
}
}