nhostclient

package
v1.28.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

This package provides functionality to interact with the Nhost API.

Index

Constants

View Source
const (
	PATDuration = 90 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func MakeJSONRequest

func MakeJSONRequest(
	ctx context.Context,
	client *http.Client,
	url string,
	method string,
	requestBody any,
	headers http.Header,
	response any,
	responseValidator ResponseValidator,
	retryer BasicRetryer,
) error

Types

type BasicRetryer

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

func NewBasicRetryer

func NewBasicRetryer(maxAttempts int, multiplier int) BasicRetryer

func (BasicRetryer) Retry

func (s BasicRetryer) Retry(f Func) error

type Client

type Client struct {
	*graphql.Client
	// contains filtered or unexported fields
}

func New

func New(authURL, graphqlURL string, interceptors ...clientv2.RequestInterceptor) *Client

func (*Client) CreatePAT

func (n *Client) CreatePAT(
	ctx context.Context,
	accessToken string,
) (credentials.Credentials, error)

func (*Client) Login

func (n *Client) Login(ctx context.Context, email, password string) (credentials.Session, error)

func (*Client) LoginPAT

func (n *Client) LoginPAT(ctx context.Context, pat string) (credentials.Session, error)

func (*Client) Logout

func (n *Client) Logout(ctx context.Context, refreshTokenID string, accessToken string) error

func (*Client) RefreshToken added in v1.12.0

func (n *Client) RefreshToken(
	ctx context.Context,
	refreshToken string,
) (RefreshTokenResponse, error)

func (*Client) VerifyEmail added in v1.15.4

func (n *Client) VerifyEmail(ctx context.Context, email string) error

type CreatePATRequest

type CreatePATRequest struct {
	ExpiresAt time.Time      `json:"expiresAt"`
	Metadata  map[string]any `json:"metadata"`
}

type Func

type Func func(attempt int) error

type LoginPATRequest

type LoginPATRequest struct {
	PersonalAccessToken string `json:"personalAccessToken"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type RefreshTokenRequest added in v1.12.0

type RefreshTokenRequest struct {
	RefreshToken string `json:"refreshToken"`
}

type RefreshTokenResponse added in v1.12.0

type RefreshTokenResponse struct {
	AccessToken string `json:"accessToken"`
}

type RequestError added in v1.15.4

type RequestError struct {
	Status    int    `json:"status"`
	ErrorCode string `json:"error"`
	Message   string `json:"message"`
}

func (*RequestError) Error added in v1.15.4

func (e *RequestError) Error() string

type ResponseValidator

type ResponseValidator func(resp *http.Response) error

type VerifyEmailRequest added in v1.15.4

type VerifyEmailRequest struct {
	Email string `json:"email"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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