Skip to content

Commit 9fc75ba

Browse files
Custom Properties (custom_property and custom_property_values events) (#500)
* add test custom_property payloads * add test custom_property_values payload * custom_property custom_property_values app events * organization_custom_properties repository_custom_properties app permissions * add custom_properties to Repository * fix bug in (released) custom_property_values event * correct objects for custom_property_values events * correct objects for custom_property events * docs say values_editable_by can be null
1 parent 645eae2 commit 9fc75ba

File tree

19 files changed

+395
-62
lines changed

19 files changed

+395
-62
lines changed
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Octokit.Webhooks.Models.CustomProperty;
2-
31
namespace Octokit.Webhooks.Events.CustomProperty;
42

53
[PublicAPI]
@@ -9,19 +7,6 @@ public sealed record CustomPropertyCreatedEvent : CustomPropertyEvent
97
[JsonPropertyName("action")]
108
public override string Action => CustomPropertyAction.Created;
119

12-
[JsonPropertyName("value_type")]
13-
[JsonConverter(typeof(StringEnumConverter<CustomPropertyValueType>))]
14-
public StringEnum<CustomPropertyValueType> ValueType { get; init; } = null!;
15-
16-
[JsonPropertyName("default_value")]
17-
public string? DefaultValue { get; init; }
18-
19-
[JsonPropertyName("required")]
20-
public bool Required { get; init; }
21-
22-
[JsonPropertyName("description")]
23-
public string? Description { get; init; }
24-
25-
[JsonPropertyName("allowed_values")]
26-
public IEnumerable<string>? AllowedValues { get; init; }
10+
[JsonPropertyName("definition")]
11+
public Models.CustomPropertyEvent.CustomProperty CustomProperty { get; init; } = null!;
2712
}

src/Octokit.Webhooks/Events/CustomProperty/CustomPropertyDeletedEvent.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ public sealed record CustomPropertyDeletedEvent : CustomPropertyEvent
66
{
77
[JsonPropertyName("action")]
88
public override string Action => CustomPropertyAction.Deleted;
9+
10+
[JsonPropertyName("definition")]
11+
public Models.CustomPropertyEvent.CustomPropertyLite CustomProperty { get; init; } = null!;
912
}
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Octokit.Webhooks.Models.CustomProperty;
2-
31
namespace Octokit.Webhooks.Events.CustomProperty;
42

53
[PublicAPI]
@@ -9,19 +7,6 @@ public sealed record CustomPropertyUpdatedEvent : CustomPropertyEvent
97
[JsonPropertyName("action")]
108
public override string Action => CustomPropertyAction.Updated;
119

12-
[JsonPropertyName("value_type")]
13-
[JsonConverter(typeof(StringEnumConverter<CustomPropertyValueType>))]
14-
public StringEnum<CustomPropertyValueType> ValueType { get; init; } = null!;
15-
16-
[JsonPropertyName("default_value")]
17-
public string? DefaultValue { get; init; }
18-
19-
[JsonPropertyName("required")]
20-
public bool Required { get; init; }
21-
22-
[JsonPropertyName("description")]
23-
public string? Description { get; init; }
24-
25-
[JsonPropertyName("allowed_values")]
26-
public IEnumerable<string>? AllowedValues { get; init; }
10+
[JsonPropertyName("definition")]
11+
public Models.CustomPropertyEvent.CustomProperty CustomProperty { get; init; } = null!;
2712
}

src/Octokit.Webhooks/Events/CustomPropertyEvent.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ namespace Octokit.Webhooks.Events;
33
[PublicAPI]
44
[WebhookEventType(WebhookEventType.CustomProperty)]
55
[JsonConverter(typeof(WebhookConverter<CustomPropertyEvent>))]
6-
public abstract record CustomPropertyEvent : WebhookEvent
7-
{
8-
[JsonPropertyName("property_name")]
9-
public string PropertyName { get; init; } = null!;
10-
}
6+
public abstract record CustomPropertyEvent : WebhookEvent;

src/Octokit.Webhooks/Events/CustomPropertyValues/CustomPropertyValuesUpdatedEvent.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ namespace Octokit.Webhooks.Events.CustomPropertyValues;
22

