client

package
v0.0.0-...-5add76e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPaginationLimit = 100

By default, the maximum `limit` parameter allowed by pagerduty API is 100.

Variables

View Source
var JSONSchema string

Functions

func FakeStringTimestamps

func FakeStringTimestamps(ptrObj any) error

Timestamp fields such as `created_at` arrive as `string`s from the API. this function pusts valid `RFC3339` timestamps into fields like `DeletedAt`, `CreatedAt`... Mostly copy-paste from the `plugin-sdk` faker. Receives an interface that is a pointer to a struct, and only looks at fields one level deep. Pionter-to-pointer structs are supported.

func New

func New(logger zerolog.Logger, spec Spec, options ...Option) (schema.ClientMeta, error)

func PagerdutyMockTestHelper

func PagerdutyMockTestHelper(t *testing.T, table *schema.Table, buildMockHttpClient func() *MockHttpClient)

Types

type Client

type Client struct {
	PagerdutyClient *pagerduty.Client

	Spec *Spec
	// contains filtered or unexported fields
}

func (*Client) ID

func (*Client) ID() string

There is no easy way to get account-id or similar from the pagerduty API.

func (*Client) Logger

func (c *Client) Logger() *zerolog.Logger

type MockHttpClient

type MockHttpClient struct {
	// contains filtered or unexported fields
}

func (*MockHttpClient) AddMockResponse

func (mockHttpClient *MockHttpClient) AddMockResponse(url string, object any)

func (*MockHttpClient) Do

func (mockHttpClient *MockHttpClient) Do(req *http.Request) (*http.Response, error)

type Option

type Option func(*Options)

func WithClient

func WithClient(client *pagerduty.Client) Option

type Options

type Options struct {
	Client *pagerduty.Client
}

type PdYmlStruct

type PdYmlStruct struct {
	Authtoken string
}

type RateLimitedHttpClient

type RateLimitedHttpClient struct {
	// contains filtered or unexported fields
}

Note that this is an implementation of 'pagerduty.HTTPClient', not of 'http.Client'.

func (*RateLimitedHttpClient) Do

type Spec

type Spec struct {
	// Used in API requests to filter only resources related to these team ids.
	// Used in the tables: ["escalation_policies", "incidents", "maintenance_windows", "services", "users"]
	TeamIds []string `json:"team_ids"`

	// PagerDuty API is heavily rate-limited (900 requests/min = 15 requests/sec, across the entire organization).
	// This option allows you to control the rate at which the plugin will make requests to the API.
	// You can reduce this parameter in case you are still seeing rate limit errors (status code 429), or increase
	// it if your PagerDuty API quota is higher. See https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTUz-rate-limiting#what-are-our-limits for more info.
	MaxRequestsPerSecond *int `json:"max_requests_per_second" jsonschema:"minimum=1,default=10"`

	// A best effort maximum number of Go routines to use. Lower this number to reduce memory usage.
	Concurrency int `json:"concurrency" jsonschema:"minimum=1,default=1000"`
}

func (*Spec) SetDefaults

func (spec *Spec) SetDefaults()

func (*Spec) Validate

func (*Spec) Validate() error

Directories

Path Synopsis
spec
gen

Jump to

Keyboard shortcuts

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