keystone

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exhaust

func Exhaust(resp *http.Response)

Exhaust reads the response body until completion, and closes it.

func GetJSON

func GetJSON(client HTTPClient, headers http.Header, path *url.URL, data interface{}, allowUnknownFields bool) error

GetJSON is a convenience wrapper for Query(client, http.MethodGet, ...) TODO: Add a variant with pagination support

func GetPaginatedJSON

func GetPaginatedJSON(client HTTPClient, headers http.Header, path *url.URL, p Paginator, allowUnknownFields bool, maximum int) error

GetPaginatedJSON is a convenience wrapper for Query(client, http.MethodGet, ...)

func PostJSON

func PostJSON(client HTTPClient, headers http.Header, path *url.URL, data interface{}) (http.Header, []byte, error)

PostJSON is a convenience wrapper for Update(client, http.MethodPost, ...)

func PutJSON

func PutJSON(client HTTPClient, headers http.Header, path *url.URL, data interface{}) (http.Header, []byte, error)

PutJSON is a convenience wrapper for Update(client, http.MethodPut, ...)

func Query

func Query(client HTTPClient, method string, headers http.Header, path *url.URL, data interface{}, allowUnknownFields bool) (http.Header, error)

Query performs an HTTP request without payload, loads the result into `data`

func Update

func Update(client HTTPClient, method string, headers http.Header, path *url.URL, data interface{}) (http.Header, []byte, error)

Update performs an HTTP request with JSON payload, returns headers.

Types

type Backoff

type Backoff interface {
	KeepTrying(retries int) (bool, time.Duration)
}

Backoff controls retry policy

type DecodeError

type DecodeError struct {
	Type interface{}
	Data json.RawMessage
	Err  error
}

DecodeError returned when failed to decode json data

func (DecodeError) Error

func (d DecodeError) Error() string

Error implements error

func (DecodeError) Unwrap

func (d DecodeError) Unwrap() error

Unwrap implements errors.Unwrap

type ExponentialBackoff

type ExponentialBackoff struct {
	MaxRetries   int
	InitialDelay time.Duration
	DelayFactor  float64
	MaxDelay     time.Duration
}

ExponentialBackoff performs exponential backoff

func (ExponentialBackoff) KeepTrying

func (l ExponentialBackoff) KeepTrying(retries int) (bool, time.Duration)

KeepTrying implements Retry

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient encapsulates the funcionality required from *http.Client.

type Keystone

type Keystone struct {
	URL               *url.URL
	Username, Service string
}

Keystone manages Requests to the Identity Manager

func New

func New(keystoneURL string, username, service string) (*Keystone, error)

New Keystone client instance

func (*Keystone) Domains

func (k *Keystone) Domains(client HTTPClient, headers http.Header, enabled bool) ([]models.Domain, error)

func (*Keystone) GroupRoles

func (k *Keystone) GroupRoles(client HTTPClient, headers http.Header, gids []string, skipErrors bool) ([]models.RoleAssignment, error)

func (*Keystone) Groups

func (k *Keystone) Groups(client HTTPClient, headers http.Header) ([]models.Group, error)

func (*Keystone) Headers

func (o *Keystone) Headers(subservice, token string) http.Header

Headers returns the authentication headers for a subservice

func (*Keystone) Login

func (o *Keystone) Login(client HTTPClient, password string, retries Backoff) (string, string, error)

Login into the Context Broker, get a session token

func (*Keystone) MyDomain

func (k *Keystone) MyDomain(client HTTPClient, headers http.Header) (string, string, error)

func (*Keystone) PostAssignments

func (k *Keystone) PostAssignments(client HTTPClient, headers http.Header, assignments []models.RoleAssignment) error

func (*Keystone) PostGroups

func (k *Keystone) PostGroups(client HTTPClient, headers http.Header, groups []models.Group) error

func (*Keystone) PostProjects

func (k *Keystone) PostProjects(client HTTPClient, headers http.Header, projects []models.Project) error

func (*Keystone) PostUsers

func (k *Keystone) PostUsers(client HTTPClient, headers http.Header, users []models.User) error

func (*Keystone) Projects

func (k *Keystone) Projects(client HTTPClient, headers http.Header) ([]models.Project, error)

func (*Keystone) Roles

func (k *Keystone) Roles(client HTTPClient, headers http.Header) ([]models.Role, error)

func (*Keystone) UserRoles

func (k *Keystone) UserRoles(client HTTPClient, headers http.Header, uids []string, skipErrors bool) ([]models.RoleAssignment, error)

func (*Keystone) Users

func (k *Keystone) Users(client HTTPClient, headers http.Header) ([]models.User, error)

type LinealBackoff

type LinealBackoff struct {
	MaxRetries int
	Delay      time.Duration
}

LinealBackoff performs lineal backoff

func (LinealBackoff) KeepTrying

func (l LinealBackoff) KeepTrying(retries int) (bool, time.Duration)

KeepTrying implements Retry

type NetError

type NetError struct {
	Req         http.Request
	StatusCode  int
	RespHeaders http.Header
	Resp        []byte
	Err         error
}

NetError describes an error performing a request

func (NetError) Error

func (n NetError) Error() string

Error implements error

func (NetError) Unwrap

func (n NetError) Unwrap() error

Unwrap implements errors.Unwrap

type Paginator

type Paginator interface {
	Append(item json.RawMessage, allowUnknownFields bool) error
}

type SlicePaginator

type SlicePaginator[T any] struct {
	Slice []T
}

SlicePaginator is a generic type of Paginator based on a slice

func NewPaginator

func NewPaginator[T any](slice []T) *SlicePaginator[T]

NewPaginator creates a new paginator backed by the given slice

func (*SlicePaginator[T]) Append

func (s *SlicePaginator[T]) Append(raw json.RawMessage, allowUnknownFields bool) error

Append implements Paginator

Jump to

Keyboard shortcuts

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