NAV

RubyPythonNode.jsPerlPHPC#JavacURL

Search
Introduction

This document describes the Pulseway REST API v2 usage.

The REST API accepts JSON as input. The output matches the Accept header and defaults to JSON if the Accept header is not present.

We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients.

Authentication

BASIC Authentication
class PublishResource < ActiveResource::Base self.site = ENDPOINT self.user = USERNAME self.password = PASSWORD self.timeout = 30 self.include_format_in_path = false end requests.post(ENDPOINT + ‘publish’, publish, auth=(USERNAME, PASSWORD), headers={“content-type”:”application/json”}) var Client = require(‘node-rest-client’).Client; var options_auth = {user: USERNAME, password: PASSWORD}; var client = new Client(options_auth); my $client = HTTP::Request->new( ‘GET’, $url);
$client->authorization_basic(“$username”, “$password”);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(ENDPOINT);
const string auth = USERNAME + “:” + PASSWORD;
byte[] authBytes = Encoding.ASCII.GetBytes(auth);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Basic”, Convert.ToBase64String(authBytes));
}
HttpPost post = new HttpPost(ENDPOINT + “publish”);
String auth = Base64.encodeBase64String((USERNAME + “:” + PASSWORD).getBytes());
post.setHeader(“Authorization”, “Basic ” + auth);
curl https://api.pulseway.com/v2/systems \
-u username:password
# If you host your own Pulseway Enterprise Server, use:
# curl https:///api/v2/systems \
Make sure to replace USERNAME and PASSWORD with your own credentials.
Pulseway REST API uses Basic Authentication for all requests. All requests must be via HTTPS otherwise the request will fail.

Basic Authentication requires an Authorization header with the Pulseway username and password in the username:password format encoded as Base64.

Systems

Publish
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

INSTANCE_ID = “production_website_1”
INSTANCE_NAME = “Production Web Site”
INSTANCE_GROUP = “Web Sites”

class System < ActiveRestClient::Base request_body_type :json base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ post :publish, “/systems” end begin puts “Publish…” @result = System.publish( “instance_id”: “production_website_1”, “name”: “Production Web Site”, “group”: “Web Sites”, “description”: “Running on ip.91.71.60.196.us-west-2.compute.internal”, “contents”: [ { “name”: “Status”, “contents”: [ { “icon”: “error”, “type”: “label”, “title”: “Could not connect to the database.”, “subtitle”: “Database Connection” }, { “icon”: “information”, “type”: “label”, “title”: “5 hours, 39 minutes”, “subtitle”: “Uptime” } ] }, { “name”: “Commands”, “contents”: [ { “callback_url”: “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;, “type”: “webhook_command”, “title”: “Reload Configuration”, “subtitle”: “Reads configuration from file” } ] } ], “next_refresh_interval_minutes”: 5, “notify_when_offline”: “false” ) puts @result.meta[‘response_code’] rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
result = api.systems.post(
{
“instance_id”: “production_website_1”,
“name”: “Production Web Site”,
“group”: “Web Sites”,
“description”: “Running on ip.91.71.60.196.us-west-2.compute.internal”,
“contents”: [
{
“name”: “Status”,
“contents”: [
{
“icon”: “error”,
“type”: “label”,
“title”: “Could not connect to the database.”,
“subtitle”: “Database Connection”
},
{
“icon”: “information”,
“type”: “label”,
“title”: “5 hours, 39 minutes”,
“subtitle”: “Uptime”
}
]
},
{
“name”: “Commands”,
“contents”: [
{
“callback_url”: “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;,
“type”: “webhook_command”,
“title”: “Reload Configuration”,
“subtitle”: “Reads configuration from file”
}
]
}
],
“next_refresh_interval_minutes”: 5,
“notify_when_offline”: “false”
});

print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;
var instance_id = “production_website_1”;
var instance_name = “Production Web Site”;
var instance_group = “Web Sites”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
// use limit & offset parameters
// parameters: { limit: “2”, offset: “0” }
data: {
instance_id: instance_id,
name: instance_name,
group: instance_group,
description: “Running on ip.91.71.60.196.us-west-2.compute.internal”,
contents: [
{
name: “Status”,
contents: [
{
icon: “error”,
type: “label”,
title: “Could not connect to the database.”,
subtitle: “Database Connection”
},
{
icon: “information”,
type: “label”,
title: “5 hours, 39 minutes”,
subtitle: “Uptime”
}
]
},
{
name: “Commands”,
contents: [
{
callback_url: “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;,
type: “webhook_command”,
title: “Reload Configuration”,
subtitle: “Reads configuration from file”
}]
}],
next_refresh_interval_minutes: 5,
notify_when_offline: “false”
},
headers: {“Content-Type”: “application/json”}
}

client.registerMethod(“publish”, endpoint + “systems”, “POST”);

