From 518da9c52ebd943f354595f8f38d436bf94a8339 Mon Sep 17 00:00:00 2001 From: VladimirOplustil Date: Thu, 14 Mar 2024 10:37:48 +0100 Subject: [PATCH 1/2] Fix mistake in patch summaries --- .../Models/AssetFolders/Patch/AssetFolderAddIntoModel.cs | 2 +- .../TaxonomyGroups/Patch/TaxonomyGroupAddIntoPatchModel.cs | 2 +- .../TypeSnippets/Patch/ContentTypeSnippetAddIntoPatchModel.cs | 2 +- .../Models/Types/Patch/ContentTypeAddIntoPatchModel.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kontent.Ai.Management/Models/AssetFolders/Patch/AssetFolderAddIntoModel.cs b/Kontent.Ai.Management/Models/AssetFolders/Patch/AssetFolderAddIntoModel.cs index eefe7337..6236669b 100644 --- a/Kontent.Ai.Management/Models/AssetFolders/Patch/AssetFolderAddIntoModel.cs +++ b/Kontent.Ai.Management/Models/AssetFolders/Patch/AssetFolderAddIntoModel.cs @@ -27,7 +27,7 @@ public class AssetFolderAddIntoModel : AssetFolderOperationBaseModel public Reference Before { get; set; } /// - /// Gets or sets reference of the existing folder before which you want to add the new folder. + /// Gets or sets reference of the existing folder after which you want to add the new folder. /// Note: The before and after properties are mutually exclusive. /// [JsonProperty("after")] diff --git a/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupAddIntoPatchModel.cs b/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupAddIntoPatchModel.cs index 4540c793..a5b8e576 100644 --- a/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupAddIntoPatchModel.cs +++ b/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupAddIntoPatchModel.cs @@ -28,7 +28,7 @@ public class TaxonomyGroupAddIntoPatchModel : TaxonomyGroupOperationBaseModel public Reference Before { get; set; } /// - /// Gets or sets reference of the existing taxonomy term before which you want to add the new taxonomy term. + /// Gets or sets reference of the existing taxonomy term after which you want to add the new taxonomy term. /// Note: The before and after properties are mutually exclusive. /// [JsonProperty("after")] diff --git a/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetAddIntoPatchModel.cs b/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetAddIntoPatchModel.cs index f8a827ad..922eb5c8 100644 --- a/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetAddIntoPatchModel.cs +++ b/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetAddIntoPatchModel.cs @@ -29,7 +29,7 @@ public class ContentTypeSnippetAddIntoPatchModel : ContentTypeSnippetOperationBa public Reference Before { get; set; } /// - /// Gets or sets reference of the existing object before which you want to add the new object. + /// Gets or sets reference of the existing object after which you want to add the new object. /// Note: The before and after properties are mutually exclusive. /// [JsonProperty("after")] diff --git a/Kontent.Ai.Management/Models/Types/Patch/ContentTypeAddIntoPatchModel.cs b/Kontent.Ai.Management/Models/Types/Patch/ContentTypeAddIntoPatchModel.cs index 2cb04dce..b5592ac4 100644 --- a/Kontent.Ai.Management/Models/Types/Patch/ContentTypeAddIntoPatchModel.cs +++ b/Kontent.Ai.Management/Models/Types/Patch/ContentTypeAddIntoPatchModel.cs @@ -29,7 +29,7 @@ public class ContentTypeAddIntoPatchModel : ContentTypeOperationBaseModel public Reference Before { get; set; } /// - /// Gets or sets reference of the existing object before which you want to add the new object. + /// Gets or sets reference of the existing object after which you want to add the new object. /// Note: The before and after properties are mutually exclusive. /// [JsonProperty("after")] From 03d4e039429d48d0bd87ea924949551af163daa0 Mon Sep 17 00:00:00 2001 From: VladimirOplustil Date: Mon, 18 Mar 2024 10:50:39 +0100 Subject: [PATCH 2/2] Add move operation to type, snippet and taxonomy PATCH --- .../CodeSamples/CmApiV2.cs | 25 +++++++++++++ .../ContentTypeSnippetTests.cs | 4 ++ .../ManagementClientTests/ContentTypeTests.cs | 4 ++ .../TaxonomyGroupTests.cs | 4 ++ .../Patch/TaxonomyGroupMovePatchModel.cs | 37 +++++++++++++++++++ .../Patch/ContentTypeSnippetPatchMoveModel.cs | 30 +++++++++++++++ .../Types/Patch/ContentTypeMovePatchModel.cs | 30 +++++++++++++++ 7 files changed, 134 insertions(+) create mode 100644 Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupMovePatchModel.cs create mode 100644 Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetPatchMoveModel.cs create mode 100644 Kontent.Ai.Management/Models/Types/Patch/ContentTypeMovePatchModel.cs diff --git a/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs b/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs index 6b12f425..e4c6d135 100644 --- a/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs +++ b/Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs @@ -846,6 +846,16 @@ public async void PatchSnippet() new ContentTypeSnippetPatchRemoveModel { Path = "/elements/external_id:my-multiple-choice-id/options/codename:my_option" + }, + new ContentTypeSnippetPatchMoveModel + { + Path = "/elements/codename:my_metadata_snippet__my_meta_title", + After = Reference.ByCodename("my_metadata_snippet__my_meta_description") + }, + new ContentTypeSnippetPatchMoveModel + { + Path = "/elements/external_id:my-multiple-choice-id/options/id:8e6ec8b1-6510-4b9b-b4be-6c977f4bdfbc", + Before = Reference.ById(Guid.Parse("6bfe5a60-5cc2-4303-8f72-9cc53431046b")) } }); @@ -908,6 +918,11 @@ public async void PatchTaxonomyGroup() ExternalId = "my-new-term", Terms = Array.Empty() } + }, + new TaxonomyGroupMovePatchModel + { + Reference = Reference.ByExternalId("my-new-term"), + Before = Reference.ByCodename("first_term") } }); @@ -959,6 +974,16 @@ public async void PatchContentType() new ContentTypeRemovePatchModel { Path = "/elements/id:0b2015d0-16ae-414a-85f9-7e1a4b3a3eae" + }, + new ContentTypeMovePatchModel + { + Path = "/elements/codename:my_text_element", + After = Reference.ByExternalId("my-title-id") + }, + new ContentTypeMovePatchModel + { + Path = "/elements/external_id:my-multiple-choice-id/options/id:d66ffa49-86ff-eeaa-c33b-e5d9eefe8b81", + Before = Reference.ById(Guid.Parse("523e6231-8d80-a158-3601-dffde4e64a78")) } }); diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeSnippetTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeSnippetTests.cs index 8e72ff96..9b307a6e 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeSnippetTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeSnippetTests.cs @@ -304,6 +304,10 @@ public async void ModifyContentTypeSnippetAsync_NoChanges_Throws() }, After = Reference.ByCodename("personas"), Path = "/elements" + }, + new ContentTypeSnippetPatchMoveModel { + Path = "/elements/codename:summary", + After = Reference.ByCodename("personas") } }; diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeTests.cs index a7f91c9b..70b73f6f 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/ContentTypeTests.cs @@ -303,6 +303,10 @@ public async void ModifyContentTypeAsync_NoChanges_Throws() }, Before = Reference.ByCodename("theme"), Path = "/elements" + }, + new ContentTypeMovePatchModel { + Path = "/elements/codename:display_options", + After = Reference.ByCodename("theme") } }; } diff --git a/Kontent.Ai.Management.Tests/ManagementClientTests/TaxonomyGroupTests.cs b/Kontent.Ai.Management.Tests/ManagementClientTests/TaxonomyGroupTests.cs index 1e0d9d2a..c5541347 100644 --- a/Kontent.Ai.Management.Tests/ManagementClientTests/TaxonomyGroupTests.cs +++ b/Kontent.Ai.Management.Tests/ManagementClientTests/TaxonomyGroupTests.cs @@ -296,6 +296,10 @@ public async void ModifyTaxonomyGroupAsync_IdentifierIsNull_Throws() ExternalId = "b378225f-6dfc-e261-3848-dd030a6d7883", Terms = Array.Empty() } + }, + new TaxonomyGroupMovePatchModel { + Reference = Reference.ByCodename("chemex"), + Under = Reference.ByCodename("hario") } }; } diff --git a/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupMovePatchModel.cs b/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupMovePatchModel.cs new file mode 100644 index 00000000..44ff250f --- /dev/null +++ b/Kontent.Ai.Management/Models/TaxonomyGroups/Patch/TaxonomyGroupMovePatchModel.cs @@ -0,0 +1,37 @@ +using Kontent.Ai.Management.Models.Shared; +using Newtonsoft.Json; + +namespace Kontent.Ai.Management.Models.TaxonomyGroups.Patch; + +/// +/// Represents the move operation. +/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-taxonomy-group +/// +public class TaxonomyGroupMovePatchModel : TaxonomyGroupOperationBaseModel +{ + /// + /// Represents the move operation. + /// + public override string Op => "move"; + + /// + /// Gets or sets reference of the existing taxonomy term before which you want to move the specified taxonomy term. + /// Note: The before, after and under properties are mutually exclusive. + /// + [JsonProperty("before")] + public Reference Before { get; set; } + + /// + /// Gets or sets reference of the existing taxonomy term after which you want to move the specified taxonomy term. + /// Note: The before, after and under properties are mutually exclusive. + /// + [JsonProperty("after")] + public Reference After { get; set; } + + /// + /// Gets or sets reference of the existing taxonomy term under which you want to move the specified taxonomy term. + /// Note: The before, after and under properties are mutually exclusive. + /// + [JsonProperty("under")] + public Reference Under { get; set; } +} \ No newline at end of file diff --git a/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetPatchMoveModel.cs b/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetPatchMoveModel.cs new file mode 100644 index 00000000..60580d23 --- /dev/null +++ b/Kontent.Ai.Management/Models/TypeSnippets/Patch/ContentTypeSnippetPatchMoveModel.cs @@ -0,0 +1,30 @@ +using Kontent.Ai.Management.Models.Shared; +using Newtonsoft.Json; + +namespace Kontent.Ai.Management.Models.TypeSnippets.Patch; + +/// +/// Represents the move operation. +/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-content-type-snippet +/// +public class ContentTypeSnippetPatchMoveModel : ContentTypeSnippetOperationBaseModel +{ + /// + /// Represents the move operation. + /// + public override string Op => "move"; + + /// + /// Gets or sets reference of the existing object before which you want to move the specified object. + /// Note: The before and after properties are mutually exclusive. + /// + [JsonProperty("before")] + public Reference Before { get; set; } + + /// + /// Gets or sets reference of the existing object after which you want to move the specified object. + /// Note: The before and after properties are mutually exclusive. + /// + [JsonProperty("after")] + public Reference After { get; set; } +} \ No newline at end of file diff --git a/Kontent.Ai.Management/Models/Types/Patch/ContentTypeMovePatchModel.cs b/Kontent.Ai.Management/Models/Types/Patch/ContentTypeMovePatchModel.cs new file mode 100644 index 00000000..2fac343f --- /dev/null +++ b/Kontent.Ai.Management/Models/Types/Patch/ContentTypeMovePatchModel.cs @@ -0,0 +1,30 @@ +using Kontent.Ai.Management.Models.Shared; +using Newtonsoft.Json; + +namespace Kontent.Ai.Management.Models.Types.Patch; + +/// +/// Represents the move operation. +/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-content-type +/// +public class ContentTypeMovePatchModel : ContentTypeOperationBaseModel +{ + /// + /// Represents the move operation. + /// + public override string Op => "move"; + + /// + /// Gets or sets reference of the existing object before which you want to move the specified object. + /// Note: The before and after properties are mutually exclusive. + /// + [JsonProperty("before")] + public Reference Before { get; set; } + + /// + /// Gets or sets reference of the existing object after which you want to move the specified object. + /// Note: The before and after properties are mutually exclusive. + /// + [JsonProperty("after")] + public Reference After { get; set; } +} \ No newline at end of file