mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 16:35:23 +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',
|
'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({
|
const tags = (await this.balenaApi.get({
|
||||||
resource: 'device_tag',
|
resource: 'device_tag',
|
||||||
|
id: deviceId,
|
||||||
options: {
|
options: {
|
||||||
$select: ['id', 'tag_key', 'value'],
|
$select: ['id', 'tag_key', 'value'],
|
||||||
},
|
},
|
||||||
|
@ -445,11 +445,18 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.get('/v2/device/tags', async (_req, res) => {
|
router.get('/v2/device/tags', async (_req, res) => {
|
||||||
|
try {
|
||||||
const tags = await applications.apiBinder.fetchDeviceTags();
|
const tags = await applications.apiBinder.fetchDeviceTags();
|
||||||
return res.json({
|
return res.json({
|
||||||
status: 'success',
|
status: 'success',
|
||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
res.status(500).json({
|
||||||
|
status: 'failed',
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/v2/cleanup-volumes', async (_req, res) => {
|
router.get('/v2/cleanup-volumes', async (_req, res) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user