Skip to content

OcWorkflowsApi

FarbodZamani edited this page Mar 29, 2022 · 5 revisions

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

Namespace

It is accessible under OpencastApi\Rest namespace.

Version

This endpoint is available for API Version 1.1.0 or greater, therefore, it throws an Exception upon direct class instantiation, or it won't be defined as property in OpencastApi\OpenCast class when api version is incompatible!

How to use

  1. In OpencastApi\OpenCast as its property with OpenCast properties naming convention:
use OpencastApi\OpenCast;
$opencastApi = new OpenCast($config);
$ocWorkflowsApi = $opencastApi->workflowsApi;
...
  1. Direct instantiation:
use OpencastApi\Rest\OcRestClient;
use OpencastApi\Rest\OcWorkflowsApi;
$ocRestClient = new OcRestClient($config);
$ocWorkflowsApi = new OcWorkflowsApi($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:
[
    'withoperations' => '{Whether the workflow operations should be included in the response}',
    'withconfiguration' => '{Whether the workflow configuration should be included in the response}',
    'sort' => '{an assiciative array for sorting e.g. ['event_identifier' => 'DESC']}',
    'limit' => '{the maximum number of results to return}',
    'offset' => '{the index of the first result to return}',
    'filter' => '{an assiciative array for filtering e.g. ['state' => '{Workflow instances that are in this state}']}',
]
  • Returns an array: ['code' => 200, 'body' => '{A (potentially empty) list of workflow instances}']

get($workflowInstanceId, $withoperations = false, $withconfiguration = false)

Returns a single workflow instance. More Detail

  • $workflowInstanceId (string) The workflow instance id

  • $withoperations (boolean) (optional) Whether the workflow operations should be included in the response (Default value=false)

  • $withconfiguration (boolean) (optional) Whether the workflow configuration should be included in the response (Default value=false)

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

run($eventIdentifier, $definitionIdentifier, $configuration = [], $withoperations = false, $withconfiguration = false)

Creates (runs) a workflow instance agianst an event. More Detail

  • $eventIdentifier (string) The event identifier this workflow should run against

  • $definitionIdentifier (string) The identifier of the workflow definition to use

  • $configuration (string|array) (optional) The optional configuration for this workflow

  • $withoperations (boolean) (optional) Whether the workflow operations should be included in the response (Default value=false)

  • $withconfiguration (boolean) (optional) Whether the workflow configuration should be included in the response (Default value=false)

  • Returns an array: ['code' => 201, 'body' => '{A new workflow is created and its identifier as Object is returned}', 'location' => 'The url']

update($workflowInstanceId, $state = '', $configuration = [], $withoperations = false, $withconfiguration = false)

Updates a workflow instance. More Detail

  • $workflowInstanceId (string) The workflow instance id

  • $state (string) (optional) The optional state transition for this workflow

  • $configuration (string|array) (optional) The optional configuration for this workflow

  • $withoperations (boolean) (optional) Whether the workflow operations should be included in the response (Default value=false)

  • $withconfiguration (boolean) (optional) Whether the workflow configuration should be included in the response (Default value=false)

  • Returns an array: ['code' => 200, 'reason' => 'OK'] (updated)

delete($workflowInstanceId)

Deletes a workflow instance. More Detail

  • $workflowInstanceId (string) The workflow instance id

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

getAllDefinitions($params = [])

Returns a list of workflow definitions. More Detail

  • $params is an optional array that could contain the following:
[
    'withoperations' => '{(boolean) Whether the workflow operations should be included in the response}',
    'withconfigurationpanel' => '{(boolean) Whether the workflow configuration panel should be included in the response}',
    'sort' => '{an assiciative array for sorting e.g. ['title' => 'DESC']}',
    'limit' => '{the maximum number of results to return}',
    'offset' => '{the index of the first result to return}',
    'filter' => '{an assiciative array for filtering e.g. ['tag' => '{Workflow definitions where the tag is included}']}',
]
  • Returns an array: ['code' => 200, 'body' => '{A (potentially empty) list of workflow definitions}']

getDefinition($workflowDefinitionId, $withoperations = false, $withconfigurationpanel = false)

Returns a single workflow definition. More Detail

  • $workflowDefinitionId (string) the identifier of the workflow definition.

  • $withoperations (boolean) (optional) Whether the workflow operations should be included in the response (Default value=false)

  • $withconfigurationpanel (boolean) (optional) Whether the workflow configuration should be included in the response (Default value=false)

  • Returns an array: ['code' => 200, 'body' => '{ The workflow definition is returned as JSON object}']