mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-19 11:16:34 +00:00
Pass in deviceId when fetching device tags
Change-type: patch Closes: #1237 Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
921a74f04f
commit
3c59944ce1
@ -383,8 +383,14 @@ export class APIBinder {
|
||||
'Attempt to communicate with API, without initialized client',
|
||||
);
|
||||
}
|
||||
|
||||
const deviceId = await this.config.get('deviceId');
|
||||
if (deviceId == null) {
|
||||
throw new Error('Attempt to retrieve device tags before provision');
|
||||
}
|
||||
const tags = (await this.balenaApi.get({
|
||||
resource: 'device_tag',
|
||||
id: deviceId,
|
||||
options: {
|
||||
$select: ['id', 'tag_key', 'value'],
|
||||
},
|
||||
|
@ -445,11 +445,18 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
||||
});
|
||||
|
||||
router.get('/v2/device/tags', async (_req, res) => {
|
||||
const tags = await applications.apiBinder.fetchDeviceTags();
|
||||
return res.json({
|
||||
status: 'success',
|
||||
tags,
|
||||
});
|
||||
try {
|
||||
const tags = await applications.apiBinder.fetchDeviceTags();
|
||||
return res.json({
|
||||
status: 'success',
|
||||
tags,
|
||||
});
|
||||
} catch (e) {
|
||||
res.status(500).json({
|
||||
status: 'failed',
|
||||
message: e.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/v2/cleanup-volumes', async (_req, res) => {
|
||||
|
Loading…
Reference in New Issue
Block a user