scimserviceprovider/lib/Controller/GroupController.php

95 lines
2.1 KiB
PHP
Raw Normal View History

2022-05-02 12:44:40 +00:00
<?php
declare(strict_types=1);
namespace OCA\SCIMServiceProvider\Controller;
2022-05-18 16:51:34 +00:00
use OCP\AppFramework\ApiController;
2022-05-02 12:44:40 +00:00
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
use OCA\SCIMServiceProvider\Responses\SCIMListResponse;
use OCA\SCIMServiceProvider\Responses\SCIMJSONResponse;
2023-03-03 11:21:27 +00:00
use OCA\SCIMServiceProvider\Service\GroupService;
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
class GroupController extends ApiController
{
/** @var GroupService */
private $groupService;
2022-05-18 16:51:34 +00:00
2023-03-03 11:21:27 +00:00
public function __construct(
string $appName,
IRequest $request,
GroupService $groupService
) {
parent::__construct(
$appName,
$request
);
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
$this->groupService = $groupService;
}
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
/**
* @NoCSRFRequired
*
* @param string $filter
* @return SCIMListResponse
* returns a list of groups and their data
*/
public function index(string $filter = ''): SCIMListResponse
{
return $this->groupService->getAll($filter);
}
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
/**
* @NoCSRFRequired
*
* 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);
}
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
/**
* @NoCSRFRequired
*
* @param string $displayName
* @param array $members
* @return SCIMJSONResponse
*/
public function create(string $displayName = '', array $members = []): SCIMJSONResponse
{
return $this->groupService->create($displayName, $members);
}
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
/**
* @NoCSRFRequired
*
* @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);
}
2022-05-02 12:44:40 +00:00
2023-03-03 11:21:27 +00:00
/**
* @NoCSRFRequired
*
* @param string $id
* @return Response
*/
public function destroy(string $id): Response
{
return $this->groupService->destroy($id);
}
2022-05-02 12:44:40 +00:00
}