-
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 #1073 from TattsGroup/enterprise-api
Implement GitHub Enterprise License and Organization API's
- Loading branch information
Showing
41 changed files
with
940 additions
and
22 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
25 changes: 25 additions & 0 deletions
25
Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseLicenseClient.cs
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,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(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseOrganizationClient.cs
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,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); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLicenseClient.cs
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,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(); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseOrganizationClient.cs
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,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(); | ||
} | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
Octokit.Tests.Integration/Clients/Enterprise/EnterpriseLicenseClientTests.cs
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,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); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Octokit.Tests.Integration/Clients/Enterprise/EnterpriseOrganizationClientTests.cs
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,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); | ||
} | ||
} |
Oops, something went wrong.