client.methods.publish(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $query_object = ‘systems’;

my $uri = URI->new($endpoint.$query_object);

my $username = “username”;
my $password = “password”;

my $instance_id = “production_website_1”;
my $instance_name = “Production Web Site”;
my $instance_group = “Web Sites”;

my $publish = {
‘instance_id’ => $instance_id,
‘name’ => $instance_name,
‘group’ => $instance_group,
‘description’ => “Running on ip.91.71.60.196.us-west-2.compute.internal”,
‘contents’ => [
{
‘name’ => “Status”,
‘contents’ =>
[
{
‘icon’ => “error”,
‘type’ => “label”,
‘title’ => “Could not connect to the database.”,
‘subtitle’ => “Database Connection”
},
{
‘icon’ => “information”,
‘type’ => “label”,
‘title’=> “5 hours, 39 minutes”,
‘subtitle’ => “Uptime”
}
]
},
{
‘name’ => “Commands”,
‘contents’ =>
[
{
‘callback_url’ => “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;,
‘type’ => “webhook_command”,
‘title’ => “Reload Configuration”,
‘subtitle’ => “Reads configuration from file”
}
]
}],
‘next_refresh_interval_minutes’ => “5”,
‘notify_when_offline’ => “false”
};

my $json = new JSON;
my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($publish);

my $client = HTTP::Request->new( ‘POST’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘systems’
);

$publishRequest = array(
“instance_id” => INSTANCE_ID,
“name” => INSTANCE_NAME,
“group” => INSTANCE_GROUP,
“description” => “Running on ip.91.71.60.196.us-west-2.compute.internal”,
“contents” => array(
array(
“name” => “Status”,
“contents” => array(
array(
“icon” => “error”,
“type” => “label”,
“title” => “Could not connect to the database.”,
“subtitle” => “Database Connection”
),
array(
“icon” => “information”,
“type” => “label”,
“title” => “5 hours, 39 minutes”,
“subtitle” => “Uptime”
)
)
),
array(
“name” => “Commands”,
“contents” => array(
array(
“callback_url” => “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;,
“type” => “webhook_command”,
“title” => “Reload Configuration”,
“subtitle” => “Reads configuration from file”
)
)
)
),
“next_refresh_interval_minutes” => 5,
“notify_when_offline” => “false”
);

function request($opt, $data) {
$request = curl_init();
$data_string = json_encode($data);
$headers = array(
‘Content-Type: application/json’,
‘Content-Length: ‘.strlen($data_string)
);

$url = ENDPOINT . $opt[‘object’];

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($request, CURLOPT_POST, TRUE);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Publish

“;
$publishResponse = request(options, $publishRequest);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Publish’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class Program
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;
private const string INSTANCE_ID = “production_website_1”;
private const string INSTANCE_NAME = “Production Web Site”;
private const string INSTANCE_GROUP = “Web Sites”;

static void Main(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“systems”, Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(GetPublishRequest());

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}

private static PublishRequest GetPublishRequest()
{
PublishRequest publishRequest = new PublishRequest();
publishRequest.instance_id = INSTANCE_ID;
publishRequest.name = INSTANCE_NAME;
publishRequest.group = INSTANCE_GROUP;
publishRequest.description = “Running on ip.91.71.60.196.us-west-2.compute.internal”;
publishRequest.groups = new Group[2];
publishRequest.next_refresh_interval_minutes = 5;
publishRequest.notify_when_offline = false;

// Status Group
Group status = new Group();
status.name = “Status”;
Item label1 = new Item
{
icon = “error”,
title = “Cannot connect to the database.”,
subtitle = “Database Connection”,
type = “label”
};
Item label2 = new Item
{
icon = “information”,
title = “5 hours, 39 minutes”,
subtitle = “Uptime”,
type = “label”
};
status.contents = new[] { label1, label2 };
// Commands Group
Group commands = new Group();
commands.name = “Commands”;
Item webhook1 = new Item();
webhook1.callback_url = “https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;;
webhook1.title = “Reload Configuration”;
webhook1.subtitle = “Reads configuration from file”;
webhook1.type = “webhook_command”;
commands.contents = new[] { webhook1 };

publishRequest.groups = new[] { status, commands };
return publishRequest;
}

public class PublishRequest
{
public string instance_id { get; set; }
public string name { get; set; }
public string group { get; set; }
public string description { get; set; }
public Group[] groups { get; set; }
public int? next_refresh_interval_minutes { get; set; }
public bool notify_when_offline { get; set; }
}
public class Group
{
public string name { get; set; }
public Item[] contents { get; set; }
}
public class Item
{
public string icon { get; set; }
public string type { get; set; }
public string title { get; set; }
public string subtitle { get; set; }
public string callback_url { get; set; }
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Publish
{
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;
private static final String INSTANCE_ID = “production_website_1”;
private static final String INSTANCE_NAME = “Production Web Site”;
private static final String INSTANCE_GROUP = “Web Sites”;

private static PublishRequest getPublishRequest()
{
PublishRequest request = new PublishRequest();

request.setInstanceId(INSTANCE_ID);
request.setName(INSTANCE_NAME);
request.setGroup(INSTANCE_GROUP);
request.setDescription(“Running on ip.91.71.60.196.us-west-2.compute.internal”);
request.setNextRefreshIntervalMinutes(5);
request.notifyWhenOffline(false);

// Status Group
Group status = new Group();
status.setName(“Status”);
Item label1 = new Item();
label1.setIcon(“error”);
label1.setTitle(“Cannot connect to the database”);
label1.setSubtitle(“Database Connection”);
label1.setType(“label”);
Item label2 = new Item();
label2.setIcon(“information”);
label2.setTitle(“5 hours, 39 minutes”);
label2.setSubtitle(“Uptime”);
label2.setType(“label”);
status.setContents(new Item[]{label1, label2});

// Commands Group
Group commands = new Group();
commands.setName(“Commands”);
Item webhook1 = new Item();
webhook1.setCallbackUrl(“https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;);
webhook1.setTitle(“Reload Configuration”);
webhook1.setSubtitle(“Reads configuration from file.”);
webhook1.setType(“webhook_command”);
commands.setContents(new Item[]{webhook1});

request.setContents(new Group[]{status, commands});

return request;
}

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/systems”);
URI uri = builder.build();

HttpPost request = new HttpPost(uri);
request.setHeader(“Content-Type”, “application/json”);

String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

Gson gson = new Gson();

PublishRequest notifyRequest = getPublishRequest();
StringEntity notifyJson = new StringEntity(gson.toJson(notifyRequest));

request.setEntity(notifyJson);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.meta.response_code);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}
public static class Response
{
public Meta meta;

public Response() {}
}
public static class Meta
{
public String response_code;
public String error_message;

public Meta() {}
}
public static class PublishRequest
{
public String instance_id;
public String name;
public String group;
public String description;
public Group[] contents;
public int next_refresh_interval_minutes;
public boolean notify_when_offline;

public PublishRequest() {}

public void setInstanceId(String instance_id)
{
this.instance_id = instance_id;
}
public void setName(String name)
{
this.name = name;
}
public void setGroup(String group)
{
this.group = group;
}
public void setDescription(String description)
{
this.description = description;
}
public void setContents(Group[] contents)
{
this.contents = contents;
}
public void setNextRefreshIntervalMinutes(int next_refresh_interval_minutes)
{
this.next_refresh_interval_minutes = next_refresh_interval_minutes;
}
public void notifyWhenOffline(boolean notify_when_offline)
{
this.notify_when_offline = notify_when_offline;
}
}
public static class Group
{
public String name;
public Item[] contents;

public Group() {}

public void setName(String name)
{
this.name = name;
}
public void setContents(Item[] contents)
{
this.contents = contents;
}
}

public static class Item
{
public String icon;
public String type;
public String title;
public String subtitle;
public String callback_url;

public Item() {}

public void setIcon(String icon)
{
this.icon = icon;
}
public void setType(String type)
{
this.type = type;
}
public void setTitle(String title)
{
this.title = title;
}
public void setSubtitle(String subtitle)
{
this.subtitle = subtitle;
}
public void setCallbackUrl(String callback_url)
{
this.callback_url = callback_url;
}
}
}
curl https://api.pulseway.com/v2/systems \
-u username:password \
-X POST \
-H “Content-Type: application/json” \
-d ‘{“instance_id”:”production_website_1″,”name”:”Production Web Site”,”group”:”Web Sites”,”description”:”Running on ip.91.71.60.196.us-west-2.compute.internal”,”contents”:[{“name”:”Status”,”contents”:[{“icon”:”error”,”type”:”label”,”title”:”Could not connect to the database.”,”subtitle”:”Database Connection”},{“icon”:”information”,”type”:”label”,”title”:”5 hours, 39 minutes”,”subtitle”:”Uptime”}]},{“name”:”Commands”,”contents”:[{“callback_url”:”https://admin.revoproject.com/api.php?key=d41d8cd98&action=reset_config&#8221;,”type”:”webhook_command”,”title”:”Reload Configuration”,”subtitle”:”Reads configuration from file”}]}],”next_refresh_interval_minutes”:5,”notify_when_offline”:”false”}’
The above command returns JSON structured like this:
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
Publish registers or updates a Pulseway system instance.

HTTP Request

https://api.pulseway.com/v2/systems

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

POST

Fields

Name Value Required Description
instance_id string yes Unique instance identifier. (maximum 100 characters)
name string yes Name of the instance. (maximum 100 characters)
group string no Group of the instance. Defaults to ‘Default’. (maximum 100 characters)
description string no Instance description. Shows under the instance name. (maximum 255 characters)
contents array no Data used to create the details view. See Group.
next_refresh_interval_minutes string no Marks the instance as offline if the Publish method is not called again after the specified interval. Zero disables the offline counter.
notify_when_offline string no If the next refresh interval was specified, a notification will be sent if the instance goes offline for an extended period of time.
Group

Name Value Required Description
name string yes Name of the group.
contents array no An array of items of type Label or Web Hook Commands that are part of the group. See Label and Web Hook Command.
Label

Name Value Required Description
type string yes Type of the object. Must be set to label.
title string yes Title of the label. Appears on the first line of the label.
subtitle string no Subtitle of the label. Appears on the second line of the label.
icon string no Appears to the left of the text. Possible values: information, warning and error.
Web Hook Command

Name Value Required Description
type string yes Type of the object. Must be set to webhook_command.
callback_url string yes Url that gets invoked when the command triggers.
title string yes Title of the command. Appears on the first line of the button.
subtitle string no Subtitle of the command. Appears on the second line of the button.
Get All Systems
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class System < ActiveRestClient::Base # use limit & offset parameters before_request do |name, request| request.get_params[:limit] = “50” request.get_params[:offset] = “0” end base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ get :all, “/systems” end begin puts “Get Systems…” @result = System.all puts @result.data.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
# use limit & offset parameters
result = api.systems.get(limit=’50’, offset=’0′)
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
// use limit & offset parameters
parameters: { limit: “50”, offset: “0” }
}

client.registerMethod(“getSystems”, endpoint + “systems”, “GET”);

client.methods.getSystems(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $query_object = ‘systems’;

my $uri = URI->new($endpoint.$query_object);
# use limit & offset parameters
$uri->query_form(‘limit’ => ’50’, ‘offset’ => ‘0’);

my $username = “username”;
my $password = “password”;

my $client = HTTP::Request->new( ‘GET’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘systems’
);

// use limit & offset parameters
const params = array (
‘limit’ => ’50’,
‘offset’ => ‘0’
);

function request($opt, $params) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];

$parameters = ”;
if (isset($params[‘limit’]) || isset($params[‘offset’]))
foreach($params as $key=>$value)
$parameters .= $key.’=’.$value.’&’;

$parameters = trim($parameters, ‘&’);

curl_setopt($request, CURLOPT_URL, (isset($params[‘limit’]) || isset($params[‘offset’])) ? $url.’?’.$parameters : $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get Systems

“;
$publishResponse = request(options, params);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get Systems’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;
using System;

namespace Program
{
class GetSystems
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“systems”, Method.GET);

request.AddParameter(“limit”, “50”);
request.AddParameter(“offset”, “0”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSystems {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/systems”)
.setParameter(“limit”, “50”)
.setParameter(“offset”, “0”);
URI uri = builder.build();

HttpGet request = new HttpGet(uri);
request.setHeader(“Content-Type”, “application/json”);
String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Gson gson = new Gson();
Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.data[0].identifier);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}
public class Response
{
public Systems[] data;
public Meta meta;
}
public class Systems
{
public String identifier;
public String name;
public String group;
}
public class Meta
{
public String response_code;
public String error_message;
}
}
curl https://https://api.pulseway.com/v2/systems \
-u username:password

# If you want to use limit & offset parameters, append
# “?&limit=50&offset=0” to the url
The above command returns JSON structured like this:
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“identifier”:”11111111-2222-3333-9B2F-016B8D621AB5″,
“name”:” Computer1″,
“group”:”Group1″
},
{
“identifier”:”66666666-7777-8888-9B2F-016B8D621AB5″,
“name”:” Computer2″,
“group”:”Group1″
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
Returns a list of systems.

HTTP Request

https://api.pulseway.com/v2/systems

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

GET

Query Parameters

Parameter Value Required Description
limit string no maximum number of items to return, limited to 100
offset string no starting position
Get a Specific System
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class System < ActiveRestClient::Base base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ get :find, “/systems/:id” end begin puts “Get System…” @result = System.find(‘28440dda-f385-4ec8-a5c3-d1e6074113bb’) puts @result.data.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
# result = api.systems.get();
result = api.systems(“28440dda-f385-4ec8-a5c3-d1e6074113bb”).get()
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
path: { “id”: ‘28440dda-f385-4ec8-a5c3-d1e6074113bb’ },
}

client.registerMethod(“getSystem”, endpoint + “systems/${id}”, “GET”);

client.methods.getSystems(args, function (data, response) {
console.log(data);
});
#!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use Data::Dumper;
use MIME::Base64;

my $endpoint = “https://api.pulseway.com/v2/&#8221;;
my $username = “username”;
my $password = “password”;
my $id = “28440dda-f385-4ec8-a5c3-d1e6074113bb”;

my $client = HTTP::Request->new( ‘GET’, $endpoint .’systems’.’/’.$id);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘systems’,
‘id’ => ‘28440dda-f385-4ec8-a5c3-d1e6074113bb’
);

function request($opt) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];
if (isset($opt[‘id’]))
$url = ENDPOINT . $opt[‘object’] . ‘/’ . $opt[“id”];

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get System

