@@ -85,7 +85,7 @@ public function list(Request $request)
8585 * 'daemonSFTP' => 2022,
8686 * 'daemonListen' => 8080
8787 * }, headers={"Authorization": "Bearer <jwt-token>"}),
88- * @Response(201 ),
88+ * @Response(200 ),
8989 * @Response(422, body={
9090 * "message": "A validation error occured.",
9191 * "errors": {},
@@ -102,9 +102,7 @@ public function create(Request $request)
102102 try {
103103 $ node = new NodeRepository ;
104104 $ new = $ node ->create ($ request ->all ());
105- return $ this ->response ->created (route ('api.nodes.view ' , [
106- 'id ' => $ new
107- ]));
105+ return [ 'id ' => $ new ];
108106 } catch (DisplayValidationException $ ex ) {
109107 throw new ResourceException ('A validation error occured. ' , json_decode ($ ex ->getMessage (), true ));
110108 } catch (DisplayException $ ex ) {
@@ -129,23 +127,23 @@ public function create(Request $request)
129127 */
130128 public function view (Request $ request , $ id , $ fields = null )
131129 {
132- $ query = Models \Node::where ('id ' , $ id );
130+ $ node = Models \Node::where ('id ' , $ id );
133131
134132 if (!is_null ($ request ->input ('fields ' ))) {
135133 foreach (explode (', ' , $ request ->input ('fields ' )) as $ field ) {
136134 if (!empty ($ field )) {
137- $ query ->addSelect ($ field );
135+ $ node ->addSelect ($ field );
138136 }
139137 }
140138 }
141139
142140 try {
143- if (!$ query ->first ()) {
141+ if (!$ node ->first ()) {
144142 throw new NotFoundHttpException ('No node by that ID was found. ' );
145143 }
146144
147145 return [
148- 'node ' => $ query ->first (),
146+ 'node ' => $ node ->first (),
149147 'allocations ' => [
150148 'assigned ' => Models \Allocation::where ('node ' , $ id )->whereNotNull ('assigned_to ' )->get (),
151149 'unassigned ' => Models \Allocation::where ('node ' , $ id )->whereNull ('assigned_to ' )->get ()
@@ -158,6 +156,59 @@ public function view(Request $request, $id, $fields = null)
158156 }
159157 }
160158
159+ public function config (Request $ request , $ id )
160+ {
161+ if (!$ request ->secure ()) {
162+ throw new BadRequestHttpException ('This API route can only be accessed using a secure connection. ' );
163+ }
164+
165+ $ node = Models \Node::where ('id ' , $ id )->first ();
166+ if (!$ node ) {
167+ throw new NotFoundHttpException ('No node by that ID was found. ' );
168+ }
169+
170+ return [
171+ 'web ' => [
172+ 'listen ' => $ node ->daemonListen ,
173+ 'ssl ' => [
174+ 'enabled ' => ($ node ->scheme === 'https ' ),
175+ 'certificate ' => '/etc/certs/ ' . $ node ->fqdn . '/fullchain.pem ' ,
176+ 'key ' => '/etc/certs/ ' . $ node ->fqdn . '/privkey.pem '
177+ ]
178+ ],
179+ 'docker ' => [
180+ 'socket ' => '/var/run/docker.sock ' ,
181+ 'autoupdate_images ' => true
182+ ],
183+ 'sftp ' => [
184+ 'path ' => $ node ->daemonBase ,
185+ 'port ' => (int ) $ node ->daemonSFTP ,
186+ 'container ' => '0x0000 '
187+ ],
188+ 'logger ' => [
189+ 'path ' => 'logs/ ' ,
190+ 'src ' => false ,
191+ 'level ' => 'info ' ,
192+ 'period ' => '1d ' ,
193+ 'count ' => 3
194+ ],
195+ 'remote ' => [
196+ 'download ' => route ('remote.download ' ),
197+ 'installed ' => route ('remote.install ' )
198+ ],
199+ 'uploads ' => [
200+ 'maximumSize ' => 100000000
201+ ],
202+ 'keys ' => [
203+ $ node ->daemonSecret
204+ ],
205+ 'query ' => [
206+ 'kill_on_fail ' => true ,
207+ 'fail_limit ' => 3
208+ ]
209+ ];
210+ }
211+
161212 /**
162213 * List all Node Allocations
163214 *
0 commit comments