clients

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NHOST_AUTH_URL string
View Source
var NHOST_GRAPHQL_URL string

URLs

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
	Message string      `json:"message,omitempty"`
}

type ClientType

type ClientType string
const (
	HTTPClientType    ClientType = "HTTPClient"
	HasuraClientType  ClientType = "HasuraClient"
	GraphQLClientType ClientType = "GraphQLClient"
)

type CustomHeader

type CustomHeader struct {
	Key   string
	Value string
}

type Error

type Error struct {
	Error   error       `json:"error"`
	Message string      `json:"message"`
	Type    ErrorType   `json:"type"`
	Source  ErrorSource `json:"source"`
}

func New

func New(err error, message string, typ ErrorType, source ErrorSource) *Error

func Parse

func Parse(err error) *Error

func ParseExternal

func ParseExternal(err error) *Error

func (*Error) GenerateMessage

func (e *Error) GenerateMessage(defaultMessage string) string

func (*Error) IsType

func (e *Error) IsType(errType ErrorType) bool

func (*Error) Log

func (e *Error) Log(logger *logrus.Logger, defaultMessage string)

func (*Error) ToError

func (e *Error) ToError() error

type ErrorSource

type ErrorSource string
const (
	ErrorSourceHTTP    ErrorSource = "http"
	ErrorSourceGraphQL ErrorSource = "graphql"
	ErrorSourceNhost   ErrorSource = "nhost"
	ErrorSourceGo      ErrorSource = "go"
	ErrorSourceSystem  ErrorSource = "system"
)

type ErrorType

type ErrorType string
const (
	ErrorTypeBase64Encode ErrorType = "Base64Encode"
	ErrorTypeBase64Decode ErrorType = "Base64Decode"

	ErrorTypeJSONMarshal      ErrorType = "JSONMarshal"
	ErrorTypeJSONUnmarshal    ErrorType = "JSONUnmarshal"
	ErrorTypeJWTExpired       ErrorType = "JWTExpired"
	ErrorTypeMalformedHeader  ErrorType = "Malformed Authorization header"
	ErrorTypeUnauthorized     ErrorType = "Unauthorized"
	ErrorTypePermissionDenied ErrorType = "PermissionDenied"
	ErrorTypeTokenRefresh     ErrorType = "TokenRefresh"

	ErrorTypeInvalidResponse ErrorType = "InvalidResponse"
	ErrorTypeBadResponse     ErrorType = "BadResponse"
	ErrorTypeBadRequest      ErrorType = "BadRequest"
	ErrorTypeBadGateway      ErrorType = "BadGateway"
	ErrorTypeRequestFailed   ErrorType = "RequestFailed"

	ErrorTypeDoesNotExist   ErrorType = "DoesNotExist"
	ErrorTypeInvalidKey     ErrorType = "InvalidKey"
	ErrorTypeKeyNotFound    ErrorType = "KeyNotFound"
	ErrorTypeRecordNotFound ErrorType = "RecordNotFound"

	ErrorTypeInvalidToken ErrorType = "InvalidToken"

	ErrorTypeInvalidAccountConfiguration ErrorType = "InvalidAccountConfiguration"
	ErrorTypeInvalidProjectConfiguration ErrorType = "InvalidProjectConfiguration"

	ErrorTypeEmailFailed ErrorType = "EmailFailed"
)

func (*ErrorType) GetStatusCode

func (e *ErrorType) GetStatusCode() int

type GQLClient

type GQLClient struct {
	*clients.GQLClient
	// contains filtered or unexported fields
}

func NewGQLClient

func NewGQLClient(config *GQLConfig) *GQLClient

func (*GQLClient) Do

func (c *GQLClient) Do(ctx context.ServiceContext, req *graphql.Request, resp interface{}) error

type GQLConfig

type GQLConfig struct {
	BaseURL       string
	Authorization string
	Logger        *logrus.Logger
}

type HTTPClient

type HTTPClient struct {
	*http.Client
	BaseURL       string
	Authorization string
	CustomHeaders []CustomHeader

	ResponseHandler func(*http.Response) error
	Type            ClientType
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(config *HTTPConfig) *HTTPClient

func (*HTTPClient) Run

func (c *HTTPClient) Run(ctx context.ServiceContext, req *http.Request, response interface{}) error

type HTTPConfig

type HTTPConfig struct {
	Type            ClientType
	BaseURL         string
	Authorization   string
	Headers         []Header
	CustomHeaders   []CustomHeader
	Logger          *logrus.Logger
	ResponseHandler func(*http.Response) error
}
type Header string
const (

	//	Standard HTTP headers
	AuthorizationHeader Header = "Authorization"
	ContentTypeHeader   Header = "Content-Type"
	TokenHeader         Header = "x-envsecrets-token"
	OrgIDHeader         Header = "x-envsecrets-org-id"
	HasuraWebhookSecret Header = "X-Hasura-Webhook-Secret"

	//	Hasura headers
	XHasuraAdminSecretHeader Header = "x-hasura-admin-secret"
)

type LoginResponse

type LoginResponse struct {
	MFA struct {
		Ticket string `json:"ticket"`
	} `json:"mfa"`

	Session NhostSession `json:"session"`
}

type NhostClient

type NhostClient struct {
	*clients.NhostClient
	// contains filtered or unexported fields
}

func NewNhostClient

func NewNhostClient(config *NhostConfig) *NhostClient

func (*NhostClient) Run

func (c *NhostClient) Run(ctx context.ServiceContext, req *http.Request, response interface{}) error

type NhostConfig

type NhostConfig struct {
	Authorization string
	Logger        *logrus.Logger
	BaseURL       string
}

type NhostSession

type NhostSession struct {
	AccessToken          string     `json:"accessToken"`
	AccessTokenExpiresIn int        `json:"accessTokenExpiresIn"`
	RefreshToken         string     `json:"refreshToken"`
	User                 users.User `json:"user"`
}

Jump to

Keyboard shortcuts

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