“;
$publishResponse = request(options);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get System’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class GetSystem
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“systems/{id}”, Method.GET);
request.AddUrlSegment(“id”, “28440dda-f385-4ec8-a5c3-d1e6074113bb”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSystem {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;
private static final String ID = “28440dda-f385-4ec8-a5c3-d1e6074113bb”;

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/systems/”+ ID);
URI uri = builder.build();

HttpGet request = new HttpGet(uri);
request.setHeader(“Content-Type”, “application/json”);
String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Gson gson = new Gson();
Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.data.description);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}

public class Response
{
public SystemDetails data;
public Meta meta;
}
public class SystemDetails
{
public String identifier;
public String name;
public String group;
public String description;
public String external_ip_address;
public String uptime;
public boolean is_online;
public String computer_type;
public String client_version;
public boolean in_maintenance;
public int critical_notifications;
public int elevated_notifications;
public int normal_notifications;
public int low_notifications;
}
public class Meta
{
public String response_code;
public String error_message;
}
}
curl https://api.pulseway.com/v2/systems/28440dda-f385-4ec8-a5c3-d1e6074113bb \
-u username:password
The above command returns JSON structured like this:
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
{
“description”:”Windows 10 Enterprise”,
“uptime”:”Offline since 63 days ago”,
“is_online”:false,
“computer_type”:”windows”,
“in_maintenance”:false,
“external_ip_address”:”1.2.3.4″,
“critical_notifications”:0,
“elevated_notifications”:0,
“normal_notifications”:0,
“low_notifications”:0,
“client_version”:”4.8.5″,
“identifier”:”28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“name”:”MyPC”,
“group”:”Home”
},
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
Returns the system details.

