Subversion Repositories oidplus

Rev

Rev 1440 | Rev 1445 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1440 Rev 1444
Line 126... Line 126...
126
                        foreach ($obj->getIris() as $iri) {
126
                        foreach ($obj->getIris() as $iri) {
127
                                $output['iris'][] = $iri->getName();
127
                                $output['iris'][] = $iri->getName();
128
                        }
128
                        }
129
                }
129
                }
130
 
130
 
-
 
131
                $output['children'] = array();
-
 
132
                $children = $obj->getChildren();
-
 
133
                foreach ($children as $child) {
-
 
134
                        $output['children'][] = $child->nodeId(true);
-
 
135
                }
-
 
136
 
131
                http_response_code(200);
137
                http_response_code(200);
132
                return $output;
138
                return $output;
133
        }
139
        }
134
 
140
 
135
        /**
141
        /**
Line 157... Line 163...
157
 
163
 
158
                if (OIDplusObject::exists($id)) {
164
                if (OIDplusObject::exists($id)) {
159
                        // TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command!
165
                        // TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command!
160
                        $output = self::action_Update($params);
166
                        $output = self::action_Update($params);
161
                } else {
167
                } else {
162
                        $params['parent'] = $obj->getParent();
168
                        $params['parent'] = $obj->getParent()->nodeId(true);
163
                        $params['id_fully_qualified'] = true;
169
                        $params['id_fully_qualified'] = true;
164
                        $output = self::action_Insert($params);
170
                        $output = self::action_Insert($params);
165
                }
171
                }
166
 
172
 
167
                $output['status_bits'] = [];
173
                $output['status_bits'] = [];
Line 183... Line 189...
183
        private function restApiCall_POST(string $endpoint, array $json_in): array {
189
        private function restApiCall_POST(string $endpoint, array $json_in): array {
184
                $id = substr($endpoint, strlen('objects/'));
190
                $id = substr($endpoint, strlen('objects/'));
185
                $obj = OIDplusObject::parse($id);
191
                $obj = OIDplusObject::parse($id);
186
                if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'GET', $id), null, 400);
192
                if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'GET', $id), null, 400);
187
                $params = $json_in;
193
                $params = $json_in;
188
                $params['parent'] = $obj->getParent();
194
                $params['parent'] = $obj->getParent()->nodeId(true);
189
                $params['id_fully_qualified'] = true;
195
                $params['id_fully_qualified'] = true;
190
                $params['id'] = $id;
196
                $params['id'] = $id;
191
                $output = self::action_Insert($params);
197
                $output = self::action_Insert($params);
192
 
198
 
193
                $output['status_bits'] = [];
199
                $output['status_bits'] = [];
Line 279... Line 285...
279
         */
285
         */
