Documentation
¶
Overview ¶
Package rest provides shared request helpers for the cloud API wrapper packages: context checking, JSON fetching, response nil-checking, and nextPageToken pagination.
Index ¶
- func Do(ctx context.Context, method string, urlString string, ...) error
- func DoWithBody[B any](ctx context.Context, method string, urlString string, body B, ...) error
- func GetJson[T any](ctx context.Context, urlString string, options []fetch_config.Option) (*T, error)
- func ListPaginated[R any, T any](ctx context.Context, makeUrlString func(pageToken string) string, ...) ([]T, error)
- func SendJson[T any, B any](ctx context.Context, method string, urlString string, body B, ...) (*T, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoWithBody ¶
func DoWithBody[B any]( ctx context.Context, method string, urlString string, body B, options []fetch_config.Option, ) error
DoWithBody performs a request with the given method and JSON body, ignoring the response body.
func GetJson ¶
func GetJson[T any](ctx context.Context, urlString string, options []fetch_config.Option) (*T, error)
GetJson performs a GET request and returns the decoded, nil-checked response.
func ListPaginated ¶
func ListPaginated[R any, T any]( ctx context.Context, makeUrlString func(pageToken string) string, extract func(response *R) (items []T, nextPageToken string), options []fetch_config.Option, ) ([]T, error)
ListPaginated repeatedly performs GET requests, following the page token returned by extract until it is empty, and concatenates the extracted items.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.