Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations API support #1141

Merged
merged 34 commits into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0832c2a
Added Migrations API models for requests and responses.
devkhan Mar 11, 2016
665b70c
Added Migrations Client interface.
devkhan Mar 11, 2016
ce25b17
Implemented MigrationsClient. Added URLs to ApiUrls.
devkhan Mar 11, 2016
35b07c5
Tried first unit tests. Testing models.
devkhan Mar 11, 2016
acc1ed0
Check for empty string also in Migrations Client
devkhan Mar 14, 2016
e64084a
Add unit tests for EnterpriseMigrationsClient
devkhan Mar 14, 2016
8b0f5bf
Implemented Reactive Clients.
devkhan Mar 14, 2016
2fb2a73
Fix: Removed async void methods as NoTestsUseAsyncVoid() was failing.
devkhan Mar 14, 2016
04b807b
Added Reactive tests to Migrations API. Passing. :confetti_ball:
devkhan Mar 15, 2016
b867f45
:memo:ed Client and its interface.
devkhan Mar 17, 2016
31850a2
Models :memo:ed.
devkhan Mar 17, 2016
a8cfe84
:memo:ed Reactive Clients.
devkhan Mar 17, 2016
36a64d6
Fix: Default ctor added so CanBeDesrialized tests passes.
devkhan Mar 17, 2016
7634a4d
Re-ordered methods to follow API docs.
devkhan Mar 17, 2016
005a2a8
Refactor: Change method names to follow Octokit's conventions.
devkhan Mar 17, 2016
73d321d
Refactor: Pull out Migrations client from Enterprise.
devkhan Mar 22, 2016
8aeb987
Fix: Added DebuggerDisplay attribute.
devkhan Mar 22, 2016
b1b8206
Add accept header for Migrations API preview.
devkhan Mar 28, 2016
c4ca802
Indent JSON string in MigrationTests
devkhan Mar 28, 2016
0b0e264
Add integration tests for Migrations API.
devkhan Mar 28, 2016
53bb22b
Migrations API: Added deletion integration tests.
devkhan Mar 28, 2016
dce2be2
"FixProjects" for Migrations API.
devkhan Mar 30, 2016
e5e5261
Refactoring for consistency.
devkhan Apr 6, 2016
f74a946
Reflect changes made to clients in tests.
devkhan Apr 7, 2016
293ac97
Empty object passed to avoid ArgumentNullException.
devkhan Apr 7, 2016
5722754
Change "state" from string to enum in Migration Response.
devkhan Apr 7, 2016
5c2da84
MigrationsClientTests implements IDisposable.
devkhan Apr 7, 2016
55b8c79
Re-implemented integration tests using world-making approach.
devkhan Apr 13, 2016
23a59f1
Add preview header to DELETE methods tests.
devkhan Apr 13, 2016
4b0b74e
Fix: Models were removed from csproj files on rebase.
devkhan Apr 19, 2016
822a757
Remove files from projects after FixProjects.
devkhan Apr 19, 2016
798fe1f
Update `GetArchive()` to return a byte array. All tests passing. :+1:
devkhan Apr 19, 2016
fe4108f
Add Ctor classes to tests.
devkhan Apr 19, 2016
05bdbab
Minor touch-up.
devkhan Apr 22, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Octokit.Reactive/Clients/IObservableMigrationClient.cs
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; }
}
}
97 changes: 97 additions & 0 deletions Octokit.Reactive/Clients/IObservableMigrationsClient.cs
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);
}
}
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/ObservableMigrationClient.cs
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; }
}
}
115 changes: 115 additions & 0 deletions Octokit.Reactive/Clients/ObservableMigrationsClient.cs
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();
}
}
}
1 change: 1 addition & 0 deletions Octokit.Reactive/IObservableGitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ public interface IObservableGitHubClient : IApiInfoProvider
IObservableGitDatabaseClient GitDatabase { get; }
IObservableSearchClient Search { get; }
IObservableEnterpriseClient Enterprise { get; }
IObservableMigrationClient Migration { get; }
}
}
2 changes: 2 additions & 0 deletions Octokit.Reactive/ObservableGitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient)
Gist = new ObservableGistsClient(gitHubClient);
Search = new ObservableSearchClient(gitHubClient);
Enterprise = new ObservableEnterpriseClient(gitHubClient);
Migration = new ObservableMigrationClient(gitHubClient);
}

public IConnection Connection
Expand All @@ -72,6 +73,7 @@ public IConnection Connection
public IObservableGitDatabaseClient Git { get; private set; }
public IObservableSearchClient Search { get; private set; }
public IObservableEnterpriseClient Enterprise { get; private set; }
public IObservableMigrationClient Migration { get; private set; }

/// <summary>
/// Gets the latest API Info - this will be null if no API calls have been made
Expand Down
4 changes: 4 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableMigrationClient.cs" />
<Compile Include="Clients\IObservableMigrationsClient.cs" />
<Compile Include="Clients\ObservableMigrationClient.cs" />
<Compile Include="Clients\ObservableMigrationsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableMigrationClient.cs" />
<Compile Include="Clients\IObservableMigrationsClient.cs" />
<Compile Include="Clients\ObservableMigrationClient.cs" />
<Compile Include="Clients\ObservableMigrationsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableMigrationClient.cs" />
<Compile Include="Clients\IObservableMigrationsClient.cs" />
<Compile Include="Clients\ObservableMigrationClient.cs" />
<Compile Include="Clients\ObservableMigrationsClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions Octokit.Reactive/Octokit.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\IObservableMigrationsClient.cs" />
<Compile Include="Clients\IObservableMergingClient.cs" />
<Compile Include="Clients\IObservableMigrationClient.cs" />
<Compile Include="Clients\IObservableOauthClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
<Compile Include="Clients\IObservableUserKeysClient.cs" />
<Compile Include="Clients\ObservableMigrationsClient.cs" />
<Compile Include="Clients\ObservableMergingClient.cs" />
<Compile Include="Clients\ObservableMigrationClient.cs" />
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\ObservableOauthClient.cs" />
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
Expand Down
Loading