diff --git a/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/ProfilingControllerBase.cs b/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/ProfilingControllerBase.cs new file mode 100644 index 0000000000..ebcae8fcf4 --- /dev/null +++ b/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/ProfilingControllerBase.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc; +using NSwag.Annotations; +using Umbraco.New.Cms.Web.Common.Routing; + +namespace Umbraco.Cms.ManagementApi.Controllers.Profiling; + +[ApiVersion("1.0")] +[ApiController] +[BackOfficeRoute("api/v{version:apiVersion}/profiling")] +[OpenApiTag("Profiling")] +public class ProfilingControllerBase : ManagementApiControllerBase +{ +} diff --git a/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/StatusProfilingController.cs b/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/StatusProfilingController.cs new file mode 100644 index 0000000000..e3c2c3bfd2 --- /dev/null +++ b/src/Umbraco.Cms.ManagementApi/Controllers/Profiling/StatusProfilingController.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Cms.Core.Hosting; +using Umbraco.Cms.ManagementApi.ViewModels.Profiling; + +namespace Umbraco.Cms.ManagementApi.Controllers.Profiling; + +public class StatusProfilingController : ProfilingControllerBase +{ + private readonly IHostingEnvironment _hosting; + + public StatusProfilingController(IHostingEnvironment hosting) => _hosting = hosting; + + [HttpGet("status")] + [MapToApiVersion("1.0")] + [ProducesResponseType(typeof(ProfilingStatusViewModel), StatusCodes.Status200OK)] + public async Task> Status() + => await Task.FromResult(Ok(new ProfilingStatusViewModel(_hosting.IsDebugMode))); +} diff --git a/src/Umbraco.Cms.ManagementApi/OpenApi.json b/src/Umbraco.Cms.ManagementApi/OpenApi.json index 47bc9e0fbb..9c5c335cb3 100644 --- a/src/Umbraco.Cms.ManagementApi/OpenApi.json +++ b/src/Umbraco.Cms.ManagementApi/OpenApi.json @@ -253,6 +253,26 @@ } } } + }, + "/umbraco/api/v1/profiling/status": { + "get": { + "tags": [ + "Profiling" + ], + "operationId": "StatusProfiling_Status", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProfilingStatusViewModel" + } + } + } + } + } + } } }, "components": { @@ -535,6 +555,15 @@ "type": "string" } } + }, + "ProfilingStatusViewModel": { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean" + } + } } } }, @@ -545,6 +574,9 @@ { "name": "Server" }, + { + "name": "Profiling" + }, { "name": "Install" } diff --git a/src/Umbraco.Cms.ManagementApi/ViewModels/Profiling/ProfilingStatusViewModel.cs b/src/Umbraco.Cms.ManagementApi/ViewModels/Profiling/ProfilingStatusViewModel.cs new file mode 100644 index 0000000000..d165a613a4 --- /dev/null +++ b/src/Umbraco.Cms.ManagementApi/ViewModels/Profiling/ProfilingStatusViewModel.cs @@ -0,0 +1,8 @@ +namespace Umbraco.Cms.ManagementApi.ViewModels.Profiling; + +public class ProfilingStatusViewModel +{ + public ProfilingStatusViewModel(bool enabled) => Enabled = enabled; + + public bool Enabled { get; } +}