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

Begin implementation of Enterprise ManagementConsole API #1269

Closed
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3b34c01
Initial implementation of ManagementConsole - maintenance mode
ryangribble Apr 9, 2016
676ea3b
Add environment var support for management console password for integ…
ryangribble Apr 10, 2016
d4f1a9c
Add reactive client and unit tests
ryangribble Apr 10, 2016
e23400f
Update some xmlDoc
ryangribble Apr 10, 2016
4177441
I think this is a better way to setup the underlying baseUri on IConn…
ryangribble Apr 10, 2016
46495e1
Update EnterpriseClient.cs
ryangribble Apr 18, 2016
bdaf56f
Update IEnterpriseClient.cs
ryangribble Apr 18, 2016
1b772f3
Still trying to get the xmDoc perfect, thanks app veyor :)
ryangribble Apr 19, 2016
d9fec7e
XmlDoc'ing my way to success
ryangribble Apr 19, 2016
1313348
Merge remote-tracking branch 'upstream/master' into enterprise-consol…
ryangribble Jun 8, 2016
644898e
Merge remote-tracking branch 'upstream/master' into enterprise-consol…
ryangribble Jul 3, 2016
5d2bc5e
Merge remote-tracking branch 'upstream/master' into enterprise-consol…
ryangribble Jul 5, 2016
9f0704d
Add specific test attribute for management console tests
ryangribble Aug 16, 2016
567db46
check chronic string empty/null
ryangribble Aug 16, 2016
b75573c
Use helper's password field in test
ryangribble Aug 16, 2016
4a94554
Tidy up maintenance mode tests by using a context/destructor to manag…
ryangribble Aug 16, 2016
579d20d
make internal and tidy up URL concatenation
ryangribble Aug 16, 2016
83c25f0
Merge remote-tracking branch 'upstream/master' into enterprise-consol…
ryangribble Aug 16, 2016
17e4102
move GHE endpoint fixup inside ApiUrls methods
ryangribble Aug 16, 2016
8a42bb0
Rework request object to be the correct structure so SimpleJsonSerial…
ryangribble Aug 16, 2016
fc0aa33
Create abstract base class for FormUrlEncoded parameters (similar to …
ryangribble Aug 16, 2016
19ab15b
Fix projects
ryangribble Aug 16, 2016
47c9525
Fix maintenance context logic - destructor should always turn mainten…
ryangribble Aug 16, 2016
6de9ade
Fix xml comment
ryangribble Aug 16, 2016
cddf3ba
Fix Xml comment
ryangribble Aug 16, 2016
20b217a
Those pesky xml comments!
ryangribble Aug 16, 2016
e11f275
Fine, I give up!
ryangribble Aug 16, 2016
b31eac4
Merge branch 'master' into enterprise-console-maintenance
ryangribble Aug 24, 2016
c5d220f
Fix string.Format
ryangribble Aug 30, 2016
2a08269
Merge branch 'master' into enterprise-console-maintenance
ryangribble Sep 6, 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
18 changes: 13 additions & 5 deletions Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,47 @@ public interface IObservableEnterpriseClient
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/enterprise/admin_stats/">Enterprise Admin Stats API documentation</a> for more information.
///</remarks>
/// </remarks>
IObservableEnterpriseAdminStatsClient AdminStats { get; }

/// <summary>
/// A client for GitHub's Enterprise LDAP API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/ldap/">Enterprise LDAP API documentation</a> for more information.
///</remarks>
/// </remarks>
IObservableEnterpriseLdapClient Ldap { 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>
/// </remarks>
IObservableEnterpriseLicenseClient License { get; }

/// <summary>
/// A client for GitHub's Enterprise Management Console API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/management_console/">Enterprise Management Console API documentation</a> for more information.
/// </remarks>
IObservableEnterpriseManagementConsoleClient ManagementConsole { 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>
/// </remarks>
IObservableEnterpriseOrganizationClient Organization { get; }

/// <summary>
/// A client for GitHub's Enterprise Search Indexing API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/search_indexing/">Enterprise Search Indexing API documentation</a> for more information.
///</remarks>
/// </remarks>
IObservableEnterpriseSearchIndexingClient SearchIndexing { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise Management Console API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/management_console/">Enterprise Management Console API documentation</a> for more information.
/// </remarks>
public interface IObservableEnterpriseManagementConsoleClient
{
/// <summary>
/// Gets GitHub Enterprise Maintenance Mode Status
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status
/// </remarks>
/// <returns>The <see cref="MaintenanceModeResponse"/>.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
IObservable<MaintenanceModeResponse> GetMaintenanceMode(string managementConsolePassword);

/// <summary>
/// Sets GitHub Enterprise Maintenance Mode
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status
/// </remarks>
/// <returns>The <see cref="MaintenanceModeResponse"/>.</returns>
IObservable<MaintenanceModeResponse> EditMaintenanceMode(UpdateMaintenanceRequest maintenance, string managementConsolePassword);
}
}
19 changes: 14 additions & 5 deletions Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ObservableEnterpriseClient(IGitHubClient client)
AdminStats = new ObservableEnterpriseAdminStatsClient(client);
Ldap = new ObservableEnterpriseLdapClient(client);
License = new ObservableEnterpriseLicenseClient(client);
ManagementConsole = new ObservableEnterpriseManagementConsoleClient(client);
Organization = new ObservableEnterpriseOrganizationClient(client);
SearchIndexing = new ObservableEnterpriseSearchIndexingClient(client);
}
Expand All @@ -24,39 +25,47 @@ public ObservableEnterpriseClient(IGitHubClient client)
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/enterprise/admin_stats/">Enterprise Admin Stats API documentation</a> for more information.
///</remarks>
/// </remarks>
public IObservableEnterpriseAdminStatsClient AdminStats { get; private set; }

/// <summary>
/// A client for GitHub's Enterprise LDAP API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/ldap/">Enterprise LDAP API documentation</a> for more information.
///</remarks>
/// </remarks>
public IObservableEnterpriseLdapClient Ldap { 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>
/// </remarks>
public IObservableEnterpriseLicenseClient License { get; private set; }

/// <summary>
/// A client for GitHub's Enterprise Management Console API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/management_console/">Enterprise Management Console API documentation</a> for more information.
/// </remarks>
public IObservableEnterpriseManagementConsoleClient ManagementConsole { 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>
/// </remarks>
public IObservableEnterpriseOrganizationClient Organization { get; private set; }

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

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Enterprise Management Console API
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/enterprise/management_console/">Enterprise Management Console API documentation</a> for more information.
/// </remarks>
public class ObservableEnterpriseManagementConsoleClient : IObservableEnterpriseManagementConsoleClient
{
readonly IEnterpriseManagementConsoleClient _client;

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

_client = client.Enterprise.ManagementConsole;
}

/// <summary>
/// Gets GitHub Enterprise Maintenance Mode Status
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status
/// </remarks>
/// <returns>The <see cref="MaintenanceModeResponse"/>.</returns>
public IObservable<MaintenanceModeResponse> GetMaintenanceMode(string managementConsolePassword)
{
Ensure.ArgumentNotNullOrEmptyString(managementConsolePassword, "managementConsolePassword");

return _client.GetMaintenanceMode(managementConsolePassword).ToObservable();
}

/// <summary>
/// Sets GitHub Enterprise Maintenance Mode
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status
/// </remarks>
/// <returns>The <see cref="MaintenanceModeResponse"/>.</returns>
public IObservable<MaintenanceModeResponse> EditMaintenanceMode(UpdateMaintenanceRequest maintenance, string managementConsolePassword)
{
Ensure.ArgumentNotNull(maintenance, "maintenance");
Ensure.ArgumentNotNullOrEmptyString(managementConsolePassword, "managementConsolePassword");

return _client.EditMaintenanceMode(maintenance, managementConsolePassword).ToObservable();
}
}
}
4 changes: 3 additions & 1 deletion Octokit.Reactive/Octokit.Reactive-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@
<Compile Include="Clients\ObservableIssueTimelineClient.cs" />
<Compile Include="Clients\IObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\ObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseManagementConsoleClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseManagementConsoleClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand All @@ -204,4 +206,4 @@
<Name>Octokit-Mono</Name>
</ProjectReference>
</ItemGroup>
</Project>
</Project>
4 changes: 3 additions & 1 deletion Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
<Compile Include="Clients\ObservableIssueTimelineClient.cs" />
<Compile Include="Clients\IObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\ObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseManagementConsoleClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseManagementConsoleClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
Expand All @@ -220,4 +222,4 @@
<Name>Octokit-MonoAndroid</Name>
</ProjectReference>
</ItemGroup>
</Project>
</Project>
4 changes: 3 additions & 1 deletion Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
<Compile Include="Clients\ObservableIssueTimelineClient.cs" />
<Compile Include="Clients\IObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\ObservableRepositoryBranchesClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseManagementConsoleClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseManagementConsoleClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand All @@ -216,4 +218,4 @@
<Name>Octokit-Monotouch</Name>
</ProjectReference>
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions Octokit.Reactive/Octokit.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\Enterprise\IObservableEnterpriseManagementConsoleClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseOrganizationClient.cs" />
Expand All @@ -86,6 +87,7 @@
<Compile Include="Clients\Enterprise\IObservableEnterpriseAdminStatsClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseManagementConsoleClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseOrganizationClient.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
using Octokit.Tests.Integration.Helpers;
using Xunit;

public class EnterpriseManagementConsoleClientTests
{
readonly IGitHubClient _github;

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

[GitHubEnterpriseManagementConsoleTest]
public async Task CanGetMaintenanceMode()
{
var maintenance = await _github.Enterprise.ManagementConsole.GetMaintenanceMode(EnterpriseHelper.ManagementConsolePassword);

Assert.NotNull(maintenance);
}

[GitHubEnterpriseManagementConsoleTest]
public async Task CanSetMaintenanceModeOff()
{
using (_github.CreateMaintenanceModeContext(true))
{
// Set maintenance mode OFF now
var maintenance = await
_github.Enterprise.ManagementConsole.EditMaintenanceMode(
new UpdateMaintenanceRequest(),
EnterpriseHelper.ManagementConsolePassword);

Assert.Equal(maintenance.Status, MaintenanceModeStatus.Off);
}
}

[GitHubEnterpriseManagementConsoleTest]
public async Task CanSetMaintenanceModeOnNow()
{
using (_github.CreateMaintenanceModeContext(false))
{
// Set maintenance mode ON now
var maintenance = await
_github.Enterprise.ManagementConsole.EditMaintenanceMode(
new UpdateMaintenanceRequest(
new UpdateMaintenanceRequestDetails(true)),
EnterpriseHelper.ManagementConsolePassword);

Assert.Equal(maintenance.Status, MaintenanceModeStatus.On);
}
}

[GitHubEnterpriseManagementConsoleTest]
public async Task CanScheduleMaintenanceModeOnWithDateTime()
{
using (_github.CreateMaintenanceModeContext(false))
{
// Schedule maintenance mode ON in 5 minutes
var scheduledTime = DateTimeOffset.Now.AddMinutes(5);
var maintenance = await
_github.Enterprise.ManagementConsole.EditMaintenanceMode(
new UpdateMaintenanceRequest(
new UpdateMaintenanceRequestDetails(true, scheduledTime)),
EnterpriseHelper.ManagementConsolePassword);

Assert.Equal(maintenance.Status, MaintenanceModeStatus.Scheduled);
}
}

[GitHubEnterpriseManagementConsoleTest]
public async Task CanScheduleMaintenanceModeOnWithPhrase()
{
using (_github.CreateMaintenanceModeContext(false))
{
// Schedule maintenance mode ON with phrase
var maintenance = await
_github.Enterprise.ManagementConsole.EditMaintenanceMode(
new UpdateMaintenanceRequest(
new UpdateMaintenanceRequestDetails(true, "tomorrow at 5pm")),
EnterpriseHelper.ManagementConsolePassword);

Assert.Equal(maintenance.Status, MaintenanceModeStatus.Scheduled);
}
}
}
Loading