Due to api serialisation, must use LdapDn rather than LdapDN (the latter turns into ldap_d_n instead of ldap_dn)

Get rid of LdapTeam and LdapUser, the regular Team and User objects contain ldap_dn field if LDAP sync is enabled
This commit is contained in:
Ryan Gribble
2016-02-08 16:13:23 +10:00
committed by Ryan Gribble
parent 1f13001fd8
commit e4eb1166b7
16 changed files with 63 additions and 102 deletions
@@ -21,8 +21,8 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
IObservable<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="User"/> object.</returns>
IObservable<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <summary>
/// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
@@ -31,7 +31,7 @@ namespace Octokit.Reactive
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName);
/// <summary>
@@ -42,8 +42,8 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
IObservable<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="Team"/> object.</returns>
IObservable<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
@@ -52,7 +52,7 @@ namespace Octokit.Reactive
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
IObservable<LdapSyncResponse> QueueSyncTeamMapping(int teamId);
}
}
@@ -31,8 +31,8 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
public IObservable<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="User"/> object.</returns>
public IObservable<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
{
return _client.UpdateUserMapping(userName, newLdapMapping).ToObservable();
}
@@ -44,7 +44,7 @@ namespace Octokit.Reactive
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public IObservable<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
return _client.QueueSyncUserMapping(userName).ToObservable();
@@ -58,8 +58,8 @@ namespace Octokit.Reactive
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
public IObservable<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="Team"/> object.</returns>
public IObservable<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
{
return _client.UpdateTeamMapping(teamId, newLdapMapping).ToObservable();
}
@@ -71,7 +71,7 @@ namespace Octokit.Reactive
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public IObservable<LdapSyncResponse> QueueSyncTeamMapping(int teamId)
{
return _client.QueueSyncTeamMapping(teamId).ToObservable();
@@ -23,15 +23,15 @@ namespace Octokit
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
public async Task<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="User"/> object.</returns>
public async Task<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping)
{
Ensure.ArgumentNotNull(userName, "userName");
Ensure.ArgumentNotNull(newLdapMapping, "newLdapMapping");
var endpoint = ApiUrls.EnterpriseLdapUserMapping(userName);
return await ApiConnection.Patch<LdapUser>(endpoint, newLdapMapping);
return await ApiConnection.Patch<User>(endpoint, newLdapMapping);
}
/// <summary>
@@ -41,7 +41,7 @@ namespace Octokit
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The userName to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public async Task<LdapSyncResponse> QueueSyncUserMapping(string userName)
{
Ensure.ArgumentNotNull(userName, "userName");
@@ -65,17 +65,17 @@ namespace Octokit
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
public async Task<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
/// <returns>The <see cref="Team"/> object.</returns>
public async Task<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping)
{
Ensure.ArgumentNotNull(teamId, "teamId");
Ensure.ArgumentNotNull(newLdapMapping, "newLdapMapping");
var endpoint = ApiUrls.EnterpriseLdapTeamMapping(teamId);
return await ApiConnection.Patch<LdapTeam>(endpoint, newLdapMapping);
return await ApiConnection.Patch<Team>(endpoint, newLdapMapping);
}
/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
/// </summary>
@@ -83,7 +83,7 @@ namespace Octokit
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
public async Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId)
{
Ensure.ArgumentNotNull(teamId, "teamId");
@@ -18,8 +18,8 @@ namespace Octokit
/// </remarks>
/// <param name="userName">The username to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapUser"/> object.</returns>
Task<LdapUser> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="User"/> object.</returns>
Task<User> UpdateUserMapping(string userName, NewLdapMapping newLdapMapping);
/// <summary>
/// Queue an LDAP Sync job for a user on a GitHub Enterprise appliance (must be Site Admin user).
@@ -28,7 +28,7 @@ namespace Octokit
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
/// </remarks>
/// <param name="userName">The username to sync LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
Task<LdapSyncResponse> QueueSyncUserMapping(string userName);
/// <summary>
@@ -39,8 +39,8 @@ namespace Octokit
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <param name="newLdapMapping">The <see cref="NewLdapMapping"/></param>
/// <returns>The <see cref="LdapTeam"/> object.</returns>
Task<LdapTeam> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <returns>The <see cref="Team"/> object.</returns>
Task<Team> UpdateTeamMapping(int teamId, NewLdapMapping newLdapMapping);
/// <summary>
/// Queue an LDAP Sync job for a team on a GitHub Enterprise appliance (must be Site Admin user).
@@ -49,7 +49,7 @@ namespace Octokit
/// https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
/// </remarks>
/// <param name="teamId">The teamId to update LDAP mapping</param>
/// <returns>The <see cref="HttpStatusCode"/> of the queue request.</returns>
/// <returns>The <see cref="LdapSyncResponse"/> of the queue request.</returns>
Task<LdapSyncResponse> QueueSyncTeamMapping(int teamId);
}
}
@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Octokit
@@ -15,21 +16,25 @@ namespace Octokit
/// Initializes a new instance of the <see cref="NewLdapMapping"/> class.
/// </summary>
/// <param name="ldapDn">The LDAP Distinguished Name</param>
public NewLdapMapping(string ldapDN)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public NewLdapMapping(string ldapDn)
{
LdapDN = ldapDN;
LdapDn = ldapDn;
}
/// <summary>
/// The LDAP Distinguished Name (required)
/// </summary>
public string LdapDN { get; private set; }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "LdapDn: {0}", LdapDN);
return string.Format(CultureInfo.InvariantCulture, "LdapDn: {0}", LdapDn);
}
}
}
@@ -11,12 +11,12 @@ namespace Octokit
{
public LdapSyncResponse() { }
public LdapSyncResponse(IReadOnlyList<string> status)
public LdapSyncResponse(string status)
{
Status = status;
}
public IReadOnlyList<string> Status
public string Status
{
get;
private set;
@@ -26,7 +26,7 @@ namespace Octokit
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Status: {0}", string.Join("\r\n", Status));
return String.Format(CultureInfo.InvariantCulture, "Status: {0}", Status);
}
}
}
@@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class LdapTeam : Team
{
public LdapTeam() { }
public LdapTeam(Uri url, int id, string name, Permission permission, int membersCount, int reposCount, Organization organization, string ldapDN)
: base(url, id, name, permission, membersCount, reposCount, organization)
{
LdapDN = ldapDN;
}
public string LdapDN { get; protected set; }
internal new string DebuggerDisplay
{
get { return base.DebuggerDisplay; }
}
}
}
@@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class LdapUser : User
{
public LdapUser() { }
public LdapUser(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, bool siteAdmin, string ldapDN)
: base(avatarUrl, bio, blog, collaborators, company, createdAt, diskUsage, email, followers, following, hireable, htmlUrl, totalPrivateRepos, id, location, login, name, ownedPrivateRepos, plan, privateGists, publicGists, publicRepos, url, siteAdmin)
{
LdapDN = ldapDN;
}
public string LdapDN { get; protected set; }
internal new string DebuggerDisplay
{
get { return base.DebuggerDisplay; }
}
}
}
+12 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Octokit
@@ -12,7 +13,9 @@ namespace Octokit
{
public Team() { }
public Team(Uri url, int id, string name, Permission permission, int membersCount, int reposCount, Organization organization)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public Team(Uri url, int id, string name, Permission permission, int membersCount, int reposCount, Organization organization, string ldapDn)
{
Url = url;
Id = id;
@@ -21,6 +24,7 @@ namespace Octokit
MembersCount = membersCount;
ReposCount = reposCount;
Organization = organization;
LdapDn = ldapDn;
}
/// <summary>
@@ -58,6 +62,13 @@ namespace Octokit
/// </summary>
public Organization Organization { get; protected set; }
/// <summary>
/// LDAP Binding (GitHub Enterprise only)
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; protected set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} ", Name); }
+12 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Octokit
@@ -12,10 +13,13 @@ namespace Octokit
{
public User() { }
public User(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, bool siteAdmin)
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public User(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, bool siteAdmin, string ldapDn)
: base(avatarUrl, bio, blog, collaborators, company, createdAt, diskUsage, email, followers, following, hireable, htmlUrl, totalPrivateRepos, id, location, login, name, ownedPrivateRepos, plan, privateGists, publicGists, publicRepos, AccountType.User, url)
{
SiteAdmin = siteAdmin;
LdapDn = ldapDn;
}
/// <summary>
@@ -23,6 +27,13 @@ namespace Octokit
/// </summary>
public bool SiteAdmin { get; protected set; }
/// <summary>
/// LDAP Binding (GitHub Enterprise only)
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dn")]
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Dn")]
public string LdapDn { get; protected set; }
internal string DebuggerDisplay
{
get
-2
View File
@@ -450,8 +450,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-2
View File
@@ -458,8 +458,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
-2
View File
@@ -454,8 +454,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
-2
View File
@@ -447,8 +447,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<ItemGroup>
-2
View File
@@ -454,8 +454,6 @@
<Compile Include="Clients\Enterprise\EnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\IEnterpriseLdapClient.cs" />
<Compile Include="Models\Request\Enterprise\NewLdapMapping.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
</ItemGroup>
<ItemGroup>
-2
View File
@@ -154,8 +154,6 @@
<Compile Include="Models\Response\Enterprise\AdminStatsPulls.cs" />
<Compile Include="Models\Response\Enterprise\AdminStatsRepos.cs" />
<Compile Include="Models\Response\Enterprise\LdapSyncResponse.cs" />
<Compile Include="Models\Response\Enterprise\LdapTeam.cs" />
<Compile Include="Models\Response\Enterprise\LdapUser.cs" />
<Compile Include="Models\Response\Enterprise\SearchIndexingResponse.cs" />
<Compile Include="Models\Response\Enterprise\LicenseInfo.cs" />
<Compile Include="Models\Response\Enterprise\AdminStatsUsers.cs" />