statuspage

package module
v0.0.0-...-99ed1b6 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: MIT Imports: 11 Imported by: 0

README

statuspage-go GitHub Actions

This repository contains a Go client library for accessing the Statuspage REST API v1.

Install the package

Install statuspage-go via go-get:

go get github.com/nagelflorian/statuspage-go

Getting Started

Before you can initialize an instance you'll have to obtain an API key from the Statuspage account view.

package main

import "github.com/nagelflorian/statuspage-go"

func main() {
  client := statuspage.New("YOUR_API_KEY", nil)

  // Use the client.

  // Get the page profile for a given page id
  page, err := client.Page.GetPage(context.TODO(), "YOUR_PAGE_ID")
}

API Documentation

The official Statuspage API documentation can be found here: developer.statuspage.io.

License

This library is distributed under the MIT-style license found in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stringify

func Stringify(message interface{}) string

Stringify attempts to create a reasonable string representation of types

Types

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public Statuspage API.
	BaseURL   *url.URL
	UserAgent string
	Token     string
	Version   string

	// Services used for talking to different parts of the Statuspage API.
	Page      *PageService
	Component *ComponentService
	// contains filtered or unexported fields
}

A Client manages communication with the Statuspage API.

func NewClient

func NewClient(token string, httpClient *http.Client) *Client

NewClient returns a new Statuspage API client. If a nil httpClient is provided, http.DefaultClient will be used.

type Component

type Component struct {
	ID                 *string    `json:"id,omitempty"`
	PageID             *string    `json:"page_id,omitempty"`
	GroupID            *string    `json:"group_id,omitempty"`
	CreatedAt          *Timestamp `json:"created_at,omitempty"`
	UpdatedAt          *Timestamp `json:"updated_at,omitempty"`
	Group              *bool      `json:"group,omitempty"`
	Name               *string    `json:"name,omitempty"`
	Description        *string    `json:"description,omitempty"`
	Position           *int32     `json:"position,omitempty"`
	Status             *string    `json:"status,omitempty"`
	Showcase           *bool      `json:"showcase,omitempty"`
	OnlyShowIfDegraded *bool      `json:"only_show_if_degraded,omitempty"`
	AutomationEmail    *string    `json:"automation_email,omitempty"`
}

Component is the Statuspage API component representation

func (Component) String

func (c Component) String() string

type ComponentService

type ComponentService service

ComponentService handles communication with the page related methods of the Statuspage API.

Statuspage API docs: https://developer.statuspage.io/#tag/pages

func (*ComponentService) DeleteComponent

func (s *ComponentService) DeleteComponent(ctx context.Context, pageID string, componentID string) error

DeleteComponent deletes a component for a given page and component id

func (*ComponentService) GetComponent

func (s *ComponentService) GetComponent(ctx context.Context, pageID string, componentID string) (*Component, error)

GetComponent returns component information for a given page and component id

func (*ComponentService) ListComponents

func (s *ComponentService) ListComponents(ctx context.Context, pageID string) (*[]Component, error)

ListComponents returns a list of all components for a given page id

func (*ComponentService) UpdateComponent

func (s *ComponentService) UpdateComponent(ctx context.Context, pageID string, componentID string, component UpdateComponentParams) (*Component, error)

UpdateComponent updates a component for a given page and component id

type Page

type Page struct {
	ID                       *string    `json:"id,omitempty"`
	CreatedAt                *Timestamp `json:"created_at,omitempty"`
	UpdatedAt                *Timestamp `json:"updated_at,omitempty"`
	Name                     *string    `json:"name,omitempty"`
	PageDescription          *string    `json:"page_description,omitempty"`
	Headline                 *string    `json:"headline,omitempty"`
	Branding                 *string    `json:"branding,omitempty"`
	Subdomain                *string    `json:"subdomain,omitempty"`
	Domain                   *string    `json:"domain,omitempty"`
	URL                      *string    `json:"url,omitempty"`
	SupportURL               *string    `json:"support_url,omitempty"`
	HiddenFromSearch         *bool      `json:"hidden_from_search,omitempty"`
	AllowPageSubscribers     *bool      `json:"allow_page_subscribers,omitempty"`
	AllowIncidentSubscribers *bool      `json:"allow_incident_subscribers,omitempty"`
	AllowEmailSubscribers    *bool      `json:"allow_email_subscribers,omitempty"`
	AllowSmsSubscribers      *bool      `json:"allow_sms_subscribers,omitempty"`
	AllowRssAtomFeeds        *bool      `json:"allow_rss_atom_feeds,omitempty"`
	AllowWebhookSubscribers  *bool      `json:"allow_webhook_subscribers,omitempty"`
	NotificationsFromEmail   *string    `json:"notifications_from_email,omitempty"`
	NotificationsEmailFooter *string    `json:"notifications_email_footer,omitempty"`
	ActivityScore            *int64     `json:"activity_score,omitempty"`
	TwitterUsername          *string    `json:"twitter_username,omitempty"`
	ViewersMustBeTeamMembers *bool      `json:"viewers_must_be_team_members,omitempty"`
	IPRestrictions           *string    `json:"ip_restrictions,omitempty"`
	City                     *string    `json:"city,omitempty"`
	State                    *string    `json:"state,omitempty"`
	Country                  *string    `json:"country,omitempty"`
	TimeZone                 *string    `json:"time_zone,omitempty"`
	CSSBodyBackgroundColor   *string    `json:"css_body_background_color,omitempty"`
	CSSFontColor             *string    `json:"css_font_color,omitempty"`
	CSSLightFontColor        *string    `json:"css_light_font_color,omitempty"`
	CSSGreens                *string    `json:"css_greens,omitempty"`
	CSSYellows               *string    `json:"css_yellows,omitempty"`
	CSSOranges               *string    `json:"css_oranges,omitempty"`
	CSSReds                  *string    `json:"css_reds,omitempty"`
	CSSBlues                 *string    `json:"css_blues,omitempty"`
	CSSBorderColor           *string    `json:"css_border_color,omitempty"`
	CSSGraphColor            *string    `json:"css_graph_color,omitempty"`
	CSSLinkColor             *string    `json:"css_link_color,omitempty"`
	HeroCover                *PageLogo  `json:"hero_cover,omitempty"`
}

