client

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyAuthIn

type APIKeyAuthIn string
const (
	APIKeyAuthInHeader APIKeyAuthIn = "header"
	APIKeyAuthInQuery  APIKeyAuthIn = "query"
	APIKeyAuthInCookie APIKeyAuthIn = "cookie"
)

type APIKeyAuthOpt

type APIKeyAuthOpt struct {
	Name  string
	In    APIKeyAuthIn
	Value string
}

type APIKeyAuthOption

type APIKeyAuthOption []APIKeyAuthOpt

type BodyLocator

type BodyLocator string

func (BodyLocator) LocateValueInResp added in v0.8.0

func (loc BodyLocator) LocateValueInResp(resp resty.Response) string

func (BodyLocator) String

func (loc BodyLocator) String() string

type BuildOption

type BuildOption struct {
	Security      securityOption
	CookieEnabled bool
	TLSConfig     tls.Config
}

type Client

type Client struct {
	*resty.Client
}

func New

func New(ctx context.Context, baseURL string, opt *BuildOption) (*Client, error)

func (*Client) Create

func (c *Client) Create(ctx context.Context, path string, body interface{}, opt CreateOption) (*resty.Response, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, opt DeleteOption) (*resty.Response, error)

func (*Client) Operation added in v0.4.0

func (c *Client) Operation(ctx context.Context, path string, body interface{}, opt OperationOption) (*resty.Response, error)

func (*Client) Read

func (c *Client) Read(ctx context.Context, path string, opt ReadOption) (*resty.Response, error)

func (*Client) ReadDS added in v0.12.0

func (c *Client) ReadDS(ctx context.Context, path string, opt ReadOptionDS) (*resty.Response, error)

func (*Client) Update

func (c *Client) Update(ctx context.Context, path string, body interface{}, opt UpdateOption) (*resty.Response, error)

type CodeLocator

type CodeLocator struct{}

func (CodeLocator) LocateValueInResp added in v0.8.0

func (loc CodeLocator) LocateValueInResp(resp resty.Response) string

func (CodeLocator) String

func (loc CodeLocator) String() string

type CreateOption

type CreateOption struct {
	Method string
	Query  Query
	Header Header
	Retry  *RetryOption
}

type DeleteOption

type DeleteOption struct {
	Method string
	Query  Query
	Header Header
	Retry  *RetryOption
}

type ExactLocator added in v0.4.0

type ExactLocator string

func (ExactLocator) LocateValueInResp added in v0.8.0

func (loc ExactLocator) LocateValueInResp(_ resty.Response) string

func (ExactLocator) String added in v0.4.0

func (loc ExactLocator) String() string

type HTTPBasicOption added in v0.7.0

type HTTPBasicOption struct {
	Username string
	Password string
}

type HTTPTokenOption added in v0.7.0

type HTTPTokenOption struct {
	Token  string
	Scheme string
}
type Header map[string]string

func (Header) Clone

func (h Header) Clone() Header

func (Header) TakeOrSelf

func (h Header) TakeOrSelf(ctx context.Context, v types.Map) Header

func (Header) ToTFValue

func (h Header) ToTFValue() types.Map

type HeaderLocator

type HeaderLocator string

func (HeaderLocator) LocateValueInResp added in v0.8.0

func (loc HeaderLocator) LocateValueInResp(resp resty.Response) string

func (HeaderLocator) String

func (loc HeaderLocator) String() string

type OAuth2AuthStyle

type OAuth2AuthStyle string
const (
	OAuth2AuthStyleInParams OAuth2AuthStyle = "params"
	OAuth2AuthStyleInHeader OAuth2AuthStyle = "header"
)

type OAuth2ClientCredentialOption

type OAuth2ClientCredentialOption struct {
	TokenURL     string
	ClientId     string
	ClientSecret string

	Scopes         []string
	EndpointParams map[string][]string
	AuthStyle      OAuth2AuthStyle
}

type OAuth2PasswordOption

type OAuth2PasswordOption struct {
	TokenURL string
	ClientId string
	Username string
	Password string

	ClientSecret string
	AuthStyle    OAuth2AuthStyle
	Scopes       []string
}

type OAuth2RefreshTokenOption added in v0.7.0

type OAuth2RefreshTokenOption struct {
	TokenURL     string
	ClientId     string
	RefreshToken string

	ClientSecret string
	AuthStyle    OAuth2AuthStyle
	TokenType    string
	Scopes       []string
}

type OperationOption added in v0.4.0

type OperationOption struct {
	Method string
	Query  Query
	Header Header
	Retry  *RetryOption
}

type PollOption

type PollOption struct {
	// StatusLocator indicates where the polling status is located in the response of the polling requests.
	StatusLocator ValueLocator

	// Status the status sentinels for polling.
	Status PollingStatus

	// UrlLocator configures the how to discover the polling location.
	// If it is nil, the original request URL is used for polling.
	UrlLocator ValueLocator

	Header Header

	Query Query

	// DefaultDelay specifies the interval between two pollings. The `Retry-After` in the response header takes higher precedence than this.
	DefaultDelay time.Duration
}

type Pollable

type Pollable struct {
	InitDelay     time.Duration
	URL           string
	Header        Header
	Query         Query
	Status        PollingStatus
	StatusLocator ValueLocator
	DefaultDelay  time.Duration
}

func NewPollableForPoll added in v0.12.0

func NewPollableForPoll(resp resty.Response, opt PollOption) (*Pollable, error)

func NewPollableForPrecheck added in v0.12.0

func NewPollableForPrecheck(opt PollOption) (*Pollable, error)

func (*Pollable) PollUntilDone

func (f *Pollable) PollUntilDone(ctx context.Context, client *Client) error

type PollingStatus

type PollingStatus struct {
	Pending []string
	Success string
}

type Query

type Query url.Values

func (Query) Clone

func (q Query) Clone() Query

func (Query) TakeOrSelf

func (q Query) TakeOrSelf(ctx context.Context, v types.Map) Query

func (Query) ToTFValue

func (q Query) ToTFValue() types.Map

type ReadOption

type ReadOption struct {
	Query  Query
	Header Header
	Retry  *RetryOption
}

type ReadOptionDS added in v0.12.0

type ReadOptionDS struct {
	// Method used for reading, which defaults to GET
	Method string
	Query  Query
	Header Header
	Retry  *RetryOption
}

type RetryOption added in v0.12.0

type RetryOption struct {
	StatusLocator ValueLocator
	Status        PollingStatus
	Count         int
	WaitTime      time.Duration
	MaxWaitTime   time.Duration
}

type UpdateOption

type UpdateOption struct {
	Method             string
	MergePatchDisabled bool
	Query              Query
	Header             Header
	Retry              *RetryOption
}

type ValueLocator

type ValueLocator interface {
	LocateValueInResp(resty.Response) string
	String() string
}

ValueLocator indicates where a value is located in a HTTP response.

Jump to

Keyboard shortcuts

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