NAV Navigation
Shell HTTP JavaScript Ruby Python PHP Java Go

Policy Management API v1.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Please note this API is only available if you have deployed and configured MongoDB with the Glasswall Halo

Authentication

PolicyManagement

Create Policy

Code samples

# You can also use wget
curl -X POST /api/v1/policies/{policyName} \
-H 'Content-Type: application/json'
POST /api/v1/policies/{policyName} HTTP/1.1

Content-Type: application/json
const inputBody = '{
"policySettings": null
}';
const headers = {
'Content-Type':'application/json'
};

fetch('/api/v1/policies/{policyName}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

headers = {
'Content-Type' => 'application/json'
}

result = RestClient.post '/api/v1/policies/{policyName}',
params: {
}, headers: headers

p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}

r = requests.post('/api/v1/policies/{policyName}', headers = headers)

print(r.json())
<?php

require 'vendor/autoload.php';

$headers = array(
'Content-Type' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('POST','/api/v1/policies/{policyName}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies/{policyName}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

headers := map[string][]string{
"Content-Type": []string{"application/json"},
}

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "/api/v1/policies/{policyName}", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

POST /api/v1/policies/{policyName}

Creates a named policy with the provided values

Body parameter

{
"policySettings": null
}

Parameters

Name In Type Required Description
policyName path string true The name of the policy to create
body body WritePolicyBody true none

Responses

Status Meaning Description Schema
201 Created Policy Created None
400 Bad Request Policy failed validation, reasons in response None
403 Forbidden Attempt to create ‘default’ policy None
404 Not Found Specified schema not found None
500 Internal Server Error Issues occurred when attempting to access storage. None

Update Policy

Code samples

# You can also use wget
curl -X PUT /api/v1/policies/{policyName} \
-H 'Content-Type: application/json'
PUT /api/v1/policies/{policyName} HTTP/1.1

Content-Type: application/json
const inputBody = '{
"policySettings": null
}';
const headers = {
'Content-Type':'application/json'
};

fetch('/api/v1/policies/{policyName}',
{
method: 'PUT',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

headers = {
'Content-Type' => 'application/json'
}

result = RestClient.put '/api/v1/policies/{policyName}',
params: {
}, headers: headers

p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}

r = requests.put('/api/v1/policies/{policyName}', headers = headers)

print(r.json())
<?php

require 'vendor/autoload.php';

$headers = array(
'Content-Type' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('PUT','/api/v1/policies/{policyName}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies/{policyName}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

headers := map[string][]string{
"Content-Type": []string{"application/json"},
}

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "/api/v1/policies/{policyName}", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

PUT /api/v1/policies/{policyName}

Updates a named policy with the provided values

Body parameter

{
"policySettings": null
}

Parameters

Name In Type Required Description
policyName path string true The name of the policy to create
body body WritePolicyBody true none

Responses

Status Meaning Description Schema
200 OK Policy Updated None
400 Bad Request Policy failed validation, reasons in response None
404 Not Found Specified schema or policy not found None
500 Internal Server Error Issues occurred when attempting to access storage. None

Get Policy

Code samples

# You can also use wget
curl -X GET /api/v1/policies/{policyName}
GET /api/v1/policies/{policyName} HTTP/1.1

fetch('/api/v1/policies/{policyName}',
{
method: 'GET'

})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

result = RestClient.get '/api/v1/policies/{policyName}',
params: {
}

p JSON.parse(result)
import requests

r = requests.get('/api/v1/policies/{policyName}')

print(r.json())
<?php

require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('GET','/api/v1/policies/{policyName}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies/{policyName}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "/api/v1/policies/{policyName}", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

GET /api/v1/policies/{policyName}

Gets a named policy

Parameters

Name In Type Required Description
policyName path string true The name of the policy to retrieve the details of

Responses

Status Meaning Description Schema
200 OK Policy found None
404 Not Found Specified schema or policy not found None
500 Internal Server Error Issues occurred when attempting to access storage. None

Delete Policy

Code samples

# You can also use wget
curl -X DELETE /api/v1/policies/{policyName}
DELETE /api/v1/policies/{policyName} HTTP/1.1

fetch('/api/v1/policies/{policyName}',
{
method: 'DELETE'

})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

result = RestClient.delete '/api/v1/policies/{policyName}',
params: {
}

p JSON.parse(result)
import requests

r = requests.delete('/api/v1/policies/{policyName}')

print(r.json())
<?php

require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('DELETE','/api/v1/policies/{policyName}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies/{policyName}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("DELETE", "/api/v1/policies/{policyName}", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

DELETE /api/v1/policies/{policyName}

Delete the specified policy

Parameters

Name In Type Required Description
policyName path string true The name of the policy to delete

Responses

Status Meaning Description Schema
200 OK OK None
403 Forbidden Attempt to delete ‘default’ policy None
404 Not Found Specified schema or policy not found None
500 Internal Server Error Storage error None

Get All Policies

Code samples

# You can also use wget
curl -X GET /api/v1/policies
GET /api/v1/policies HTTP/1.1

fetch('/api/v1/policies',
{
method: 'GET'

})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

result = RestClient.get '/api/v1/policies',
params: {
}

p JSON.parse(result)
import requests

r = requests.get('/api/v1/policies')

print(r.json())
<?php

require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('GET','/api/v1/policies', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "/api/v1/policies", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

GET /api/v1/policies

Gets a full list of all configured policies

Responses

Status Meaning Description Schema
200 OK A list of all policies None
404 Not Found Specified schema or policy not found None
500 Internal Server Error Issues occurred when attempting to access storage. None

Reset Policy

Code samples

# You can also use wget
curl -X PUT /api/v1/policies/{policyName}/reset
PUT /api/v1/policies/{policyName}/reset HTTP/1.1

fetch('/api/v1/policies/{policyName}/reset',
{
method: 'PUT'

})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'

result = RestClient.put '/api/v1/policies/{policyName}/reset',
params: {
}

p JSON.parse(result)
import requests

r = requests.put('/api/v1/policies/{policyName}/reset')

print(r.json())
<?php

require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('PUT','/api/v1/policies/{policyName}/reset', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...
URL obj = new URL("/api/v1/policies/{policyName}/reset");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main

import (
"bytes"
"net/http"
)

func main() {

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "/api/v1/policies/{policyName}/reset", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

PUT /api/v1/policies/{policyName}/reset

Resets a named policy to the default schema values

Parameters

Name In Type Required Description
policyName path string true The name of the policy to reset

Responses

Status Meaning Description Schema
200 OK Policy Updated None
400 Bad Request Policy failed validation, reasons in response None
404 Not Found Specified schema or policy not found None
500 Internal Server Error Issues occurred when attempting to access storage. None

Schemas

WritePolicyBody

{
"policySettings": null
}

The policy settings to be set for a named policy

Properties

Name Type Required Restrictions Description
policySettings any true none none