Documentation
¶
Index ¶
- Variables
- func AddNextPageQueryParams(u *url.URL, nextPage string) *url.URL
- type AddEntriesToResult
- type RequestInfo
- type RespError
- type Response
- func Delete(ctx context.Context, client *http.Client, url string) (Response, error)
- func Get(ctx context.Context, client *http.Client, url string) (Response, error)
- func GetWithRetry(ctx context.Context, client *http.Client, url string, settings RetrySetting) (resp Response, err error)
- func ListPaginated(ctx context.Context, client *http.Client, retrySettings RetrySettings, ...) (Response, error)
- func Post(ctx context.Context, client *http.Client, url string, data []byte) (Response, error)
- func PostMultiPartFile(ctx context.Context, client *http.Client, url string, data *bytes.Buffer, ...) (Response, error)
- func Put(ctx context.Context, client *http.Client, url string, data []byte) (Response, error)
- func SendWithRetry(ctx context.Context, client *http.Client, sendWithBody SendRequestWithBody, ...) (resp Response, err error)
- func SendWithRetryWithInitialTry(ctx context.Context, client *http.Client, sendWithBody SendRequestWithBody, ...) (resp Response, err error)
- type RetrySetting
- type RetrySettings
- type SendRequestWithBody
Constants ¶
This section is empty.
Variables ¶
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 ¶
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
Types ¶
type AddEntriesToResult ¶
AddEntriesToResult is a function which should parse an API response body and append the returned entries to a result slice. Handling the parsing, any possible filtering and owning and filling the result list is left to the caller of ListPaginated, as it might differ notably between client implementations. The function MUST return the number of entries it has parsed from the received API payload body. This is used to validate that the final parsed number matches the reported total count of the API. This receivedEntries count is not necessarily equal to the number of entries added to the result slice, as filtering might exclude some entries that where received from the API.
type RequestInfo ¶
type RespError ¶
type RespError struct {
Reason string `json:"reason"`
StatusCode int `json:"statusCode"`
Body string `json:"body"`
Err error `json:"error"`
Request *RequestInfo `json:"request"`
}
func NewRespErr ¶
func (RespError) ConcurrentError ¶
func (RespError) WithRequestInfo ¶
type Response ¶
type Response struct {
StatusCode int
Body []byte
Headers map[string][]string
NextPageKey string
TotalCount int
PageSize int
}
func GetWithRetry ¶
func GetWithRetry(ctx context.Context, 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 ListPaginated ¶
func PostMultiPartFile ¶
func SendWithRetry ¶
func SendWithRetry(ctx context.Context, 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(ctx context.Context, 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 (Response) Is5xxError ¶
type RetrySetting ¶
type RetrySettings ¶
type RetrySettings struct {
Normal RetrySetting
Long RetrySetting
VeryLong RetrySetting
}