Skip to main content

Configuring Virtual Endpoint with REST API

Endpoint​

URL to send requests to will depend on type of Flexify IO installation. In the default installation when Management Server has its own IP address, the URL is http://<ip>.

When Management Server is deployed using Docker Compose on the same IP address as the Web Console (and possibly Engine), it’s placed behind nginx that redirects requests. In this case Management Server URL is http://<ip>/flexify-io/manage/api/rest/.

Examples below use the first option.

Steps​

Add storage account​

This request adds Azure Blob Storage account with specified SAS token. Note that for Azure providerId is 2.

POST /storage-accounts HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"storageAccount": {
"providerId": 2,
"settings": {
"name": "New Storage Account",
"identity": "flexifyeastus",
"credential": "<SAS token>",
"useSsl": true,
"refreshIntervalSec": 3600,
"refreshStoragesStat": false
}
},
"verify": true,
"refreshNow": false
}

This request will attempt to verify account by listing containers. To skip the verification, set verify to false. name is optional and, if not provided, identity will be shown in the UI instead of the name.

Response contains ID of the storage account added:

{
"id": 7423
}

Create Virtual Endpoint​

This request creates new virtual endpoint. The body is empty.

POST /endpoints HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"name": "My virtual endpoint"
}

It’s also possible to specify other settings, such as keys:

POST /endpoints HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"name": "My virtual endpoint",
"identity": "FlIOFBG7mkK69UGYZB6u5DZV",
"credential": "CaFC...................Hw",
"selectionPolicy": "NEWEST"
}

Response contains ID of created Virtual Endpoint:

{
"id": 1017
}

(Option 1) Attach Storage Account to Virtual Endpoint​

The following request attached storage account with ID <storage-account-id> to virtual endpoint with ID <virtual-endpoint-id>. All Blob Storage Account containers of that account will be accessible through the virtual endpoint.

Use IDs received in responses for previous requests.

POST /endpoints/<virtual-endpoint-id>/storage-accounts HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"newStorageAccounts": [
{
"storageAccountId": <storage-account-id>,
"settings": {
"putObjects": true,
"deleteObjects": true
}
}
]
}

(Option 2) Create Virtual Bucket​

The following requests creates a Virtual Bucket named new-vb-name for Virtual Endpoint with ID <virtual-endpoint-id>:

POST /endpoints/1016/virtual-buckets HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"settings": {
"bucketName": "new-vb-name",
"accessPolicy": { }
}
}

The 200 OK response is empty.

(Option 2) Find Azure container ID in Flexify IO​

Flexify IO assigns ID to each bucket/container it knows. The following request can be used to find Flexify ID of specific Azure container under storage account with ID <storage-account-id>:

GET /storage-accounts?include-buckets=true HTTP/1.1
Authorization: Bearer <API token>

Example response:

[
{
"id": 7423,
...
"buckets": [
{
"id": 1408956,
"name": "flexify.io",
"displayName": null,
"stat": {
"objects": null,
"bytes": null,
"state": "NONE",
"region": "eastus",
"lastRefreshed": null
}
},
{
"id": 1408952,
"name": "perf",
"displayName": null,
"stat": {
"objects": null,
"bytes": null,
"state": "NONE",
"region": "eastus",
"lastRefreshed": null
}
},
{
"id": 1408961,
"name": "flexify",
"displayName": null,
"stat": {
"objects": null,
"bytes": null,
"state": "NONE",
"region": "eastus",
"lastRefreshed": null
}
}
]
}
]

(Option 2) Attach Azure Container to Virtual Bucket​

This request attaches bucket/container with ID <bucket-id> to Virtual Bucket new-vb-name of Virtual Endpoint <virtual-endpoint-id>:

POST /endpoints/<virtual-endpoint-id>/virtual-buckets/new-vb-name/buckets HTTP/1.1
Authorization: Bearer <API token>
Content-Type: application/json

{
"newStorages": [
{
"bucketId": <bucket-id>,
"settings": {
"putObjects": true,
"deleteObjects": true
}
}
]
}

The 200 OK response is empty.

Retrieve HMAC keys by Endpoint ID​

Starting from version 2.12.17, two separate requests need to be used to retrieve Access Key ID and Secret Key.

This request returns Access Key ID (in identity field) for the virtual endpoint with ID <virtual-endpoint-id>.

GET /endpoints/<virtual-endpoint-id> HTTP/1.1
Authorization: Bearer <API token>

Example response:

{
"id": 1016,
"settings": {
"name": "My virtual endpoint",
"protocol": "S3",
"identity": "FlIOlEv02AarAnc9WvQMds3k",
"selectionPolicy": "NEWEST",
"selectionBreakTimeout": null
},
...
}

The S3 HMAC Access Key for the virtual endpoint can be found in the identity field.

To retrieve Secret Key, use the following request:

GET /endpoints/<virtual-endpoint-id>/settings/secret-key HTTP/1.1
Authorization: Bearer <API token>

Example response:

{
"secretKey": "PEp..................S5K"
}

Retrieve Endpoint by Endpoint Name​

Instead of using endpoint ID, it’s possible to search for an endpoint by name:

GET /endpoints?name=My%20virtual%20endpoint HTTP/1.1
Authorization: Bearer <API token>

The result will be an array of all endpoints with the specified name:

[
{
"id": 1017,
"settings": {
"name": "My virtual endpoint",
"protocol": "S3",
...
},
....
}
]

The name parameters accepts SQL LIKE syntax and is not case-sensitive. You can use filters such as %virtual%. Make sure to URL encode %.

Virtual Bucket Access Policy​

Virtual bucket access policy allows to control which operations are allowed for different objects keys and prefixes.

The accessPolicy object can be specified when adding or modifying virtual bucket. For example, the following policy will give read access to the whole bucket and write access to the folder1/ prefix, forbidding everything else.

"accessPolicy": {
"rules": [
{
"action": "allow",
"operations": [
"GetObject",
"HeadBucket",
"ListObjects"
]
},
{
"action": "allow",
"operations": [
"PutObject",
"RestoreObject",
"DeleteObject"
],
"keyPattern": "folder1/*"
},
{
"action": "forbid"
}
]
}