-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1141 from devkhan/migrations-client
Migrations API support
- Loading branch information
Showing
32 changed files
with
1,447 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Octokit.Reactive | ||
{ | ||
public interface IObservableMigrationClient | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Migrations API | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/migration/migrations/">Enterprise License API documentation</a> for more information. | ||
/// </remarks> | ||
IObservableMigrationsClient Migrations { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// An interface for GitHub's Migrations API client. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/migration/migrations/">docs</a> | ||
/// for more information. | ||
/// </remarks> | ||
public interface IObservableMigrationsClient | ||
{ | ||
/// <summary> | ||
/// Starts a new migration specified for the given organization. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#start-a-migration | ||
/// </remarks> | ||
/// <param name="org">The organization for which to start a migration.</param> | ||
/// <param name="migration">Sprcifies parameters for the migration in a | ||
/// <see cref="StartMigrationRequest"/> object.</param> | ||
/// <returns>The started migration.</returns> | ||
IObservable<Migration> Start( | ||
string org, | ||
StartMigrationRequest migration); | ||
|
||
/// <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> | ||
/// <returns>List of most recent <see cref="Migration"/>s.</returns> | ||
IObservable<List<Migration>> GetAll( | ||
string org); | ||
|
||
/// <summary> | ||
/// Get the status of a migration. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#get-the-status-of-a-migration | ||
/// </remarks> | ||
/// <param name="org">The organization which is migrating.</param> | ||
/// <param name="id">Migration ID of the organization.</param> | ||
/// <returns>A <see cref="Migration"/> object representing the state of migration.</returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] | ||
IObservable<Migration> Get( | ||
string org, | ||
int id); | ||
|
||
/// <summary> | ||
/// Get the migration archive. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <returns>The binary contents of the archive as a byte array.</returns> | ||
IObservable<byte[]> GetArchive( | ||
string org, | ||
int id); | ||
|
||
/// <summary> | ||
/// Deletes a previous migration archive. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#delete-a-migration-archive | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <returns></returns> | ||
IObservable<Unit> DeleteArchive( | ||
string org, | ||
int id); | ||
|
||
/// <summary> | ||
/// Unlocks a repository that was locked for migration. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#unlock-a-repository | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <param name="repo">The repo to unlock.</param> | ||
/// <returns></returns> | ||
IObservable<Unit> UnlockRepository( | ||
string org, | ||
int id, | ||
string repo); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Octokit.Reactive | ||
{ | ||
public class ObservableMigrationClient : IObservableMigrationClient | ||
{ | ||
public ObservableMigrationClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
Migrations = new ObservableMigrationsClient(client); | ||
} | ||
|
||
/// <summary> | ||
/// A client for GitHub's Enterprise Migrations API. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/#enterprise-migrations | ||
/// </remarks> | ||
public IObservableMigrationsClient Migrations { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
/// <summary> | ||
/// An interface for GitHub's Migrations API client. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/migration/migrations/">docs</a> | ||
/// for more information. | ||
/// </remarks> | ||
public class ObservableMigrationsClient : IObservableMigrationsClient | ||
{ | ||
private readonly IMigrationsClient _client; | ||
|
||
/// <summary> | ||
/// Instantiates a GitHub Migrations API client. | ||
/// </summary> | ||
/// <param name="client">An <see cref="IGitHubClient"/> for making requests.</param> | ||
public ObservableMigrationsClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
_client = client.Migration.Migrations; | ||
} | ||
|
||
/// <summary> | ||
/// Starts a new migration specified for the given organization. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#start-a-migration | ||
/// </remarks> | ||
/// <param name="org">The organization for which to start a migration.</param> | ||
/// <param name="migration">Sprcifies parameters for the migration in a | ||
/// <see cref="StartMigrationRequest"/> object.</param> | ||
/// <returns>The started migration.</returns> | ||
public IObservable<Migration> Start(string org, StartMigrationRequest migration) | ||
{ | ||
return _client.Start(org, migration).ToObservable(); | ||
} | ||
|
||
/// <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> | ||
/// <returns>List of most recent <see cref="Migration"/>s.</returns> | ||
public IObservable<List<Migration>> GetAll(string org) | ||
{ | ||
return _client.GetAll(org).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Get the status of a migration | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#get-the-status-of-a-migration | ||
/// </remarks> | ||
/// <param name="org">The organization which is migrating.</param> | ||
/// <param name="id">Migrations ID of the organization.</param> | ||
/// <returns>A <see cref="Migration"/> object representing the state of migration.</returns> | ||
public IObservable<Migration> Get(string org, int id) | ||
{ | ||
return _client.Get(org, id).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Get the migration archive. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#download-a-migration-archive | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <returns>The binary contents of the archive as a byte array.</returns> | ||
public IObservable<byte[]> GetArchive(string org, int id) | ||
{ | ||
return _client.GetArchive(org, id).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes a previous migration archive. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#delete-a-migration-archive | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <returns></returns> | ||
public IObservable<Unit> DeleteArchive(string org, int id) | ||
{ | ||
return _client.DeleteArchive(org, id).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Unlocks a repository that was locked for migration. | ||
/// </summary> | ||
/// <remarks> | ||
/// https://developer.github.com/v3/migration/migrations/#unlock-a-repository | ||
/// </remarks> | ||
/// <param name="org">The organization of which the migration was.</param> | ||
/// <param name="id">The ID of the migration.</param> | ||
/// <param name="repo">The repo to unlock.</param> | ||
/// <returns></returns> | ||
public IObservable<Unit> UnlockRepository(string org, int id, string repo) | ||
{ | ||
return _client.UnlockRepository(org, id, repo).ToObservable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.