HTTP Request

https://api.pulseway.com/v2/systems/:id

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes the value of the system identifier
Get System Notifications
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class System < ActiveRestClient::Base # use limit & offset parameters before_request do |name, request| request.get_params[:limit] = “50” request.get_params[:offset] = “0” end base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ get :notifications, “/systems/:id/notifications” end begin puts “Get System Notifications…” @result = System.notifications(‘28440dda-f385-4ec8-a5c3-d1e6074113bb’) puts @result.data.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
# result = api.systems.get();
result = api.systems(“28440dda-f385-4ec8-a5c3-d1e6074113bb”).notifications.get()
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
path: { “id”: ‘28440dda-f385-4ec8-a5c3-d1e6074113bb’ },
}

client.registerMethod(“getSystemNotifications”, endpoint + “systems/${id}/notifications”, “GET”);

client.methods.getSystemNotifications(args, function (data, response) {
console.log(data);
});
##!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
$endpoint->query_form(‘limit’ => ’50’, ‘offset’ => ‘0’);
my $username = “username”;
my $password = “password”;
my $id = “28440dda-f385-4ec8-a5c3-d1e6074113bb”;

my $uri = URI->new(‘systems/’.$id.’/notifications’)->abs($endpoint);

my $client = HTTP::Request->new( ‘GET’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘systems’,
‘id’ => ‘28440dda-f385-4ec8-a5c3-d1e6074113bb’
);

