Add missing properties for meta and app payloads (#2625)

* Add missing properties for meta and app payloads

* Update test with actual value instead of null

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
This commit is contained in:
Matisse Hack
2022-12-01 16:38:54 -08:00
committed by GitHub
parent 64614ce1d3
commit 0475f084f0
5 changed files with 231 additions and 73 deletions
+2 -1
View File
@@ -23,7 +23,8 @@ namespace Octokit.Tests.Clients
new[] { "1.1.6.1/24", "1.1.6.2/24" },
new[] { "1.1.7.1", "1.1.7.2" },
new[] { "1.1.8.1/24", "1.1.8.2/24" },
new[] { "1.1.9.1", "1.1.9.2" }
new[] { "1.1.9.1", "1.1.9.2" },
"3.7.0"
);
@@ -156,7 +156,8 @@ namespace Octokit.Tests.Clients
new[] { "1.1.6.1/24", "1.1.6.2/24" },
new[] { "1.1.7.1", "1.1.7.2" },
new[] { "1.1.8.1/24", "1.1.8.2/24" },
new[] { "1.1.9.1", "1.1.9.2" }
new[] { "1.1.9.1", "1.1.9.2" },
"3.7.0"
);
var apiConnection = Substitute.For<IApiConnection>();
+14 -1
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -12,7 +13,7 @@ namespace Octokit
{
public GitHubApp() { }
public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt)
public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, InstallationPermissions permissions, IReadOnlyList<string> events)
{
Id = id;
Slug = slug;
@@ -23,6 +24,8 @@ namespace Octokit
HtmlUrl = htmlUrl;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Permissions = permissions;
Events = events;
}
/// <summary>
@@ -70,6 +73,16 @@ namespace Octokit
/// </summary>
public DateTimeOffset UpdatedAt { get; private set; }
/// <summary>
/// The Permissions granted to the Installation
/// </summary>
public InstallationPermissions Permissions { get; private set; }
/// <summary>
/// The Events subscribed to by the Installation
/// </summary>
public IReadOnlyList<string> Events { get; private set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name); }
@@ -9,111 +9,246 @@ namespace Octokit
{
public InstallationPermissions() { }
public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks)
public InstallationPermissions
(
InstallationPermissionLevel? actions,
InstallationPermissionLevel? administration,
InstallationPermissionLevel? checks,
InstallationPermissionLevel? contents,
InstallationPermissionLevel? deployments,
InstallationPermissionLevel? environments,
InstallationPermissionLevel? issues,
InstallationPermissionLevel? metadata,
InstallationPermissionLevel? packages,
InstallationPermissionLevel? pages,
InstallationPermissionLevel? pullRequests,
InstallationPermissionLevel? repositoryAnnouncementBanners,
InstallationPermissionLevel? repositoryHooks,
InstallationPermissionLevel? repositoryProjects,
InstallationPermissionLevel? secretScanningAlerts,
InstallationPermissionLevel? secrets,
InstallationPermissionLevel? securityEvents,
InstallationPermissionLevel? singleFile,
InstallationPermissionLevel? statuses,
InstallationPermissionLevel? vulnerabilityAlerts,
InstallationPermissionLevel? workflows,
InstallationPermissionLevel? members,
InstallationPermissionLevel? organizationAdministration,
InstallationPermissionLevel? organizationCustomRoles,
InstallationPermissionLevel? organizationAnnouncementBanners,
InstallationPermissionLevel? organizationHooks,
InstallationPermissionLevel? organizationPlan,
InstallationPermissionLevel? organizationProjects,
InstallationPermissionLevel? organizationPackages,
InstallationPermissionLevel? organizationSecrets,
InstallationPermissionLevel? organizationSelfHostedRunners,
InstallationPermissionLevel? organizationUserBlocking,
InstallationPermissionLevel? teamDiscussions
)
{
Metadata = metadata;
Actions = actions;
Administration = administration;
Statuses = statuses;
Checks = checks;
Contents = contents;
Deployments = deployments;
Environments = environments;
Issues = issues;
Metadata = metadata;
Packages = packages;
Pages = pages;
PullRequests = pullRequests;
Contents = contents;
SingleFile = singleFile;
RepositoryAnnouncementBanners = repositoryAnnouncementBanners;
RepositoryHooks = repositoryHooks;
RepositoryProjects = repositoryProjects;
SecretScanningAlerts = secretScanningAlerts;
Secrets = secrets;
SecurityEvents = securityEvents;
SingleFile = singleFile;
Statuses = statuses;
VulnerabilityAlerts = vulnerabilityAlerts;
Workflows = workflows;
Members = members;
OrganizationAdministration = organizationAdministration;
OrganizationCustomRoles = organizationCustomRoles;
OrganizationAnnouncementBanners = organizationAnnouncementBanners;
OrganizationHooks = organizationHooks;
OrganizationPlan = organizationPlan;
OrganizationProjects = organizationProjects;
OrganizationPackages = organizationPackages;
OrganizationSecrets = organizationSecrets;
OrganizationSelfHostedRunners = organizationSelfHostedRunners;
OrganizationUserBlocking = organizationUserBlocking;
TeamDiscussions = teamDiscussions;
Checks = checks;
}
/// <summary>
/// Repository metadata
/// Search repositories, list collaborators, and access repository metadata.
/// The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; }
public StringEnum<InstallationPermissionLevel>? Actions { get; private set; }
/// <summary>
/// Repository administration
/// Repository creation, deletion, settings, teams, and collaborators.
/// The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Administration { get; private set; }
/// <summary>
/// Commit statuses
/// Commit statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; }
/// <summary>
/// Deployments
/// Deployments and deployment statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; }
/// <summary>
/// Issues
/// Issues and related comments, assignees, labels, and milestones.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Issues { get; private set; }
/// <summary>
/// Pages
/// Retrieve Pages statuses, configuration, and builds, as well as create new builds.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Pages { get; private set; }
/// <summary>
/// Pull requests
/// Pull requests and related comments, assignees, labels, milestones, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? PullRequests { get; private set; }
/// <summary>
/// Repository contents
/// Repository contents, commits, branches, downloads, releases, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Contents { get; private set; }
/// <summary>
/// Single file
/// Manage just a single file.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; }
/// <summary>
/// Repository projects
/// Manage repository projects, columns, and cards.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; private set; }
/// <summary>
/// Checks
/// Detailed information about CI checks
/// The level of permission to grant the access token for checks on code.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Checks { get; private set; }
/// <summary>
/// Organization members (only applicable when installed for an Organization )
/// Organization members and teams.
/// The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Contents { get; private set; }
/// <summary>
/// The level of permission to grant the access token for deployments and deployment statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; }
/// <summary>
/// The level of permission to grant the access token for managing repository environments.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Environments { get; private set; }
/// <summary>
/// The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Issues { get; private set; }
/// <summary>
/// The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; }
/// <summary>
/// The level of permission to grant the access token for packages published to GitHub Packages.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Packages { get; private set; }
/// <summary>
/// The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Pages { get; private set; }
/// <summary>
/// The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges.
/// </summary>
public StringEnum<InstallationPermissionLevel>? PullRequests { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage announcement banners for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryAnnouncementBanners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage the post-receive hooks for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryHooks { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage repository projects, columns, and cards.
/// </summary>
public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage secret scanning alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SecretScanningAlerts { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage repository secrets.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Secrets { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage security events like code scanning alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SecurityEvents { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage just a single file.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; }
/// <summary>
/// The level of permission to grant the access token for commit statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage Dependabot alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? VulnerabilityAlerts { get; private set; }
/// <summary>
/// The level of permission to grant the access token to update GitHub Actions workflow files.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Workflows { get; private set; }
/// <summary>
/// The level of permission to grant the access token for organization teams and members.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Members { get; private set; }
/// <summary>
/// Organization projects (only applicable when installed for an Organization )
/// Manage organization projects, columns, and cards.
/// The level of permission to grant the access token to manage access to an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationAdministration { get; private set; }
/// <summary>
/// The level of permission to grant the access token for custom roles management. This property is in beta and is subject to change.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationCustomRoles { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage announcement banners for an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationAnnouncementBanners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage the post-receive hooks for an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationHooks { get; private set; }
/// <summary>
/// The level of permission to grant the access token for viewing an organization's plan.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationPlan { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage organization projects and projects beta (where available).
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationProjects { get; private set; }
/// <summary>
/// Team discussions (only applicable when installed for an Organization )
/// Team discussions.
/// The level of permission to grant the access token for organization packages published to GitHub Packages.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationPackages { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage organization secrets.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationSecrets { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage GitHub Actions self-hosted runners available to an organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationSelfHostedRunners { get; private set; }
/// <summary>
/// The level of permission to grant the access token to view and manage users blocked by the organization.
/// </summary>
public StringEnum<InstallationPermissionLevel>? OrganizationUserBlocking { get; private set; }
/// <summary>
/// The level of permission to grant the access token to manage team discussions and related comments.
/// </summary>
public StringEnum<InstallationPermissionLevel>? TeamDiscussions { get; private set; }
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Metadata: {0}, Contents: {1}, Issues: {2}, Single File: {3}", Metadata, Contents, Issues, SingleFile); }
get => $"Actions: {Actions}, Administration: {Administration}, Checks: {Checks}, Contents: {Contents}, Deployments: {Deployments}, Environments: {Environments}, Issues: {Issues}, Metadata: {Metadata}, Packages: {Packages}, Pages: {Pages}, PullRequests: {PullRequests}, RepositoryAnnouncementBanners: {RepositoryAnnouncementBanners}, RepositoryHooks: {RepositoryHooks}, RepositoryProjects: {RepositoryProjects}, SecretScanningAlerts: {SecretScanningAlerts}, Secrets: {Secrets}, SecurityEvents: {SecurityEvents}, SingleFile: {SingleFile}, Statuses: {Statuses}, VulnerabilityAlerts: {VulnerabilityAlerts}, Workflows: {Workflows}, Members: {Members}, OrganizationAdministration: {OrganizationAdministration}, OrganizationCustomRoles: {OrganizationCustomRoles}, OrganizationAnnouncementBanners: {OrganizationAnnouncementBanners}, OrganizationHooks: {OrganizationHooks}, OrganizationPlan: {OrganizationPlan}, OrganizationProjects: {OrganizationProjects}, OrganizationPackages: {OrganizationPackages}, OrganizationSecrets: {OrganizationSecrets}, OrganizationSelfHostedRunners: {OrganizationSelfHostedRunners}, OrganizationUserBlocking: {OrganizationUserBlocking}, TeamDiscussions: {TeamDiscussions}";
}
}
+10 -2
View File
@@ -7,7 +7,7 @@ using Octokit.Internal;
namespace Octokit
{
/// <summary>
/// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance.
/// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Meta
@@ -33,6 +33,7 @@ namespace Octokit
/// <param name="importer">An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com.</param>
/// <param name="actions">An array of IP addresses in CIDR format specifying the Actions servers for GitHub</param>
/// <param name="dependabot">An array of IP addresses in CIDR format specifying the Dependabot servers for GitHub</param>
/// <param name="installedVersion">The installed version of GitHub Enterprise Server</param>
public Meta(
bool verifiablePasswordAuthentication,
string gitHubServicesSha,
@@ -44,7 +45,8 @@ namespace Octokit
IReadOnlyList<string> pages,
IReadOnlyList<string> importer,
IReadOnlyList<string> actions,
IReadOnlyList<string> dependabot)
IReadOnlyList<string> dependabot,
string installedVersion)
{
VerifiablePasswordAuthentication = verifiablePasswordAuthentication;
#pragma warning disable CS0618 // Type or member is obsolete
@@ -59,6 +61,7 @@ namespace Octokit
Importer = importer;
Actions = actions;
Dependabot = dependabot;
InstalledVersion = installedVersion;
}
/// <summary>
@@ -124,6 +127,11 @@ namespace Octokit
/// </summary>
public IReadOnlyList<string> Dependabot { get; private set; }
/// <summary>
/// The installed version of GitHub Enterprise Server.
/// </summary>
public string InstalledVersion { get; private set; }
internal string DebuggerDisplay
{
get