-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:infrasonar/docs
- Loading branch information
Showing
19 changed files
with
330 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,6 @@ curl \ | |
Response: | ||
```json | ||
{ | ||
"assetId": 123 | ||
"assetId": 456 | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Delete a file | ||
**`DELETE` /container/<containerId\>/file/<fileId\>** | ||
|
||
### Description | ||
Delete a file. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
`fileId` | File Id. | ||
|
||
### Query parameters | ||
_none_ | ||
|
||
### Body | ||
_none_ | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`204` | Success. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`ASSET_MANAGEMENT`)_. | ||
`404` | Container or file not found. | ||
|
||
### Example | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X DELETE 'https://api.infrasonar.com/container/123/file/456' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Upload file | ||
**`GET` /container/<containerId\>/file/<fileId\>** | ||
|
||
### Description | ||
Download a file. For file info, see the [Query file](../query-file) section. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
`fileId` | File Id. | ||
|
||
### Query parameters | ||
_none_ | ||
|
||
### Body | ||
_none_ | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`200` | Success. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`READ`)_. | ||
`404` | Container or file not found. | ||
|
||
### Example | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X GET 'https://api.infrasonar.com/container/123/file' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
``` | ||
|
||
_Returns with the raw file_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Modify file | ||
**`PUT` /container/<containerId\>/file/<fileId\>** | ||
|
||
### Description | ||
Rename the file or change the attached labels for a file. | ||
|
||
Note that if _labels_ are provided, they will overwrite existing labels. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
`fileId` | File Id. | ||
|
||
### Body | ||
Param | Type | Required | Description | ||
----------------|---------------|-----------|------------- | ||
`name` | string | No | New file name. | ||
`labels` | array(integer)| No | Overwrite labels. Be careful with an empty list as this will remove all labels from the file. | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`204` | Success. | ||
`400` | Invalid body. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`ASSET_MANAGEMENT`)_. | ||
`404` | Container, file or one of the labels not found. | ||
|
||
### Example | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X PUT 'https://api.infrasonar.com/container/123/file/456' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \ | ||
-H 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"name": "My file.docx", | ||
"labels": [456, 789] | ||
}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Upload file | ||
**`GET` /container/<containerId\>/file/<fileId\>/info?fields=...** | ||
|
||
### Description | ||
Query file info. For downloading the file, see the [Download file](../download-file) section. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
`fileId` | File Id. | ||
|
||
### Query parameters | ||
Param | Default | Description | ||
--------------------|-------------------|------------- | ||
`fields` | _all fields_ | Fields to return _(see fields below for all available fields)_. | ||
|
||
### Body | ||
_none_ | ||
|
||
### Fields | ||
Field | Return type | Description | ||
--------------------|------------------ |------------- | ||
`id` | integer | Key string of the alert. | ||
`size` | integer | Initial message when the alert was opened. | ||
`created` | integer | Unix timestamp in seconds when the file was created in InfraSonar. | ||
`type` | string | One of `xml`, `json`, `docx`, `xlsx`, `csv`, `pdf`, `image`, `text`, `markdown`, `compressed` or `unknown`. | ||
`name` | string | File name. | ||
`labels` | array(integer) | List with label Ids. | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`200` | Success. | ||
`400` | Unknown field. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`READ`)_. | ||
`404` | Container or file not found. | ||
|
||
### Example | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X GET 'https://api.infrasonar.com/container/123/file/456/info?fields=id,name,labels' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
``` | ||
|
||
Response: | ||
```json | ||
{ | ||
"id": 456, | ||
"name": "network-diagram.png", | ||
"labels": [789] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Query container files | ||
**`GET` /container/<containerId\>/files?fields=...** | ||
|
||
### Description | ||
Query all files for a given container. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
|
||
### Query parameters | ||
Param | Default | Description | ||
--------------------|-------------------|------------- | ||
`fields` | `id` | Fields to return _(see fields below for all available fields)_. | ||
|
||
### Fields | ||
Field | Return type | Description | ||
--------------------|------------------ |------------- | ||
`id` | integer | Key string of the alert. | ||
`size` | integer | Initial message when the alert was opened. | ||
`created` | integer | Unix timestamp in seconds when the file was created in InfraSonar. | ||
`type` | string | One of `xml`, `json`, `docx`, `xlsx`, `csv`, `pdf`, `image`, `text`, `markdown`, `compressed` or `unknown`. | ||
`name` | string | File name. | ||
`labels` | array(integer) | List with label Ids. | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`200` | Success. | ||
`400` | Unknown field. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`READ`)_. | ||
`404` | Container not found. | ||
|
||
### Example | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X GET 'https://api.infrasonar.com/container/123/files?fields=id,name,type' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
``` | ||
|
||
Response: | ||
```json | ||
[ | ||
{ | ||
"id": 456, | ||
"name": "network-diagram.png", | ||
"type": "image" | ||
} | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Upload file | ||
**`POST` /container/<containerId\>/file** | ||
|
||
### Description | ||
Upload a new file. Only files with a size less than 250KB are allowed. | ||
|
||
### Path parameters | ||
Param | Description | ||
--------------------|------------- | ||
`containerId` | Container Id. | ||
|
||
### Query parameters | ||
_none_ | ||
|
||
### Body | ||
Files must be uploaded using multipart/form-data. See the examples below. | ||
|
||
### Return codes | ||
Error code | Reason | ||
------------|-------- | ||
`201` | Success. | ||
`400` | Invalid file _(for example too large)_. | ||
`401` | Invalid or missing token. | ||
`403` | Insufficient permissions _(required: `API`+`INSERT_CHECK_DATA`)_. | ||
`404` | Container not found. | ||
|
||
### Examples | ||
Curl request: | ||
```bash | ||
curl \ | ||
-X POST 'https://api.infrasonar.com/container/123/file' \ | ||
-H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \ | ||
-H 'Content-Type: application/json' \ | ||
--form '=@"/path-to-file/network-drawing.png"' | ||
``` | ||
|
||
Response: | ||
```json | ||
{ | ||
"id": 456 | ||
} | ||
``` | ||
|
||
Python: | ||
```python | ||
import requests | ||
|
||
url = "https://api.infrasonar.com/container/123/file" | ||
|
||
files = [('', ( | ||
'network-drawing.png', | ||
open('/path-to-file/network-drawing.png','rb'), | ||
'image/jpeg' | ||
))] | ||
|
||
headers = { | ||
'Content-Type': 'multipart/form-data', | ||
'Authorization': 'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
} | ||
|
||
response = requests.request("POST", url, headers=headers, files=files) | ||
|
||
print(response.json()) # {"id":456} | ||
``` | ||
|
||
C# (Http Client) | ||
```c# | ||
var client = new HttpClient(); | ||
var request = new HttpRequestMessage( | ||
HttpMethod.Post, | ||
"https://api.infrasonar.com/container/123/file"); | ||
|
||
// Set Authentication header | ||
request.Headers.Add( | ||
"Authorization", | ||
"Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); | ||
|
||
// Create multipart content | ||
var content = new MultipartFormDataContent(); | ||
content.Add( | ||
new StreamContent(File.OpenRead("/path-to-file/network-drawing.png")), | ||
"", | ||
"/path-to-file/network-drawing.png"); | ||
|
||
// Add contend to request | ||
request.Content = content; | ||
|
||
var response = await client.SendAsync(request); | ||
response.EnsureSuccessStatusCode(); | ||
|
||
Console.WriteLine(await response.Content.ReadAsStringAsync()); | ||
// "{\"id\":456}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.