33
[PublicAPI]
44
[WebhookActionType(CustomPropertyValuesActionValue.Updated)]
5-
public abstract record CustomPropertyValuesUpdatedEvent : CustomPropertyValuesEvent
5+
public sealed record CustomPropertyValuesUpdatedEvent : CustomPropertyValuesEvent
66
{
77
[JsonPropertyName("action")]
88
public override string Action => CustomPropertyValuesAction.Updated;
9+
10+
[JsonPropertyName("new_property_values")]
11+
public IEnumerable<Models.CustomPropertyValuesEvent.CustomPropertyValue> NewPropertyValues { get; init; } = null!;
12+
13+
[JsonPropertyName("old_property_values")]
14+
public IEnumerable<Models.CustomPropertyValuesEvent.CustomPropertyValue> OldPropertyValues { get; init; } = null!;
915
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
using Octokit.Webhooks.Models.CustomPropertyValues;
2-
31
namespace Octokit.Webhooks.Events;
42

53
[PublicAPI]
64
[WebhookEventType(WebhookEventType.CustomPropertyValues)]
75
[JsonConverter(typeof(WebhookConverter<CustomPropertyValuesEvent>))]
8-
public abstract record CustomPropertyValuesEvent : WebhookEvent
9-
{
10-
[JsonPropertyName("new_property_values")]
11-
public IEnumerable<CustomPropertyValue> NewPropertyValues { get; init; } = null!;
12-
13-
[JsonPropertyName("old_property_values")]
14-
public IEnumerable<CustomPropertyValue> OldPropertyValues { get; init; } = null!;
15-
}
6+
public abstract record CustomPropertyValuesEvent : WebhookEvent;

src/Octokit.Webhooks/Models/AppEvent.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public enum AppEvent
2121
ContentReference,
2222
[EnumMember(Value = "create")]
2323
Create,
24+
[EnumMember(Value = "custom_property")]
25+
CustomProperty,
26+
[EnumMember(Value = "custom_property_values")]
27+
CustomPropertyValues,
2428
[EnumMember(Value = "delete")]
2529
Delete,
2630
[EnumMember(Value = "deploy_key")]

src/Octokit.Webhooks/Models/AppPermissions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public sealed record AppPermissions
7474
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
7575
public StringEnum<AppPermissionsLevel>? OrganizationAdministration { get; init; }
7676

77+
[JsonPropertyName("organization_custom_properties")]
78+
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
79+
public StringEnum<AppPermissionsLevel>? OrganizationCustomProperties { get; init; }
80+
7781
[JsonPropertyName("organization_hooks")]
7882
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
7983
public StringEnum<AppPermissionsLevel>? OrganizationHooks { get; init; }
@@ -117,6 +121,10 @@ public sealed record AppPermissions
117121
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
118122
public StringEnum<AppPermissionsLevel>? PullRequests { get; init; }
119123

124+
[JsonPropertyName("repository_custom_properties")]
125+
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
126+
public StringEnum<AppPermissionsLevel>? RepositoryCustomProperties { get; init; }
127+
120128
[JsonPropertyName("repository_hooks")]
121129
[JsonConverter(typeof(StringEnumConverter<AppPermissionsLevel>))]
122130
public StringEnum<AppPermissionsLevel>? RepositoryHooks { get; init; }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace Octokit.Webhooks.Models.CustomPropertyEvent;
2+
3+
[PublicAPI]
4+
public sealed record CustomProperty
5+
{
6+
[JsonPropertyName("property_name")]
7+
public string PropertyName { get; init; } = null!;
8+
9+
[JsonPropertyName("value_type")]
10+
[JsonConverter(typeof(StringEnumConverter<CustomPropertyValueType>))]
11+
public StringEnum<CustomPropertyValueType> ValueType { get; init; } = null!;
12+
13+
[JsonPropertyName("required")]
14+
public bool Required { get; init; }
15+
16+
[JsonPropertyName("default_value")]
17+
public string? DefaultValue { get; init; }
18+
19+
[JsonPropertyName("description")]
20+
public string? Description { get; init; }
21+
22+
[JsonPropertyName("allowed_values")]
23+
public IEnumerable<string>? AllowedValues { get; init; }
24+
25+
[JsonPropertyName("values_editable_by")]
26+
[JsonConverter(typeof(StringEnumConverter<CustomPropertyValuesEditableBy>))]
27+
public StringEnum<CustomPropertyValuesEditableBy>? ValuesEditableBy { get; init; }
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Octokit.Webhooks.Models.CustomPropertyEvent;
2+
3+
[PublicAPI]
4+
public sealed record CustomPropertyLite
5+
{
6+
[JsonPropertyName("property_name")]
7+
public string PropertyName { get; init; } = null!;
8+
}

0 commit comments

Comments
 (0)