diff --git a/restapi/index.php b/restapi/index.php index 5e0d8ba61..8a59cdb58 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -2823,6 +2823,22 @@ final class SeedDMS_RestapiController { /* {{{ */ return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$data))->withStatus(200); } /* }}} */ + function getAttributeDefinition($request, $response, $args) { /* {{{ */ + $dms = $this->container->get('dms'); + $userobj = $this->container->get('userobj'); + + if (!ctype_digit($args['id'])) { + return $this->renderer->json($response, array('success'=>false, 'message'=>'Invalid parameter', 'data'=>''))->withStatus(400); + } + + $attrdef = $dms->getAttributeDefinition($args['id']); + if ($attrdef) { + return $this->renderer->json($response, array('success'=>true, 'message'=>'', 'data'=>$this->__getAttributeDefinitionData($attrdef)))->withStatus(200); + } else { + return $this->renderer->json($response, array('success'=>false, 'message'=>'No such attributedefinition', 'data'=>''))->withStatus(404); + } + } /* }}} */ + /** * Updates the name of an existing attribute definition * @@ -3257,6 +3273,7 @@ $app->delete('/categories/{id}', \SeedDMS_RestapiController::class.':deleteCateg $app->post('/categories', \SeedDMS_RestapiController::class.':createCategory'); $app->put('/categories/{id}/name', \SeedDMS_RestapiController::class.':changeCategoryName'); $app->get('/attributedefinitions', \SeedDMS_RestapiController::class.':getAttributeDefinitions'); +$app->get('/attributedefinitions/{id}', \SeedDMS_RestapiController::class.':getAttributeDefinition'); $app->put('/attributedefinitions/{id}/name', \SeedDMS_RestapiController::class.':changeAttributeDefinitionName'); $app->get('/echo/{data}', \SeedDMS_TestController::class.':echoData'); $app->get('/version', \SeedDMS_TestController::class.':version');