nhostclient

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 10 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(domain 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)

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 ResponseValidator

type ResponseValidator func(resp *http.Response) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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