> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/j/json-file-services.md).

# JSON File Services

The JSON File Services adapter imports services and cloud resources from a JSON file that you copy to the connector.

## Use cases

* **Inventory services from a file.** Bring service records from an export into the service inventory.

```
Adapters = json-file-services
```

* **Find services by region.** Review services in one region.

```
Adapters = json-file-services AND Region = <region>
```

## Before you begin

### Network

| Source              | Destination                      | Port           | Protocol       |
| ------------------- | -------------------------------- | -------------- | -------------- |
| OctoXLabs connector | Local file on the connector host | Not applicable | Not applicable |

The adapter reads a file from disk. It makes no network connection.

### Required permissions

The connector process must be able to read the file. The baseline asks you to check the file permissions after you copy the file.

## Create credentials in JSON file

This adapter needs no credentials. Prepare the file and copy it to the connector instead.

{% stepper %}
{% step %}

### Prepare the JSON file

Create a JSON file that contains either one object or a list of objects. Each object is one record. An empty file is rejected.
{% endstep %}

{% step %}

### Copy the file to the connector

Copy the file to `/opt/octoxlabs/connector/media/json` on the connector host.
{% endstep %}

{% step %}

### Check the file permissions

Make sure the connector process can read the file, then run the connection test.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter         | Required | Type   | Default    | Description                                                                                                                                             |
| ----------------- | -------- | ------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Filename          | Yes      | String | None       | File name or glob pattern inside the JSON folder. Absolute paths and `..` are not allowed. If a pattern matches several files, the newest file is used. |
| Primary Key Field | No       | String | PrimaryKey | JSON key with the unique identifier of each service. A dotted path such as `info.id` reaches a nested key.                                              |

## Troubleshooting

| Error message                     | Cause                                                                                      | Fix                                                             |
| --------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
| File not found with this pattern. | No file in the JSON folder matches **Filename**, or the match resolves outside the folder. | Copy the file to the JSON folder and check the name or pattern. |
| {filename} file is empty.         | The JSON file contains no data.                                                            | Add at least one record to the file.                            |

## Change history