// use limit & offset parameters
const params = array (
‘limit’ => ’50’,
‘offset’ => ‘0’
);

function request($opt, $params) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];
if (isset($opt[‘id’]))
$url = ENDPOINT . $opt[‘object’] . ‘/’ . $opt[“id”].’/’.’notifications’;

$parameters = ”;
if (isset($params[‘limit’]) || isset($params[‘offset’]))
foreach($params as $key=>$value)
$parameters .= $key.’=’.$value.’&’;

$parameters = trim($parameters, ‘&’);

curl_setopt($request, CURLOPT_URL, (isset($params[‘limit’]) || isset($params[‘offset’])) ? $url.’?’.$parameters : $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get System Notifications

“;
$publishResponse = request(options, params);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get System Notifications’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class GetSystemNotifications
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“systems/{id}/notifications”, Method.GET);
request.AddUrlSegment(“id”, “28440dda-f385-4ec8-a5c3-d1e6074113bb”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetSystemNotifications {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;
private static final String ID = “28440dda-f385-4ec8-a5c3-d1e6074113bb”;

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/systems/”+ ID + “/notifications”)
.setParameter(“limit”, “50”)
.setParameter(“offset”, “0”);
URI uri = builder.build();

HttpGet request = new HttpGet(uri);
request.setHeader(“Content-Type”, “application/json”);
String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Gson gson = new Gson();

Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.data.length);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}

public class Response
{
public Notification[] data;
public Meta meta;
}
public class Notification
{
public int id;
public String message;
public int date_time;
public String priority;
}
public class Meta
{
public String response_code;
public String error_message;
}
}
curl https://https://api.pulseway.com/v2/systems/28440dda-f385-4ec8-a5c3-d1e6074113bb/notifications \
-u username:password

# If you want to use limit & offset parameters, append
# “?&limit=50&offset=0” to the url
The above command returns JSON structured like this:
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
{
“data”:
[
{
“id”:2733,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388894,
“priority”:”critical”
},
{
“id”:2732,
“message”:”Production Web Site Instance in group Web Sites cannot connect to the database.”,
“date_time”:1463388888,
“priority”:”critical”
}
],
“meta”:
{
“response_code”:200,
“error_message”:null
}
}
Return the system notifications.

