ecclient

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package client provides a base client implementation for interacting with EdgeCast CDN APIs. Configuration and authentication types are also provided.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	SubmitRequest(params SubmitRequestParams) (*Response, error)
}

APIClient describes structs that can send HTTP requests to an API given the request's method, path relative to the API base path.

type CheckRetry

type CheckRetry func(
	ctx context.Context,
	resp *http.Response,
	err error,
) (bool, error)

type ClientConfig

type ClientConfig struct {
	// Generates Authorization Header values for HTTP requests
	AuthProvider ecauth.AuthorizationProvider

	// APIURL contains the base URL for the target API
	BaseAPIURL url.URL

	// The User Agent for outgoing HTTP requests
	UserAgent string

	// The Logger that APIClients will use to write messages
	Logger eclog.Logger

	// The minimum wait time for retries on API errors
	RetryWaitMin *time.Duration

	// The maximum wait time for retries on API errors
	RetryWaitMax *time.Duration

	// The maximum number of retries on API errors
	RetryMax *int

	// CheckRetry is a handler that allows users to define custom logic
	// to determine whether the API Client should retry a failed API call
	CheckRetry CheckRetry
}

ClientConfig provides configuration for the core SDK client code

type ECClient

type ECClient struct {
	Config ClientConfig
	// contains filtered or unexported fields
}

ECClient -

func New

func New(config ClientConfig) ECClient

New creates a default instance of ECClient using the provided configuration

func (ECClient) SubmitRequest

func (c ECClient) SubmitRequest(params SubmitRequestParams) (*Response, error)

SubmitRequest invokes an HTTP request with the given parameters

type HTTPMethod

type HTTPMethod int
const (
	Connect HTTPMethod = iota
	Delete
	Get
	Head
	Options
	Patch
	Post
	Put
	Trace
	Unknown
)

func ToHTTPMethod

func ToHTTPMethod(m string) (HTTPMethod, error)

func (HTTPMethod) IsValid

func (m HTTPMethod) IsValid() bool

func (HTTPMethod) String

func (m HTTPMethod) String() string

type Response

type Response struct {
	Data         string
	HTTPResponse *http.Response
}

response contains the response body as a string from a request along with the raw http.Response itself if present

type SubmitRequestParams

type SubmitRequestParams struct {
	Method      HTTPMethod
	Path        string
	RawBody     interface{}
	QueryParams map[string]string
	PathParams  map[string]string
	Headers     map[string]string
	// ParsedResponse will be filled in using the API response
	ParsedResponse interface{}
}

func NewSubmitRequestParams added in v0.1.25

func NewSubmitRequestParams() SubmitRequestParams

NewSubmitRequestParams creates a new instance of SubmitRequestParams.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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