From c19ce2affb25bb49b0578dc28a9f162816728fb4 Mon Sep 17 00:00:00 2001 From: Jan Cerman Date: Tue, 3 Dec 2024 11:06:01 +0100 Subject: [PATCH] CTC-2631 Add cURL samples for custom apps --- .../cm_api_v2_delete_custom_app.cs | 4 +- .../cm_api_v2_get_custom_app.cs | 4 +- ...m_app.cs => cm_api_v2_patch_custom_app.cs} | 0 ...om_app.cs => cm_api_v2_post_custom_app.cs} | 0 .../cm_api_v2_delete_custom_app.curl | 3 ++ .../cm_api_v2_get_custom_app.curl | 3 ++ .../cm_api_v2_get_custom_apps.curl | 3 ++ .../cm_api_v2_patch_custom_app.curl | 47 +++++++++++++++++++ .../cm_api_v2_post_custom_app.curl | 17 +++++++ 9 files changed, 77 insertions(+), 4 deletions(-) rename net/management-api-v2/{cm_api_v2_patch_modify_custom_app.cs => cm_api_v2_patch_custom_app.cs} (100%) rename net/management-api-v2/{cm_api_v2_post_create_custom_app.cs => cm_api_v2_post_custom_app.cs} (100%) create mode 100644 rest/management-api-v2/cm_api_v2_delete_custom_app.curl create mode 100644 rest/management-api-v2/cm_api_v2_get_custom_app.curl create mode 100644 rest/management-api-v2/cm_api_v2_get_custom_apps.curl create mode 100644 rest/management-api-v2/cm_api_v2_patch_custom_app.curl create mode 100644 rest/management-api-v2/cm_api_v2_post_custom_app.curl diff --git a/net/management-api-v2/cm_api_v2_delete_custom_app.cs b/net/management-api-v2/cm_api_v2_delete_custom_app.cs index 1ccc4c2b..d943bdda 100644 --- a/net/management-api-v2/cm_api_v2_delete_custom_app.cs +++ b/net/management-api-v2/cm_api_v2_delete_custom_app.cs @@ -3,8 +3,8 @@ var client = new ManagementClient(new ManagementOptions { - ApiKey = "", - ProjectId = "" + ApiKey = "KONTENT_AI_MANAGEMENT_API_KEY", + EnvironmentId = "KONTENT_AI_ENVIRONMENT_ID" }); var identifier = Reference.ById(Guid.Parse("f4b3fc05-e988-4dae-9ac1-a94aba566474")); diff --git a/net/management-api-v2/cm_api_v2_get_custom_app.cs b/net/management-api-v2/cm_api_v2_get_custom_app.cs index 86d2d325..e37ab40e 100644 --- a/net/management-api-v2/cm_api_v2_get_custom_app.cs +++ b/net/management-api-v2/cm_api_v2_get_custom_app.cs @@ -3,8 +3,8 @@ var client = new ManagementClient(new ManagementOptions { - ApiKey = "", - ProjectId = "" + ApiKey = "KONTENT_AI_MANAGEMENT_API_KEY", + EnvironmentId = "KONTENT_AI_ENVIRONMENT_ID" }); var identifier = Reference.ById(Guid.Parse("f4b3fc05-e988-4dae-9ac1-a94aba566474")); diff --git a/net/management-api-v2/cm_api_v2_patch_modify_custom_app.cs b/net/management-api-v2/cm_api_v2_patch_custom_app.cs similarity index 100% rename from net/management-api-v2/cm_api_v2_patch_modify_custom_app.cs rename to net/management-api-v2/cm_api_v2_patch_custom_app.cs diff --git a/net/management-api-v2/cm_api_v2_post_create_custom_app.cs b/net/management-api-v2/cm_api_v2_post_custom_app.cs similarity index 100% rename from net/management-api-v2/cm_api_v2_post_create_custom_app.cs rename to net/management-api-v2/cm_api_v2_post_custom_app.cs diff --git a/rest/management-api-v2/cm_api_v2_delete_custom_app.curl b/rest/management-api-v2/cm_api_v2_delete_custom_app.curl new file mode 100644 index 00000000..7e347d6a --- /dev/null +++ b/rest/management-api-v2/cm_api_v2_delete_custom_app.curl @@ -0,0 +1,3 @@ +curl -X DELETE "https://manage.kontent.ai/v2/projects//custom-apps/f4b3fc05-e988-4dae-9ac1-a94aba566474" \ +-H "Authorization: Bearer KONTENT_AI_MANAGEMENT_API_KEY" \ +-H "Content-Type: application/json" \ No newline at end of file diff --git a/rest/management-api-v2/cm_api_v2_get_custom_app.curl b/rest/management-api-v2/cm_api_v2_get_custom_app.curl new file mode 100644 index 00000000..dce1bd6a --- /dev/null +++ b/rest/management-api-v2/cm_api_v2_get_custom_app.curl @@ -0,0 +1,3 @@ +curl -X GET "https://manage.kontent.ai/v2/projects//custom-apps/f4b3fc05-e988-4dae-9ac1-a94aba566474" \ +-H "Authorization: Bearer KONTENT_AI_MANAGEMENT_API_KEY" \ +-H "Content-Type: application/json" \ No newline at end of file diff --git a/rest/management-api-v2/cm_api_v2_get_custom_apps.curl b/rest/management-api-v2/cm_api_v2_get_custom_apps.curl new file mode 100644 index 00000000..4b1b5571 --- /dev/null +++ b/rest/management-api-v2/cm_api_v2_get_custom_apps.curl @@ -0,0 +1,3 @@ +curl -X GET "https://manage.kontent.ai/v2/projects//custom-apps/" \ +-H "Authorization: Bearer KONTENT_AI_MANAGEMENT_API_KEY" \ +-H "Content-Type: application/json" \ No newline at end of file diff --git a/rest/management-api-v2/cm_api_v2_patch_custom_app.curl b/rest/management-api-v2/cm_api_v2_patch_custom_app.curl new file mode 100644 index 00000000..36072d49 --- /dev/null +++ b/rest/management-api-v2/cm_api_v2_patch_custom_app.curl @@ -0,0 +1,47 @@ +curl -X PATCH "https://manage.kontent.ai/v2/projects//custom-apps/f8f0b5cb-f5b7-42e8-af85-fbdab3ddfacf" \ +-H "Authorization: Bearer KONTENT_AI_MANAGEMENT_API_KEY" \ +-H "Content-Type: application/json" \ +-d '[ + { + "op": "addInto", + "property_name": "allowed_roles", + "value": [ + { "codename": "new_allowed_role_codename_to_be_add_into" } + ] + }, + { + "op": "remove", + "property_name": "allowed_roles", + "value": [ + { "codename": "allowed_role_codename_to_be_removed" } + ] + }, + { + "op": "replace", + "property_name": "name", + "value": "New Custom App Name" + }, + { + "op": "replace", + "property_name": "codename", + "value": "new_custom_app_codename" + }, + { + "op": "replace", + "property_name": "source_url", + "value": "https://newcustomapplication.net" + }, + { + "op": "replace", + "property_name": "config", + "value": "{}" + }, + { + "op": "replace", + "property_name": "allowed_roles", + "value": [ + { "codename": "allowed_role_codename" }, + { "id": "f8f0b5cb-f5b7-42e8-af85-fbdab3ddfacf" } + ] + } +]' \ No newline at end of file diff --git a/rest/management-api-v2/cm_api_v2_post_custom_app.curl b/rest/management-api-v2/cm_api_v2_post_custom_app.curl new file mode 100644 index 00000000..2c4ef80d --- /dev/null +++ b/rest/management-api-v2/cm_api_v2_post_custom_app.curl @@ -0,0 +1,17 @@ +curl -X POST "https://manage.kontent.ai/v2/projects//custom-apps/" \ +-H "Authorization: Bearer KONTENT_AI_MANAGEMENT_API_KEY" \ +-H "Content-Type: application/json" \ +-d '{ + "name": "Custom App Name", + "codename": "custom_app_codename", + "source_url": "https://customapp.net", + "config": "{}", + "allowed_roles": [ + { + "id": "7740a768-bfa5-4f64-bab4-d77cc0791d4c" + }, + { + "id": "7a51d721-7302-4a85-b4ce-a6a3f3cce4a6" + } + ] +}' \ No newline at end of file