Skip to content

Commit

Permalink
EN-326 Add custom apps code samples
Browse files Browse the repository at this point in the history
  • Loading branch information
František Záhora authored and František Záhora committed Nov 25, 2024
1 parent 5fe5eb1 commit ae3078e
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/management-api-v2/cm_api_v2_delete_custom_app.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// DocSection: cm_api_v2_delete_custom_app
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;

var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});

var identifier = Reference.ById(Guid.Parse("f4b3fc05-e988-4dae-9ac1-a94aba566474");
//var identifier = Reference.ByCodename("my_custom_app");

var response = await client.DeleteCustomAppAsync(identifier);
// EndDocSection
15 changes: 15 additions & 0 deletions net/management-api-v2/cm_api_v2_get_custom_app.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// DocSection: cm_api_v2_get_custom_app
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;

var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});

var identifier = Reference.ById(Guid.Parse("f4b3fc05-e988-4dae-9ac1-a94aba566474");
//var identifier = Reference.ByCodename("my_custom_app");

var response = await client.GetCustomAppAsync(identifier);
// EndDocSection
12 changes: 12 additions & 0 deletions net/management-api-v2/cm_api_v2_get_custom_apps.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// DocSection: cm_api_v2_get_custom_apps
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;

var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});

var response = await client.ListCustomAppsAsync();
// EndDocSection
61 changes: 61 additions & 0 deletions net/management-api-v2/cm_api_v2_patch_modify_custom_app.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// DocSection: cm_api_v2_patch_modify_custom_app
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;

var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});

var changes = new CustomAppOperationBaseModel[]
{
new CustomAppAddIntoPatchModel()
{
PropertyName = PropertyName.AllowedRoles,
Value = new[]
{
Reference.ByCodename("new_allowed_role_codename_to_be_add_into")
}
},
new CustomAppRemovePatchModel()
{
PropertyName = PropertyName.AllowedRoles,
Value = new[]
{
Reference.ByCodename("allowed_role_codename_to_be_removed")
}
},
new CustomAppReplacePatchModel()
{
PropertyName = PropertyName.Name,
Value = "New Custom App Name"
},
new CustomAppReplacePatchModel()
{
PropertyName = PropertyName.Codename,
Value = "new_custom_app_codename"
},
new CustomAppReplacePatchModel()
{
PropertyName = PropertyName.SourceUrl,
Value = "https://newcustomapplication.net"
},
new CustomAppReplacePatchModel()
{
PropertyName = PropertyName.Config,
Value = "{ .. }"
},
new CustomAppReplacePatchModel()
{
PropertyName = PropertyName.AllowedRoles,
Value = new[]
{
Reference.ByCodename("allowed_role_codename"),
Reference.ById(new Guid("f8f0b5cb-f5b7-42e8-af85-fbdab3ddfacf"))
}
}
};

var response = await client.ModifyCustomAppAsync(customAppCreateModel);
// EndDocSection
24 changes: 24 additions & 0 deletions net/management-api-v2/cm_api_v2_post_create_custom_app.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// DocSection: cm_api_v2_post_create_sutom_app
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Management;

var client = new ManagementClient(new ManagementOptions
{
ApiKey = "<YOUR_API_KEY>",
ProjectId = "<YOUR_PROJECT_ID>"
});

var customAppCreateModel = new CustomAppCreateModel
{
Name = "Custom App Name",
Codename = "custom_app_codename",
SourceUrl = "https://customapp.net",
Config = "{ .. }",
AllowedRoles = = [
Reference.ById(Guid.Parse("7740a768-bfa5-4f64-bab4-d77cc0791d4c")),
Reference.ById(Guid.Parse("7a51d721-7302-4a85-b4ce-a6a3f3cce4a6"))
]
};

var response = await client.GetCustomAppAsync(customAppCreateModel);
// EndDocSection

0 comments on commit ae3078e

Please sign in to comment.