Skip to content

Commit

Permalink
Splitting out the misc client into separate clients as per current do…
Browse files Browse the repository at this point in the history
…cumentation (#2574)
  • Loading branch information
JonruAlveus authored Sep 20, 2022
1 parent 05aa951 commit 3c05db4
Show file tree
Hide file tree
Showing 49 changed files with 1,729 additions and 30 deletions.
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/IObservableEmojiClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Emojis APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details.
/// </remarks>
public interface IObservableEmojisClient
{
/// <summary>
/// Gets all the emojis available to use on GitHub.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns>
IObservable<Emoji> GetAllEmojis();
}
}
25 changes: 25 additions & 0 deletions Octokit.Reactive/Clients/IObservableGitIgnoreClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's gitignore APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details.
/// </remarks>
public interface IObservableGitIgnoreClient
{
/// <summary>
/// List all templates available to pass as an option when creating a repository.
/// </summary>
/// <returns>An observable list of gitignore template names.</returns>
IObservable<string> GetAllGitIgnoreTemplates();

/// <summary>
/// Retrieves the source for a single GitIgnore template
/// </summary>
/// <param name="templateName">Returns the template source for the given template</param>
IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName);
}
}
35 changes: 35 additions & 0 deletions Octokit.Reactive/Clients/IObservableLicensesClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's licenses APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details.
/// </remarks>
public interface IObservableLicensesClient
{
/// <summary>
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
/// </summary>
/// <returns>A list of licenses available on the site</returns>
IObservable<LicenseMetadata> GetAllLicenses();

/// <summary>
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
/// </summary>
/// <param name="options">Options for changing the API response</param>
/// <returns>A list of licenses available on the site</returns>
IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options);

/// <summary>
/// Retrieves a license based on the license key such as "MIT"
/// </summary>
/// <param name="key"></param>
/// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns>
IObservable<License> GetLicense(string key);
}
}
29 changes: 29 additions & 0 deletions Octokit.Reactive/Clients/IObservableMarkdownClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's markdown APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/markdown">Markdown API documentation</a> for more details.
/// </remarks>
public interface IObservableMarkdownClient
{
/// <summary>
/// Gets the rendered Markdown for an arbitrary markdown document.
/// </summary>
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown);

/// <summary>
/// Gets the rendered Markdown for the specified plain-text Markdown document.
/// </summary>
/// <param name="markdown">A plain-text Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
IObservable<string> RenderRawMarkdown(string markdown);
}
}
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/IObservableMetaClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's meta APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/meta">Meta API documentation</a> for more details.
/// </remarks>
public interface IObservableMetaClient
{
/// <summary>
/// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns>
IObservable<Meta> GetMetadata();
}
}
18 changes: 11 additions & 7 deletions Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Octokit.Reactive
{
[Obsolete("Use individual clients for these methods")]
public interface IObservableMiscellaneousClient
{
/// <summary>
/// Gets all the emojis available to use on GitHub.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Makes a network request")]
[Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")]
IObservable<Emoji> GetAllEmojis();

/// <summary>
Expand All @@ -20,6 +19,7 @@ public interface IObservableMiscellaneousClient
/// <param name="markdown">An arbitrary Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
[Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderArbitraryMarkdown instead.")]
IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown);

/// <summary>
Expand All @@ -28,27 +28,29 @@ public interface IObservableMiscellaneousClient
/// <param name="markdown">A plain-text Markdown document</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The rendered Markdown.</returns>
[Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderRawMarkdown instead.")]
IObservable<string> RenderRawMarkdown(string markdown);

/// <summary>
/// List all templates available to pass as an option when creating a repository.
/// </summary>
/// <returns>An observable list of gitignore template names.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")]
IObservable<string> GetAllGitIgnoreTemplates();

/// <summary>
/// Retrieves the source for a single GitIgnore template
/// </summary>
/// <param name="templateName">Returns the template source for the given template</param>
[Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetGitIgnoreTemplate instead.")]
IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName);

/// <summary>
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
/// </summary>
/// <returns>A list of licenses available on the site</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")]
IObservable<LicenseMetadata> GetAllLicenses();

/// <summary>
Expand All @@ -57,29 +59,31 @@ public interface IObservableMiscellaneousClient
/// </summary>
/// <param name="options">Options for changing the API response</param>
/// <returns>A list of licenses available on the site</returns>
[Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")]
IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options);

/// <summary>
/// Retrieves a license based on the license key such as "MIT"
/// </summary>
/// <param name="key"></param>
/// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns>
[Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetLicense instead.")]
IObservable<License> GetLicense(string key);

/// <summary>
/// Gets API Rate Limits (API service rather than header info).
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[Obsolete("This client is being deprecated and will be removed in the future. Use RateLimitClient.GetRateLimits instead.")]
IObservable<MiscellaneousRateLimit> GetRateLimits();

/// <summary>
/// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[Obsolete("This client is being deprecated and will be removed in the future. Use MetaClient.GetMetadata instead.")]
IObservable<Meta> GetMetadata();
}
}
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/IObservableRateLimitClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's rate-limit APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/rate-limit">Rate-Limit API documentation</a> for more details.
/// </remarks>
public interface IObservableRateLimitClient
{
/// <summary>
/// Gets API Rate Limits (API service rather than header info).
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns>
IObservable<MiscellaneousRateLimit> GetRateLimits();
}
}
34 changes: 34 additions & 0 deletions Octokit.Reactive/Clients/ObservableEmojiClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Emojis APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details.
/// </remarks>
public class ObservableEmojisClient : IObservableEmojisClient
{
private readonly IEmojisClient _client;

public ObservableEmojisClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));

_client = client.Emojis;
}

