akamai

package
v0.0.0-...-86f1c50 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppVersion is a version of the application.
	AppVersion = "0.0.1"

	// AppName is a global application name.
	AppName = "go-akamai"

	// DefaultUserAgent contains basic user agent that will be used in queries.
	DefaultUserAgent = AppName + "/" + AppVersion
)

Variables

This section is empty.

Functions

func IsClientError

func IsClientError(r *http.Response) bool

IsClientError determines if a response was a client error (4XX status)

func IsError

func IsError(r *http.Response) bool

IsError determines if the response was a client or server error (4XX or 5XX status)

func IsInformational

func IsInformational(r *http.Response) bool

IsInformational determines if a response was informational (1XX status)

func IsRedirection

func IsRedirection(r *http.Response) bool

IsRedirection determines if a response was a redirect (3XX status)

func IsServerError

func IsServerError(r *http.Response) bool

IsServerError determines if a response was a server error (5XX status)

func IsSuccess

func IsSuccess(r *http.Response) bool

IsSuccess determines if a response was successful (2XX status)

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient returns a reference to an initialized configured HTTP client.

Types

type APIError

type APIError struct {
	Type        string         `json:"type"`
	Title       string         `json:"title"`
	Status      int            `json:"status"`
	Detail      string         `json:"detail"`
	Instance    string         `json:"instance"`
	Method      string         `json:"method"`
	ServerIP    string         `json:"serverIp"`
	ClientIP    string         `json:"clientIp"`
	RequestID   string         `json:"requestId"`
	RequestTime string         `json:"requestTime"`
	Warnings    []Warning      `json:"warnings"`
	Response    *http.Response `json:"-"`
	RawBody     string         `json:"-"`
	// contains filtered or unexported fields
}

APIError exposes an Akamai OPEN Edge Grid Error.

func NewAPIError

func NewAPIError(response *http.Response) *APIError

NewAPIError creates a new API error based on a Response, or http.Response-like.

func NewAPIErrorFromBody

func NewAPIErrorFromBody(response *http.Response, body []byte) *APIError

NewAPIErrorFromBody creates a new API error, allowing you to pass in a body

This function is intended to be used after the body has already been read for other purposes.

func (APIError) Error

func (error APIError) Error() string

Error is custom implementation of error interface.

type ResponseResult

type ResponseResult struct {
	*http.Response

	// Err contains error that can be provided to a caller.
	Err *APIError
}

ResponseResult represents a result of a HTTP request. It embeds standard http.Response and adds a custom error description.

func (*ResponseResult) ExtractResult

func (result *ResponseResult) ExtractResult(to interface{}) error

ExtractResult allows to provide an object into which ResponseResult body will be extracted.

type ServiceClient

type ServiceClient struct {
	// HTTPClient represents an initialized HTTP client that will be used to do requests.
	HTTPClient *http.Client

	// Endpoint represents an endpoint that will be used in all requests.
	Endpoint string

	// UserAgent contains user agent that will be used in all requests.
	UserAgent string

	// Config represents Akamai Edge Grid config.
	Config *edgegrid.Config
	// contains filtered or unexported fields
}

ServiceClient stores details that are needed to work with different Akamai APIs.

func (*ServiceClient) DoRequest

func (client *ServiceClient) DoRequest(ctx context.Context,
	method, path string,
	body interface{}) (*ResponseResult, error)

DoRequest creates an HTTP request and sends it to Akamai APIs. A relative URL can be provided in path, which will be resolved to the Host specified in Config. If body is specified, it will be sent as the request body.

func (*ServiceClient) DoRequestWithCustomHeaders

func (client *ServiceClient) DoRequestWithCustomHeaders(ctx context.Context,
	method, path string,
	headers http.Header,
	body interface{}) (*ResponseResult, error)

DoRequestWithCustomHeaders creates an HTTP request with re-written headers and sends it to Akamai APIs. A relative URL can be provided in path, which will be resolved to the Host specified in Config. If body is specified, it will be sent as the JSON request body.

func (*ServiceClient) SetLogger

func (client *ServiceClient) SetLogger(log logger.GenericLogger)

SetLogger sets logger to the given.

type Warning

type Warning struct {
	Type      string `json:"type"`
	Detail    string `json:"detail"`
	MessageID string `json:"messageId"`
}

Warning represents less severe issue.

Directories

Path Synopsis
ccu
v3
Package edgegrid allows you to sign up your request to calling Akamai APIs.
Package edgegrid allows you to sign up your request to calling Akamai APIs.
internal
v1

Jump to

Keyboard shortcuts

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