# Packages

No description provided by the author
No description provided by the author

# README

Go API client for openapi

Welcome to the Pingdom API!

The Pingdom API is a way for you to automate your interaction with the Pingdom system. With the API, you can create your own scripts or applications with most of the functionality you can find inside the Pingdom control panel.

The Pingdom API is RESTful and HTTP-based. Basically, this means that the communication is made through normal HTTP requests.

Authentication

Authentication is needed in order to use the Pingdom API, and for this a Pingdom API Token is required. You generate your Pingdom API Token inside My Pingdom. The Pingdom API Token has a property called “Access level” to define its permissions. All operations that create or modify something (e.g. checks) need the Read/Write permission. If you only need to read data using the API token, we recommend to set the access level to “Read access”.

The authentication method for using tokens is HTTP Bearer Authentication (encrypted over HTTPS). This means that you will provide your token every time you make a request. No sessions are used.

Request

GET /checks HTTP/1.1
Host: api.pingdom.com
Authorization: Bearer ofOhK18Ca6w4S_XmInGv0QPkqly-rbRBBoHsp_2FEH5QnIbH0VZhRPO3tlvrjMIKQ36VapX

Response

HTTP/1.1 200 OK
Content-Length: 13
Content-Type: application/json
{\"checks\":[]}

Basic Auth

For compatibility reasons, the Pingdom API allows to use HTTP Basic Authentication with tokens. In cases where this is necessary, input the API token as the username and leave the password field empty.

An example request of how that would look like with the following API token: ofOhK18Ca6w4S_XmInGv0QPkqly-rbRBBoHsp_2FEH5QnIbH0VZhRPO3tlvrjMIKQ36VapX

GET /checks HTTP/1.1
Host: api.pingdom.com
Authorization: Basic b2ZPaEsxOENhNnc0U19YbUluR3YwUVBrcWx5LXJiUkJCb0hzcF8yRkVINVFuSWJIMFZaaFJQTzN0bHZyak1JS1EzNlZhcFg6

Server Address

The base server address is: https://api.pingdom.com

Please note that HTTPS is required. You will not be able to connect through unencrypted HTTP.

Providing Parameters

GET requests should provide their parameters as a query string, part of the URL.

POST, PUT and DELETE requests should provide their parameters as a JSON. This should be part of the request body. Remember to add the proper content type header to the request: Content-Type: application/json.

We still support providing parameters as a query string for POST, PUT and DELETE requests, but we recommend using JSON going forward. If you are using query strings, they should be part of the body, URL or a combination. The encoding of the query string should be standard URL-encoding, as provided by various programming libraries.

When using requests library for Python, use json parameter instead of data. Due to the inner mechanisms of requests.post() etc. some endpoints may return responses not conforming to the documentation when dealing with data body.

HTTP/1.1 Status Code Definitions

The HTTP status code returned by a successful API request is defined in the documentation for that method. Usually, this will be 200 OK.

If something goes wrong, other codes may be returned. The API uses standard HTTP/1.1 status codes defined by RFC 2616.

JSON Responses

All responses are sent JSON-encoded. The specific responses (successful ones) are described in the documentation section for each method.

However, if something goes wrong, our standard JSON error message (together with an appropriate status code) follows this format:

{
    \"error\": {
        \"statuscode\": 403,
        \"statusdesc\": \"Forbidden\",
        \"errormessage\":\" Something went wrong! This string describes what happened.\"
    }
}

See http://en.wikipedia.org/wiki/Json for more information on JSON.

Please note that all attributes of a method response are not always present. A client application should never assume that a certain attribute is present in a response.

Limits

The Pingdom API has usage limits to avoid individual rampant applications degrading the overall user experience. There are two layers of limits, the first cover a shorter period of time and the second a longer period. This enables you to "burst" requests for shorter periods. There are two HTTP headers in every response describing your limits status.

The response headers are:

  • Req-Limit-Short
  • Req-Limit-Long

An example of the values of these headers:

  • Req-Limit-Short: Remaining: 394 Time until reset: 3589
  • Req-Limit-Long: Remaining: 71994 Time until reset: 2591989

In this case, we can see that the user has 394 requests left until the short limit is reached. In 3589 seconds, the short limit will be reset. In similar fashion, the long limit has 71994 requests left, and will be reset in 2591989 seconds.

