implement start and stop for containers

This commit is contained in:
Philipp Kunz 2016-06-16 04:45:22 +02:00
parent 188c7af749
commit 4eae29cec9
3 changed files with 48 additions and 4 deletions

View File

@ -2,11 +2,16 @@ import "typings-global";
export declare class Dockersock {
sockPath: string;
constructor(pathArg?: string);
auth(userArg: string, passArg: string): any;
listContainers(): any;
listContainersDetailed(): any;
listContainersRunning(): any;
listContainersStopped(): any;
listImages(): any;
getContainerId(): void;
startContainer(containerNameArg: any): any;
stopContainer(): any;
clean(): any;
getChange(): void;
request(methodArg: string, routeArg: string, dataArg?: {}): any;
}

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,11 @@ export class Dockersock {
}
// methods
auth(userArg:string,passArg:string){
let done = plugins.q.defer();
this.request("POST","");
return done.promise;
}
listContainers() {
let done = plugins.q.defer();
this.request("GET","/containers")
@ -49,17 +54,30 @@ export class Dockersock {
let done = plugins.q.defer();
return done.promise;
}
getContainerId(){
}
startContainer(containerNameArg){
return this.request("POST","/containers/"+ containerNameArg +"/start");
};
stopContainer(){
return this.request("POST","/containers/"+ containerNameArg +"/stop");
}
clean() {
let done = plugins.q.defer();
return done.promise;
}
};
getChange(){
};
request(methodArg:string,routeArg:string,dataArg = {}){
let done = plugins.q.defer();
let jsonArg:string = JSON.stringify(dataArg);
let suffix:string = ""
if(methodArg == "GET") suffix = "/json";
let options = {
method:methodArg,
url:this.sockPath + routeArg + "/json",
url:this.sockPath + routeArg + suffix,
headers:{
"Content-Type":"application/json"
},