Create a NetApp DII SWS DataCollectors via API Swagger

#Create a NetApp DII SWS DataCollectors via API Swagger

# 1. Log into DII 
<font color="red">__You need a DII API token to create a DataCollector via API.__
<font color="red">__You can create a API token refer to below URL.__
https://qiita.com/lewip/items/a0f06606be00e06f6d30 

# 2. Click Admin> API Access> API Documentation> Workload Security.

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/98b4fe82-3580-4066-a312-c8c9d10e18ca.png)

# 3. Click on "Authorize".
Lets enter API Token first.

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/44b63ebb-a98d-493d-ac5a-5b6be3d7cc91.png)

# 4. Enter your API security token in "Value", then click on "Authorize".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/b69ec1ec-011a-41bf-93c0-3d9150268e5c.png)

# 5. Click "Close" to authorize.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/1d89aa69-c1b1-48e6-ae11-915a428e9ebc.png)

# 6. Get Agent/DataCollector UUID first.
To use "Add a collector" API call, you will need;
1. Agent UUID
1. Collector UUID

### 1-1. Get Agent UUID.
Click "GET /v1/cloudsecure/agents Retrieve all agents" to expand the field.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/46d1a26c-cba1-4f07-a24c-43f5c898b36d.png)
### 1-2. Click "Try it out".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/779007f2-608b-4160-ad57-ec638a0d8dfa.png)
### 1-3. Click "execute".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/6d05b4af-baa2-4755-a968-8c5b5c979411.png)
### 1-4. Curl command and Agent UUID for all agents are displayed.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/6bc0aedb-fbc7-4a36-9520-e7b2e309daf1.png)

### 2-1. Get Collector UUID.
Click "GET /v1/cloudsecure/collector-types Retrieve all collector-type by collectorCategory" to expand the field.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/4af17fb3-e604-486c-bf17-5f426ff50367.png)
### 2-2. Click "Try it out".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/f2b6f20e-a414-4658-b402-c27e457255f6.png)
### 2-3. Click "execute".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/d3c20df9-d1c9-41d2-85cd-0bb03a2351a4.png)
### 2-4. Curl command and DataCollector UUID for Collector types are displayed.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/ad9afdc1-6b74-429e-a824-1dab39321fad.png)

# 7. Create a DataCollector.
Click "POST "/v1/cloudsecure/collectors Add a collector" to expand the field.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/d70cfb65-31a9-40a0-8865-76ea38a86e33.png)

# 8. Click "Try it out".
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/6067ddb4-259f-4422-a92c-a6afeca98f31.png)

# 9. Enter parameters then click "Execute".
<font color="red"> __[Parameters]__

hostname =  Cluster management IP Address
password = User password
sub-datasource-name = SVM name
username = Username
CollectorTypeUuid = DataCollector UUID
name = DataCollector name.
agentUudi = Agent UUID

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/412936eb-a51a-4e1d-9b6c-5d7311b515df.png)

### In this example, I am going to create a;
ONTAP Collector(DataCollector UUID) called "Tokyo" with the cluster management IP address 0.0.0.0(hostname), monitoring svm called "svm01"(sub-datasource-name).

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/672183ec-fb75-4906-89ef-c23c5f8db546.png)

# 10. Curl command and Response Code are displayed.
Response code is 200, API call is successfully posted. 
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/5a850ebe-4338-48ce-a72a-b83c449d00a2.png)

# 11. Go back to DII and check the DataCollector is added.
Click Workload Security> Collectors> Data Collectors
In this example, Tokyo DataCollector is sueccessfully added as below.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/254a970a-efea-4200-8601-2d679e4e0131.png)

Data Collector details;
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/c4c4460b-6df6-4a64-9f1d-82840c555015.png)

# Create multiple DataCollectors using curl command.
If you would like to setup 100 DataCollectors on SWS, you can use for command to run the curl for 100 times with appropriate parameters.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/4071714/5a850ebe-4338-48ce-a72a-b83c449d00a2.png)