From 2c7c141d983745c33e83138cacb1eebcfbd6fcf4 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Tue, 18 Apr 2023 09:57:54 +0200 Subject: [PATCH] baculum: Add tenant indentifier list endpoint --- .../API/Pages/API/PluginM365TenantList.php | 66 +++++++++++++++++++ .../protected/API/Pages/API/endpoints.xml | 1 + .../protected/API/openapi_baculum.json | 48 ++++++++++++-- 3 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 gui/baculum/protected/API/Pages/API/PluginM365TenantList.php diff --git a/gui/baculum/protected/API/Pages/API/PluginM365TenantList.php b/gui/baculum/protected/API/Pages/API/PluginM365TenantList.php new file mode 100644 index 000000000..c4164efb8 --- /dev/null +++ b/gui/baculum/protected/API/Pages/API/PluginM365TenantList.php @@ -0,0 +1,66 @@ + + * @category API + * @package Baculum API + */ +class PluginM365TenantList extends BaculumAPIServer { + + public function get() { + $misc = $this->getModule('misc'); + $client = null; + $clientid = $this->Request->contains('id') ? (int)$this->Request['id'] : 0; + $result = $this->getModule('bconsole')->bconsoleCommand( + $this->director, + ['.client'], + null, + true + ); + if ($result->exitcode === 0) { + $client_val = $this->getModule('client')->getClientById($clientid); + if (is_object($client_val) && in_array($client_val->name, $result->output)) { + $client = $client_val->name; + } else { + $this->output = ClientError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS; + $this->error = ClientError::ERROR_CLIENT_DOES_NOT_EXISTS; + return; + } + } else { + $this->output = PluginError::MSG_ERROR_WRONG_EXITCODE; + $this->error = PluginError::ERROR_WRONG_EXITCODE; + return; + } + + $tenants = $this->getModule('fd_plugin_cfg')->getConfig('m365', $client); + + $this->output = array_keys($tenants); + $this->error = PluginM365Error::ERROR_NO_ERRORS; + } +} diff --git a/gui/baculum/protected/API/Pages/API/endpoints.xml b/gui/baculum/protected/API/Pages/API/endpoints.xml index 49710576a..2f12e9a18 100644 --- a/gui/baculum/protected/API/Pages/API/endpoints.xml +++ b/gui/baculum/protected/API/Pages/API/endpoints.xml @@ -143,6 +143,7 @@ + diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index 7c0f91876..8e9f7a675 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -8304,6 +8304,44 @@ ] } }, + "/api/v2/plugins/m365/{clientid}/tenants": { + "get": { + "tags": ["plugins"], + "summary": "Microsoft 365 plugin tenant identifier list", + "description": "Get Microsoft 365 tenant identifier list.", + "responses": { + "200": { + "description": "List of Microsoft 365 tenant identifiers.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "type": "array", + "items": { + "type": "string", + "description": "Tenant identifier" + } + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] + } + } + } + } + } + } + }, + "parameters": [ + { + "$ref": "#/components/parameters/ClientId" + } + ] + } + }, "/api/v2/plugins/m365/{clientid}/users": { "get": { "tags": ["plugins"], @@ -8333,7 +8371,7 @@ "error": { "type": "integer", "description": "Error code", - "enum": [0, 1, 4, 5, 6, 7, 11, 1000] + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] } } } @@ -8389,7 +8427,7 @@ "error": { "type": "integer", "description": "Error code", - "enum": [0, 1, 4, 5, 6, 7, 11, 1000] + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] } } } @@ -8429,7 +8467,7 @@ "error": { "type": "integer", "description": "Error code", - "enum": [0, 1, 4, 5, 6, 7, 11, 1000] + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] } } } @@ -8580,7 +8618,7 @@ "error": { "type": "integer", "description": "Error code", - "enum": [0, 1, 4, 5, 6, 7, 11, 1000] + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] } } } @@ -8683,7 +8721,7 @@ "error": { "type": "integer", "description": "Error code", - "enum": [0, 1, 4, 5, 6, 7, 11, 1000] + "enum": [0, 1, 4, 5, 6, 7, 10, 11, 1000] } } } -- 2.47.3