mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-28 08:58:37 +00:00
Add IObservable + impl
This commit is contained in:
@@ -347,5 +347,12 @@ namespace Octokit.Reactive
|
||||
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository Deploy Keys API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryDeployKeysClient DeployKeys { get; }
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Pages API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/">Repository Pages API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryPagesClient Page { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableRepositoryPagesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the page metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
|
||||
IObservable<Page> Get(string owner, string repositoryName);
|
||||
/// <summary>
|
||||
/// Gets all build metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
IObservable<PagesBuild> GetBuilds(string owner, string repositoryName);
|
||||
/// <summary>
|
||||
/// Gets the build metadata for the last build for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
IObservable<PagesBuild> GetLatestBuild(string owner, string repositoryName);
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ namespace Octokit.Reactive
|
||||
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
|
||||
Content = new ObservableRepositoryContentsClient(client);
|
||||
Merging = new ObservableMergingClient(client);
|
||||
Page = new ObservableRepositoryPagesClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -493,5 +494,12 @@ namespace Octokit.Reactive
|
||||
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository Deploy Keys API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryDeployKeysClient DeployKeys { get; private set; }
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Pages API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/">Repository Pages API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryPagesClient Page { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using Octokit.Reactive.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableRepositoryPagesClient : IObservableRepositoryPagesClient
|
||||
{
|
||||
readonly IRepositoryPagesClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableRepositoryPagesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.Page;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
public IObservable<Page> Get(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _client.Get(owner, repositoryName).ToObservable();
|
||||
}
|
||||
|
||||
public IObservable<PagesBuild> GetBuilds(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName));
|
||||
}
|
||||
|
||||
public IObservable<PagesBuild> GetLatestBuild(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _client.GetLatestBuild(owner, repositoryName).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,7 @@
|
||||
<Compile Include="Clients\IObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
@@ -102,6 +103,7 @@
|
||||
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\ObservableSearchClient.cs" />
|
||||
<Compile Include="Clients\IObservableBlobsClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistCommentsClient.cs" />
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return ApiConnection.GetAll<PagesBuild>(ApiUrls.RepositoryBuilds(owner, repositoryName));
|
||||
return ApiConnection.GetAll<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +71,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return ApiConnection.Get<PagesBuild>(ApiUrls.RepositoryBuildsLatest(owner, repositoryName));
|
||||
return ApiConnection.Get<PagesBuild>(ApiUrls.RepositoryPageBuildsLatest(owner, repositoryName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1560,12 +1560,12 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/pages".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
public static Uri RepositoryBuilds(string owner, string name)
|
||||
public static Uri RepositoryPageBuilds(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/pages/builds".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
public static Uri RepositoryBuildsLatest(string owner, string name)
|
||||
public static Uri RepositoryPageBuildsLatest(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/pages/builds/latest".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user