mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Add a containerId request function to the device api module
Change-type: minor Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
5de7a50fc0
commit
39cf86ed85
@ -67,6 +67,7 @@ const deviceEndpoints = {
|
||||
ping: 'ping',
|
||||
version: 'v2/version',
|
||||
status: 'v2/state/status',
|
||||
containerId: 'v2/containerId',
|
||||
};
|
||||
|
||||
export class DeviceAPI {
|
||||
@ -124,6 +125,29 @@ export class DeviceAPI {
|
||||
});
|
||||
}
|
||||
|
||||
public async getContainerId(serviceName: string): Promise<string> {
|
||||
const url = this.getUrlForAction('containerId');
|
||||
|
||||
const body = await DeviceAPI.promisifiedRequest(
|
||||
request.get,
|
||||
{
|
||||
url,
|
||||
json: true,
|
||||
qs: {
|
||||
serviceName,
|
||||
},
|
||||
},
|
||||
this.logger,
|
||||
);
|
||||
|
||||
if (body.status !== 'success') {
|
||||
throw new ApiErrors.DeviceAPIError(
|
||||
'Non-successful response from supervisor containerId endpoint',
|
||||
);
|
||||
}
|
||||
return body.containerId;
|
||||
}
|
||||
|
||||
public async ping(): Promise<void> {
|
||||
const url = this.getUrlForAction('ping');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user