]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Change M365 tenants endpoint output to contain tenant names
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 29 May 2023 11:13:48 +0000 (13:13 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 1 Jun 2023 11:20:55 +0000 (13:20 +0200)
gui/baculum/protected/API/Pages/API/PluginM365TenantList.php
gui/baculum/protected/API/openapi_baculum.json

index c4164efb8a28c86088b58cf732e5a08676464a41..c5c63e2e42f8b164d1cc7f0164e5f62df800bc23 100644 (file)
@@ -59,8 +59,15 @@ class PluginM365TenantList extends BaculumAPIServer {
                }
 
                $tenants = $this->getModule('fd_plugin_cfg')->getConfig('m365', $client);
+               $out = [];
+               foreach ($tenants as $tenant_id => $opts) {
+                       $tenant_name = key_exists('tenant_name', $opts) ? $opts['tenant_name'] : '';
+                       $out[$tenant_id] = [
+                               'tenant_name' => $tenant_name
+                       ];
+               }
 
-               $this->output = array_keys($tenants);
+               $this->output = $out;
                $this->error = PluginM365Error::ERROR_NO_ERRORS;
        }
 }
index d020e023fdb4474121a36bf4d6997b14b0f9b78c..e0143e675245f4c7c5edef6857ff5eea339c65c8 100644 (file)
                "/api/v2/plugins/m365/{clientid}/tenants": {
                        "get": {
                                "tags": ["plugins"],
-                               "summary": "Microsoft 365 plugin tenant identifier list",
-                               "description": "Get Microsoft 365 tenant identifier list.",
+                               "summary": "Microsoft 365 plugin tenant identifier and name list",
+                               "description": "Get Microsoft 365 tenant identifier and name list.",
                                "responses": {
                                        "200": {
-                                               "description": "List of Microsoft 365 tenant identifiers.",
+                                               "description": "List of Microsoft 365 tenant identifiers with names.",
                                                "content": {
                                                        "application/json": {
                                                                "schema": {
                                                                        "type": "object",
                                                                        "properties": {
                                                                                "output": {
-                                                                                       "type": "array",
-                                                                                       "items": {
-                                                                                               "type": "string",
-                                                                                               "description": "Tenant identifier"
+                                                                                       "type": "object",
+                                                                                       "properties": {
+                                                                                               "tenant_id": {
+                                                                                                       "type": "object",
+                                                                                                       "properties": {
+                                                                                                               "tenant_name": {
+                                                                                                                       "type": "string",
+                                                                                                                       "description": "Tenant name"
+                                                                                                               }
+                                                                                                       }
+                                                                                               }
                                                                                        }
                                                                                },
                                                                                "error": {