HTTP Request

https://api.pulseway.com/v2/systems/:id/notifications

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes the value of the system identifier
Query Parameters

Parameter Value Required Description
limit string no maximum number of items to return, limited to 100
offset string no starting position
Notifications

Notify
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

INSTANCE_ID = “production_website_1”
INSTANCE_NAME = “Production Web Site”
INSTANCE_GROUP = “Web Sites”

class Notification < ActiveRestClient::Base request_body_type :json base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ post :notify, “/notifications” end begin puts “Notify…” @result = Notification.notify( “instance_id”: “production_website_1”, “title”: “Runtime error”, “message”: “Cannot connect to the database.”, “priority”: “critical” ) puts @result.meta[‘response_code’] rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
result = api.notifications.post(
{
“instance_id”: “production_website_1”,
“title”: “Runtime error”,
“message”: “Cannot connect to the database.”,
“priority”: “critical”
}
);

print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;
var instance_id = “production_website_1”;
var instance_name = “Production Web Site”;
var instance_group = “Web Sites”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
// use limit & offset parameters
// parameters: { limit: “2”, offset: “0” }
data: {
instance_id: instance_id,
title: “Database Connection Error”,
message: instance_name + ” Instance in group ” + instance_group + ” cannot connect to the database”,
priority: “critical”
},
headers: {“Content-Type”: “application/json”}
}

client.registerMethod(“notify”, endpoint + “notifications”, “POST”);

client.methods.notify(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON -support_by_pp;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $query_object = ‘notifications’;

my $uri = URI->new($endpoint.$query_object);

my $username = “username”;
my $password = “password”;

my $instance_id = “production_website_1”;
my $instance_name = “Production Web Site”;
my $instance_group = “Web Sites”;

my $notify = {
‘instance_id’ => $instance_id,
‘title’ => “Cannot connect to the database”,
‘message’ => “Database Connection Error”,
‘priority’ => “critical”
};

my $json = new JSON;

my $data = $json->allow_nonref->pretty->utf8->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->encode($notify);

my $client = HTTP::Request->new( ‘POST’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);
$client->content($data);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘notifications’
);

$notifyRequest = array(
“instance_id” => INSTANCE_ID,
“title” => “Database Connection Error”,
“message” => INSTANCE_NAME.” Instance in group “.INSTANCE_GROUP.” cannot connect to the database.”,
“priority” => “critical”
);

function request($opt, $data) {
$request = curl_init();
$data_string = json_encode($data);
$headers = array(
‘Content-Type: application/json’,
‘Content-Length: ‘.strlen($data_string)
);

$url = ENDPOINT . $opt[‘object’];

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($request, CURLOPT_POST, TRUE);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Publish

“;
$publishResponse = request(options, $notifyRequest);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Publish’ exception: “, $e.getMessage(), ”

“;
}
?>

package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class Notify {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;
private static final String INSTANCE_ID = “production_website_1”;

private static NotifyRequest getNotifyRequest()
{
NotifyRequest request = new NotifyRequest();
request.setInstanceId(INSTANCE_ID);
request.setTitle(“Could not connect to the database.”);
request.setMessage(“Database Connection Error”);
request.setPriority(“critical”);
return request;
}

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/notifications”);
URI uri = builder.build();

HttpPost request = new HttpPost(uri);
request.setHeader(“Content-Type”, “application/json”);

String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

Gson gson = new Gson();

NotifyRequest notifyRequest = getNotifyRequest();
StringEntity notifyJson = new StringEntity(gson.toJson(notifyRequest));

request.setEntity(notifyJson);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.meta.response_code);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}
public static class Response
{
public Meta meta;
}
public static class Meta
{
public String response_code;
public String error_message;
}
public static class NotifyRequest
{
public String instance_id;
public String title;
public String message;
public String priority;

public void setInstanceId(String instance_id)
{
this.instance_id = instance_id;
}
public void setTitle(String title)
{
this.title = title;
}
public void setMessage(String message)
{
this.message = message;
}
public void setPriority(String priority)
{
this.priority = priority;
}
}
}
curl https://api.pulseway.com/v2/notifications \
-u username:password \
-X POST \
-H “Content-Type: application/json” \
-d ‘{“instance_id”:”production_website_1″,”title”:”Runtime error”,”message”:”Cannot connect to the database.”,”priority”:”critical”}’
The above command returns JSON structured like this:
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
Creates a system notification.

HTTP Request

https://api.pulseway.com/v2/notifications

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

POST

Fields

