Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions en/automation/automation-cloudops-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ slug: cloudops-api
---



This article is a beginner's introduction to the CloudOps REST API, providing details on how to access it, and also builds context for the other articles in the Automation category.

## Overview
Expand Down Expand Up @@ -41,6 +42,8 @@ This wall of text may seem daunting and unrecognizable. There will be a lot of s

Similarly, the response may contain a lot of extraneous data. For example, the API call above returns many fields with values. It is not just a list of environments, it includes parameters about each listed environment. To identify each environment, you will have to inspect the response to find the value you need. This is where it becomes important to take the response, put it into a text editing tool, and use the Find feature to locate the target date. For more complex responses with a large amount of data, you may wish to use a text editor which can reformat a JSON document to make the response more human-readable.

For a detailed example on parsing the JSON data, see the [Get knowledge base ID](automation-get-knowledge-base.md) article.

## Windows users only

Windows users, please note that you will have to edit the examples before they can be used, due to how Windows treats special characters.
Expand Down
44 changes: 44 additions & 0 deletions en/automation/automation-get-knowledge-base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Get knowledge base ID"
slug: automation-get-knowledge-base-id
---


This article will show you how to find the ID of the knowledge base for your home organization.

## Before you begin

- You will need a valid API key
- You must have the **Reseller** role, or a custom role with the **Knowledge base: Manage** permission scoped to your home organization
- A valid source Git repository containing a CloudOps knowledge base must already be configured for your home organization

## API call

```
curl --request GET \
--url https://{endpoint-url}/api/v2/content/kb/effective \
--header 'Content-Type: application/json' \
--header 'MC-Api-Key: {api-key}'
```

## Result

- The response will contain the full content of the knowledge base
- You may now search through the response to identify the identifier of the knowledge base in the `data/id` field

**Attention:** Be aware that the response will contain values in `data/sources/id`, `data/categories/id`, `data/categories/translations/id`, and in `data/categories/articles/translations/id`. These are NOT the identifiers of the knowledge base.

## Discussion

This API call is a good example of where a huge amount of data is returned, but you only need one value. The response will contain the text for all articles, in all categories, in all languages. You will have to search through the JSON-formatted response to find the desired knowledge base ID. Although this may seem like a daunting task when you initially see the solid wall of text that the API call returns, there are tools which make it much easier to find your value.

Depending on the text editor you are using, it may have a JSON-formatting feature already built in. You can copy the response out of your terminal or command window, paste it into the text editor, and execute the relevant command to format the JSON content to make it more human-readable.

If your text editor does not include JSON formatting, there are publicly available tools which are free to use online. You can paste the block of text, and the tool will return it properly formatted.

Once the JSON has been formatted, it becomes easier to work with manually. Each line has a single name/value pair, separated by a colon. Lists are broken up, with the name of the list on one line, then each name/value pair in the list indented on the following lines. The beginning and end of the list are identified by opening and closing braces or square brackets. This structure makes it easier to see how the different parts of the data are related. \(The difference between braces and square brackets is important, but not relevant for this discussion.\)

In the case of the knowledge base, we wish to look at the top of the response, which is a list called `data`. Inside of this list, we see a set of indented lines, some of which contain name/value pairs, and some of which are other lists. These lists will be further indented. Because we are looking for the value associated with the `data/id` name, we can ignore any values that are further indented. We only need to look at the names that are directly in the `data` list.

Using this method, we can quickly find the name/value pair for the knowledge base identifier. The name/value pair will look something like this: `"id": "b9b69be1-36c8-473a-8400-494eba40343c",`. You can copy the value `b9b69be1-36c8-473a-8400-494eba40343c` out of the text editor or JSON formatting tool you are using, and store that knowledge base identifier for use with other API calls.

33 changes: 33 additions & 0 deletions en/automation/automation-sync-knowledge-base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "Sync the knowledge base"
slug: automation-sync-knowledge-base
---


This article will show you how to sync the knowledge base for your home organization using the CloudOps API.

## Before you begin

- You will need a valid API key
- You must have the **Reseller** role, or a custom role with the **Knowledge base: Manage** permission scoped to your home organization
- A valid source Git repository containing a CloudOps knowledge base must already be configured for your home organization
- You must have the ID for your home organization's knowledge base

## API call

```
curl --request GET \
--url https://{endpoint-url}/api/v2/content/kb/{knowledgebase-id}/sync \
--header 'Content-Type: application/json' \
--header 'MC-Api-Key: {api-key}'
```

## Result

- The response will contain the full content of the existing knowledge base
- The `data/state` field will contain the value `"SYNCHING"`

## Discussion

Upon executing this API call, the system will return the full content of the existing knowledge base. Subsequently, it will pull the latest from the Git repository and update the knowledge base. This is a long-running operation and will take a few minutes to complete. In the Web UI, you will see the operation listed in the Notifications panel. There is no way in the API to see if the sync is completed at this time.

2 changes: 2 additions & 0 deletions layout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,7 @@ categories:
- automation-cloudops-api.md
- api-credentials.md
- automation-list-roles-for-environment.md
- automation-get-knowledge-base.md
- automation-sync-knowledge-base.md
- deploy-virtual-machine-using-terraform.md
- deploy-a-kubernetes-cluster-with-rancher-2-x.md
Loading