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

Implement GitHub Enterprise License and Organization API's #1073

Merged
merged 11 commits into from
Feb 11, 2016
Merged
16 changes: 16 additions & 0 deletions Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@ public interface IObservableEnterpriseClient
/// See the <a href="http://developer.github.com/v3/enterprise/admin_stats/">Enterprise Admin Stats API documentation</a> for more information.
///</remarks>
IObservableEnterpriseAdminStatsClient AdminStats { get; }

/// <summary>
/// A client for GitHub's Enterprise License API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
///</remarks>
IObservableEnterpriseLicenseClient License { get; }

/// <summary>
/// A client for GitHub's Enterprise Organization API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
///</remarks>
IObservableEnterpriseOrganizationClient Organization { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Threading.Tasks;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise License API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
///</remarks>
public interface IObservableEnterpriseLicenseClient
{
/// <summary>
/// Gets GitHub Enterprise License Information (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/license/#get-license-information
/// </remarks>
/// <returns>The <see cref="LicenseInfo"/> statistics.</returns>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
IObservable<LicenseInfo> Get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Threading.Tasks;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise Organization API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
///</remarks>
public interface IObservableEnterpriseOrganizationClient
{
/// <summary>
/// Creates an Organization on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/orgs/#create-an-organization
/// </remarks>
/// <param name="newOrganization">A <see cref="NewOrganization"/> instance describing the organization to be created</param>
/// <returns>The <see cref="Organization"/> created.</returns>
IObservable<Organization> Create(NewOrganization newOrganization);
}
}
18 changes: 18 additions & 0 deletions Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public ObservableEnterpriseClient(IGitHubClient client)
Ensure.ArgumentNotNull(client, "client");

AdminStats = new ObservableEnterpriseAdminStatsClient(client);
License = new ObservableEnterpriseLicenseClient(client);
Organization = new ObservableEnterpriseOrganizationClient(client);
}

/// <summary>
Expand All @@ -22,5 +24,21 @@ public ObservableEnterpriseClient(IGitHubClient client)
/// See the <a href="http://developer.github.com/v3/enterprise/admin_stats/">Enterprise Admin Stats API documentation</a> for more information.
///</remarks>
public IObservableEnterpriseAdminStatsClient AdminStats { get; private set; }

/// <summary>
/// A client for GitHub's Enterprise License API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
///</remarks>
public IObservableEnterpriseLicenseClient License { get; private set; }

/// <summary>
/// A client for GitHub's Enterprise Organization API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
///</remarks>
public IObservableEnterpriseOrganizationClient Organization { get; private set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Reactive.Threading.Tasks;
using Octokit;


namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise License API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/license/">Enterprise License API documentation</a> for more information.
///</remarks>
public class ObservableEnterpriseLicenseClient : IObservableEnterpriseLicenseClient
{
readonly IEnterpriseLicenseClient _client;

public ObservableEnterpriseLicenseClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");

_client = client.Enterprise.License;
}

/// <summary>
/// Gets GitHub Enterprise License Information (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/license/#get-license-information
/// </remarks>
/// <returns>The <see cref="LicenseInfo"/> statistics.</returns>
public IObservable<LicenseInfo> Get()
{
return _client.Get().ToObservable();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Reactive.Threading.Tasks;
using Octokit;


namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise Organization API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/orgs/">Enterprise Organization API documentation</a> for more information.
///</remarks>
public class ObservableEnterpriseOrganizationClient : IObservableEnterpriseOrganizationClient
{
readonly IEnterpriseOrganizationClient _client;

public ObservableEnterpriseOrganizationClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");

_client = client.Enterprise.Organization;
}

/// <summary>
/// Creates an Organization on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/orgs/#create-an-organization
/// </remarks>
/// <param name="newOrganization">A <see cref="NewOrganization"/> instance describing the organization to be created</param>
/// <returns>The <see cref="Organization"/> created.</returns>
public IObservable<Organization> Create(NewOrganization newOrganization)
{
return _client.Create(newOrganization).ToObservable();
}
}
}
4 changes: 4 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
<Compile Include="Clients\ObservableUserAdministrationClient.cs" />
</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 @@ -171,6 +171,10 @@
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
<Compile Include="Clients\ObservableUserAdministrationClient.cs" />
</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 @@ -167,6 +167,10 @@
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
<Compile Include="Clients\ObservableUserAdministrationClient.cs" />
</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 @@ -75,10 +75,14 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLicenseClient.cs" />
<Compile Include="Clients\IObservableMergingClient.cs" />
<Compile Include="Clients\IObservableOauthClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class EnterpriseAdminStatsClientTests

public EnterpriseAdminStatsClientTests()
{
_github = Helper.GetAuthenticatedClient();
_github = EnterpriseHelper.GetAuthenticatedClient();
}

[GitHubEnterpriseTest]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Xunit;

public class EnterpriseLicenseClientTests
{
readonly IGitHubClient _github;

public EnterpriseLicenseClientTests()
{
_github = EnterpriseHelper.GetAuthenticatedClient();
}

[GitHubEnterpriseTest]
public async Task CanGetLicense()
{
var licenseInfo = await
_github.Enterprise.License.Get();

Assert.NotNull(licenseInfo);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Xunit;

public class EnterpriseOrganizationClientTests
{
readonly IGitHubClient _github;

public EnterpriseOrganizationClientTests()
{
_github = EnterpriseHelper.GetAuthenticatedClient();
}

[GitHubEnterpriseTest]
public async Task CanCreateOrganization()
{
string orgLogin = Helper.MakeNameWithTimestamp("MyOrganization");
string orgName = String.Concat(orgLogin, " Display Name");

var newOrganization = new NewOrganization(orgLogin, EnterpriseHelper.UserName, orgName);
var organization = await
_github.Enterprise.Organization.Create(newOrganization);

Assert.NotNull(organization);

// Get organization and check login/name
var checkOrg = await _github.Organization.Get(orgLogin);
Assert.Equal(checkOrg.Login, orgLogin);
Assert.Equal(checkOrg.Name, orgName);
}
}
Loading