If limits are exceeded, an HTTP 429 error code with the message "Request limit exceeded, try again later" is sent back.

gzip

Responses can be gzip-encoded on demand. This is nice if your bandwidth is limited, or if big results are causing performance issues.

To enable gzip, simply add the following header to your request:

Accept-Encoding: gzip

Best Practices

Use caching

If you are building a web page using the Pingdom API, we recommend that you do all API request on the server side, and if possible cache them. If you get any substantial traffic, you do not want to call the API each time you get a page hit, since this may cause you to hit the request limit faster than expected. In general, whenever you can cache data, do so.

Send your user credentials in a preemptive manner

Some HTTP clients omit the authentication header, and make a second request with the header when they get a 401 Unauthorized response. Please make sure you send the credentials directly, to avoid unnecessary requests.

Use common sense

Should be simple enough. For example, don't check for the status of a check every other second. The highest check resolution is one minute. Checking more often than that won't give you much of an advantage.

The Internet is unreliable

Networks in general are unreliable, and particularly one as large and complex as the Internet. Your application should not assume it will get an answer. There may be timeouts.

PHP Code Example

"This is too much to read. I just want to get started right now! Give me a simple example!"

Here is a short example of how you can use the API with PHP. You need the cURL extension for PHP.

The example prints the current status of all your checks. This sample obviously focuses on Pingdom API code and does not worry about any potential problems connecting to the API, but your code should.

Code:

<?php
    // Init cURL
    $curl = curl_init();
    // Set target URL
    curl_setopt($curl, CURLOPT_URL, \"https://api.pingdom.com/api/3.1/checks\");
    // Set the desired HTTP method (GET is default, see the documentation for each request)
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, \"GET\");
    // Add header with Bearer Authorization
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(\"Authorization: Bearer 907c762e069589c2cd2a229cdae7b8778caa9f07\"));
    // Ask cURL to return the result as a string
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    // Execute the request and decode the json result into an associative array
    $response = json_decode(curl_exec($curl), true);
    // Check for errors returned by the API
    if (isset($response['error'])) {
        print \"Error: \" . $response['error']['errormessage'] . \"\\n\";
        exit;
    }
    // Fetch the list of checks from the response
    $checksList = $response['checks'];
    // Print the names and statuses of all checks in the list
    foreach ($checksList as $check) {
        print $check['name'] . \" is \" . $check['status'] . \"\\n\";
    }
?>

Example output:

Ubuntu Packages is up
Google is up
Pingdom is up
My server 1 is down
My server 2 is up

If you are running PHP on Windows, you need to be sure that you have installed the CA certificates for HTTPS/SSL to work correctly. Please see the cURL manual for more information. As a quick (but unsafe) workaround, you can add the following cURL option to ignore certificate validation.

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

TMS Steps Vocabulary

There are two types of transaction checks:

  • script: the legacy TMS check created with predefined commands in the Pingdom UI or via the public API
  • recording: the TMS check created by recording performed actions in WPM recorder. More information about how to use it can be found in the WPM recorder documentation

Script transaction checks

Commands

Actions to be performed for the script TMS check

Step Name"fn"Required "args"Remarks
Go to URLgo_tourlThere has to be exactly one go_to step
Clickclickelementlabel, name or CSS selector
Fill in fieldfillinput, valueinput: label, name or CSS selector, value: text
Check checkboxcheckcheckboxlabel, name or CSS selector
Uncheck checkboxuncheckcheckboxlabel, name or CSS selector
Sleep forsleepsecondsnumber (e.g. 0.1)
Select radio buttonselect_radioradioname of the radio button
Select dropdownselectselect, optionselect: label, name or CSS selector, option: content, value or CSS selector
Basic auth login withbasic_authusername, passwordusername and password as text
Submit formsubmitformname or CSS selector
Wait for elementwait_for_elementelementlabel, name or CSS selector
Wait for element to containwait_for_containselement, valueelement: label, name or CSS selector, value: text

Validations

Verify the state of the page

Step Name"fn"Required "args"Remarks
URL should beurlurlurl to be verified
Element should existexistselementlabel, name or CSS selector
Element shouldn't existnot_existselementlabel, name or CSS selector
Element should containcontainselement, valueelement: label, name or CSS selector, value: text
Element shouldn't containtnot_containselement, valueelement: label, name or CSS selector, value: text
Text field should containfield_containsinput, valueinput: label, name or CSS selector, value: text
Text field shouldn't containfield_not_containsinput, valueinput: label, name or CSS selector, value: text
Checkbox should be checkedis_checkedcheckboxlabel, name or CSS selector
Checkbox shouldn't be checkedis_not_checkedcheckboxlabel, name or CSS selector
Radio button should be selectedradio_selectedradioname of the radio button
Dropdown with name should be selecteddropdown_selectedselect, optionselect: label, name or CSS selector, option: content, value or CSS selector
Dropdown with name shouldn't be selecteddropdown_not_selectedselect, optionselect: label, name or CSS selector, option: content, value or CSS selector

Example steps

\"steps\": [
{
  \"fn\": \"go_to\",
  \"args\": {
    \"url\": \"pingdom.com\"
  }
},
{
  \"fn\": \"click\",
  \"args\": {
    \"element\": \"START FREE TRIAL\"
  }
},
{
  \"fn\": \"url\",
  \"args\": {
    \"url\": \"https://www.pingdom.com/sign-up/\"
  }
}
]

