Versions in this module Expand all Collapse all v0 v0.9.0 Aug 12, 2026 Changes in this version + const DefaultAPIVersion + var ErrAlreadyStarted = errors.New("safeguard: event listener already started") + var ErrClosed = errors.New("safeguard: client is closed") + var ErrNotAuthenticated = errors.New("safeguard: not authenticated") + var ErrNotRefreshable = errors.New("safeguard: token is not refreshable") + var ErrReservedHeader = errors.New("safeguard: Authorization is a reserved header and cannot be set on a request") + var ErrSecondaryFactorFailed = auth.ErrSecondaryFactorFailed + var ErrSecondaryFactorRequired = auth.ErrSecondaryFactorRequired + func InvokeTyped[T any](ctx context.Context, c *Client, m HTTPMethod, s Service, relURL string, ...) (T, error) + type A2AContext struct + func NewA2AContext(host string, certPEM []byte, password Secret, opts ...A2AOption) (*A2AContext, error) + func (a *A2AContext) APIVersion() string + func (a *A2AContext) BrokerAccessRequest(ctx context.Context, brokerAPIKey Secret, req BrokeredAccessRequest) (*AccessRequest, error) + func (a *A2AContext) Close() error + func (a *A2AContext) GetRetrievableAccounts(ctx context.Context, filter string) ([]A2ARetrievableAccount, error) + func (a *A2AContext) Host() string + func (a *A2AContext) NewEventListener(apiKey Secret) *EventListener + func (a *A2AContext) NewPersistentEventListener(apiKey Secret) *PersistentEventListener + func (a *A2AContext) RetrieveAPIKey(ctx context.Context, apiKey Secret) ([]APIKey, error) + func (a *A2AContext) RetrievePassword(ctx context.Context, apiKey Secret) (Secret, error) + func (a *A2AContext) RetrievePrivateKey(ctx context.Context, apiKey Secret, format KeyFormat) (Secret, error) + func (a *A2AContext) SetPassword(ctx context.Context, apiKey Secret, newPassword Secret) error + func (a *A2AContext) SetPrivateKey(ctx context.Context, apiKey Secret, privateKeyPEM Secret, passphrase Secret, ...) error + type A2AOption func(*a2aConfig) error + func WithA2AConnectionOptions(opts ...Option) A2AOption + func WithA2APrivateKeyPEM(keyPEM []byte) A2AOption + type A2ARetrievableAccount struct + APIKey Secret + AccountDescription string + AccountID int + AccountName string + AccountType string + ApplicationName string + AssetDescription string + AssetID int + AssetName string + AssetNetworkAddress string + Description string + Disabled bool + DomainName string + type APIError struct + Code int + Message string + RequestID string + StatusCode int + func (e *APIError) Error() string + func (e *APIError) RawBody() []byte + type APIKey struct + ClientID string + ClientSecret Secret + ClientSecretID string + Description string + ID int + Name string + type AccessRequest struct + AccessRequestType AccessRequestType + AccountID int + AccountName string + AssetID int + AssetName string + ID string + Raw json.RawMessage + State string + type AccessRequestType string + const AccessRequestAPIKey + const AccessRequestFile + const AccessRequestPassword + const AccessRequestRemoteDesktop + const AccessRequestRemoteDesktopApplication + const AccessRequestSSH + const AccessRequestSSHKey + const AccessRequestTelnet + type AuthenticationError struct + func (e *AuthenticationError) Unwrap() error + type AuthorizationError struct + func (e *AuthorizationError) Unwrap() error + type BrokeredAccessRequest struct + AccessRequestType AccessRequestType + AccountDomainName string + AccountID int + AccountName string + AssetID int + AssetName string + ForProvider string + ForUser string + ForUserID int + IsEmergency bool + ReasonCode string + ReasonCodeID int + ReasonComment string + RequestedDurationDays int + RequestedDurationHours int + RequestedDurationMinutes int + RequestedFor time.Time + TicketNumber string + type CertOption func(*certConfig) error + func WithCertificateProvider(provider string) CertOption + func WithPrivateKeyPEM(keyPEM []byte) CertOption + type Client struct + func Connect(ctx context.Context, host string, cred Credential, opts ...Option) (*Client, error) + func (c *Client) APIVersion() string + func (c *Client) Close() error + func (c *Client) Delete(ctx context.Context, s Service, relURL string, opts ...ReqOption) (Response, error) + func (c *Client) Download(ctx context.Context, s Service, relURL string, w io.Writer, opts ...ReqOption) (Response, error) + func (c *Client) Get(ctx context.Context, s Service, relURL string, opts ...ReqOption) (Response, error) + func (c *Client) Host() string + func (c *Client) Invoke(ctx context.Context, m HTTPMethod, s Service, relURL string, body any, ...) (Response, error) + func (c *Client) Logout(ctx context.Context) error + func (c *Client) NewEventListener() *EventListener + func (c *Client) NewPersistentEventListener() *PersistentEventListener + func (c *Client) Post(ctx context.Context, s Service, relURL string, body any, opts ...ReqOption) (Response, error) + func (c *Client) Put(ctx context.Context, s Service, relURL string, body any, opts ...ReqOption) (Response, error) + func (c *Client) RefreshToken(ctx context.Context) error + func (c *Client) Stream(ctx context.Context, m HTTPMethod, s Service, relURL string, body any, ...) (io.ReadCloser, Response, error) + func (c *Client) TokenLifetimeRemaining(ctx context.Context) (time.Duration, error) + func (c *Client) Upload(ctx context.Context, s Service, relURL string, r io.Reader, opts ...ReqOption) (Response, error) + type Credential interface + func Anonymous() Credential + func AuthorizedSession(login LoginFunc) Credential + func Certificate(certPEM []byte, password Secret, opts ...CertOption) Credential + func PKCEHeadless(provider, username string, password Secret, opts ...PKCEOption) Credential + func Token(userToken Secret) Credential + func UsernamePassword(provider, username string, password Secret) Credential + type EventHandlerFunc func(name string, data json.RawMessage) + type EventListener struct + func (l *EventListener) Done() <-chan struct{} + func (l *EventListener) Err() error + func (l *EventListener) RegisterEventHandler(name string, h EventHandlerFunc) + func (l *EventListener) Start(ctx context.Context) error + func (l *EventListener) Stop() + type HTTPMethod string + const MethodDelete + const MethodGet + const MethodPost + const MethodPut + type KeyFormat string + const KeyFormatOpenSSH + const KeyFormatPuTTY + const KeyFormatSSH2 + type LoginFunc func(ctx context.Context, t LoginTransport) (userToken Secret, err error) + type LoginTransport interface + APIVersion func() string + Do func(req *http.Request) (*http.Response, error) + Host func() string + type NotFoundError struct + func (e *NotFoundError) Unwrap() error + type Option func(*clientConfig) error + func WithAPIVersion(version string) Option + func WithCABundle(pemBytes []byte) Option + func WithHTTPTimeouts(t Timeouts) Option + func WithInsecureTLS() Option + func WithLogger(logger *slog.Logger) Option + func WithServerCertValidator(v ServerCertValidator) Option + type PKCEOption func(*pkceConfig) error + func WithSecondaryFactor(fn SecondaryFactorFunc) PKCEOption + type PersistentEventListener struct + func (l *PersistentEventListener) Done() <-chan struct{} + func (l *PersistentEventListener) Err() error + func (l *PersistentEventListener) RegisterEventHandler(name string, h EventHandlerFunc) + func (l *PersistentEventListener) Start(ctx context.Context) error + func (l *PersistentEventListener) Stop() + type ReqOption func(*requestConfig) error + func WithAPIVersionOverride(version string) ReqOption + func WithAccept(mediaType string) ReqOption + func WithHeader(key, value string) ReqOption + func WithHost(host string) ReqOption + func WithQueryParam(key, value string) ReqOption + func WithQueryParams(params map[string]string) ReqOption + func WithRequestTimeout(d time.Duration) ReqOption + type Response struct + Body []byte + Headers http.Header + RequestID string + StatusCode int + func (r Response) BodyString() string + func (r Response) IsSuccess() bool + type SecondaryFactorFunc func(ctx context.Context, prompt string) (Secret, error) + type Secret struct + func NewSecret(b []byte) Secret + func NewSecretString(s string) Secret + func (s *Secret) Close() error + func (s *Secret) Zero() + func (s Secret) Equal(other Secret) bool + func (s Secret) Expose() []byte + func (s Secret) ExposeString() string + func (s Secret) Format(f fmt.State, _ rune) + func (s Secret) GoString() string + func (s Secret) IsZero() bool + func (s Secret) Len() int + func (s Secret) LogValue() slog.Value + func (s Secret) MarshalJSON() ([]byte, error) + func (s Secret) MarshalText() ([]byte, error) + func (s Secret) String() string + type ServerCertValidator func(leaf *x509.Certificate, verifiedChains [][]*x509.Certificate) error + type Service string + const A2A + const Appliance + const Core + const Event + const Management + const Notification + const RSTS + type Timeouts struct + Dial time.Duration + ResponseHeader time.Duration + TLSHandshake time.Duration + type TransportError struct + Err error + Op string + func (e *TransportError) Error() string + func (e *TransportError) Unwrap() error