280
        public function restApiInfo(string $kind='html'): string {
286
        public function restApiInfo(string $kind='html'): string {
281
                if ($kind === 'html') {
287
                if ($kind === 'html') {
282
                        $struct = [
288
                        $struct = [
283
                                _L('Receive') => [
289
                                _L('Receive') => [
284
                                        '<b>GET</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[id]</abbr>',
290
                                        '<b>GET</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[ns]:[id]</abbr>',
285
                                        _L('Input parameters') => [
291
                                        _L('Input parameters') => [
286
                                                '<i>'._L('None').'</i>'
292
                                                '<i>'._L('None').'</i>'
287
                                        ],
293
                                        ],
288
                                        _L('Output parameters') => [
294
                                        _L('Output parameters') => [
289
                                                'status ('._L('<0 is error, >=0 is success').')',
295
                                                'status ('._L('<0 is error, >=0 is success').')',
Line 293... Line 299...
293
                                                'comment',
299
                                                'comment',
294
                                                'iris ('._L('for OID only').')',
300
                                                'iris ('._L('for OID only').')',
295
                                                'asn1ids ('._L('for OID only').')',
301
                                                'asn1ids ('._L('for OID only').')',
296
                                                'confidential',
302
                                                'confidential',
297
                                                'title',
303
                                                'title',
298
                                                'description'
304
                                                'description',
-
 
305
                                                'children'
299
                                        ]
306
                                        ]
300
                                ],
307
                                ],
301
                                _L('Re-Create') => [
308
                                _L('Re-Create') => [
302
                                        '<b>PUT</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[id]</abbr>',
309
                                        '<b>PUT</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[ns]:[id]</abbr>',
303
                                        _L('Input parameters') => [
310
                                        _L('Input parameters') => [
304
                                                'ra_email ('._L('optional').')',
311
                                                'ra_email ('._L('optional').')',
305
                                                'comment ('._L('optional').')',
312
                                                'comment ('._L('optional').')',
306
                                                'iris ('._L('optional').')',
313
                                                'iris ('._L('optional').')',
307
                                                'asn1ids ('._L('optional').')',
314
                                                'asn1ids ('._L('optional').')',
Line 315... Line 322...
315
                                                'error ('._L('if an error occurred').')',
322
                                                'error ('._L('if an error occurred').')',
316
                                                'inserted_id ('._L('if it was created').')'
323
                                                'inserted_id ('._L('if it was created').')'
317
                                        ]
324
                                        ]
318
                                ],
325
                                ],
319
                                _L('Create') => [
326
                                _L('Create') => [
320
                                        '<b>POST</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[id]</abbr>',
327
                                        '<b>POST</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[ns]:[id]</abbr>',
321
                                        _L('Input parameters') => [
328
                                        _L('Input parameters') => [
322
                                                'ra_email ('._L('optional').')',
329
                                                'ra_email ('._L('optional').')',
323
                                                'comment ('._L('optional').')',
330
                                                'comment ('._L('optional').')',
324
                                                'iris ('._L('optional').')',
331
                                                'iris ('._L('optional').')',
325
                                                'asn1ids ('._L('optional').')',
332
                                                'asn1ids ('._L('optional').')',
Line 333... Line 340...
333
                                                'error ('._L('if an error occurred').')',
340
                                                'error ('._L('if an error occurred').')',
334
                                                'inserted_id'
341
                                                'inserted_id'
335
                                        ]
342
                                        ]
336
                                ],
343
                                ],
337
                                _L('Update') => [
344
                                _L('Update') => [
338
                                        '<b>PATCH</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[id]</abbr>',
345
                                        '<b>PATCH</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[ns]:[id]</abbr>',
339
                                        _L('Input parameters') => [
346
                                        _L('Input parameters') => [
340
                                                'ra_email ('._L('optional').')',
347
                                                'ra_email ('._L('optional').')',
341
                                                'comment ('._L('optional').')',
348
                                                'comment ('._L('optional').')',
342
                                                'iris ('._L('optional').')',
349
                                                'iris ('._L('optional').')',
343
                                                'asn1ids ('._L('optional').')',
350
                                                'asn1ids ('._L('optional').')',
Line 350... Line 357...
350
                                                'status_bits',
357
                                                'status_bits',
351
                                                'error ('._L('if an error occurred').')',
358
                                                'error ('._L('if an error occurred').')',
352
                                        ]
359
                                        ]
353
                                ],
360
                                ],
354
                                _L('Remove') => [
361
                                _L('Remove') => [
355
                                        '<b>DELETE</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[id]</abbr>',
362
                                        '<b>DELETE</b> '.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'rest/v1/objects/<abbr title="'._L('e.g. %1', 'oid:2.999').'">[ns]:[id]</abbr>',
356
                                        _L('Input parameters') => [
363
                                        _L('Input parameters') => [
357
                                                '<i>'._L('None').'</i>'
364
                                                '<i>'._L('None').'</i>'
358
                                        ],
365
                                        ],
359
                                        _L('Output parameters') => [
366
                                        _L('Output parameters') => [
360
                                                'status ('._L('<0 is error, >=0 is success').')',
367
                                                'status ('._L('<0 is error, >=0 is success').')',