/// <summary>
/// Gets all the emojis available to use on GitHub.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns>
public IObservable<Emoji> GetAllEmojis()
{
return _client.GetAllEmojis().ToObservable().SelectMany(e => e);
}
}
}
42 changes: 42 additions & 0 deletions Octokit.Reactive/Clients/ObservableGitIgnoreClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's gitignore APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details.
/// </remarks>
public class ObservableGitIgnoreClient : IObservableGitIgnoreClient
{
private readonly IGitIgnoreClient _client;

public ObservableGitIgnoreClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));

_client = client.GitIgnore;
}

/// <summary>
/// List all templates available to pass as an option when creating a repository.
/// </summary>
/// <returns>An observable list of gitignore template names.</returns>
public IObservable<string> GetAllGitIgnoreTemplates()
{
return _client.GetAllGitIgnoreTemplates().ToObservable().SelectMany(t => t);
}

/// <summary>
/// Retrieves the source for a single GitIgnore template
/// </summary>
/// <param name="templateName">Returns the template source for the given template</param>
public IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName)
{
return _client.GetGitIgnoreTemplate(templateName).ToObservable();
}
}
}
55 changes: 55 additions & 0 deletions Octokit.Reactive/Clients/ObservableLicensesClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's licenses APIs.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details.
/// </remarks>
public class ObservableLicensesClient : IObservableLicensesClient
{
private readonly ILicensesClient _client;

public ObservableLicensesClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));

_client = client.Licenses;
}

/// <summary>
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
/// </summary>
/// <returns>A list of licenses available on the site</returns>
public IObservable<LicenseMetadata> GetAllLicenses()
{
return GetAllLicenses(ApiOptions.None);
}

/// <summary>
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
/// </summary>
/// <param name="options">Options for changing the API response</param>
/// <returns>A list of licenses available on the site</returns>
public IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options)
{
return _client.GetAllLicenses(options).ToObservable().SelectMany(l => l);
}

/// <summary>
/// Retrieves a license based on the license key such as "MIT"
/// </summary>
/// <param name="key"></param>
/// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns>
public IObservable<License> GetLicense(string key)
{
return _client.GetLicense(key).ToObservable();
}
}
}
Loading

0 comments on commit 3c05db4

Please sign in to comment.