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

Fix runner group access return type #2965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions Octokit.AsyncPaginationExtension/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
=> pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, issueNumber, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/>
public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE)

Check warning on line 119 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'IMiscellaneousClient' is obsolete: 'Use individual clients available on the GitHubClient for these methods'

Check warning on line 119 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'IMiscellaneousClient' is obsolete: 'Use individual clients available on the GitHubClient for these methods'
=> pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/>
Expand Down Expand Up @@ -235,14 +235,6 @@
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IActionsSelfHostedRunnerGroupsClient.ListAllRunnerGroupOrganizationsForEnterprise(string, long, ApiOptions)"/>
public static IPaginatedList<Organization> ListAllRunnerGroupOrganizationsForEnterpriseAsync(this IActionsSelfHostedRunnerGroupsClient t, string enterprise, long runnerGroupId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Organization>(options => t.ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IActionsSelfHostedRunnerGroupsClient.ListAllRunnerGroupRepositoriesForOrganization(string, long, ApiOptions)"/>
public static IPaginatedList<Repository> ListAllRunnerGroupRepositoriesForOrganizationAsync(this IActionsSelfHostedRunnerGroupsClient t, string org, long runnerGroupId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Repository>(options => t.ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/>
public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
Expand Down Expand Up @@ -927,7 +919,7 @@
public static IPaginatedList<object> GetAllJsonAsync(this IEnterpriseAuditLogClient t, string enterprise, AuditLogApiOptions auditLog, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<object>(options => t.GetAllJson(enterprise, auditLog), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IEnterpriseAuditLogClient.GetAllJson(string, AuditLogRequest, AuditLogApiOptions, ApiOptions" />

Check warning on line 922 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

XML comment has syntactically incorrect cref attribute 'IEnterpriseAuditLogClient.GetAllJson(string, AuditLogRequest, AuditLogApiOptions, ApiOptions'

Check warning on line 922 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

) expected. See also error CS1026.

Check warning on line 922 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

XML comment has syntactically incorrect cref attribute 'IEnterpriseAuditLogClient.GetAllJson(string, AuditLogRequest, AuditLogApiOptions, ApiOptions'

Check warning on line 922 in Octokit.AsyncPaginationExtension/Extensions.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

) expected. See also error CS1026.
public static IPaginatedList<object> GetAllJsonAsync(this IEnterpriseAuditLogClient t, string enterprise, AuditLogRequest request, AuditLogApiOptions auditLog, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<object>(options => t.GetAllJson(enterprise, request, auditLog), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);
IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);

/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
Expand All @@ -128,7 +128,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);
IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -138,7 +138,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);
IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -149,7 +149,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(stri
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
public IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
{
return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None);
}
Expand All @@ -189,12 +189,12 @@ public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(st
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
public IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Organization>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options);
return _client.ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, options).ToObservable();
}

/// <summary>
Expand All @@ -205,7 +205,7 @@ public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(st
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
public IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
{
return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None);
}
Expand All @@ -219,12 +219,12 @@ public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(str
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
public IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options);
return _client.ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, options).ToObservable();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public async Task RequestsCorrectUrl()

await client.ListAllRunnerGroupOrganizationsForEnterprise("fake", 1);

connection.Received().GetAll<Organization>(
connection.Received().GetAll<OrganizationsResponse>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runner-groups/1/organizations"), Args.ApiOptions);
}

Expand Down Expand Up @@ -248,7 +248,7 @@ public async Task RequestsCorrectUrl()

await client.ListAllRunnerGroupRepositoriesForOrganization("fake", 1, ApiOptions.None);

connection.Received().GetAll<Repository>(
connection.Received().GetAll<RepositoriesResponse>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runner-groups/1/repositories"), Args.ApiOptions);
}

Expand Down
22 changes: 16 additions & 6 deletions Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public async Task<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(strin
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")]
public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
public Task<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
{
return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None);
}
Expand All @@ -218,11 +218,16 @@ public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnter
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")]
public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
public async Task<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));

return ApiConnection.GetAll<Organization>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options);
var results = await ApiConnection.GetAll<OrganizationsResponse>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options).ConfigureAwait(false);

return new OrganizationsResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Organizations).ToList()
);
}

/// <summary>
Expand All @@ -234,7 +239,7 @@ public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnter
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")]
public Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
public Task<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
{
return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None);
}
Expand All @@ -249,11 +254,16 @@ public Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganiza
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")]
public Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
public async Task<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));

return ApiConnection.GetAll<Repository>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options);
var results = await ApiConnection.GetAll<RepositoriesResponse>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options).ConfigureAwait(false);

return new RepositoriesResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Repositories).ToList()
);
}
}
}
8 changes: 4 additions & 4 deletions Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public interface IActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);
Task<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);

/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
Expand All @@ -130,7 +130,7 @@ public interface IActionsSelfHostedRunnerGroupsClient
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);
Task<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -140,7 +140,7 @@ public interface IActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);
Task<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -151,6 +151,6 @@ public interface IActionsSelfHostedRunnerGroupsClient
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
Task<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
}
}
32 changes: 32 additions & 0 deletions Octokit/Models/Response/OrganizationsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;

namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class OrganizationsResponse
{
public OrganizationsResponse()
{
}

public OrganizationsResponse(int totalCount, IReadOnlyList<Repository> organizations)
{
TotalCount = totalCount;
Organizations = organizations;
}

/// <summary>
/// The total number of organizations
/// </summary>
public int TotalCount { get; private set; }

/// <summary>
/// The retrieved organizations
/// </summary>
public IReadOnlyList<Repository> Organizations { get; private set; }

internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Organizations: {1}", TotalCount, Organizations.Count);
}
}
4 changes: 2 additions & 2 deletions Octokit/Models/Response/RepositoriesResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public RepositoriesResponse(int totalCount, IReadOnlyList<Repository> repositori
}

/// <summary>
/// The total number of check suites that match the request filter
/// The total number of repositories
/// </summary>
public int TotalCount { get; private set; }

/// <summary>
/// The retrieved check suites
/// The retrieved repositories
/// </summary>
public IReadOnlyList<Repository> Repositories { get; private set; }

Expand Down
Loading