syntheticsclient

module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2023 License: Apache-2.0

README

syntheticsclient

A Splunk Synthetics (Formerly Rigor) client for golang.

Installation

go get https://github.com/splunk/syntheticsclient.git

Important Note

V2 client is used to make API calls and CRUD operations to the Splunk Observability Synthetics endpoints (E.G. API Tests)

Deprecated V1 Client is used to make the API calls for the Splunk Synthetics (Formerly Rigor) public API.

Example Usages

package main

import (
	"fmt"
	"os"
	"encoding/json"
	sc2 "github.com/splunk/syntheticsclient/syntheticsclientv2"
)

func main() {
	//Expects a token is available from the API_ACCESS_TOKEN environment variable
	//Expects a realm (e.g. us1) is available from REALM environment variable
	token := os.Getenv("API_ACCESS_TOKEN")
	realm := os.Getenv("REALM")

	//Create your client with the token
	c := sc2.NewClient(token, realm)

	//Take your ugly (but valid) JSON string as bytes and unmarshal into a CreateHttpCheckV2 struct
	jsonData := []byte(`{"test":{"name":"http-test","type":"http","url":"https://www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true,"requestMethod":"GET","body":null,"headers":[{"name":"boop","value":"beep"}]}}`)
	var httpCheckDetail sc2.HttpCheckV2Input
	err := json.Unmarshal(jsonData, &httpCheckDetail)
	if err != nil {
		fmt.Println(err)
	}

	//Use your converted JSON to make the request and print
	res, _, err := c.CreateHttpCheckV2(&httpCheckDetail)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(res)
	}
}

API Documentation

API Docs are available here

Additional Information

This client is largely a copypasta mutation of the go-victor client for Splunk On-Call (formerly known as VictorOps).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL