rest

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 9 Imported by: 0

README

opslevel-go CircleCI Go Report Card GoDoc

opslevel-go is a client library for the OpsLevel integrations API

To get started create a new client:

client := opslevel.NewClient()

Deploys Integration

The Deploys Integration requires the following fields:

deployRequest := opslevel.DeployRequest{
    Service:     "my_service",
    Description: "my_service was deployed",
    Deployer: rest.Deployer{
        Email: "deployer@myapp.com",
    },
    Environment: "env",
    DeployedAt:  time.Now(),
}
err := client.Deploy(deployRequest, "my-integration-uuid")

For a full list fields, see the docs.

Checks Integration

The Deploys Integration requires the following fields:

checkRequest := CheckRequest{
    Service: "my_service",
    Check:   "my_check",
    Message: "Checks passed",
    Status:  "passed",
}
err := client.Check(checkRequest, "my-integration-uuid")

The Message field is optional and Status should be one of passed or failed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckRequest

type CheckRequest struct {
	Service string `validate:"required" json:"service"`
	Check   string `validate:"required" json:"check"`
	Status  string `validate:"required,oneof=passed failed" json:"status"`
	Message string `json:"message"`
}

CheckRequest represents a structured request to the OpsLevel checks webhook endpoint

type Client

type Client struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Client represents a rest http client and is used to send requests to OpsLevel integrations

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient returns a Client pointer

func (*Client) Check

func (c *Client) Check(req CheckRequest, integrationID string) error

Check sends a CheckRequest to the OpsLevel check integration at integrationID

func (*Client) Deploy

func (c *Client) Deploy(req DeployRequest, integrationID string) error

Deploy sends a DeployRequest to the OpsLevel deploy integration at integrationID

func (*Client) Payload added in v0.0.3

func (c *Client) Payload(req PayloadRequest, integrationID string) error

Payload sends a PayloadRequest to the OpsLevel payload check integration at integrationID

type ClientOption added in v0.0.4

type ClientOption func(c *Client)

ClientOption modifies fields on a Client

func WithBaseURL added in v0.0.4

func WithBaseURL(baseURL string) ClientOption

WithBaseURL modifies the Client baseURL.

func WithHTTPClient added in v0.0.4

func WithHTTPClient(hc *http.Client) ClientOption

WithHTTPClient modifies the Client http.Client.

type Commit

type Commit struct {
	SHA            string    `json:"sha"`
	Message        string    `json:"message"`
	Branch         string    `json:"branch"`
	Date           time.Time `json:"date"`
	CommitterName  string    `json:"committer_name"`
	CommitterEmail string    `json:"committer_email"`
	AuthorName     string    `json:"author_name"`
	AuthorEmail    string    `json:"author_email"`
	AuthoringDate  time.Time `json:"authoring_date"`
}

Commit represents the commit being deployed

type DeployRequest

type DeployRequest struct {
	Service      string    `validate:"required" json:"service"`
	Deployer     Deployer  `validate:"required" json:"deployer"`
	DeployedAt   time.Time `validate:"required" json:"deployed_at"`
	Description  string    `validate:"required" json:"description"`
	Environment  string    `json:"environment"`
	DeployURL    string    `json:"deploy_url"`
	DeployNumber string    `json:"deploy_number"`
	Commit       Commit    `json:"commit"`
	DedupID      string    `json:"dedup_id"`
}

DeployRequest represents a structured request to the OpsLevel deploys webhook endpoint

type Deployer

type Deployer struct {
	Email string `validate:"required" json:"email"`
	Name  string `json:"name"`
}

Deployer represents the entity taking the action

type PayloadRequest added in v0.0.3

type PayloadRequest struct {
	Service string      `validate:"required" json:"service"`
	Check   string      `validate:"required" json:"check"`
	Data    interface{} `validate:"required" json:"data"`
}

PayloadRequest represents a structured request to the OpsLevel payload webhook endpoint

Jump to

Keyboard shortcuts

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