mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
[FEAT]: Adds codespaces APIs
This commit is contained in:
20
Octokit.Reactive/IObservableCodespacesClient.cs
Normal file
20
Octokit.Reactive/IObservableCodespacesClient.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Codespaces API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the codespaces API documentation for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableCodespacesClient
|
||||
{
|
||||
IObservable<CodespacesCollection> GetAll();
|
||||
IObservable<CodespacesCollection> GetForRepository(string owner, string repo);
|
||||
IObservable<Codespace> Get(string codespaceName);
|
||||
IObservable<Codespace> Start(string codespaceName);
|
||||
IObservable<Codespace> Stop(string codespaceName);
|
||||
}
|
||||
}
|
||||
@@ -42,5 +42,6 @@ namespace Octokit.Reactive
|
||||
IObservableRateLimitClient RateLimit { get; }
|
||||
IObservableMetaClient Meta { get; }
|
||||
IObservableActionsClient Actions { get; }
|
||||
IObservableCodespacesClient Codespaces { get; }
|
||||
}
|
||||
}
|
||||
|
||||
47
Octokit.Reactive/ObservableCodespacesClient.cs
Normal file
47
Octokit.Reactive/ObservableCodespacesClient.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableCodespacesClient : IObservableCodespacesClient
|
||||
{
|
||||
private ICodespacesClient _client;
|
||||
private IConnection _connection;
|
||||
|
||||
public ObservableCodespacesClient(IGitHubClient githubClient)
|
||||
{
|
||||
_client = githubClient.Codespaces;
|
||||
_connection = githubClient.Connection;
|
||||
}
|
||||
|
||||
public IObservable<Codespace> Get(string codespaceName)
|
||||
{
|
||||
Ensure.ArgumentNotNull(codespaceName, nameof(codespaceName));
|
||||
return _client.Get(codespaceName).ToObservable();
|
||||
}
|
||||
|
||||
public IObservable<CodespacesCollection> GetAll()
|
||||
{
|
||||
return _client.GetAll().ToObservable();
|
||||
}
|
||||
|
||||
public IObservable<CodespacesCollection> GetForRepository(string owner, string repo)
|
||||
{
|
||||
Ensure.ArgumentNotNull(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNull(repo, nameof(repo));
|
||||
return _client.GetForRepository(owner, repo).ToObservable();
|
||||
}
|
||||
|
||||
public IObservable<Codespace> Start(string codespaceName)
|
||||
{
|
||||
Ensure.ArgumentNotNull(codespaceName, nameof(codespaceName));
|
||||
return _client.Start(codespaceName).ToObservable();
|
||||
}
|
||||
|
||||
public IObservable<Codespace> Stop(string codespaceName)
|
||||
{
|
||||
Ensure.ArgumentNotNull(codespaceName, nameof(codespaceName));
|
||||
return _client.Stop(codespaceName).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ namespace Octokit.Reactive
|
||||
RateLimit = new ObservableRateLimitClient(gitHubClient);
|
||||
Meta = new ObservableMetaClient(gitHubClient);
|
||||
Actions = new ObservableActionsClient(gitHubClient);
|
||||
Codespaces = new ObservableCodespacesClient(gitHubClient);
|
||||
}
|
||||
|
||||
public IConnection Connection
|
||||
@@ -105,6 +106,7 @@ namespace Octokit.Reactive
|
||||
public IObservableMetaClient Meta { get; private set; }
|
||||
public IObservableActionsClient Actions { get; private set; }
|
||||
|
||||
public IObservableCodespacesClient Codespaces { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets the latest API Info - this will be null if no API calls have been made
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user