core

package
v3.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiErrorHttpRequestMethod = "Error while initializing http request"
	ApiErrorHttpBodyResponse  = "Error reading body response"
	ApiErrorHttpRequest       = "Error when sending http request to Glide API"
	ApiErrorHttpReadResponse  = "Error while reading response body"
)

Functions

func GetExpandFields

func GetExpandFields(fieldIds ...string) string

func GetJwt

func GetJwt(key Key, iss string, sub string, aud string, scopes []string, expiresIn int64) (string, error)

func GetRsa256Key

func GetRsa256Key(privateKeyFilePath string) rsa256Key

func GetRsa256KeyFromPEMBytes

func GetRsa256KeyFromPEMBytes(privateKeyBytes []byte) rsa256Key

func GetRsa256KeyFromPEMString

func GetRsa256KeyFromPEMString(privateKeyString string) rsa256Key

Types

type ApiError

type ApiError interface {
	error
	Unwrap() error
	IsMissingScopes() bool
	GetMissingScopes() []string
	HasToRequestScopes() bool
	RequestScopesUrl() string
	GetDescription() string
	GetStatusCode() int
}

type ApiErrorImpl added in v3.0.10

type ApiErrorImpl struct {
	Description     string
	StatusCode      int
	ResponseHeaders http.Header
	Params          map[string]interface{}
	Err             error
}

func GetApiError

func GetApiError(e error) *ApiErrorImpl

func NewApiErrorWithArgs added in v3.0.10

func NewApiErrorWithArgs(
	description string,
	statusCode int,
	responseHeaders http.Header,
	params map[string]interface{},
	baseError error,
) *ApiErrorImpl

func NewHttpMethodApiError added in v3.0.10

func NewHttpMethodApiError(e error) *ApiErrorImpl

func NewHttpRequestApiError added in v3.0.10

func NewHttpRequestApiError(e error) *ApiErrorImpl

func (*ApiErrorImpl) Error added in v3.0.10

func (e *ApiErrorImpl) Error() string

func (*ApiErrorImpl) GetDescription added in v3.0.10

func (e *ApiErrorImpl) GetDescription() string

func (*ApiErrorImpl) GetMissingScopes added in v3.0.10

func (e *ApiErrorImpl) GetMissingScopes() []string

func (*ApiErrorImpl) GetStatusCode added in v3.0.10

func (e *ApiErrorImpl) GetStatusCode() int

func (*ApiErrorImpl) HasToRequestScopes added in v3.0.10

func (e *ApiErrorImpl) HasToRequestScopes() bool

func (*ApiErrorImpl) IsMissingScopes added in v3.0.10

func (e *ApiErrorImpl) IsMissingScopes() bool

func (*ApiErrorImpl) RequestScopesUrl added in v3.0.10

func (e *ApiErrorImpl) RequestScopesUrl() string

func (*ApiErrorImpl) Unwrap added in v3.0.10

func (e *ApiErrorImpl) Unwrap() error

type ClientOption

type ClientOption func(options ClientOptions)

func WithAudience

func WithAudience(audience string) ClientOption

func WithBasePath

func WithBasePath(basePath string) ClientOption

func WithHost

func WithHost(host string) ClientOption

func WithProtocol

func WithProtocol(protocol string) ClientOption

func WithURL

func WithURL(URL string) ClientOption

type ClientOptions

type ClientOptions interface {
	GetProtocol() string
	GetHost() string
	GetUrl() string
	GetBasePath() string
	GetAudience() string
	SetProtocol(value string) ClientOptions
	SetHost(value string) ClientOptions
	SetUrl(value string) ClientOptions
	SetBasePath(value string) ClientOptions
	SetAudience(value string) ClientOptions
}

func NewClientOptions

func NewClientOptions() ClientOptions

type ClientOptionsImpl

type ClientOptionsImpl struct {
	// contains filtered or unexported fields
}

func (*ClientOptionsImpl) GetAudience

func (co *ClientOptionsImpl) GetAudience() string

func (*ClientOptionsImpl) GetBasePath

func (co *ClientOptionsImpl) GetBasePath() string

func (*ClientOptionsImpl) GetHost

func (co *ClientOptionsImpl) GetHost() string

func (*ClientOptionsImpl) GetProtocol

func (co *ClientOptionsImpl) GetProtocol() string

func (*ClientOptionsImpl) GetUrl

func (co *ClientOptionsImpl) GetUrl() string

func (*ClientOptionsImpl) SetAudience

func (co *ClientOptionsImpl) SetAudience(value string) ClientOptions

func (*ClientOptionsImpl) SetBasePath

func (co *ClientOptionsImpl) SetBasePath(value string) ClientOptions

func (*ClientOptionsImpl) SetHost

func (co *ClientOptionsImpl) SetHost(value string) ClientOptions

func (*ClientOptionsImpl) SetProtocol

func (co *ClientOptionsImpl) SetProtocol(value string) ClientOptions

func (*ClientOptionsImpl) SetUrl

func (co *ClientOptionsImpl) SetUrl(value string) ClientOptions

type ErrorObject added in v3.0.32

type ErrorObject struct {
	Message string                 `json:"message"`
	Object  string                 `json:"error"`
	Params  map[string]interface{} `json:"params"`
}

type File added in v3.0.19

type File struct {
	Content http.File
	Title   string
}

type HttpClient

