scimserviceprovider/lib/Controller/GroupBearerController.php
2023-03-03 11:21:27 +00:00

99 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\SCIMServiceProvider\Controller;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
use OCA\SCIMServiceProvider\Responses\SCIMListResponse;
use OCA\SCIMServiceProvider\Responses\SCIMJSONResponse;
use OCA\SCIMServiceProvider\Service\GroupService;
class GroupBearerController extends ApiController
{
/** @var GroupService */
private $groupService;
public function __construct(
string $appName,
IRequest $request,
GroupService $groupService
) {
parent::__construct(
$appName,
$request
);
$this->groupService = $groupService;
}
/**
* @NoCSRFRequired
* @PublicPage
*
* @param string $filter
* @return SCIMListResponse
* returns a list of groups and their data
*/
public function index(string $filter = ''): SCIMListResponse
{
return $this->groupService->getAll($filter);
}
/**
* @NoCSRFRequired
* @PublicPage
*
* gets group info
*
* @param string $id
* @return SCIMJSONResponse
*/
// TODO: Add filtering support here as well
public function show(string $id): SCIMJSONResponse
{
return $this->groupService->getOneById($id);
}
/**
* @NoCSRFRequired
* @PublicPage
*
* @param string $displayName
* @param array $members
* @return SCIMJSONResponse
*/
public function create(string $displayName = '', array $members = []): SCIMJSONResponse
{
return $this->groupService->create($displayName, $members);
}
/**
* @NoCSRFRequired
* @PublicPage
*
* @param string $id
*
* @param string $displayName
* @param array $members
* @return SCIMJSONResponse
*/
public function update(string $id, string $displayName = '', array $members = []): SCIMJSONResponse
{
return $this->groupService->update($id, $displayName, $members);
}
/**
* @NoCSRFRequired
* @PublicPage
*
* @param string $id
* @return Response
*/
public function destroy(string $id): Response
{
return $this->groupService->destroy($id);
}
}