Endurance

Locks

The configuration lock stops two people, or two scripts, from writing conflicting changes at the same time.

Get the configuration lock status

Get locks status

GET /locks

curl
curl -X GET "https://appliance.example.com/api/v1/locks" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/locks';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.get("https://appliance.example.com/api/v1/locks", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/locks', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Bruno
meta {
  name: Get the configuration lock status
  type: http
  seq: 1
}

get {
  url: https://{{node-0}}:{{port}}/api/v1/locks
  body: none
  auth: bearer
}

auth:bearer {
  token: {{token}}
}
Response
{
  "status": "success",
  "message": "API: Locks retrieved successfully",
  "data": {
    "APILock": true,
    "UserLock": true,
    "TransactionLocked": false
  }
}

Force the configuration lock off

Force Unlock API to allow all Users to make API calls

DELETE /locks/force

Releases a lock somebody else holds. Use it when a session has gone away without unlocking.

This change is staged. Send PUT /services/apply to apply it.

curl
curl -X DELETE "https://appliance.example.com/api/v1/locks/force" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/locks/force';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.delete("https://appliance.example.com/api/v1/locks/force", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/locks/force', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Bruno
meta {
  name: Force the configuration lock off
  type: http
  seq: 1
}

delete {
  url: https://{{node-0}}:{{port}}/api/v1/locks/force
  body: none
  auth: bearer
}

auth:bearer {
  token: {{token}}
}
Response
{
  "status": "success",
  "message": "API: Lock removed."
}

User

Lock API to allow only the User to make API calls Refused while a transaction is open. Commit or roll back the transaction first.

PUT /locks/user

Takes the configuration lock for yourself, so no one else can write while you hold it.

This change is staged. Send PUT /services/apply to apply it.

Body parameters
message string Required

a message for the lock

curl
curl -X PUT "https://appliance.example.com/api/v1/locks/user" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "message": "<message>"
}'
PHP
<?php

$url = 'https://appliance.example.com/api/v1/locks/user';
$headers = [
    'Authorization: Bearer ' . $token,
    'Content-Type: application/json',
];

$payload = [
    'message' => '<message>',
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}
payload = {
    "message": "<message>"
}

response = requests.put("https://appliance.example.com/api/v1/locks/user", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/locks/user', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "message": "<message>"
}),
});

const data = await response.json();
Bruno
meta {
  name: Lock the configuration
  type: http
  seq: 1
}

put {
  url: https://{{node-0}}:{{port}}/api/v1/locks/user
  body: json
  auth: bearer
}

headers {
  Content-Type: application/json
}

auth:bearer {
  token: {{token}}
}

body:json {
  {
    "message": "<message>"
  }
}
Response
{
  "status": "success",
  "message": "API: User lock set."
}

Unlock API to allow all Users to make API calls Refused while a transaction is open. Commit or roll back the transaction first.

DELETE /locks/user

This change is staged. Send PUT /services/apply to apply it.

curl
curl -X DELETE "https://appliance.example.com/api/v1/locks/user" \
  -H "Authorization: Bearer $TOKEN"
PHP
<?php

$url = 'https://appliance.example.com/api/v1/locks/user';
$headers = [
    'Authorization: Bearer ' . $token,
];

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests

headers = {"Authorization": f"Bearer {token}"}

response = requests.delete("https://appliance.example.com/api/v1/locks/user", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/locks/user', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${token}`,
  },
});

const data = await response.json();
Bruno
meta {
  name: Unlock the configuration
  type: http
  seq: 1
}

delete {
  url: https://{{node-0}}:{{port}}/api/v1/locks/user
  body: none
  auth: bearer
}

auth:bearer {
  token: {{token}}
}
Response
{
  "status": "success",
  "message": "API: User lock removed."
}