Skip to content

Commit

Permalink
Add new webhook filters
Browse files Browse the repository at this point in the history
  • Loading branch information
winklertomas authored and pokornyd committed Feb 5, 2024
1 parent fa3ae84 commit 8644a10
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 20 deletions.
19 changes: 18 additions & 1 deletion Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,11 @@ public async void PostWebhook()
new ContentTypeActionModel { Action = ContentTypeAction.Created },
new ContentTypeActionModel { Action = ContentTypeAction.Changed },
new ContentTypeActionModel { Action = ContentTypeAction.Deleted }
},
Filters = new ContentTypeFiltersModel {
ContentTypes = new [] {
Reference.ById(Guid.Parse("dd1439d5-4ee2-4895-a4e4-5b0d9d8c754e"))
}
}
},
ContentItem = new ContentItemTriggerModel
Expand Down Expand Up @@ -1455,6 +1460,12 @@ public async void PostWebhook()
{
new TaxonomyActionModel { Action = TaxonomyAction.TermChanged },
new TaxonomyActionModel { Action = TaxonomyAction.MetadataChanged }
},
Filters = new TaxonomyFiltersModel
{
Taxonomies = new[] {
Reference.ById(Guid.Parse("dd1439d5-4ee2-4895-a4e4-5b0d9d8c754e"))
}
}
},
Asset = new AssetTriggerModel
Expand All @@ -1472,9 +1483,15 @@ public async void PostWebhook()
Actions = new []
{
new LanguageActionModel { Action = LanguageAction.Created }
},
Filters = new LanguageFiltersModel
{
Languages = new[] {
Reference.ById(Guid.Parse("1aeb9220-f167-4f8e-a7db-1bfec365fa80"))
}
}
},
Slot = DeliverySlot.Published,
Slot = DeliverySlot.Preview,
Events = WebhookEvents.Specific
}
});
Expand Down
2 changes: 1 addition & 1 deletion Kontent.Ai.Management.Tests/CodeSamples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Info

This folder is ment to be for creating code camples. This should help to create code samples that are compilable.
This folder is ment to be for creating code samples. This should help to create code samples that are compilable.

Once the code sample are bing merged here, update also code samples sources => https://github.com/KenticoDocs/kontent-docs-samples/tree/master/net
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
{
"action": "created"
}
]
],
"filters": {
"content_types": [
{
"id": "dd1439d5-4ee2-4895-a4e4-5b0d9d8c754e"
}
]
}
},
"content_item": {
"enabled": true,
Expand All @@ -40,7 +47,7 @@
"filters": {
"languages": [
{
"id" : "1aeb9220-f167-4f8e-a7db-1bfec365fa80"
"id": "1aeb9220-f167-4f8e-a7db-1bfec365fa80"
}
]
}
Expand All @@ -54,7 +61,14 @@
{
"action": "metadata_changed"
}
]
],
"filters": {
"taxonomies": [
{
"id": "bef9dd62-a3b8-4146-83e4-33be707899b4"
}
]
}
},
"asset": {
"enabled": true,
Expand All @@ -73,7 +87,14 @@
{
"action": "created"
}
]
],
"filters": {
"languages": [
{
"id": "1aeb9220-f167-4f8e-a7db-1bfec365fa80"
}
]
}
},
"slot": "published",
"events": "all"
Expand Down
15 changes: 12 additions & 3 deletions Kontent.Ai.Management.Tests/Data/CodeSamples/Webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
{
"action": "created"
}
]
],
"filters": {
"content_types": []
}
},
"content_item": {
"enabled": true,
Expand Down Expand Up @@ -54,7 +57,10 @@
{
"action": "metadata_changed"
}
]
],
"filters": {
"taxonomies": []
}
},
"asset": {
"enabled": true,
Expand All @@ -79,7 +85,10 @@
{
"action": "created"
}
]
],
"filters": {
"languages": []
}
},
"slot": "published",
"events": "all"
Expand Down
15 changes: 12 additions & 3 deletions Kontent.Ai.Management.Tests/Data/CodeSamples/Webhooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
{
"action": "created"
}
]
],
"filters": {
"content_types": []
}
},
"content_item": {
"enabled": true,
Expand Down Expand Up @@ -55,7 +58,10 @@
{
"action": "metadata_changed"
}
]
],
"filters": {
"taxonomies": []
}
},
"asset": {
"enabled": true,
Expand All @@ -80,7 +86,10 @@
{
"action": "created"
}
]
],
"filters": {
"languages": []
}
},
"slot": "published",
"events": "all"
Expand Down
15 changes: 12 additions & 3 deletions Kontent.Ai.Management.Tests/Data/Webhook/Webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
{
"action": "created"
}
]
],
"filters": {
"content_types": []
}
},
"content_item": {
"enabled": true,
Expand Down Expand Up @@ -66,7 +69,10 @@
{
"action": "terms_moved"
}
]
],
"filters": {
"taxonomies": []
}
},
"asset": {
"enabled": true,
Expand Down Expand Up @@ -97,7 +103,10 @@
{
"action": "created"
}
]
],
"filters": {
"languages": []
}
},
"slot": "published",
"events": "all"
Expand Down
25 changes: 20 additions & 5 deletions Kontent.Ai.Management.Tests/Data/Webhook/Webhooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
{
"action": "terms_moved"
}
]
],
"filters": {
"taxonomies": []
}
},
"asset": {
"enabled": true,
Expand Down Expand Up @@ -98,7 +101,10 @@
{
"action": "created"
}
]
],
"filters": {
"languages": []
}
},
"slot": "published",
"events": "all"
Expand All @@ -121,7 +127,10 @@
{
"action": "created"
}
]
],
"filters": {
"content_types": []
}
},
"content_item": {
"enabled": true,
Expand Down Expand Up @@ -155,7 +164,10 @@
},
"taxonomy": {
"enabled": false,
"actions": []
"actions": [],
"filters": {
"taxonomies": []
}
},
"asset": {
"enabled": true,
Expand All @@ -180,7 +192,10 @@
{
"action": "deleted"
}
]
],
"filters": {
"languages": []
}
},
"slot": "preview",
"events": "specific"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Kontent.Ai.Management.Models.Webhooks.Triggers.ContentType;

