diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 618c591b36..e74cc97b83 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -376,6 +376,47 @@ public void CanFilterBySortDirection() Arg.Is>(d => d["type"] == "member" && d["sort"] == "updated" && d["direction"] == "asc")); } + + [Fact] + public void CanFilterByVisibility() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var request = new RepositoryRequest + { + Visibility = RepositoryVisibility.Private + }; + client.GetAllForCurrent(request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "user/repos"), + Arg.Is>(d => + d["visibility"] == "private")); + } + + [Fact] + public void CanFilterByAffiliation() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var request = new RepositoryRequest + { + + Affiliation = RepositoryAffiliation.Owner, + Sort = RepositorySort.FullName + }; + + client.GetAllForCurrent(request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "user/repos"), + Arg.Is>(d => + d["affiliation"] == "owner" && d["sort"] == "full_name")); + } } public class TheGetAllForUserMethod diff --git a/Octokit/Helpers/UriExtensions.cs b/Octokit/Helpers/UriExtensions.cs index a2db9969a4..2ee1b873d6 100644 --- a/Octokit/Helpers/UriExtensions.cs +++ b/Octokit/Helpers/UriExtensions.cs @@ -10,7 +10,7 @@ namespace Octokit public static class UriExtensions { /// - /// Merge a dictionary of valeus with an existing + /// Merge a dictionary of values with an existing /// /// Original request Uri /// Collection of key-value pairs diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index f22b881fa6..1f5d2e8907 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -37,6 +37,22 @@ public class RepositoryRequest : RequestParameters /// public SortDirection Direction { get; set; } + /// + /// Gets or sets the visibility property. + /// + /// + /// The visibility. + /// + public RepositoryVisibility Visibility { get; set; } + + /// + /// Gets or sets the affiliation property. + /// + /// + /// The affiliation. + /// + public RepositoryAffiliation Affiliation { get; set; } + internal string DebuggerDisplay { get @@ -103,4 +119,72 @@ public enum RepositorySort [Parameter(Value = "full_name")] FullName } + + /// + /// The properties that repositories can be visible by. + /// + public enum RepositoryVisibility + { + /// + /// Returns only public repositories + /// + Public, + + /// + /// Returns only private repositories + /// + Private, + + /// + /// Return both public and private repositories + /// + All, + } + + /// + /// The properties that repositories can be affiliated by. + /// + public enum RepositoryAffiliation + { + /// + /// Repositories that are owned by the authenticated user + /// + Owner, + + /// + /// Repositories that the user has been added to as a collaborator. + /// + Collaborator, + + /// + /// Repositories that the user has access to through being a member of an organization. + /// This includes every repository on every team that the user is on. + /// + [Parameter(Value = "organization_member")] + OrganizationMember, + + /// + /// Return repositories that are owned by authenticated user and added to as a collaborator. + /// + [Parameter(Value = "owner, collaborator")] + OwnerAndCollaborator, + + /// + /// Return repositories that are owned by authenticated user or user is a organization member. + /// + [Parameter(Value = "owner, organization_member")] + OwnerAndOrganizationMember, + + /// + /// Return repositories that user has been added as collaborator or user is a organization member. + /// + [Parameter(Value = "collaborator, organization_member")] + CollaboratorAndOrganizationMember, + + /// + /// Returns all repositories where user is owner,collaborator or organization member. + /// + [Parameter(Value = "owner, collaborator, organization_member")] + All + } }