Skip to content

Commit

Permalink
Add missing properties for meta and app payloads (#2625)
Browse files Browse the repository at this point in the history
* Add missing properties for meta and app payloads

* Update test with actual value instead of null

Co-authored-by: Keegan Campbell <[email protected]>
  • Loading branch information
MatisseHack and kfcampbell authored Dec 2, 2022
1 parent 64614ce commit 0475f08
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 45 deletions.
3 changes: 2 additions & 1 deletion Octokit.Tests/Clients/MetaClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task RequestsTheMetadataEndpoint()
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"
);


Expand Down
3 changes: 2 additions & 1 deletion Octokit.Tests/Clients/MiscellaneousClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ public async Task RequestsTheMetadataEndpoint()
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>();
Expand Down
15 changes: 14 additions & 1 deletion Octokit/Models/Response/GitHubApp.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;

Expand All @@ -12,7 +13,7 @@ public class GitHubApp
{
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;
Expand All @@ -23,6 +24,8 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti
HtmlUrl = htmlUrl;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Permissions = permissions;
Events = events;
}

/// <summary>
Expand Down Expand Up @@ -70,6 +73,16 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti
/// </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); }
Expand Down
215 changes: 175 additions & 40 deletions Octokit/Models/Response/InstallationPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,111 +9,246 @@ public class InstallationPermissions
{
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.
/// The level of permission to grant the access token for checks on code.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; }
public StringEnum<InstallationPermissionLevel>? Checks { get; private set; }

/// <summary>
/// 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>
/// Deployments
/// Deployments and deployment statuses.
/// The level of permission to grant the access token for deployments and deployment statuses.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; }

/// <summary>
/// Issues
/// Issues and related comments, assignees, labels, and milestones.
/// 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>
/// Pages
/// Retrieve Pages statuses, configuration, and builds, as well as create new builds.
/// 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>
/// Pull requests
/// Pull requests and related comments, assignees, labels, milestones, and merges.
/// 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>
/// Repository contents
/// Repository contents, commits, branches, downloads, releases, and merges.
/// The level of permission to grant the access token to view and manage announcement banners for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Contents { get; private set; }
public StringEnum<InstallationPermissionLevel>? RepositoryAnnouncementBanners { get; private set; }

/// <summary>
/// Single file
/// Manage just a single file.
/// The level of permission to grant the access token to manage the post-receive hooks for a repository.
/// </summary>
public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; }
public StringEnum<InstallationPermissionLevel>? RepositoryHooks { get; private set; }

/// <summary>
/// Repository projects
/// Manage repository projects, columns, and cards.
/// 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>
/// Checks
/// Detailed information about CI checks
/// The level of permission to grant the access token to view and manage secret scanning alerts.
/// </summary>
public StringEnum<InstallationPermissionLevel>? Checks { get; private set; }
public StringEnum<InstallationPermissionLevel>? SecretScanningAlerts { 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 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}";
}
}

Expand Down
Loading

0 comments on commit 0475f08

Please sign in to comment.