/// <summary>
/// Represents the content type filters model.
/// </summary>
public class ContentTypeFiltersModel
{
/// <summary>
/// References to content types
/// </summary>
[JsonProperty("content_types")]
public IEnumerable<Reference> ContentTypes { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ public class ContentTypeTriggerModel
/// </summary>
[JsonProperty("actions")]
public IEnumerable<ContentTypeActionModel> Actions { get; set; }

/// <summary>
/// Represents content type filters.
/// More info: https://kontent.ai/learn/docs/apis/openapi/management-api-v2/#section/Webhook-object
/// </summary>
[JsonProperty("filters")]
public ContentTypeFiltersModel Filters { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Kontent.Ai.Management.Models.Webhooks.Triggers.Language;

/// <summary>
/// Represents the language filters model.
/// </summary>
public class LanguageFiltersModel
{
/// <summary>
/// References to languages
/// </summary>
[JsonProperty("languages")]
public IEnumerable<Reference> Languages { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ public class LanguageTriggerModel
/// </summary>
[JsonProperty("actions")]
public IEnumerable<LanguageActionModel> Actions { get; set; }

/// <summary>
/// Represents language filters.
/// More info: https://kontent.ai/learn/docs/apis/openapi/management-api-v2/#section/Webhook-object
/// </summary>
[JsonProperty("filters")]
public LanguageFiltersModel Filters { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Kontent.Ai.Management.Models.Webhooks.Triggers.Taxonomy;

/// <summary>
/// Represents the taxonomy filters model.
/// </summary>
public class TaxonomyFiltersModel
{
/// <summary>
/// References to taxonomies
/// </summary>
[JsonProperty("taxonomies")]
public IEnumerable<Reference> Taxonomies { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ public class TaxonomyTriggerModel
/// </summary>
[JsonProperty("actions")]
public IEnumerable<TaxonomyActionModel> Actions { get; set; }

/// <summary>
/// Represents taxonomy filters.
/// More info: https://kontent.ai/learn/docs/apis/openapi/management-api-v2/#section/Webhook-object
/// </summary>
[JsonProperty("filters")]
public TaxonomyFiltersModel Filters { get; set; }
}

0 comments on commit 8644a10

Please sign in to comment.