pollers

package
v0.1.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSucceeded  = "Succeeded"
	StatusCanceled   = "Canceled"
	StatusFailed     = "Failed"
	StatusInProgress = "InProgress"
)

the well-known set of LRO status/provisioning state values.

View Source
const (
	StatusCancelled  = "Cancelled"
	StatusCompleted  = "Completed"
	StatusNotStarted = "NotStarted"
	StatusRunning    = "Running"
	StatusUndefined  = "Undefined"
	StatusDeduped    = "Deduped"
)

these are non-conformant states that we've seen in the wild. we support them for back-compat.

Variables

View Source
var ErrNoBody = errors.New("the response did not contain a body")

ErrNoBody is returned if the response didn't contain a body.

Functions

func Failed

func Failed(s string) bool

Failed returns true if the LRO's state is terminal failure.

func GetJSON

func GetJSON(resp *http.Response) (map[string]any, error)

GetJSON reads the response body into a raw JSON object. It returns ErrNoBody if there was no content.

func GetProvisioningState

func GetProvisioningState(resp *http.Response) (string, error)

GetProvisioningState returns the LRO's state from the response body. If there is no state in the response body the empty string is returned.

func GetResourceLocation

func GetResourceLocation(resp *http.Response) (string, error)

GetResourceLocation returns the LRO's resourceLocation value from the response body. Typically used for Operation-Location flows. If there is no resourceLocation in the response body the empty string is returned.

func GetStatus

func GetStatus(resp *http.Response) (string, error)

GetStatus returns the LRO's status from the response body. Typically used for Azure-AsyncOperation flows. If there is no status in the response body the empty string is returned.

func InProgress

func InProgress(s string) bool

InProgress returns true if the LRO's state is in progress.

func IsTerminalState

func IsTerminalState(s string) bool

IsTerminalState returns true if the LRO's state is terminal.

func IsValidURL

func IsValidURL(s string) bool

IsValidURL verifies that the URL is valid and absolute.

func PollHelper

func PollHelper(ctx context.Context, endpoint string, pl runtime.Pipeline, update func(resp *http.Response) (string, error)) error

func ResultHelper

func ResultHelper[T any](resp *http.Response, failed bool, out *T) error

func StatusCodeValid

func StatusCodeValid(resp *http.Response) bool

returns true if the LRO response contains a valid HTTP status code

func Succeeded

func Succeeded(s string) bool

Succeeded returns true if the LRO's state is terminal success.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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