Skip to content

Commit

Permalink
Update payload types (#250)
Browse files Browse the repository at this point in the history
* feat: new app permissions

* feat: new `subject_type` property for `PullRequestReviewComment` events

* feat: new properties for `workflow_job` events

* feat: new `has_discussions` property on `Repository` schema

* fix: update schema for `organization.renamed` event

* fix: update types for `registry_package` event

* feat: add new properties to `merge_group` event

* feat: new properties found on the `repository` object

* feat: new `cve_id` for `SecurityAdvisoryEvent`

* misc fixes

* ci: update sample payloads
  • Loading branch information
JamieMagee authored Apr 24, 2023
1 parent b6e30b0 commit dcae15e
Show file tree
Hide file tree
Showing 39 changed files with 1,077 additions and 290 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace Octokit.Webhooks.Events.Organization;

using Octokit.Webhooks.Models.OrganizationEvent;

[PublicAPI]
[WebhookActionType(OrganizationActionValue.Renamed)]
public sealed record OrganizationRenamedEvent : OrganizationEvent
{
[JsonPropertyName("action")]
public override string Action => OrganizationAction.Renamed;

[JsonPropertyName("membership")]
public Octokit.Webhooks.Models.Membership Membership { get; init; } = null!;
[JsonPropertyName("changes")]
public Changes Changes { get; init; } = null!;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Octokit.Webhooks.Events.RegistryPackage;

[PublicAPI]
public sealed record RegistryPackageAction : WebhookEventAction
{
public static readonly RegistryPackageAction Published = new(RegistryPackageActionValue.Published);

public static readonly RegistryPackageAction Updated = new(RegistryPackageActionValue.Updated);

private RegistryPackageAction(string value)
: base(value)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Octokit.Webhooks.Events.RegistryPackage;

public static class RegistryPackageActionValue
{
public const string Published = "published";

public const string Updated = "updated";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Octokit.Webhooks.Events.RegistryPackage;

[PublicAPI]
[WebhookActionType(RegistryPackageActionValue.Published)]
public sealed record RegistryPackagePublishedEvent : RegistryPackageEvent
{
[JsonPropertyName("action")]
public override string Action => RegistryPackageAction.Published;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Octokit.Webhooks.Events.RegistryPackage;

[PublicAPI]
[WebhookActionType(RegistryPackageActionValue.Updated)]
public sealed record RegistryPackageUpdatedEvent : RegistryPackageEvent
{
[JsonPropertyName("action")]
public override string Action => RegistryPackageAction.Updated;
}
6 changes: 5 additions & 1 deletion src/Octokit.Webhooks/Events/RegistryPackageEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
[PublicAPI]
[WebhookEventType(WebhookEventType.RegistryPackage)]
[JsonConverter(typeof(WebhookConverter<RegistryPackageEvent>))]
public abstract record RegistryPackageEvent : WebhookEvent;
public abstract record RegistryPackageEvent : WebhookEvent
{
[JsonPropertyName("registry_package")]
public Models.Package Package { get; init; } = null!;
}
21 changes: 21 additions & 0 deletions src/Octokit.Webhooks/Models/AppPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,21 @@ public sealed record AppPermissions
[JsonPropertyName("environments")]
public AppPermissionsLevel? Environments { get; init; }

[JsonPropertyName("followers")]
public AppPermissionsLevel? Followers { get; init; }

[JsonPropertyName("gpg_keys")]
public AppPermissionsLevel? GpgKeys { get; init; }

[JsonPropertyName("interaction_limits")]
public AppPermissionsLevel? InteractionLimits { get; init; }

[JsonPropertyName("issues")]
public AppPermissionsLevel? Issues { get; init; }

[JsonPropertyName("keys")]
public AppPermissionsLevel? Keys { get; init; }

[JsonPropertyName("members")]
public AppPermissionsLevel? Members { get; init; }

Expand Down Expand Up @@ -75,6 +87,9 @@ public sealed record AppPermissions
[JsonPropertyName("pages")]
public AppPermissionsLevel? Pages { get; init; }

[JsonPropertyName("plan")]
public AppPermissionsLevel? Plan { get; init; }

[JsonPropertyName("pull_requests")]
public AppPermissionsLevel? PullRequests { get; init; }

Expand All @@ -99,6 +114,9 @@ public sealed record AppPermissions
[JsonPropertyName("single_file")]
public AppPermissionsLevel? SingleFile { get; init; }

[JsonPropertyName("starring")]
public AppPermissionsLevel? Starring { get; init; }

[JsonPropertyName("statuses")]
public AppPermissionsLevel? Statuses { get; init; }

Expand All @@ -108,6 +126,9 @@ public sealed record AppPermissions
[JsonPropertyName("vulnerability_alerts")]
public AppPermissionsLevel? VulnerabilityAlerts { get; init; }

[JsonPropertyName("watching")]
public AppPermissionsLevel? Watching { get; init; }

[JsonPropertyName("workflows")]
public AppPermissionsLevel? Workflows { get; init; }
}
14 changes: 14 additions & 0 deletions src/Octokit.Webhooks/Models/ContainerMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Octokit.Webhooks.Models;

[PublicAPI]
public sealed record ContainerMetadata
{
[JsonPropertyName("labels")]
public IDictionary<string, dynamic>? Labels { get; init; }

[JsonPropertyName("manifest")]
public IDictionary<string, dynamic>? Manifest { get; init; }

[JsonPropertyName("tag")]
public ContainerMetadataTag? Tag { get; init; }
}
11 changes: 11 additions & 0 deletions src/Octokit.Webhooks/Models/ContainerMetadataTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Octokit.Webhooks.Models;

[PublicAPI]
public sealed record ContainerMetadataTag
{
[JsonPropertyName("digest")]
public string? Digest { get; init; }

[JsonPropertyName("name")]
public string? Name { get; init; }
}
6 changes: 6 additions & 0 deletions src/Octokit.Webhooks/Models/MergeGroupEvent/MergeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public sealed record MergeGroup

[JsonPropertyName("base_ref")]
public string BaseRef { get; init; } = null!;

[JsonPropertyName("base_sha")]
public string BaseSha { get; init; } = null!;

[JsonPropertyName("head_commit")]
public SimpleCommit HeadCommit { get; init; } = null!;
}
8 changes: 8 additions & 0 deletions src/Octokit.Webhooks/Models/OrganizationEvent/Changes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Octokit.Webhooks.Models.OrganizationEvent;

[PublicAPI]
public sealed record Changes
{
[JsonPropertyName("login")]
public ChangesLogin Login { get; init; } = null!;
}
8 changes: 8 additions & 0 deletions src/Octokit.Webhooks/Models/OrganizationEvent/ChangesLogin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Octokit.Webhooks.Models.OrganizationEvent;

[PublicAPI]
public record ChangesLogin
{
[JsonPropertyName("from")]
public string From { get; init; } = null!;
}
4 changes: 2 additions & 2 deletions src/Octokit.Webhooks/Models/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed record Package
public string Ecosystem { get; init; } = null!;

[JsonPropertyName("package_type")]
public string PackageType { get; init; } = null!;
public PackageType PackageType { get; init; }

[JsonPropertyName("html_url")]
public string HtmlUrl { get; init; } = null!;
Expand All @@ -36,7 +36,7 @@ public sealed record Package
public User Owner { get; init; } = null!;

[JsonPropertyName("package_version")]
public PackageVersion PackageVersion { get; init; } = null!;
public PackageVersion? PackageVersion { get; init; }

[JsonPropertyName("registry")]
public PackageRegistry Registry { get; init; } = null!;
Expand Down
20 changes: 20 additions & 0 deletions src/Octokit.Webhooks/Models/PackageType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Octokit.Webhooks.Models;

[PublicAPI]
[JsonConverter(typeof(JsonStringEnumMemberConverterWithFallback))]
public enum PackageType
{
Unknown = -1,
[EnumMember(Value = "npm")]
Npm,
[EnumMember(Value = "maven")]
Maven,
[EnumMember(Value = "rubygems")]
RubyGems,
[EnumMember(Value = "docker")]
Docker,
[EnumMember(Value = "nuget")]
NuGet,
[EnumMember(Value = "CONTAINER")]
Container,
}
47 changes: 31 additions & 16 deletions src/Octokit.Webhooks/Models/PackageVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,72 @@ public sealed record PackageVersion
public string Description { get; init; } = null!;

[JsonPropertyName("body")]
public string Body { get; init; } = null!;
public dynamic? Body { get; init; }

[JsonPropertyName("body_html")]
public string BodyHtml { get; init; } = null!;
public string? BodyHtml { get; init; }

[JsonPropertyName("release")]
public PackageVersionRelease Release { get; init; } = null!;
public PackageVersionRelease? Release { get; init; }

[JsonPropertyName("manifest")]
public string Manifest { get; init; } = null!;
public string? Manifest { get; init; }

[JsonPropertyName("html_url")]
public string HtmlUrl { get; init; } = null!;

[JsonPropertyName("tag_name")]
public string TagName { get; init; } = null!;
public string? TagName { get; init; }

[JsonPropertyName("target_commitish")]
public string TargetCommitish { get; init; } = null!;
public string? TargetCommitish { get; init; }

[JsonPropertyName("target_oid")]
public string TargetOid { get; init; } = null!;
public string? TargetOid { get; init; }

[JsonPropertyName("draft")]
public bool Draft { get; init; }
public bool? Draft { get; init; }

[JsonPropertyName("prerelease")]
public bool Prerelease { get; init; }
public bool? Prerelease { get; init; }

[JsonPropertyName("created_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset CreatedAt { get; init; }
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? CreatedAt { get; init; }

[JsonPropertyName("updated_at")]
[JsonConverter(typeof(DateTimeOffsetConverter))]
public DateTimeOffset UpdatedAt { get; init; }
[JsonConverter(typeof(NullableDateTimeOffsetConverter))]
public DateTimeOffset? UpdatedAt { get; init; }

[JsonPropertyName("metadata")]
public IEnumerable<dynamic> Metadata { get; init; } = null!;

[JsonPropertyName("container_metadata")]
public ContainerMetadata? ContainerMetadata { get; init; }

[JsonPropertyName("docker_metadata")]
public IEnumerable<dynamic> DockerMetadata { get; init; } = null!;
public IEnumerable<dynamic>? DockerMetadata { get; init; }

[JsonPropertyName("npm_metadata")]
public IDictionary<string, dynamic>? NpmMetadata { get; init; }

[JsonPropertyName("nuget_metadata")]
public IDictionary<string, dynamic>? NugetMetadata { get; init; }

[JsonPropertyName("rubygems_metadata")]
public IDictionary<string, dynamic>? RubygemsMetadata { get; init; }

[JsonPropertyName("package_files")]
public IEnumerable<PackageVersionPackageFile> PackageFiles { get; init; } = null!;

[JsonPropertyName("package_url")]
public string? PackageUrl { get; init; }

[JsonPropertyName("author")]
public User Author { get; init; } = null!;
public User? Author { get; init; }

[JsonPropertyName("source_url")]
public string SourceUrl { get; init; } = null!;
public string? SourceUrl { get; init; }

[JsonPropertyName("installation_command")]
public string InstallationCommand { get; init; } = null!;
Expand Down
3 changes: 3 additions & 0 deletions src/Octokit.Webhooks/Models/PullRequestReviewComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,7 @@ public sealed record PullRequestReviewComment

[JsonPropertyName("in_reply_to_id")]
public int? InReplyToId { get; init; }

[JsonPropertyName("subject_type")]
public PullRequestReviewCommentSubjectType? SubjectType { get; init; }
}
12 changes: 12 additions & 0 deletions src/Octokit.Webhooks/Models/PullRequestReviewCommentSubjectType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Octokit.Webhooks.Models;

[PublicAPI]
[JsonConverter(typeof(JsonStringEnumMemberConverterWithFallback))]
public enum PullRequestReviewCommentSubjectType
{
Unknown = -1,
[EnumMember(Value = "line")]
Line,
[EnumMember(Value = "file")]
File,
}
15 changes: 15 additions & 0 deletions src/Octokit.Webhooks/Models/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public sealed record Repository
[JsonPropertyName("has_pages")]
public bool HasPages { get; init; }

[JsonPropertyName("has_discussions")]
public bool? HasDiscussions { get; init; }

[JsonPropertyName("forks_count")]
public long ForksCount { get; init; }

Expand Down Expand Up @@ -249,6 +252,18 @@ public sealed record Repository
[JsonPropertyName("use_squash_pr_title_as_default")]
public bool? UseSquashPrTitleAsDefault { get; init; }

[JsonPropertyName("squash_merge_commit_message")]
public string? SquashMergeCommitMessage { get; init; }

[JsonPropertyName("squash_merge_commit_title")]
public string? SquashMergeCommitTitle { get; init; }

[JsonPropertyName("merge_commit_message")]
public string? MergeCommitMessage { get; init; }

[JsonPropertyName("merge_commit_title")]
public string? MergeCommitTitle { get; init; }

[JsonPropertyName("is_template")]
public bool IsTemplate { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public sealed record SecurityAdvisory
[JsonPropertyName("ghsa_id")]
public string GhsaId { get; init; } = null!;

[JsonPropertyName("cve_id")]
public string? CveId { get; init; }

[JsonPropertyName("summary")]
public string Summary { get; init; } = null!;

Expand Down
9 changes: 9 additions & 0 deletions src/Octokit.Webhooks/Models/WorkflowJobEvent/WorkflowJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ public sealed record WorkflowJob

[JsonPropertyName("completed_at")]
public string? CompletedAt { get; init; }

[JsonPropertyName("workflow_name")]
public string? WorkflowName { get; init; }

[JsonPropertyName("head_branch")]
public string? HeadBranch { get; init; }

[JsonPropertyName("created_at")]
public string CreatedAt { get; init; } = null!;
}
Loading

0 comments on commit dcae15e

Please sign in to comment.