rest

package
v0.0.0-rc.005-test-cos... Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetrySettings = RetrySettings{
	Normal: RetrySetting{
		WaitTime:   5 * time.Second,
		MaxRetries: 3,
	},
	Long: RetrySetting{
		WaitTime:   5 * time.Second,
		MaxRetries: 6,
	},
	VeryLong: RetrySetting{
		WaitTime:   15 * time.Second,
		MaxRetries: 5,
	},
}

Functions

func AddNextPageQueryParams

func AddNextPageQueryParams(u *url.URL, nextPage string) *url.URL

AddNextPageQueryParams handles both Dynatrace v1 and v2 pagination logic. For api/v2 URLs the given next page key will be the only query parameter of the modified URL For any other ULRs the given next page key will be added to existing query parameters

func DeleteConfig

func DeleteConfig(client *http.Client, url string, id string) error

the name delete() would collide with the built-in function

Types

type Response

type Response struct {
	StatusCode  int
	Body        []byte
	Headers     map[string][]string
	NextPageKey string
	TotalCount  int
	PageSize    int
}

func Get

func Get(client *http.Client, url string) (Response, error)

func GetWithRetry

func GetWithRetry(client *http.Client, url string, settings RetrySetting) (resp Response, err error)

GetWithRetry will retry a GET request for a given number of times, waiting a give duration between calls this method can be used for API calls we know to have occasional timing issues on GET - e.g. paginated queries that are impacted by replication lag, returning unequal amounts of objects/pages per node

func Post

func Post(client *http.Client, url string, data []byte) (Response, error)

func PostMultiPartFile

func PostMultiPartFile(client *http.Client, url string, data *bytes.Buffer, contentType string) (Response, error)

func Put

func Put(client *http.Client, url string, data []byte) (Response, error)

func SendWithRetry

func SendWithRetry(client *http.Client, sendWithBody SendRequestWithBody, objectName string, path string, body []byte, setting RetrySetting) (resp Response, err error)

SendWithRetry will retry to call sendWithBody for a given number of times, waiting a give duration between calls

func SendWithRetryWithInitialTry

func SendWithRetryWithInitialTry(client *http.Client, sendWithBody SendRequestWithBody, objectName string, path string, body []byte, setting RetrySetting) (resp Response, err error)

SendWithRetryWithInitialTry will try to call sendWithBody and if it didn't succeed call SendWithRetry

func (Response) Is4xxError

func (resp Response) Is4xxError() bool

func (Response) Is5xxError

func (resp Response) Is5xxError() bool

func (Response) IsSuccess

func (resp Response) IsSuccess() bool

type RetrySetting

type RetrySetting struct {
	WaitTime   time.Duration
	MaxRetries int
}

type RetrySettings

type RetrySettings struct {
	Normal   RetrySetting
	Long     RetrySetting
	VeryLong RetrySetting
}

type SendRequestWithBody

type SendRequestWithBody func(client *http.Client, url string, data []byte) (Response, error)

SendRequestWithBody is a function doing a PUT or POST HTTP request

Jump to

Keyboard shortcuts

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