Recording transaction checks

Each of check steps contains:

  • fn: function name of the step
  • args: function arguments
  • guid: automatically generated identifier
  • contains_navigate: recorder sets it on true if the step would trigger a page navigation

Commands

Actions to be performed for the recording TMS check

Step Name"fn"Required "args"Remarks
Go to URLwpm_go_tourlGoes to the given url location
Clickwpm_clickelement, offsetX, offsetYelement: label, name or CSS selector,
offsetX/Y: exact position of a click in the element
Click in a exact locationwpm_click_xyelement, x, y, scrollX, scrollYelement: label, name or CSS selector,
x/y: coordinates for the click (in viewport),
scrollX/Y: scrollbar position
Fillwpm_fillinput, valueinput: target element,
value: text to fill the target
Move mouse to elementwpm_move_mouse_to_elementelement, offsetX, offsetYelement: target element,
offsetX/Y: exact position of the mouse in the element
Select dropdownwpm_select_dropdownselect, optionselect: target element (drop-down),
option: text of the option to select
Waitwpm_waitsecondsseconds: numbers of seconds to wait
Close tabwpm_close_tab-Closes the latest tab on the tab stack

Validations

Verify the state of the page

Step Name"fn"Required "args"Remarks
Contains textwpm_contains_timeoutelement, value, waitTime, useRegularExpressionelement: label, name or CSS selector,
value: text to search for,
waitTime: time to wait for the value to appear,
useRegularExpression: use the value as a RegEx
Does not contains textwpm_not_contains_timeoutelement, value, waitTime, useRegularExpressionelement: label, name or CSS selector,
value: text to search for,
waitTime: time to wait for the value to appear,
useRegularExpression: use the value as a RegEx

Metadata

Recording checks contain metadata which is automatically generated by the WPM recorder. Modify with caution!

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 3.1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/karlderkaefer/pingdom-golang-client/pkg/pingdom/openapi"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.pingdom.com/api/3.1