Name Value Required Description
instance_id string yes Identifier of the instance that triggered the notification. (maximum 100 characters)
title string yes Notification title that is displayed in the PUSH notification.
message string no Notification message appears in the Notification Detail view. Defaults to the title field. (maximum 5000 characters)
priority string no Possible values: low, normal, elevated, critical. Defaults to normal.
Get All Notifications
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base # use limit & offset parameters before_request do |name, request| request.get_params[:limit] = “2” request.get_params[:offset] = “0” end base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ get :all, “/notifications” end begin puts “Get Notifications…” @result = Notification.all puts @result.data.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
# use limit & offset parameters
result = api.notifications.get(limit=’2′, offset=’0′)
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
// use limit & offset parameters
parameters: { limit: “2”, offset: “0” }
}

client.registerMethod(“getNotifications”, endpoint + “notifications”, “GET”);

client.methods.getNotifications(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $username = “username”;
my $password = “password”;

my $uri = URI->new($endpoint.’notifications’);
$uri->query_form(‘limit’ => ‘2’, ‘offset’ => ‘0’);

my $client = HTTP::Request->new( ‘GET’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘notifications’
);

// use limit & offset parameters
const params = array (
‘limit’ => ‘2’,
‘offset’ => ‘0’
);

function request($opt, $params) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];

$parameters = ”;
if (isset($params[‘limit’]) || isset($params[‘offset’]))
foreach($params as $key=>$value)
$parameters .= $key.’=’.$value.’&’;

$parameters = trim($parameters, ‘&’);

curl_setopt($request, CURLOPT_URL, (isset($params[‘limit’]) || isset($params[‘offset’])) ? $url.’?’.$parameters : $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get Notifications

“;
$publishResponse = request(options, params);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get Notifications’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class GetNotifications
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“notifications”, Method.GET);

request.AddParameter(“limit”, “2”);
request.AddParameter(“offset”, “0”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotifications {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/notifications”)
.setParameter(“limit”, “5”)
.setParameter(“offset”, “0”);
URI uri = builder.build();

HttpGet request = new HttpGet(uri);
request.setHeader(“Content-Type”, “application/json”);
String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Gson gson = new Gson();

Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.data.length);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}
public class Response
{
public Notification[] data;
public Meta meta;
}
public class Notification
{
public int id;
public String message;
public int date_time;
public String priority;
}
public class Meta
{
public String response_code;
public String error_message;
}
}
curl https://https://api.pulseway.com/v2/notifications \
-u username:password

# If you want to use limit & offset parameters, append
# “?&limit=2&offset=0” to the url
The above command returns JSON structured like this:
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
{
“data”: [
{
“id”: 2750,
“message”: ‘Production Web Site Instance in group Web Sites cannot connect to the database’,
“date_time”: 1463473104,
“priority”: ‘critical’
},
{
“id”: 2749,
“message”: ‘Cannot connect to the database.’,
“date_time”: 1463473083,
“priority”: ‘critical’
}
],
“meta”:
{
“response_code”: 200,
“error_message”: null
}
}
Returns the system notifications.

HTTP Request

https://api.pulseway.com/v2/notifications

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

GET

Query Parameters

Parameter Value Required Description
limit string no maximum number of items to return, limited to 100
offset string no starting position
Get a Specific Notification
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ get :find, “/notifications/:id” end begin puts “Get Notification…” @result = Notification.find(2643) puts @result.data.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
result = api.notifications(2643).get()
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
path: { “id”: 2643 },
}

client.registerMethod(“getNotification”, endpoint + “notifications/${id}”, “GET”);

client.methods.getNotification(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $username = “username”;
my $password = “password”;
my $id = 2643;

my $uri = URI->new($endpoint.’notifications’.’/’.$id);

my $client = HTTP::Request->new( ‘GET’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘notifications’,
‘id’ => 2643
);

function request($opt) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];
if (isset($opt[‘id’]))
$url = ENDPOINT . $opt[‘object’] . ‘/’ . $opt[“id”];

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get Notification

“;
$publishResponse = request(options);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get Notification’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class GetNotification
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“notifications/{id}”, Method.GET);
request.AddUrlSegment(“id”, “2643”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}
package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.*;
import org.apache.http.util.EntityUtils;
import com.google.gson.Gson;

public class GetNotification {
private static final String ENDPOINT = “api.pulseway.com/v2/”;
private static final String USERNAME = “username”;
private static final String PASSWORD = “password”;
private static final int ID = 2643;

public static void main(String[] args)
{
try
{
URIBuilder builder = new URIBuilder();
builder.setScheme(“https”).setHost(ENDPOINT).setPath(“/notifications/”+ ID);
URI uri = builder.build();

HttpGet request = new HttpGet(uri);
request.setHeader(“Content-Type”, “application/json”);
String auth = new String(Base64.encodeBase64((USERNAME + “:” + PASSWORD).getBytes()), StandardCharsets.UTF_8.toString());
request.setHeader(“Authorization”, “Basic ” + auth);

HttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(request);

HttpEntity httpEntity = response.getEntity();
String apiOutput = EntityUtils.toString(httpEntity);

Gson gson = new Gson();

Response resp = gson.fromJson(new StringReader(apiOutput), Response.class);

System.out.println(resp.data.computer_identifier);
}
catch (Exception ex)
{
System.out.println(“An exception has occurred: ” + ex.getMessage());
}
}

public class Response
{
public NotificationDetails data;
public Meta meta;
}
public class NotificationDetails
{
public int id;
public String message;
public int date_time;
public String priority;
public String computer_identifier;
public boolean read;
}
public class Meta
{
public String response_code;
public String error_message;
}
}
curl https://https://api.pulseway.com/v2/notifications/2643 \
-u username:password
The above command returns JSON structured like this:
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
{
“data”:
{
“computer_identifier”: “28440dda-f385-4ec8-a5c3-d1e6074113bb”,
“read”: false,
“id”: 2643,
“message”: “Production Web Site Instance in group Web Sites cannot connect to the database”,
“date_time”: 1463473104,
“priority”: “critical”
},
“meta”: {
“response_code”: 200,
“error_message”: null
}
}
Returns the notification details.