Page is the Statuspage API page representation

func (Page) String

func (p Page) String() string
type PageLogo struct {
	UpdatedAt *Timestamp `json:"updated_at,omitempty"`
	Size      *int64     `json:"size,omitempty"`
	URL       *string    `json:"url,omitempty"`
}

PageLogo is the Statuspage API page logo representation

type PageService

type PageService service

PageService handles communication with the page related methods of the Statuspage API.

Statuspage API docs: https://developer.statuspage.io/#tag/pages

func (*PageService) GetPage

func (s *PageService) GetPage(ctx context.Context, pageID string) (*Page, error)

GetPage returns the page information for a given page id

func (*PageService) ListPages

func (s *PageService) ListPages(ctx context.Context) (*[]Page, error)

ListPages returns a list of all pages

func (*PageService) UpdatePage

func (s *PageService) UpdatePage(ctx context.Context, pageID string, page UpdatePageParams) (*Page, error)

UpdatePage updates page information for a given page id

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp.

func (Timestamp) Equal

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

type UpdateComponentParams

type UpdateComponentParams struct {
	Description        string    `json:"description,omitempty"`
	Status             string    `json:"status,omitempty"`
	Name               string    `json:"name,omitempty"`
	OnlyShowIfDegraded bool      `json:"only_show_if_degraded,omitempty"`
	GroupID            string    `json:"group_id,omitempty"`
	Showcase           bool      `json:"showcase,omitempty"`
	StartDate          Timestamp `json:"start_date,omitempty"`
}

UpdateComponentParams are the parameters that can be changed using the update component API endpoint

type UpdateComponentRequestBody

type UpdateComponentRequestBody struct {
	Component UpdateComponentParams `json:"component"`
}

UpdateComponentRequestBody is the update component request body representation

type UpdatePageParams

type UpdatePageParams struct {
	Name                     string `json:"name,omitempty"`
	Domain                   string `json:"domain,omitempty"`
	Subdomain                string `json:"subdomain,omitempty"`
	URL                      string `json:"url,omitempty"`
	Branding                 string `json:"branding,omitempty"`
	CSSBodyBackgroundColor   string `json:"css_body_background_color,omitempty"`
	CSSFontColor             string `json:"css_font_color,omitempty"`
	CSSLightFontColor        string `json:"css_light_font_color,omitempty"`
	CSSGreens                string `json:"css_greens,omitempty"`
	CSSYellows               string `json:"css_yellows,omitempty"`
	CSSOranges               string `json:"css_oranges,omitempty"`
	CSSReds                  string `json:"css_reds,omitempty"`
	CSSBlues                 string `json:"css_blues,omitempty"`
	CSSBorderColor           string `json:"css_border_color,omitempty"`
	CSSGraphColor            string `json:"css_graph_color,omitempty"`
	CSSLinkColor             string `json:"css_link_color,omitempty"`
	HiddenFromSearch         *bool  `json:"hidden_from_search,omitempty"`
	ViewersMustBeTeamMembers *bool  `json:"viewers_must_be_team_members,omitempty"`
	AllowPageSubscribers     *bool  `json:"allow_page_subscribers,omitempty"`
	AllowIncidentSubscribers *bool  `json:"allow_incident_subscribers,omitempty"`
	AllowEmailSubscribers    *bool  `json:"allow_email_subscribers,omitempty"`
	AllowSmsSubscribers      *bool  `json:"allow_sms_subscribers,omitempty"`
	AllowRssAtomFeeds        *bool  `json:"allow_rss_atom_feeds,omitempty"`
	AllowWebhookSubscribers  *bool  `json:"allow_webhook_subscribers,omitempty"`
	NotificationsFromEmail   string `json:"notifications_from_email,omitempty"`
	TimeZone                 string `json:"time_zone,omitempty"`
	NotificationsEmailFooter string `json:"notifications_email_footer,omitempty"`
}

UpdatePageParams are the parameters that can be changed using the update page API endpoint

type UpdatePageRequestBody

type UpdatePageRequestBody struct {
	Page UpdatePageParams `json:"page"`
}

UpdatePageRequestBody is the update page request body representation

Jump to

Keyboard shortcuts

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