Skip to content

OcGroupsApi

FarbodZamani edited this page Mar 25, 2022 · 4 revisions

This class contains all REST API calls to the /api/groups endpoint.

Namespace

It is accessible under OpencastApi\Rest namespace.

How to use

  1. In OpencastApi\OpenCast as its property with OpenCast properties naming convention:
use OpencastApi\OpenCast;
$opencastApi = new OpenCast($config);
$ocGroupsApi = $opencastApi->groupsApi;
...
  1. Direct instantiation:
use OpencastApi\Rest\OcRestClient;
use OpencastApi\Rest\OcGroupsApi;
$ocRestClient = new OcRestClient($config);
$ocGroupsApi = new OcGroupsApi($ocRestClient);
...

Functions

Consumable functions are listed below:

getAll($params = [])

Returns a list of workflow instances. More Detail

  • $params is an optional array that could contain the following:
[
    'sort' => (array) {an assiciative array for sorting e.g. ['name' => 'DESC', 'description' => '', 'role' => '']},
    'limit' => (int) {the maximum number of results to return},
    'offset' => (int) {the index of the first result to return},
    'filter' => (array) {an assiciative array for filtering e.g. ['name' => '{Groups where the name specified in the metadata field match}']},
]
  • Returns an array: ['code' => 200, 'body' => '{A (potentially empty) list of groups}']

get($groupId)

Returns a single group. More Detail

  • $groupId (string) the identifier of the group.

  • Returns an array: ['code' => 200, 'body' => '{The group}']

create($name, $description = '', $roles = [], $members = [])

Creates a group. More Detail

  • $name (string) Group Name

  • $description (string) (optional) Group Description

  • $roles (array) (optional) list of roles

  • $members (array) (optional) list of members

  • Returns an array: ['code' => 201, 'reason' => 'CREATED'] (A new group is created)

update($groupId, $name = '', $description = '', $roles = [], $members = [])

Updates a group. If any of form parameters are ommited, the respective fields of the group will not be changed. More Detail

  • $groupId (string) group id

  • $name (string) (optional) Group Name

  • $description (string) (optional) Group Description

  • $roles (array) (optional) list of roles

  • $members (array) (optional) list of members

  • Returns an array: ['code' => 201, 'reason' => 'CREATED'] (The group has been updated)

delete($groupId)

Deletes a group. More Detail

  • $groupId (string) group id

  • Returns an array: ['code' => 204, 'reason' => 'No Content'] (The group has been deleted)

addMember($groupId, $member)

Adds a member to a group. More Detail

  • $groupId (string) group id

  • $member (string) The username of the member to be added

  • Returns an array: ['code' => 204, 'reason' => 'No Content'] (The member has been added)

deleteMember($groupId, $memberId)

Removes a member from a group. More Detail

  • $groupId (string) group id

  • $memberId (string) member id

  • Returns an array: ['code' => 204, 'reason' => 'No Content'] (The member has been removed)