From bdc16944aefc06fd0da06077c394a87decbecc6a Mon Sep 17 00:00:00 2001 From: Lars Zweifel <132883445+lars-zweifel@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:17:55 +0200 Subject: [PATCH] feat: added Missing APIOption overload for PackagesClient.GetAll* #2923 (#2934) feat: added Missing APIOption overload for PackagesClient.GetAll* #2923 added missing APIOption overload for PackagesClient and ObservablePackagesClient added overload for optional parameter packageVisibility to be a nonbreaking change extended PackagesClientTests.cs to be conform with RepositoriesClientTests.cs to take ApiOptions into account --- .../Clients/IObservablePackagesClient.cs | 102 +++++++++- .../Clients/ObservablePackagesClient.cs | 167 +++++++++++++++- Octokit.Tests/Clients/PackagesClientTests.cs | 12 +- Octokit/Clients/IPackagesClient.cs | 108 ++++++++++- Octokit/Clients/PackagesClient.cs | 178 +++++++++++++++++- 5 files changed, 540 insertions(+), 27 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservablePackagesClient.cs b/Octokit.Reactive/Clients/IObservablePackagesClient.cs index 6814cad88d..717ae04d1e 100644 --- a/Octokit.Reactive/Clients/IObservablePackagesClient.cs +++ b/Octokit.Reactive/Clients/IObservablePackagesClient.cs @@ -7,6 +7,27 @@ public interface IObservablePackagesClient { IObservablePackageVersionsClient PackageVersions { get; } + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + IObservable GetAllForOrg(string org, PackageType packageType); + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Options for changing the API response + IObservable GetAllForOrg(string org, PackageType packageType, ApiOptions options); + /// /// List all packages for an organisations, readable by the current user /// @@ -16,7 +37,19 @@ public interface IObservablePackagesClient /// Required: Organisation Name /// Required: The type of package /// Optional: The visibility of the package - IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null); + IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility); + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Optional: The visibility of the package + /// Options for changing the API response + IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Get a specific package for an Organization. @@ -51,6 +84,35 @@ public interface IObservablePackagesClient /// Required: The name of the package IObservable RestoreForOrg(string org, PackageType packageType, string packageName); + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + IObservable GetAllForActiveUser(PackageType packageType); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Options for changing the API response + IObservable GetAllForActiveUser(PackageType packageType, ApiOptions options); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Optional: The visibility of the package + IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility); + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -59,7 +121,8 @@ public interface IObservablePackagesClient /// /// Required: The type of package /// Optional: The visibility of the package - IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null); + /// Options for changing the API response + IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Gets a specific package for a package owned by the authenticated user. @@ -91,6 +154,38 @@ public interface IObservablePackagesClient /// Required: The name of the package IObservable RestoreForActiveUser(PackageType packageType, string packageName); + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + IObservable GetAllForUser(string username, PackageType packageType); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Options for changing the API response + IObservable GetAllForUser(string username, PackageType packageType, ApiOptions options); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Optional: The visibility of the package + IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility); + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -100,7 +195,8 @@ public interface IObservablePackagesClient /// Required: Username /// Required: The type of package /// Optional: The visibility of the package - IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null); + /// Options for changing the API response + IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Gets a specific package metadata for a public package owned by a user. diff --git a/Octokit.Reactive/Clients/ObservablePackagesClient.cs b/Octokit.Reactive/Clients/ObservablePackagesClient.cs index 662efb556b..a1e0981c91 100644 --- a/Octokit.Reactive/Clients/ObservablePackagesClient.cs +++ b/Octokit.Reactive/Clients/ObservablePackagesClient.cs @@ -20,6 +20,40 @@ public ObservablePackagesClient(IGitHubClient client) public IObservablePackageVersionsClient PackageVersions { get; private set; } + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + public IObservable GetAllForOrg(string org, PackageType packageType) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForOrg(org, packageType, (PackageVisibility?)null); + } + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Options for changing the API response + public IObservable GetAllForOrg(string org, PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForOrg(org, packageType, null, options); + } + /// /// List all packages for an organisations, readable by the current user /// @@ -29,15 +63,34 @@ public ObservablePackagesClient(IGitHubClient client) /// Required: Organisation Name /// Required: The type of package /// Optional: The visibility of the package - public IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null) + public IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(packageType, nameof(packageType)); + return GetAllForOrg(org, packageType, packageVisibility, ApiOptions.None); + } + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Optional: The visibility of the package + /// Options for changing the API response + public IObservable GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + var route = ApiUrls.PackagesOrg(org); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return _connection.GetAndFlattenAllPages(route, parameters); + return _connection.GetAndFlattenAllPages(route, parameters, options); } /// @@ -94,6 +147,51 @@ public IObservable RestoreForOrg(string org, PackageType packageType, stri return _client.RestoreForOrg(org, packageType, packageName).ToObservable(); } + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + public IObservable GetAllForActiveUser(PackageType packageType) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForActiveUser(packageType, ApiOptions.None); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Options for changing the API response + public IObservable GetAllForActiveUser(PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForActiveUser(packageType, null, options); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Optional: The visibility of the package + public IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForActiveUser(packageType, packageVisibility, ApiOptions.None); + } + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -102,12 +200,16 @@ public IObservable RestoreForOrg(string org, PackageType packageType, stri /// /// Required: The type of package /// Optional: The visibility of the package - public IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null) + /// Options for changing the API response + public IObservable GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + var route = ApiUrls.PackagesActiveUser(); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return _connection.GetAndFlattenAllPages(route, parameters); + return _connection.GetAndFlattenAllPages(route, parameters, options); } /// @@ -158,6 +260,57 @@ public IObservable RestoreForActiveUser(PackageType packageType, string pa return _client.RestoreForActiveUser(packageType, packageName).ToObservable(); } + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + public IObservable GetAllForUser(string username, PackageType packageType) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForUser(username, packageType, ApiOptions.None); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Options for changing the API response + public IObservable GetAllForUser(string username, PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForUser(username, packageType, null, options); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Optional: The visibility of the package + public IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForUser(username, packageType, packageVisibility, ApiOptions.None); + } + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -167,15 +320,17 @@ public IObservable RestoreForActiveUser(PackageType packageType, string pa /// Required: Username /// Required: The type of package /// Optional: The visibility of the package - public IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null) + /// Options for changing the API response + public IObservable GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); var route = ApiUrls.PackagesUser(username); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return _connection.GetAndFlattenAllPages(route, parameters); + return _connection.GetAndFlattenAllPages(route, parameters, options); } /// diff --git a/Octokit.Tests/Clients/PackagesClientTests.cs b/Octokit.Tests/Clients/PackagesClientTests.cs index 2da109bf1f..7832ac6bf2 100644 --- a/Octokit.Tests/Clients/PackagesClientTests.cs +++ b/Octokit.Tests/Clients/PackagesClientTests.cs @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForOrg("fake", PackageType.RubyGems); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type")), Args.ApiOptions); } [Fact] @@ -39,7 +39,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForOrg("fake", PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility")), Args.ApiOptions); } [Fact] @@ -141,7 +141,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForActiveUser(PackageType.RubyGems); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/packages"), Arg.Is>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/packages"), Arg.Is>(d => d.ContainsKey("package_type")), Args.ApiOptions); } [Fact] @@ -153,7 +153,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForActiveUser(PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility")), Args.ApiOptions); } } @@ -236,7 +236,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForUser("fake", PackageType.RubyGems); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type")), Args.ApiOptions); } [Fact] @@ -248,7 +248,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForUser("fake", PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/packages"), Arg.Is>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility")), Args.ApiOptions); } [Fact] diff --git a/Octokit/Clients/IPackagesClient.cs b/Octokit/Clients/IPackagesClient.cs index 25dac896d0..5c657b87ea 100644 --- a/Octokit/Clients/IPackagesClient.cs +++ b/Octokit/Clients/IPackagesClient.cs @@ -7,6 +7,27 @@ public interface IPackagesClient { IPackageVersionsClient PackageVersions { get; } + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + Task> GetAllForOrg(string org, PackageType packageType); + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Options for changing the API response + Task> GetAllForOrg(string org, PackageType packageType, ApiOptions options); + /// /// List all packages for an organisations, readable by the current user /// @@ -16,8 +37,20 @@ public interface IPackagesClient /// Required: Organisation Name /// Required: The type of package /// Optional: The visibility of the package - [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] - Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null); + Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility); + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// The default page size on GitHub.com is 30. + /// + /// Required: Organisation Name + /// Required: The type of package + /// Optional: The visibility of the package + /// Options for changing the API response + Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Get a specific package for an Organization. @@ -59,9 +92,39 @@ public interface IPackagesClient /// See the API documentation for more details /// /// Required: The type of package + Task> GetAllForActiveUser(PackageType packageType); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Options for changing the API response + Task> GetAllForActiveUser(PackageType packageType, ApiOptions options); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Optional: The visibility of the package + Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// The default page size on GitHub.com is 30. + /// + /// Required: The type of package /// Optional: The visibility of the package - [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] - Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null); + /// Options for changing the API response + Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Gets a specific package for a package owned by the authenticated user. @@ -101,9 +164,42 @@ public interface IPackagesClient /// /// Required: Username /// Required: The type of package + Task> GetAllForUser(string username, PackageType packageType); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Options for changing the API response + Task> GetAllForUser(string username, PackageType packageType, ApiOptions options); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Optional: The visibility of the package + Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility); + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// The default page size on GitHub.com is 30. + /// + /// Required: Username + /// Required: The type of package /// Optional: The visibility of the package - [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] - Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null); + /// Options for changing the API response + Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options); /// /// Gets a specific package metadata for a public package owned by a user. diff --git a/Octokit/Clients/PackagesClient.cs b/Octokit/Clients/PackagesClient.cs index 91a6983315..9ace9828c5 100644 --- a/Octokit/Clients/PackagesClient.cs +++ b/Octokit/Clients/PackagesClient.cs @@ -19,6 +19,60 @@ public PackagesClient(IApiConnection apiConnection) : base(apiConnection) public IPackageVersionsClient PackageVersions { get; private set; } #region Organization + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + [ManualRoute("GET", "/orgs/{org}/packages")] + public Task> GetAllForOrg(string org, PackageType packageType) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForOrg(org, packageType, ApiOptions.None); + } + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/packages")] + public Task> GetAllForOrg(string org, PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForOrg(org, packageType, null, options); + } + + /// + /// List all packages for an organisations, readable by the current user + /// + /// + /// See the API documentation for more details + /// + /// Required: Organisation Name + /// Required: The type of package + /// Optional: The visibility of the package + [ManualRoute("GET", "/orgs/{org}/packages")] + public Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForOrg(org, packageType, packageVisibility, ApiOptions.None); + } + /// /// List all packages for an organisations, readable by the current user /// @@ -28,15 +82,18 @@ public PackagesClient(IApiConnection apiConnection) : base(apiConnection) /// Required: Organisation Name /// Required: The type of package /// Optional: The visibility of the package + /// Options for changing the API response [ManualRoute("GET", "/orgs/{org}/packages")] - public Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null) + public Task> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); var route = ApiUrls.PackagesOrg(org); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return ApiConnection.GetAll(route, parameters); + return ApiConnection.GetAll(route, parameters, options); } /// @@ -73,6 +130,7 @@ public Task DeleteForOrg(string org, PackageType packageType, string packageName { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); var route = ApiUrls.PackageOrg(org, packageType, packageName); @@ -101,6 +159,38 @@ public Task RestoreForOrg(string org, PackageType packageType, string packageNam #endregion #region Active User + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + [ManualRoute("GET", "/user/packages")] + public Task> GetAllForActiveUser(PackageType packageType) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForActiveUser(packageType, (PackageVisibility?)null); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Options for changing the API response + [ManualRoute("GET", "/user/packages")] + public Task> GetAllForActiveUser(PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForActiveUser(packageType, null, options); + } + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -110,12 +200,32 @@ public Task RestoreForOrg(string org, PackageType packageType, string packageNam /// Required: The type of package /// Optional: The visibility of the package [ManualRoute("GET", "/user/packages")] - public Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null) + public Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility) { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForActiveUser(packageType, packageVisibility, ApiOptions.None); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: The type of package + /// Optional: The visibility of the package + /// Options for changing the API response + [ManualRoute("GET", "/user/packages")] + public Task> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + var route = ApiUrls.PackagesActiveUser(); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return ApiConnection.GetAll(route, parameters); + return ApiConnection.GetAll(route, parameters, options); } /// @@ -174,6 +284,59 @@ public Task RestoreForActiveUser(PackageType packageType, string packageName) #endregion #region Specific User + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + [ManualRoute("GET", "/users/{username}/packages")] + public Task> GetAllForUser(string username, PackageType packageType) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForUser(username, packageType, ApiOptions.None); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Options for changing the API response + [ManualRoute("GET", "/users/{username}/packages")] + public Task> GetAllForUser(string username, PackageType packageType, ApiOptions options) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return GetAllForUser(username, packageType, null, options); + } + + /// + /// Lists packages owned by the authenticated user within the user's namespace + /// + /// + /// See the API documentation for more details + /// + /// Required: Username + /// Required: The type of package + /// Optional: The visibility of the package + [ManualRoute("GET", "/users/{username}/packages")] + public Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + return GetAllForUser(username, packageType, packageVisibility, ApiOptions.None); + } + /// /// Lists packages owned by the authenticated user within the user's namespace /// @@ -183,15 +346,18 @@ public Task RestoreForActiveUser(PackageType packageType, string packageName) /// Required: Username /// Required: The type of package /// Optional: The visibility of the package + /// Options for changing the API response [ManualRoute("GET", "/users/{username}/packages")] - public Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null) + public Task> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNull(options, nameof(options)); var route = ApiUrls.PackagesUser(username); var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); - return ApiConnection.GetAll(route, parameters); + return ApiConnection.GetAll(route, parameters, options); } ///