Skip to content

Commit

Permalink
Add move operation to type, snippet and taxonomy PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirO-kontent committed Mar 18, 2024
1 parent 518da9c commit 03d4e03
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Kontent.Ai.Management.Tests/CodeSamples/CmApiV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
});

Expand Down Expand Up @@ -908,6 +918,11 @@ public async void PatchTaxonomyGroup()
ExternalId = "my-new-term",
Terms = Array.Empty<TaxonomyTermCreateModel>()
}
},
new TaxonomyGroupMovePatchModel
{
Reference = Reference.ByExternalId("my-new-term"),
Before = Reference.ByCodename("first_term")
}
});

Expand Down Expand Up @@ -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"))
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ public async void ModifyTaxonomyGroupAsync_IdentifierIsNull_Throws()
ExternalId = "b378225f-6dfc-e261-3848-dd030a6d7883",
Terms = Array.Empty<TaxonomyTermCreateModel>()
}
},
new TaxonomyGroupMovePatchModel {
Reference = Reference.ByCodename("chemex"),
Under = Reference.ByCodename("hario")
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;

namespace Kontent.Ai.Management.Models.TaxonomyGroups.Patch;

/// <summary>
/// Represents the move operation.
/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-taxonomy-group
/// </summary>
public class TaxonomyGroupMovePatchModel : TaxonomyGroupOperationBaseModel
{
/// <summary>
/// Represents the move operation.
/// </summary>
public override string Op => "move";

/// <summary>
/// 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.
/// </summary>
[JsonProperty("before")]
public Reference Before { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonProperty("after")]
public Reference After { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonProperty("under")]
public Reference Under { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;

namespace Kontent.Ai.Management.Models.TypeSnippets.Patch;

/// <summary>
/// Represents the move operation.
/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-content-type-snippet
/// </summary>
public class ContentTypeSnippetPatchMoveModel : ContentTypeSnippetOperationBaseModel
{
/// <summary>
/// Represents the move operation.
/// </summary>
public override string Op => "move";

/// <summary>
/// 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.
/// </summary>
[JsonProperty("before")]
public Reference Before { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonProperty("after")]
public Reference After { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Kontent.Ai.Management.Models.Shared;
using Newtonsoft.Json;

namespace Kontent.Ai.Management.Models.Types.Patch;

/// <summary>
/// Represents the move operation.
/// More info: https://kontent.ai/learn/reference/management-api-v2#operation/modify-a-content-type
/// </summary>
public class ContentTypeMovePatchModel : ContentTypeOperationBaseModel
{
/// <summary>
/// Represents the move operation.
/// </summary>
public override string Op => "move";

/// <summary>
/// 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.
/// </summary>
[JsonProperty("before")]
public Reference Before { get; set; }

/// <summary>
/// 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.
/// </summary>
[JsonProperty("after")]
public Reference After { get; set; }
}

0 comments on commit 03d4e03

Please sign in to comment.