Files
xRPKRMAApi/Controllers/AzureController.cs
T
2026-11-19 18:08:53 +03:30

138 lines
3.9 KiB
C#

using xApi.Interfaces;
using Microsoft.AspNetCore.Mvc;
using xApi.Models;
namespace xApi.Controllers
{
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class AzureController : ControllerBase
{
//
private readonly IAzureServices azureServices;
private readonly ILogger<AzureController> logger;
public AzureController(
IAzureServices azureServices,
ILogger<AzureController> logger
)
{
//
this.logger = logger;
this.azureServices = azureServices;
}
/// <summary>
/// Get Connection data from Azure Services ...
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("ConnectionData")]
public async Task<ActionResult<AzureConnectionDataDto>> GetConnectionData(
CancellationToken cancellationToken = default
)
{
//
try
{
//
var response = await azureServices
.GetConnectionDataAsync(cancellationToken);
//
return Ok(response);
}
catch (Exception ex)
{
//
logger.LogError(ex, "Error occurred ...");
return StatusCode(500, "Internal server error");
}
}
/// <summary>
/// Get Projects from Azure Services ...
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("GetProjects")]
public async Task<ActionResult<AzureListDto<AzureProjectDto>>> GetProjects(
CancellationToken cancellationToken = default
)
{
//
try
{
//
var response = await azureServices
.GetProjectsAsync(cancellationToken);
//
return Ok(response);
}
catch (Exception ex)
{
//
logger.LogError(ex, "Error occurred ...");
return StatusCode(500, "Internal server error");
}
}
/// <summary>
/// Get Repositories from Azure Services ...
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("GetRepositories")]
public async Task<ActionResult<AzureListDto<AzureRepositoryDto>>> GetRepositories(
CancellationToken cancellationToken = default
)
{
//
try
{
//
var response = await azureServices
.GetRepositoriesAsync(cancellationToken);
//
return Ok(response);
}
catch (Exception ex)
{
//
logger.LogError(ex, "Error occurred ...");
return StatusCode(500, "Internal server error");
}
}
/// <summary>
/// Get WorkItem Types from Azure Services ...
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("GetWorkItemTypes")]
public async Task<ActionResult<string>> GetWorkItemTypes(
CancellationToken cancellationToken = default
)
{
//
try
{
//
var response = await azureServices
.GetWorkItemTypesAsync(cancellationToken);
//
return Ok(response);
}
catch (Exception ex)
{
//
logger.LogError(ex, "Error occurred ...");
return StatusCode(500, "Internal server error");
}
}
}
}