@@ -24,7 +24,7 @@ public function listRepositories()
2424 $ repositories = array ();
2525 foreach ($ res ["rows " ] as $ row )
2626 {
27- $ repository = new Repository ($ this -> client , $ row );
27+ $ repository = new Repository ($ this , $ row );
2828 array_push ($ repositories , $ repository );
2929 }
3030
@@ -38,7 +38,7 @@ public function readRepository($repositoryId)
3838 try
3939 {
4040 $ res = $ this ->client ->get ($ uri );
41- $ repository = new Repository ($ this -> client , $ res );
41+ $ repository = new Repository ($ this , $ res );
4242 }
4343 catch (\GuzzleHttp \Exception \ClientException $ ex )
4444 {
@@ -56,4 +56,73 @@ public function createRepository($obj = array())
5656 $ repositoryId = $ res ["_doc " ];
5757 return $ this ->readRepository ($ repositoryId );
5858 }
59+
60+ public function readJob ($ jobId )
61+ {
62+ $ uri = $ this ->uri () . "/jobs/ " . $ jobId ;
63+ $ res = $ this ->client ->get ($ uri );
64+
65+ return new Job ($ this ->client , $ res );
66+ }
67+
68+ public function queryJobs ($ query , $ pagination = array ())
69+ {
70+ $ uri = $ this ->uri () . "/jobs/query " ;
71+ $ res = $ this ->client ->post ($ uri , $ pagination , $ query );
72+
73+ $ jobs = array ();
74+ foreach ($ res ["rows " ] as &$ row )
75+ {
76+ array_push ($ jobs , new Job ($ this ->client , $ row ));
77+ }
78+
79+ return $ jobs ;
80+ }
81+
82+ // Projects
83+
84+ public function readProject ($ projectId )
85+ {
86+ $ uri = $ this ->uri () . "/projects/ " . $ projectId ;
87+ $ res = $ this ->client ->get ($ uri );
88+
89+ return new Project ($ this , $ res );
90+ }
91+
92+ public function listProjects ($ pagination = array ())
93+ {
94+ $ uri = $ this ->uri () . "/projects " ;
95+ $ res = $ this ->client ->get ($ uri , $ pagination );
96+
97+ $ projects = array ();
98+ foreach ($ res ["rows " ] as &$ project )
99+ {
100+ array_push ($ projects , new Project ($ this , $ project ));
101+ }
102+
103+ return $ projects ;
104+ }
105+
106+ public function queryProjects ($ query , $ pagination = array ())
107+ {
108+ $ uri = $ this ->uri () . "/projects/query " ;
109+ $ res = $ this ->client ->post ($ uri , $ pagination , $ query );
110+
111+ $ projects = array ();
112+ foreach ($ res ["rows " ] as &$ project )
113+ {
114+ array_push ($ projects , new Project ($ this , $ project ));
115+ }
116+
117+ return $ projects ;
118+ }
119+
120+ public function startCreateProject ($ obj = array ())
121+ {
122+ $ uri = $ this ->uri () . "/projects/start " ;
123+ $ res = $ this ->client ->post ($ uri , array (), $ obj );
124+
125+ $ jobId = $ res ["_doc " ];
126+ return $ this ->readJob ($ jobId );
127+ }
59128}
0 commit comments