api

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest checks if the error is a 400 Bad Request error

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the error is a 404 Not Found error

func IsServerError

func IsServerError(err error) bool

IsServerError checks if the error is a 5xx server error

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized checks if the error is a 401 or 403 error

Types

type Client

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

Client is the HTTP client for Coolify API

func NewClient

func NewClient(baseURL, token string, opts ...Option) *Client

NewClient creates a new API client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) error

Delete makes a DELETE request to the API

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, result interface{}) error

Get makes a GET request to the API

func (*Client) GetVersion

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

GetVersion fetches the API version

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, path string, body, result interface{}) error

Patch makes a PATCH request to the API

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, result interface{}) error

Post makes a POST request to the API

type Error

type Error struct {
	StatusCode int
	Message    string
	Path       string
}

Error represents an API error response

func NewError

func NewError(statusCode int, path, message string) *Error

NewError creates a new API error

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

type Option

type Option func(*Client)

Option configures the API client

func WithDebug

func WithDebug(debug bool) Option

WithDebug enables debug logging

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client

func WithRetries

func WithRetries(retries int) Option

WithRetries sets the number of retries for failed requests

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the request timeout

Jump to

Keyboard shortcuts

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