neonapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package neonapi reads a Neon project and its branches.

Read-only on purpose. A database is not a thing to converge silently: a plan that offers to create or delete one is a plan somebody eventually runs by accident.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Default bool   `json:"default"`
}

type CLISession

type CLISession struct {
	Token   string
	Expires time.Time
	// Expired is checked rather than assumed: an expired token fails as a 401,
	// which reads like a permission problem and sends people looking at their
	// Neon account instead of at `neonctl auth`.
	Expired bool
}

CLISession is a credential upkeep borrowed from neonctl rather than asking the operator for a second one.

func TokenFromCLI

func TokenFromCLI() (CLISession, bool)

TokenFromCLI reads the session `neonctl auth` already stored.

It returns nothing rather than an error when neonctl has never been used: that is not a problem to report, it is simply one fewer place to look.

func (CLISession) ExpiredMessage

func (s CLISession) ExpiredMessage() string

ExpiredMessage says what to do, rather than leaving a 401 to be diagnosed.

type Client

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

func New

func New(baseURL, token string) *Client

func (*Client) Branches

func (c *Client) Branches(ctx context.Context, projectID string) ([]Branch, error)

Branches lists a project's branches.

func (*Client) Project

func (c *Client) Project(ctx context.Context, projectID string) (Project, error)

func (*Client) String

func (c *Client) String() string

String redacts the token so that printing a Client cannot leak it.

type Error

type Error struct {
	Status   int
	Message  string
	Endpoint string
}

func (*Error) Error

func (e *Error) Error() string

type Project

type Project struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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