Reference·PHP SDK · BIMworksPHP

ActionsApi

PHP SDK: the Actions operations, 6 methods, each with its parameters, result and a complete example.

PHP SDK · BIMworks\Api · class · 6 methods

Stored queries, checks, visualizations and other actions, which Query and Check run by uuid

Construct it with the client of the connect step: new ActionsApi(config: $client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
addActionAddActionStore an action
deleteActionDeleteActionDelete an action
getActionGetActionRead an action
listActionsListActionsList the actions in a folder
undeleteActionUndeleteActionBring back a deleted action
updateActionUpdateActionChange an action

addAction#

PHP#
public function addAction(AddActionRequest $add_action_request): Action

Store an action. Stores a query, check, visualization or other action in a folder, or a new folder (main_type: FOLDER). Needs write rights on the folder.

OperationAddAction · POST /openapi/actions/AddAction
Scopeactions:write

Parameters#

NameTypeDescription
add_action_requestAddActionRequestrequiredThe request: its properties are those of the model, its JSON that of AddAction's request body.

Returns#

Action — The stored action

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\AddActionRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "parent_uuid": "5e4d3c2b-1a09-4f8e-9d7c-6b5a49382716",
  "name": "External walls",
  "main_type": "QUERY3",
  "query": "GET attribute.Name WHERE type = IFCWALL AND property.Pset_WallCommon.IsExternal = true"
}
JSON, AddActionRequest::class);

// 3. The call
$result = (new ActionsApi(config: $client))->addAction($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

deleteAction#

PHP#
public function deleteAction(DeleteActionRequest $delete_action_request): void

Delete an action. Moves the action to the deleted ones (ListActions show_deleted); UndeleteAction brings it back.

OperationDeleteAction · POST /openapi/actions/DeleteAction
Scopeactions:write

Parameters#

NameTypeDescription
delete_action_requestDeleteActionRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteAction's request body.

Returns#

Nothing: the operation answers without a body (Deleted).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\DeleteActionRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "uuid": "<version uuid of the first demo model>"
}
JSON, DeleteActionRequest::class);

// 3. The call
(new ActionsApi(config: $client))->deleteAction($request);

// 4. The result
// (DeleteAction answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

getAction#

PHP#
public function getAction(?GetActionRequest $get_action_request = null): Action

Read an action. One action with its text, by uuid or by path (from the caller's own folder).

OperationGetAction · POST /openapi/actions/GetAction
Scopeactions:read

Parameters#

NameTypeDescription
get_action_requestGetActionRequestoptionalThe request: its properties are those of the model, its JSON that of GetAction's request body.

Returns#

Action — The action

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\GetActionRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "uuid": "<version uuid of the first demo model>",
  "path": ""
}
JSON, GetActionRequest::class);

// 3. The call
$result = (new ActionsApi(config: $client))->getAction($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

listActions#

PHP#
public function listActions(?ListActionsRequest $list_actions_request = null): ActionList

List the actions in a folder. The stored actions (queries, checks, visualizations, ...) and folders in a folder, by name, and the folder's path. The folder by uuid or by path (from the caller's own folder); the caller's own folder when both are absent. Query and Check run a stored action by its uuid (action_uuid).

OperationListActions · POST /openapi/actions/ListActions
Scopeactions:read

Parameters#

NameTypeDescription
list_actions_requestListActionsRequestoptionalThe request: its properties are those of the model, its JSON that of ListActions's request body.

Returns#

ActionList — The folder's content

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\ListActionsRequest;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "uuid": "<version uuid of the first demo model>",
  "path": "",
  "show_deleted": false
}
JSON, ListActionsRequest::class);

// 3. The call
$result = (new ActionsApi(config: $client))->listActions($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;

undeleteAction#

PHP#
public function undeleteAction(UndeleteActionRequest $undelete_action_request): void

Bring back a deleted action. Undoes DeleteAction.

OperationUndeleteAction · POST /openapi/actions/UndeleteAction
Scopeactions:write

Parameters#

NameTypeDescription
undelete_action_requestUndeleteActionRequestrequiredThe request: its properties are those of the model, its JSON that of UndeleteAction's request body.

Returns#

Nothing: the operation answers without a body (Restored).

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\UndeleteActionRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "uuid": "<version uuid of the first demo model>"
}
JSON, UndeleteActionRequest::class);

// 3. The call
(new ActionsApi(config: $client))->undeleteAction($request);

// 4. The result
// (UndeleteAction answers no content: the call returns once it succeeded and throws an ApiException otherwise)
echo 'Done', PHP_EOL;

updateAction#

PHP#
public function updateAction(UpdateActionRequest $update_action_request): Action

Change an action. Changes the fields that are passed; the others stay as they are. A change to an action (not a folder) is a new version unless save_mode is OVERWRITE. Pass base_version, the version you started from, to have a change by someone else in between refused with 409 instead of overwritten. A folder takes only a new name.

OperationUpdateAction · POST /openapi/actions/UpdateAction
Scopeactions:write

Parameters#

NameTypeDescription
update_action_requestUpdateActionRequestrequiredThe request: its properties are those of the model, its JSON that of UpdateAction's request body.

Returns#

Action — The action as it is now

Example#

PHP#
<?php
require __DIR__ . '/vendor/autoload.php';

use BIMworks\Api\ActionsApi;
use BIMworks\Api\AuthApi;
use BIMworks\Configuration;
use BIMworks\Model\LoginWithApiTokenRequest;
use BIMworks\Model\UpdateActionRequest;
use BIMworks\ObjectSerializer;

// 1. Connect to BIM.works and log in with your API token
$client = (new Configuration())->setHost('https://bim.works/openapi');
$auth = (new AuthApi(config: $client))->loginWithApiToken(new LoginWithApiTokenRequest(['token' => "<your API token>"]));
$client->setAccessToken($auth->getBase64());

// 2. The request
$request = ObjectSerializer::deserialize(<<<'JSON'
{
  "uuid": "<version uuid of the first demo model>",
  "name": "",
  "query": "",
  "description": "",
  "output_hint": "VIEWER_3D",
  "favourite": false,
  "save_mode": "NEW_VERSION",
  "save_comment": "",
  "base_version": 0
}
JSON, UpdateActionRequest::class);

// 3. The call
$result = (new ActionsApi(config: $client))->updateAction($request);

// 4. The result
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), PHP_EOL;