type HttpClient interface {
	Get(res interface{}, url string, opts ...RequestOption) error
	Post(res interface{}, url string, payload interface{}, opts ...RequestOption) error
	PostWithFiles(res interface{}, url string, payload interface{}, files []File, opts ...RequestOption) error
	Request(res interface{}, requestMethod string, url string, opts ...RequestOption) error
	SetRequester(requester HttpClientRequester)
}

func NewHttpClient

func NewHttpClient() HttpClient

func NewHttpClientWithRequester

func NewHttpClientWithRequester(requester HttpClientRequester) HttpClient

type HttpClientImpl

type HttpClientImpl struct {
	// contains filtered or unexported fields
}

func (*HttpClientImpl) Get

func (hc *HttpClientImpl) Get(res interface{}, url string, opts ...RequestOption) error

func (*HttpClientImpl) Post

func (hc *HttpClientImpl) Post(res interface{}, url string, payload interface{}, opts ...RequestOption) error

func (*HttpClientImpl) PostWithFiles added in v3.0.19

func (hc *HttpClientImpl) PostWithFiles(res interface{}, url string, payload interface{}, files []File, opts ...RequestOption) error

func (*HttpClientImpl) Request

func (hc *HttpClientImpl) Request(res interface{}, requestMethod string, url string, opts ...RequestOption) error

func (*HttpClientImpl) SetRequester

func (hc *HttpClientImpl) SetRequester(requester HttpClientRequester)

type HttpClientRequester

type HttpClientRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

type HttpReqFuncType

type HttpReqFuncType func(string) (*http.Response, error)

type Impersonation

type Impersonation interface {
	GetSub() string
	GetScopes() []string
	GetAccessToken() string
	GetAccessTokenExpires() time.Time
	SetSub(string) Impersonation
	SetScopes([]string) Impersonation
	SetAccessToken(string) Impersonation
	SetAccessTokenExpires(time.Time) Impersonation
}

func NewImpersonation

func NewImpersonation() Impersonation

func NewImpersonationWithParams added in v3.0.10

func NewImpersonationWithParams(
	sub string,
	scopes []string,
	accessToken string,
	accessTokenExpires time.Time) Impersonation

type ImpersonationImpl

type ImpersonationImpl struct {
	// contains filtered or unexported fields
}

func (*ImpersonationImpl) GetAccessToken

func (imp *ImpersonationImpl) GetAccessToken() string

func (*ImpersonationImpl) GetAccessTokenExpires

func (imp *ImpersonationImpl) GetAccessTokenExpires() time.Time

func (*ImpersonationImpl) GetScopes

func (imp *ImpersonationImpl) GetScopes() []string

func (*ImpersonationImpl) GetSub

func (imp *ImpersonationImpl) GetSub() string

func (*ImpersonationImpl) SetAccessToken

func (imp *ImpersonationImpl) SetAccessToken(value string) Impersonation

func (*ImpersonationImpl) SetAccessTokenExpires

func (imp *ImpersonationImpl) SetAccessTokenExpires(value time.Time) Impersonation

func (*ImpersonationImpl) SetScopes

func (imp *ImpersonationImpl) SetScopes(value []string) Impersonation

func (*ImpersonationImpl) SetSub

func (imp *ImpersonationImpl) SetSub(value string) Impersonation

type Key

type Key interface {
	GetJwtSigningMethod() jwt.SigningMethod
	GetDecoded() (crypto.PrivateKey, error)
}

type PageParams

type PageParams interface {
	GetQueryParams() map[string]string
}

func NewPageParamsWith added in v3.0.10

func NewPageParamsWith(limit int, startingAfter string) PageParams

type PageParamsImpl added in v3.0.10

type PageParamsImpl struct {
	StartingAfter string
	Limit         int
}

func (*PageParamsImpl) GetQueryParams added in v3.0.10

func (p *PageParamsImpl) GetQueryParams() map[string]string

type QueryParams

type QueryParams map[string]string

type Request

type Request interface{}

type RequestOption

type RequestOption func(requestOptions *RequestOptionsImpl)

func WithExpand

func WithExpand(paths ...string) RequestOption

func WithHeader

func WithHeader(name string, value string) RequestOption

func WithPage

func WithPage(pageParams PageParams) RequestOption

func WithPageParams

func WithPageParams(limit int, startingAfter string) RequestOption

func WithQueryParam

func WithQueryParam(qParam string, value string) RequestOption

func WithQueryParamList

func WithQueryParamList(qParam string, values ...string) RequestOption

func WithReqOptQueryParamList

func WithReqOptQueryParamList(name string, values []string) RequestOption

func WithRequestHost

func WithRequestHost(host string) RequestOption

func WithUpdatedAfter

func WithUpdatedAfter(ts int) RequestOption

type RequestOptions added in v3.0.10

type RequestOptions interface {
	GetHeaders() http.Header
	GetHost() string
	GetQParams() QueryParams
	GetPayload() *bytes.Buffer
}

type RequestOptionsImpl

type RequestOptionsImpl struct {
	// contains filtered or unexported fields
}

func (*RequestOptionsImpl) GetHeaders added in v3.0.10

func (reqOpt *RequestOptionsImpl) GetHeaders() http.Header

func (*RequestOptionsImpl) GetHost added in v3.0.10

func (reqOpt *RequestOptionsImpl) GetHost() string

func (*RequestOptionsImpl) GetPayload added in v3.0.10

func (reqOpt *RequestOptionsImpl) GetPayload() *bytes.Buffer

func (*RequestOptionsImpl) GetQParams added in v3.0.10

func (reqOpt *RequestOptionsImpl) GetQParams() QueryParams

type Response

type Response interface {
	IsRef() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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