/* Copyright CloudLinux Zug GmbH 2010-2017 All Rights Reserved
 *
 * Licensed under CLOUD LINUX LICENSE AGREEMENT
 * http://cloudlinux.com/docs/LICENSE.TXT
 */

import {Injectable} from '@angular/core';
import {XHR} from "../utils/xhr";

@Injectable()
export class CagefsRepo {

    private command: string  = 'cagefsctl';

    constructor(
        private request: XHR,
    ) {}

    public cageFsStatus() {
        return this.cageFsMethod('status')
    }

    public initCageFs() {
        return this.cageFsMethod('init')
    }

    public cagefsUpdateSkeleton() {
        return this.cageFsMethod('update')
    }

    public cageFsMethod(method) {
        return this.request.post(
            {
                 command: this.command,
                 method: method
        });
    }

    public cageFsRun(param = null) {
        let params = {};
        if (param) {
            params[param] = ''
        }
        return this.request.post(
            {
                 command: this.command,
                 params: params
        });
    }

}
