cypra

package module
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 1 Imported by: 0

README

Cypra Go SDK

Go clients for Cypra's admin REST API and tenant OIDC issuers.

Install

go get github.com/watzon/cypra/sdk/go/admin
go get github.com/watzon/cypra/sdk/go/oidc

Admin Quickstart

client, err := admin.New("https://cypra.example.com", os.Getenv("CYPRA_PAT"))
if err != nil {
    log.Fatal(err)
}

tenant, err := client.CreateTenant(context.Background(), "acme", "Acme")

Admin calls use Authorization: Bearer <pat> and typed errors from the root cypra package. Use errors.Is(err, cypra.ErrConflict) and errors.As(err, *cypra.Error) for control flow.

OIDC Quickstart

client, err := oidc.New(ctx, "https://acme.cypra.example.com", clientID, clientSecret, redirectURI)
if err != nil {
    log.Fatal(err)
}

redirect := client.AuthCodeURL("state-value")

The OIDC client is intentionally thin: it delegates discovery and verification to github.com/coreos/go-oidc/v3/oidc and token exchange to golang.org/x/oauth2.

Documentation

Overview

Package cypra contains shared SDK errors.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound identifies 404 responses from Cypra APIs.
	ErrNotFound = errors.New("cypra: not found")
	// ErrUnauthorized identifies 401 and 403 responses from Cypra APIs.
	ErrUnauthorized = errors.New("cypra: unauthorized")
	// ErrConflict identifies 409 responses from Cypra APIs.
	ErrConflict = errors.New("cypra: conflict")
	// ErrRateLimited identifies 429 responses from Cypra APIs.
	ErrRateLimited = errors.New("cypra: rate limited")
	// ErrValidation identifies 400 and 422 responses from Cypra APIs.
	ErrValidation = errors.New("cypra: validation failed")
)

Functions

func ErrorForStatus

func ErrorForStatus(status int, code string) error

ErrorForStatus maps an HTTP status and optional response code to a typed error.

Types

type Error

type Error struct {
	Err        error
	StatusCode int
	Code       string
}

Error wraps a typed sentinel with the HTTP status and Cypra error code.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Directories

Path Synopsis
Package admin is a typed client for the Cypra admin REST API.
Package admin is a typed client for the Cypra admin REST API.
Package oidc wraps standard OAuth2/OIDC clients for Cypra issuers.
Package oidc wraps standard OAuth2/OIDC clients for Cypra issuers.

Jump to

Keyboard shortcuts

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