feat: добавить поддержку GitLab (api, clients, tools) и обновить документацию
This commit is contained in:
75
LazyBear.MCP/Services/GitLab/GitLabApiClient.cs
Normal file
75
LazyBear.MCP/Services/GitLab/GitLabApiClient.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using RestSharp;
|
||||
|
||||
namespace LazyBear.MCP.Services.GitLab;
|
||||
|
||||
/// <summary>
|
||||
/// Обертка над RestSharp RestClient для GitLab API
|
||||
/// </summary>
|
||||
public sealed class GitLabApiClient : IDisposable
|
||||
{
|
||||
public RestClient RestClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="url">URL GitLab</param>
|
||||
public GitLabApiClient(string url)
|
||||
{
|
||||
_restClient = new RestClient(url);
|
||||
}
|
||||
|
||||
private readonly RestClient _restClient;
|
||||
|
||||
/// <summary>
|
||||
/// Создание запроса GET
|
||||
/// </summary>
|
||||
public RestRequest GetRequest(string resource)
|
||||
{
|
||||
var request = new RestRequest(resource, Method.Get);
|
||||
return request;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание запроса POST
|
||||
/// </summary>
|
||||
public RestRequest PostRequest(string resource)
|
||||
{
|
||||
var request = new RestRequest(resource, Method.Post);
|
||||
return request;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание запроса PUT
|
||||
/// </summary>
|
||||
public RestRequest PutRequest(string resource)
|
||||
{
|
||||
var request = new RestRequest(resource, Method.Put);
|
||||
return request;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание запроса DELETE
|
||||
/// </summary>
|
||||
public RestRequest DeleteRequest(string resource)
|
||||
{
|
||||
var request = new RestRequest(resource, Method.Delete);
|
||||
return request;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выполнение запроса
|
||||
/// </summary>
|
||||
public async System.Threading.Tasks.Task<RestResponse> ExecuteAsync(RestRequest request, System.Threading.CancellationToken? cancellationToken = null)
|
||||
{
|
||||
if (cancellationToken.HasValue)
|
||||
{
|
||||
return await _restClient.ExecuteAsync(request, cancellationToken.Value);
|
||||
}
|
||||
return await _restClient.ExecuteAsync(request);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_restClient.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user