Add pagination support to Migrations client (#1949)

* Add pagination to *MigrationsClient

* Add unit tests for *MigrationsClient

* Add integration tests for *MigrationsClient

* Fix the broken tests
This commit is contained in:
Henrik Andersson
2019-02-24 21:48:55 +10:00
committed by Ryan Gribble
parent 153250fbcd
commit 33f75ed149
7 changed files with 157 additions and 11 deletions

View File

@@ -36,9 +36,22 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="org">The organization of which to list migrations.</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
IObservable<List<Migration>> GetAll(
IObservable<Migration> GetAll(
string org);
/// <summary>
/// Gets the list of the most recent migrations of the the organization.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/migration/migrations/#get-a-list-of-migrations
/// </remarks>
/// <param name="org">The organization of which to list migrations.</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
IObservable<Migration> GetAll(
string org,
ApiOptions options);
/// <summary>
/// Get the status of a migration.
/// </summary>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
@@ -15,6 +16,7 @@ namespace Octokit.Reactive
public class ObservableMigrationsClient : IObservableMigrationsClient
{
private readonly IMigrationsClient _client;
private readonly IConnection _connection;
/// <summary>
/// Instantiates a GitHub Migrations API client.
@@ -25,6 +27,7 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Migration.Migrations;
_connection = client.Connection;
}
/// <summary>
@@ -50,9 +53,16 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="org">The organization of which to list migrations.</param>
/// <returns>List of most recent <see cref="Migration"/>s.</returns>
public IObservable<List<Migration>> GetAll(string org)
public IObservable<Migration> GetAll(string org)
{
return _client.GetAll(org).ToObservable();
return GetAll(org, ApiOptions.None);
}
public IObservable<Migration> GetAll(string org, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<Migration>(ApiUrls.EnterpriseMigrations(org), null, AcceptHeaders.MigrationsApiPreview, options);
}
/// <summary>