-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathlistStorageChannels.js
More file actions
56 lines (50 loc) · 2.33 KB
/
listStorageChannels.js
File metadata and controls
56 lines (50 loc) · 2.33 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
48
49
50
51
52
53
54
55
56
/**
* This function lists all storage-configured signaling channel ARNs and their associated stream's ARN.
*/
async function listStorageChannels(formValues) {
$('#logs-header')[0].scrollIntoView({
block: 'start',
});
try {
console.log('[LIST_STORAGE_CHANNELS] Attempting to list all storage-configured signaling channels and their associated stream');
// Create KVS client
const kinesisVideoClient = new AWS.KinesisVideo.KinesisVideoClient({
region: formValues.region,
credentials: {
accessKeyId: formValues.accessKeyId,
secretAccessKey: formValues.secretAccessKey,
sessionToken: formValues.sessionToken,
},
endpoint: formValues.endpoint,
logger: formValues.logAwsSdkCalls ? console : undefined,
});
// Get all signaling channels
const result = await kinesisVideoClient.send(new AWS.KinesisVideo.ListSignalingChannelsCommand());
const allChannels = result.ChannelInfoList;
// Grab channel ARNs
const allChannelARNs = allChannels.map(channel => {
return channel.ChannelARN;
});
let progressCounter = 0;
const output = [];
// Print channel ARN and its storage stream ARN if media storage is enabled for the channel
for (const channelARN of allChannelARNs) {
const request = {
ChannelARN: channelARN,
};
const storageResult = await kinesisVideoClient.send(new AWS.KinesisVideo.DescribeMediaStorageConfigurationCommand(request));
if (storageResult.MediaStorageConfiguration.Status === 'ENABLED') {
output.push({
ChannelARN: channelARN,
StreamARN: storageResult.MediaStorageConfiguration.StreamARN,
});
}
console.log('[LIST_STORAGE_CHANNELS] Progress:', ++progressCounter, '/', allChannelARNs.length);
await new Promise(res => setTimeout(res, 500)); // To avoid getting rate limited
}
console.log('[LIST_STORAGE_CHANNELS] You have', output.length, 'channels configured for storage:');
console.log('[LIST_STORAGE_CHANNELS]', output);
} catch (e) {
console.error('[LIST_STORAGE_CHANNELS] Encountered error:', e);
}
}