# Add Bulk Devices using Director Console API

The Director Console API uses CSV files to install multiple device configurations at once in a Fabric-enabled LogPoint.

Follow the steps mentioned below to add bulk devices using the Director Console API:

## Create and Upload the CSV file in the Fabric Storage

1. Create a CSV file in your local machine.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>Refer to the <code>CSV File for Bulk Device</code> section for details on the format of the CSV file.</p></div>
2. **Option A:** Upload the CSV file and make it accessible to all users across all pools:

   * Execute the **Devices - UploadPublic** API with the required parameters.

   **Option B:** Upload the CSV file and make it accessible to the users within a specific pool:

   * Execute the **Devices - Upload** API with the required parameters.

## Install the Device Configurations in a Fabric-enabled LogPoint

1. List the CSV files.

   **Option A:** List the CSV files uploaded in the private storage.

   * Execute the **Devices - ListPrivateUploads** API to list the CSV files from the private storage. Use the name of the required CSV file the *file\_name* parameter of the **Devices - Install** API.

   **Option B:** List the CSV files uploaded in the public storage.

   * Execute the **Devices - ListPublicUploads** API to list the CSV files from the public storage. Use the name of the required CSV file the *file\_name* parameter of the **Devices - Install** API..
2. Execute the **Devices - Install** API to install multiple device configurations in a Fabric-enabled LogPoint.

## Sample API Requests and Responses for Adding Bulk Devices

1. Create a CSV file in your local machine.

   Sample CSV File:

   ```
   device_name,device_ips,device_groups,log_collection_policies,distributed_collector,confidentiality,integrity,availability,timezone
   device1,192.168.2.30,windows,lcp1
   device2,192.168.2.31,windows,lcp2
   device4,192.168.2.33,linux,,lcp3
   ```
2. Execute the **Devices - UploadPublic** API with the required parameters.

   ```
   Config API:

   POST
   https:://api-server-host-name/configapi/Devices/publicupload

   Response:

   {
   "status": "Success",
   "message": "devices.csv successfully uploaded in public storage."
   }
   ```

{% hint style="info" %}

* Mention the *file\_name* and *Content-Type* in the header of the request. The value of the *Content-Type* parameter must be *application/octet-stream*.
* Browse the CSV file from your local storage to the API.
  {% endhint %}

This step successfully uploads the CSV file in the Fabric Storage.

1. Execute the **Devices - ListPublicUploads** API with the required parameters.

   ```
   Config API:

   POST
   https:://api-server-host-name/configapi/Devices/list

   Response:

   [
   "devices.csv"
   ]
   ```

This step successfully lists the CSV file from the Fabric Storage.

1. Execute the **Devices - Install** API to install multiple device configurations in a Fabric-enabled LogPoint.

   ```
   Config API:

   POST
   https:://api-server-host-name/configapi/{pool_UUID}/{logpoint_identifier}/Devices/install

   {
   "data": {
   "file_name": "devices.csv",
   "file_location": "public"
       }
   }

   Response:

   {
   "status": "Success",
   "message": "/monitorapi/7b77d08934744fdbd7c1d0194ba22aa/41b5b7fffa6c4e3cb6bc6d799a5ee6e5/orders/4624be84-66db-4248-aca4-2b125d0474c7"
   }

   Monitoring API:

   GET
   https:://api-server-host-name//monitorapi/7b77d08934744fdbd7c1d0194ba22aa/41b5b7fffa6c4e3cb6bc6d799a5ee6e5/orders/4624be84-66db-4248-aca4-2b125d0474c7"5d0474c7

   Response:

   [
   {
       "index": 10,
       "request": {
       "index": "10",
       "device_name": “device1”,
       "device_ips": "192.168.2.30",
       "device_groups": “windows”,
       "log_collection_policies": "lcp1”,
       "distributed_collector": "",
       "confidentiality": "",
       "integrity": "",
       "availability": "",
       "timezone": "",
       "machine_identifier": ""
       },
   "response": {
   "success": true,
   "id": "5e3156a18e3db55abc8f9dd2"
   }
   },
   {
       "index": 11,
       "request": {
       "index": "11",
       "device_name": “device2”,
       "device_ips": "192.168.2.31",
       "device_groups": “windows”,
       "log_collection_policies": "lcp2”,
       "distributed_collector": "",
       "confidentiality": "",
       "integrity": "",
       "availability": "",
       "timezone": "",
       "machine_identifier": ""
       },
   "response": {
   "success": true,
   "id": “59084c4b854ff52f3d29d6f1”
   }
   },
   {
       "index": 12,
       "request": {
       "index": "12",
       "device_name": “device3”,
       "device_ips": "192.168.2.32”,
       "device_groups": “linux”,
       "log_collection_policies": "lcp3”,
       "distributed_collector": "",
       "confidentiality": "",
       "integrity": "",
       "availability": "",
       "timezone": "",
       "machine_identifier": ""
       },
   "response": {
   "success": true,
   "id": “59084c28854ff52f3d29d6f0”
   }
   }
   ]
   ```

This step successfully installs the devices in the Fabric-enabled LogPoint.

## CSV File for Bulk Device

The CSV file consists of comma-separated values that define the configuration parameters and their respective values.

Consider the following points while creating a CSV file:

* The first line of the CSV file **must** be a header row and the header names must be **device\_name**, **device\_ips**, **device\_groups**, **log\_collection\_policies**, **distributed\_collector**, **confidentiality**, **integrity**, **availability**, and **timezone**.

  Note

  While importing the devices via CSV, you can also configure their Syslog collectors.

  To configure a device to use a proxy, you must add the **uses\_proxy**, **proxy\_ip**, **hostname**, and **processpolicy** fields in the header row and the value of **uses\_proxy** for the corresponding device must be **TRUE**.

  To configure a device to be used as a proxy, you must add the **use\_as\_proxy**, **charset**, and **parser** fields in the header row and the value of **use\_as\_proxy** for the corresponding device must be **TRUE**.

  Refer to the **Director Console API Documentation** for details on the parameters.
* If a parameter has multiple entries, separate the entries with a semi-colon (;).
* You can obtain the value of the required parameters using their respective API.

Refer to the [Importing Devices via a CSV file](https://docs.logpoint.com/director/director-console/search-and-configure/configure-entities#import-devices-via-a-csv-file) for more details.

### Sample CSV files

#### Adding Bulk Devices

```
device_name,device_ips,device_groups,log_collection_policies,distributed_collector,confidentiality,integrity,availability,timezone
device1,192.168.2.30,windows,lcp1,,Minor,Minimal,Major,Atlantic/Azores
device_3,192.168.2.32;192.168.2.33;192.168.2.34,Linux,lcp3
device2,192.168.2.31,windows,lcp2
device4,192.168.2.33,windows,,LogPoint43
```

{% hint style="info" %}
To edit previously configured devices, the CSV file must have **id**, **device\_name**, **device\_ips**, **device\_groups**, **log\_collection\_policies**, **distributed\_collector**, **confidentiality**, **integrity**, **availability**, and **timezone** in its header row.
{% endhint %}

#### Adding Devices with Syslog Collector

**Uses Proxy**

```
device_name,device_ips,uses_proxy,proxy_ip,hostname,processpolicy
device1,192.168.2.240,TRUE,192.168.2.207,LogPoint240,processpolicy1
device2,192.168.2.350,TRUE,192.168.2.208,LogPoint250,processpolicy2
```

**Use as Proxy**

```
device_name,device_ips,use_as_proxy,charset,parser
device2,192.168.2.207,TRUE,utf_8,LineParser
device3,192.168.2.208,TRUE,utf_8,LineParser
```
