diff --git a/Octokit.Reactive/Clients/IObservableOrganizationOutsideCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationOutsideCollaboratorsClient.cs index caee658b1b..eb7bd19bf0 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationOutsideCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationOutsideCollaboratorsClient.cs @@ -18,6 +18,19 @@ public interface IObservableOrganizationOutsideCollaboratorsClient /// The users IObservable GetAll(string org); + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// Options for changing the API response + /// The users + IObservable GetAll(string org, ApiOptions options); + /// /// List all users who are outside collaborators of an organization. An outside collaborator is a user that /// is not a member of the organization. @@ -31,6 +44,20 @@ public interface IObservableOrganizationOutsideCollaboratorsClient /// The users IObservable GetAll(string org, OrganizationMembersFilter filter); + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// The filter to use when getting the users, + /// Options for changing the API response + /// The users + IObservable GetAll(string org, OrganizationMembersFilter filter, ApiOptions options); + /// /// Removes a user as an outside collaborator from the organization, this will remove them from all repositories /// within the organization. diff --git a/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs index 88ba98a444..94d5f409dc 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs @@ -35,7 +35,26 @@ public IObservable GetAll(string org) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); - return _connection.GetAndFlattenAllPages(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview); + return GetAll(org, ApiOptions.None); + } + + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// Options for changing the API response + /// The users + public IObservable GetAll(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview, options); } /// @@ -53,7 +72,27 @@ public IObservable GetAll(string org, OrganizationMembersFilter filter) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); - return _connection.GetAndFlattenAllPages(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview); + return GetAll(org, filter, ApiOptions.None); + } + + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// The filter to use when getting the users, + /// Options for changing the API response + /// The users + public IObservable GetAll(string org, OrganizationMembersFilter filter, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview, options); } /// diff --git a/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs index 1a23424ec0..d6e4b4bf86 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs @@ -48,6 +48,54 @@ public async Task ReturnsOutsideCollaborators() } } + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var outsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, options); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var outsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, options); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + [IntegrationTest] public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() { @@ -66,6 +114,67 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() } } + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var outsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, OrganizationMembersFilter.All, options); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var firstPageOptions = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + var firstPageOfOutsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, OrganizationMembersFilter.All, firstPageOptions); + + var secondPageOptions = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 2 + }; + + var secondPageOfOutsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, OrganizationMembersFilter.All, secondPageOptions); + + Assert.Equal(1, firstPageOfOutsideCollaborators.Count); + Assert.Equal(1, secondPageOfOutsideCollaborators.Count); + Assert.NotEqual(firstPageOfOutsideCollaborators[0].Login, secondPageOfOutsideCollaborators[0].Login); + } + } + [IntegrationTest] public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() { @@ -84,6 +193,31 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() Assert.Equal(_fixtureCollaborator, outsideCollaborators[0].Login); } } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var outsideCollaborators = await _gitHub.Organization + .OutsideCollaborator + .GetAll(Helper.Organization, OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + Assert.Equal(_fixtureCollaborator, outsideCollaborators[0].Login); + } + } } public class TheDeleteMethod diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs index 6dfbdb1242..cd14bdae8a 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs @@ -46,6 +46,52 @@ public async Task ReturnsOutsideCollaborators() } } + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var outsideCollaborators = await _client + .GetAll(Helper.Organization, options).ToList(); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var outsideCollaborators = await _client + .GetAll(Helper.Organization, options).ToList(); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + [IntegrationTest] public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() { @@ -63,6 +109,64 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() } } + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var outsideCollaborators = await _client + .GetAll(Helper.Organization, OrganizationMembersFilter.All, options).ToList(); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + } + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var firstPageOptions = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + var firstPageOfOutsideCollaborators = await _client + .GetAll(Helper.Organization, OrganizationMembersFilter.All, firstPageOptions).ToList(); + + var secondPageOptions = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 2 + }; + + var secondPageOfOutsideCollaborators = await _client + .GetAll(Helper.Organization, OrganizationMembersFilter.All, secondPageOptions).ToList(); + + Assert.Equal(1, firstPageOfOutsideCollaborators.Count); + Assert.Equal(1, secondPageOfOutsideCollaborators.Count); + Assert.NotEqual(firstPageOfOutsideCollaborators[0].Login, secondPageOfOutsideCollaborators[0].Login); + } + } + [IntegrationTest] public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() { @@ -80,6 +184,30 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() Assert.Equal("alfhenrik-test-2", outsideCollaborators[0].Login); } } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions() + { + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + { + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); + await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik"); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var outsideCollaborators = await _client + .GetAll(Helper.Organization, OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options).ToList(); + + Assert.NotNull(outsideCollaborators); + Assert.Equal(1, outsideCollaborators.Count); + Assert.Equal("alfhenrik-test-2", outsideCollaborators[0].Login); + } + } } public class TheDeleteMethod diff --git a/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs index 9808076586..72ebc40a4b 100644 --- a/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs @@ -26,7 +26,25 @@ public void RequestsTheCorrectUrl() client.GetAll("org"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators"), null, "application/vnd.github.korra-preview+json"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new OrganizationOutsideCollaboratorsClient(connection); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.GetAll("org", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators"), null, "application/vnd.github.korra-preview+json", options); } [Fact] @@ -37,10 +55,17 @@ public async Task EnsuresNonNullArguments() await Assert.ThrowsAsync(() => client.GetAll(null)); + await Assert.ThrowsAsync(() => client.GetAll(null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("org", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, OrganizationMembersFilter.All)); + await Assert.ThrowsAsync(() => client.GetAll(null, OrganizationMembersFilter.All, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("org", OrganizationMembersFilter.All, null)); await Assert.ThrowsAsync(() => client.GetAll("")); + await Assert.ThrowsAsync(() => client.GetAll("", ApiOptions.None)); await Assert.ThrowsAsync(() => client.GetAll("", OrganizationMembersFilter.All)); + await Assert.ThrowsAsync(() => client.GetAll("", OrganizationMembersFilter.All, ApiOptions.None)); } [Fact] @@ -51,7 +76,25 @@ public void AllFilterRequestsTheCorrectUrl() client.GetAll("org", OrganizationMembersFilter.All); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, "application/vnd.github.korra-preview+json"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + } + + [Fact] + public void AllFilterRequestsTheCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new OrganizationOutsideCollaboratorsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("org", OrganizationMembersFilter.All, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, "application/vnd.github.korra-preview+json", options); } [Fact] @@ -62,7 +105,25 @@ public void TwoFactorFilterRequestsTheCorrectUrl() client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, "application/vnd.github.korra-preview+json"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + } + + [Fact] + public void TwoFactorFilterRequestsTheCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new OrganizationOutsideCollaboratorsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, "application/vnd.github.korra-preview+json", options); } } diff --git a/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs index e62a2829f3..6b1cff7343 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs @@ -31,7 +31,28 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get>( Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators"), - null, + Args.EmptyDictionary, + "application/vnd.github.korra-preview+json"); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.GetAll("org", options); + + gitHubClient.Connection.Received(1).Get>( + Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators"), + Arg.Is>(d => d.Count == 2), "application/vnd.github.korra-preview+json"); } @@ -43,10 +64,17 @@ public async Task EnsuresNonNullArguments() Assert.Throws(() => client.GetAll(null)); + Assert.Throws(() => client.GetAll(null, ApiOptions.None)); + Assert.Throws(() => client.GetAll("org", null)); + Assert.Throws(() => client.GetAll(null, OrganizationMembersFilter.All)); + Assert.Throws(() => client.GetAll(null, OrganizationMembersFilter.All, ApiOptions.None)); + Assert.Throws(() => client.GetAll("org", OrganizationMembersFilter.All, null)); Assert.Throws(() => client.GetAll("")); + Assert.Throws(() => client.GetAll("", ApiOptions.None)); Assert.Throws(() => client.GetAll("", OrganizationMembersFilter.All)); + Assert.Throws(() => client.GetAll("", OrganizationMembersFilter.All, ApiOptions.None)); } [Fact] @@ -59,7 +87,28 @@ public void AllFilterRequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get>( Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), - null, + Args.EmptyDictionary, + "application/vnd.github.korra-preview+json"); + } + + [Fact] + public void AllFilterRequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("org", OrganizationMembersFilter.All, options); + + gitHubClient.Connection.Received(1).Get>( + Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), + Arg.Is>(d => d.Count == 2), "application/vnd.github.korra-preview+json"); } @@ -73,7 +122,28 @@ public void TwoFactorFilterRequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get>( Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), - null, + Args.EmptyDictionary, + "application/vnd.github.korra-preview+json"); + } + + [Fact] + public void TwoFactorFilterRequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableOrganizationOutsideCollaboratorsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options); + + gitHubClient.Connection.Received(1).Get>( + Arg.Is(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), + Arg.Is>(d => d.Count == 2), "application/vnd.github.korra-preview+json"); } } diff --git a/Octokit/Clients/IOrganizationOutsideCollaboratorsClient.cs b/Octokit/Clients/IOrganizationOutsideCollaboratorsClient.cs index 95293c0e47..1ad12ad7e3 100644 --- a/Octokit/Clients/IOrganizationOutsideCollaboratorsClient.cs +++ b/Octokit/Clients/IOrganizationOutsideCollaboratorsClient.cs @@ -17,6 +17,19 @@ public interface IOrganizationOutsideCollaboratorsClient /// The users Task> GetAll(string org); + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// Options for changing the API response + /// The users + Task> GetAll(string org, ApiOptions options); + /// /// List all users who are outside collaborators of an organization. An outside collaborator is a user that /// is not a member of the organization. @@ -30,6 +43,20 @@ public interface IOrganizationOutsideCollaboratorsClient /// The users Task> GetAll(string org, OrganizationMembersFilter filter); + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// The filter to use when getting the users, + /// Options for changing the API response + /// The users + Task> GetAll(string org, OrganizationMembersFilter filter, ApiOptions options); + /// /// Removes a user as an outside collaborator from the organization, this will remove them from all repositories /// within the organization. diff --git a/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs b/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs index 91bcf0ec6e..6ad0bc5fed 100644 --- a/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs +++ b/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs @@ -36,7 +36,26 @@ public Task> GetAll(string org) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); - return ApiConnection.GetAll(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview); + return GetAll(org, ApiOptions.None); + } + + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// Options for changing the API response + /// The users + public Task> GetAll(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview, options); } /// @@ -54,7 +73,27 @@ public Task> GetAll(string org, OrganizationMembersFilter fi { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); - return ApiConnection.GetAll(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview); + return GetAll(org, filter, ApiOptions.None); + } + + /// + /// List all users who are outside collaborators of an organization. An outside collaborator is a user that + /// is not a member of the organization. + /// + /// + /// See the API documentation + /// for more information. + /// + /// The login for the organization + /// The filter to use when getting the users, + /// Options for changing the API response + /// The users + public Task> GetAll(string org, OrganizationMembersFilter filter, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview, options); } ///