ClassMethodHTTP requestDescription
ActionsAPIActionsGetGet /actionsReturns a list of actions alerts.
AnalysisAPIAnalysisCheckidAnalysisidGetGet /analysis/{checkid}/{analysisid}Returns the raw result for a specified analysis.
AnalysisAPIAnalysisCheckidGetGet /analysis/{checkid}Returns a list of the latest root cause analysis
ChecksAPIChecksCheckidDeleteDelete /checks/{checkid}Deletes a check.
ChecksAPIChecksCheckidGetGet /checks/{checkid}Returns a detailed description of a check.
ChecksAPIChecksCheckidPutPut /checks/{checkid}Modify settings for a check.
ChecksAPIChecksDeleteDelete /checksDeletes a list of checks.
ChecksAPIChecksGetGet /checks
ChecksAPIChecksPostPost /checksCreates a new check.
ChecksAPIChecksPutPut /checksPause or change resolution for multiple checks.
ContactsAPIAlertingContactsContactidDeleteDelete /alerting/contacts/{contactid}Deletes a contact with its contact methods
ContactsAPIAlertingContactsContactidGetGet /alerting/contacts/{contactid}Returns a contact with its contact methods
ContactsAPIAlertingContactsContactidPutPut /alerting/contacts/{contactid}Update a contact
ContactsAPIAlertingContactsGetGet /alerting/contactsReturns a list of all contacts
ContactsAPIAlertingContactsPostPost /alerting/contactsCreates a new contact
CreditsAPICreditsGetGet /creditsReturns information about remaining credits
MaintenanceAPIMaintenanceDeleteDelete /maintenanceDelete multiple maintenance windows.
MaintenanceAPIMaintenanceGetGet /maintenance
MaintenanceAPIMaintenanceIdDeleteDelete /maintenance/{id}Delete the maintenance window.
MaintenanceAPIMaintenanceIdGetGet /maintenance/{id}
MaintenanceAPIMaintenanceIdPutPut /maintenance/{id}
MaintenanceAPIMaintenancePostPost /maintenance
MaintenanceOccurrencesAPIMaintenanceOccurrencesDeleteDelete /maintenance.occurrencesDeletes multiple maintenance occurrences
MaintenanceOccurrencesAPIMaintenanceOccurrencesGetGet /maintenance.occurrencesReturns a list of maintenance occurrences.
MaintenanceOccurrencesAPIMaintenanceOccurrencesIdDeleteDelete /maintenance.occurrences/{id}Deletes the maintenance occurrence
MaintenanceOccurrencesAPIMaintenanceOccurrencesIdGetGet /maintenance.occurrences/{id}Gets a maintenance occurrence details
MaintenanceOccurrencesAPIMaintenanceOccurrencesIdPutPut /maintenance.occurrences/{id}Modifies a maintenance occurrence
ProbesAPIProbesGetGet /probesReturns a list of Pingdom probe servers
ReferenceAPIReferenceGetGet /referenceGet regions, timezone and date/time/number references
ResultsAPIResultsCheckidGetGet /results/{checkid}Return a list of raw test results
SingleAPISingleGetGet /singlePerforms a single check.
SummaryAverageAPISummaryAverageCheckidGetGet /summary.average/{checkid}Get the average time/uptime value for a specified
SummaryHoursofdayAPISummaryHoursofdayCheckidGetGet /summary.hoursofday/{checkid}Returns the average response time for each hour.
SummaryOutageAPISummaryOutageCheckidGetGet /summary.outage/{checkid}Get a list of status changes for a specified check
SummaryPerformanceAPISummaryPerformanceCheckidGetGet /summary.performance/{checkid}For a given interval return a list of subintervals
SummaryProbesAPISummaryProbesCheckidGetGet /summary.probes/{checkid}Get a list of probes that performed tests
TMSChecksAPIAddCheckPost /tms/checkCreates a new transaction check.
TMSChecksAPIDeleteCheckDelete /tms/check/{cid}Deletes a transaction check.
TMSChecksAPIGetAllChecksGet /tms/checkReturns a list overview of all transaction checks.
TMSChecksAPIGetCheckGet /tms/check/{cid}Returns a single transaction check.
TMSChecksAPIGetCheckReportPerformanceGet /tms/check/{check_id}/report/performanceReturns a performance report for a single transaction check
TMSChecksAPIGetCheckReportStatusGet /tms/check/{check_id}/report/statusReturns a status change report for a single transaction check
TMSChecksAPIGetCheckReportStatusAllGet /tms/check/report/statusReturns a status change report for all transaction checks in the current organization
TMSChecksAPIModifyCheckPut /tms/check/{cid}Modify settings for transaction check.
TeamsAPIAlertingTeamsGetGet /alerting/teams
TeamsAPIAlertingTeamsPostPost /alerting/teamsCreates a new team
TeamsAPIAlertingTeamsTeamidDeleteDelete /alerting/teams/{teamid}
TeamsAPIAlertingTeamsTeamidGetGet /alerting/teams/{teamid}
TeamsAPIAlertingTeamsTeamidPutPut /alerting/teams/{teamid}
TracerouteAPITracerouteGetGet /traceroutePerform a traceroute

Documentation For Models

Documentation For Authorization

Endpoints do not require authorization.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author