REST API v3: GET database restrictions
Method to retrieve an overview of all available restrictions in a database. This is an HTTP GET call to the following address:
https://api.copernica.com/v3/database/$id/restrictions?access_token=xxxx
The code $id must be replaced with the numeric identifier or the name
of the database for which you want to retrieve the restrictions.
Available parameters
The following parameters can be added to the URL as variables:
- start: first restriction that is retrieved
- limit: length of the batch that is retrieved
- total: show or hide the total number of restrictions in the output
More information about the meaning of these parameters can be found in the article about paging.
Returned fields
The method returns a list of restrictions in the database. For each restriction the general properties are returned first. In addition, a restriction contains one or more rules, which in turn contain one or more conditions.
Restriction properties
For each restriction the following properties are returned:
- ID: numeric ID of the restriction
- name: name of the restriction
- description: description of the restriction
- disabled: boolean value that indicates whether the restriction is disabled
- rules: list of rules that belong to this restriction
Rule properties
Each restriction can contain one or more rules. A rule contains the following properties:
- ID: numeric ID of the rule
- name: name of the rule
- disabled: boolean value that indicates whether the rule is disabled
- conditions: list of conditions that belong to this rule
Condition properties
A rule consists of one or more conditions. For each condition the following properties are returned:
- ID: numeric ID of the condition
- type: condition type, for example a value comparison
- field: field on which the condition is applied
- value: value that the field is compared with
- match-mode: method used for the comparison (for example contains or not_equals)
- numeric-comparison: boolean value that indicates whether the comparison is performed numerically
JSON example
The JSON for a single database looks like this:
{
"start": 0,
"limit": 100,
"count": 1,
"data": [
{
"ID": "1",
"name": "Filter email address",
"description": "This is a restriction to block all @copernica.com addresses",
"disabled": false,
"rules": [
{
"ID": "22",
"name": "Rule_0",
"disabled": false,
"conditions": [
{
"ID": "8",
"type": "Value",
"field": "Email",
"value": "@copernica.com",
"match-mode": "contains",
"numeric-comparison": false
}
]
}
]
}
]
}
Example in PHP
The following PHP script demonstrates how to call the API method:
// required scripts
require_once('copernica_rest_api.php');
// change this to your access token
$api = new CopernicaRestAPI("your-access-token", 3);
// execute method and print result
print_r($api->get("database/{$databaseID}/restrictions", $parameters));
This example requires the REST API class.