using System; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Authorization; using Sockeye.Models; using Sockeye.Api.ControllerHelpers; using Sockeye.Biz; namespace Sockeye.Api.Controllers { /// /// Enum pick list controller /// [ApiController] [ApiVersion("8.0")] [Route("api/v{version:apiVersion}/authorization-roles")] [Produces("application/json")] [Authorize] public class AuthorizationRolesController : ControllerBase { private readonly AyContext ct; private readonly ILogger log; private readonly ApiServerState serverState; /// /// ctor /// /// /// /// public AuthorizationRolesController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) { ct = dbcontext; log = logger; serverState = apiServerState; } /// /// Get roles /// /// Return as compact JSON format /// Dictionary list of Sockeye object types and their authorization role rights in Sockeye [HttpGet("list")] public ActionResult GetRoles([FromQuery] bool AsJson = false) { if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); //as json for client end of things if (AsJson) return Ok(ApiOkResponse.Response(Newtonsoft.Json.JsonConvert.SerializeObject(BizRoles.roles, Newtonsoft.Json.Formatting.None))); else return Ok(ApiOkResponse.Response(BizRoles.roles)); } }//eoc }//ens