HTTP Request

https://api.pulseway.com/v2/notifications/:id

If you host your own Pulseway Enterprise Server, use “https://your-server-name/api/v2/” as base URL.
HTTP Verb

GET

URL Parameters

Parameter Value Required Description
id string yes the value of the notification identifier
Delete a Specific Notification
require ‘rubygems’
require ‘active_rest_client’
require ‘openssl’

silence_warnings do
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

class Notification < ActiveRestClient::Base base_url ‘https://api.pulseway.com/v2/&#8217; username ‘username’ password ‘password’ delete :del, “/notifications/:id” end begin puts “Delete Notification…” @result = Notification.del(2643) puts @result.meta.to_json rescue Exception => e
puts e.message
end
import slumber

ENDPOINT = “https://api.pulseway.com/v2/&#8221;
USERNAME = “username”
PASSWORD = “password”

try:
api = slumber.API(ENDPOINT, auth=(USERNAME, PASSWORD))
result = api.notifications(2643).delete()
print (result)

except Exception as e:
print(‘Publish raised an exception.’)
print(e.strerror)
var endpoint = “https://api.pulseway.com/v2/&#8221;;
var username = “username”;
var password = “password”;

var Client = require(‘node-rest-client’).Client;
var auth = { user: username, password: password };

var client = new Client(auth);

var args = {
path: { “id”: 2643 },
}

client.registerMethod(“deleteNotification”, endpoint + “notifications/${id}”, “DELETE”);

client.methods.deleteNotification(args, function (data, response) {
console.log(data);
});
#!/usr/bin #!/usr/bin/perl

package main;
use strict;
use REST::Client;
use JSON;
use URI;
use Data::Dumper;
use MIME::Base64;

my $endpoint = ‘https://api.pulseway.com/v2/&#8217;;
my $username = “username”;
my $password = “password”;
my $id = 2643;

my $uri = URI->new($endpoint.’notifications’.’/’.$id);

my $client = HTTP::Request->new( ‘DELETE’, $uri);

$client->header(‘Content-Type’ => ‘application/json’ );
$client->authorization_basic(“$username”, “$password”);

my $response = LWP::UserAgent->new->request($client);

if ($response->is_success) {
my $jsonobj = JSON::decode_json($response->decoded_content);

# Data::Dumper makes it easy to see what the JSON returned actually looks like
# when converted into Perl data structures.

print Dumper($jsonobj->{‘meta’});
print Dumper($jsonobj->{‘data’});
} else {
die $response->status_line;
}
‘notifications’,
‘id’ => 2643
);

function request($opt) {
$request = curl_init();
$headers = array(
‘Content-Type: application/json’
);

$url = ENDPOINT . $opt[‘object’];
if (isset($opt[‘id’]))
$url = ENDPOINT . $opt[‘object’] . ‘/’ . $opt[“id”];

curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, “DELETE”);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME.”:”.PASSWORD);

$response = curl_exec($request);
if ($response == FALSE) {
die(‘Curl failed: ‘.curl_error($request).’

‘);
}

return $response;
}

try {
echo “Get Notification

“;
$publishResponse = request(options);
echo “”.$publishResponse.”

“;
}
catch (Exception $e) {
echo “‘Get Notification’ exception: “, $e.getMessage(), ”

“;
}
?>
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Authenticators;

namespace ConsoleApplication2
{
class DeleteNotification
{
private const string ENDPOINT = “https://api.pulseway.com/v2/&#8221;;
private const string USERNAME = “username”;
private const string PASSWORD = “password”;

static void Main1(string[] args)
{
var client = new RestClient(ENDPOINT);
client.Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD);

var request = new RestRequest(“notifications/{id}”, Method.DELETE);
request.AddUrlSegment(“id”, “2643”);

var response = client.Execute(request) as RestResponse;
var content = response.Content;
dynamic result = JsonConvert.DeserializeObject(content);
}
}
}

package com.pulseway.client;

import java.io.StringReader;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import org.apache.commons.codec.binary.Base64;
import org.apache.htt…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s