mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-02 07:40:48 +00:00
Add applications state v2 endpoint
Change-type: minor Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
parent
049398eec0
commit
cf85ae524b
4
src/application-manager.d.ts
vendored
4
src/application-manager.d.ts
vendored
@ -1,6 +1,7 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
import { ServiceAction } from './device-api/common';
|
import { ServiceAction } from './device-api/common';
|
||||||
|
import { DeviceApplicationState } from './types/state';
|
||||||
|
|
||||||
import Images = require('./compose/images');
|
import Images = require('./compose/images');
|
||||||
import ServiceManager = require('./compose/service-manager');
|
import ServiceManager = require('./compose/service-manager');
|
||||||
@ -45,7 +46,8 @@ export class ApplicationManager extends EventEmitter {
|
|||||||
|
|
||||||
public executeStepAction(serviceAction: ServiceAction, opts: Options): Promise<void>;
|
public executeStepAction(serviceAction: ServiceAction, opts: Options): Promise<void>;
|
||||||
|
|
||||||
|
public getStatus(): Promise<DeviceApplicationState>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ApplicationManager;
|
export default ApplicationManager;
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import * as Bluebird from 'bluebird';
|
import * as Bluebird from 'bluebird';
|
||||||
import { Response, Request, Router } from 'express';
|
import { Request, Response, Router } from 'express';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import ApplicationManager from '../application-manager';
|
import { ApplicationManager } from '../application-manager';
|
||||||
import { doPurge, doRestart, serviceAction } from './common';
|
|
||||||
|
|
||||||
import { appNotFoundMessage, serviceNotFoundMessage } from '../lib/messages';
|
import { appNotFoundMessage, serviceNotFoundMessage } from '../lib/messages';
|
||||||
|
import Service from '../types/service';
|
||||||
|
import { doPurge, doRestart, serviceAction } from './common';
|
||||||
|
|
||||||
export function createV2Api(router: Router, applications: ApplicationManager) {
|
export function createV2Api(router: Router, applications: ApplicationManager) {
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ export function createV2Api(router: Router, applications: ApplicationManager) {
|
|||||||
res.status(404).send(appNotFoundMessage);
|
res.status(404).send(appNotFoundMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const service = _.find(app.services, { imageId });
|
const service = _.find(app.services, { imageId }) as Service | null;
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
res.status(404).send(serviceNotFoundMessage);
|
res.status(404).send(serviceNotFoundMessage);
|
||||||
return;
|
return;
|
||||||
|
16
src/types/state.ts
Normal file
16
src/types/state.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
export interface DeviceApplicationState {
|
||||||
|
local: {
|
||||||
|
[appId: string]: {
|
||||||
|
services: {
|
||||||
|
[serviceId: string]: {
|
||||||
|
status: string;
|
||||||
|
releaseId: number;
|
||||||
|
download_progress: number | null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
// TODO
|
||||||
|
dependent: any;
|
||||||
|
commit: string;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user