api

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized refers to the http response code unauthorized, which really means not authenticated, despite its name. See https://stackoverflow.com/a/6937030/155585
	ErrUnauthorized = fmt.Errorf("unauthorized")
	// ErrForbidden means you don't have permissions to the requested resource
	ErrForbidden = fmt.Errorf("forbidden")

	ErrDuplicate  = fmt.Errorf("duplicate record")
	ErrNotFound   = fmt.Errorf("record not found")
	ErrBadRequest = fmt.Errorf("bad request")
	ErrInternal   = fmt.Errorf("internal error")
)

Functions

This section is empty.

Types

type APIToken added in v0.5.0

type APIToken struct {
	ID          uid.ID    `json:"id"`
	Created     time.Time `json:"created"`
	Expires     time.Time `json:"expires,omitempty"`
	Name        string    `json:"name"`
	Permissions []string  `json:"permissions"`
}

InfraAPIToken struct for InfraAPIToken

type Client added in v0.5.0

type Client struct {
	Url   string
	Token string
	Http  http.Client
}

func (Client) CreateAPIToken added in v0.5.0

func (c Client) CreateAPIToken(req *CreateAPITokenRequest) (*CreateAPITokenResponse, error)

func (Client) CreateDestination added in v0.5.0

func (c Client) CreateDestination(req *CreateDestinationRequest) (*Destination, error)

func (Client) CreateGrant added in v0.5.0

func (c Client) CreateGrant(req *CreateGrantRequest) (*Grant, error)

func (Client) CreateGroup added in v0.5.0

func (c Client) CreateGroup(req *CreateGroupRequest) (*Group, error)

func (Client) CreateProvider added in v0.5.0

func (c Client) CreateProvider(req *CreateProviderRequest) (*Provider, error)

func (Client) CreateToken added in v0.5.0

func (c Client) CreateToken(req *CreateTokenRequest) (*CreateTokenResponse, error)

func (Client) CreateUser added in v0.5.0

func (c Client) CreateUser(req *CreateUserRequest) (*User, error)

func (Client) DeleteDestination added in v0.5.0

func (c Client) DeleteDestination(id uid.ID) error

func (Client) DeleteGrant added in v0.5.0

func (c Client) DeleteGrant(id uid.ID) error

func (Client) DeleteProvider added in v0.5.0

func (c Client) DeleteProvider(id uid.ID) error

func (Client) GetGroup added in v0.5.0

func (c Client) GetGroup(id uid.ID) (*Group, error)

func (Client) GetProvider added in v0.5.0

func (c Client) GetProvider(id uid.ID) (*Provider, error)

func (Client) GetUser added in v0.5.0

func (c Client) GetUser(id uid.ID) (*User, error)

func (Client) GetVersion added in v0.5.0

func (c Client) GetVersion() (*Version, error)

func (Client) ListDestinations added in v0.5.0

func (c Client) ListDestinations(req ListDestinationsRequest) ([]Destination, error)

func (Client) ListGrants added in v0.5.0

func (c Client) ListGrants(req ListGrantsRequest) ([]Grant, error)

func (Client) ListGroupGrants added in v0.5.0

func (c Client) ListGroupGrants(id uid.ID) ([]Grant, error)

func (Client) ListGroups added in v0.5.0

func (c Client) ListGroups(req ListGroupsRequest) ([]Group, error)

func (Client) ListProviders added in v0.5.0

func (c Client) ListProviders(name string) ([]Provider, error)

func (Client) ListUserGrants added in v0.5.0

func (c Client) ListUserGrants(id uid.ID) ([]Grant, error)

func (Client) ListUserGroups added in v0.5.0

func (c Client) ListUserGroups(id uid.ID) ([]Group, error)

func (Client) ListUsers added in v0.5.0

func (c Client) ListUsers(req ListUsersRequest) ([]User, error)

func (Client) Login added in v0.5.0

func (c Client) Login(req *LoginRequest) (*LoginResponse, error)

func (Client) Logout added in v0.5.0

func (c Client) Logout() error

func (Client) UpdateDestination added in v0.5.0

func (c Client) UpdateDestination(req UpdateDestinationRequest) (*Destination, error)

func (Client) UpdateProvider added in v0.5.0

func (c Client) UpdateProvider(req UpdateProviderRequest) (*Provider, error)

type CreateAPITokenRequest added in v0.5.0

type CreateAPITokenRequest struct {
	Name        string        `json:"name"`
	Permissions []string      `json:"permissions"`
	Ttl         time.Duration `json:"ttl,omitempty"`
}

type CreateAPITokenResponse added in v0.5.0

type CreateAPITokenResponse struct {
	Token       string    `json:"token"`
	ID          uid.ID    `json:"id"`
	Created     time.Time `json:"created"`
	Expires     time.Time `json:"expires,omitempty"`
	Name        string    `json:"name"`
	Permissions []string  `json:"permissions"`
}

type CreateDestinationRequest added in v0.5.0

type CreateDestinationRequest struct {
	UniqueID   string                `json:"uniqueID"`
	Name       string                `json:"name" validate:"required"`
	Connection DestinationConnection `json:"connection"`
}

type CreateGrantRequest added in v0.5.0

type CreateGrantRequest struct {
	Identity  string `json:"identity" validate:"required"`
	Resource  string `json:"resource" validate:"required"`
	Privilege string `json:"privilege" validate:"required"`
}

type CreateGroupRequest added in v0.5.0

type CreateGroupRequest struct {
	Name       string `json:"name" validate:"required"`
	ProviderID uid.ID `json:"providerID" validate:"required"`
}

type CreateProviderRequest added in v0.5.0

type CreateProviderRequest struct {
	Name         string `json:"name" validate:"required"`
	URL          string `json:"url" validate:"required"`
	ClientID     string `json:"clientID"`
	ClientSecret string `json:"clientSecret"`
}

type CreateTokenRequest added in v0.5.0

type CreateTokenRequest struct {
	UserID uid.ID `json:"userID" validate:"required"`
}

type CreateTokenResponse added in v0.5.0

type CreateTokenResponse struct {
	Expires time.Time `json:"expires"`
	Token   string    `json:"token"`
}

type CreateUserRequest added in v0.5.0

type CreateUserRequest struct {
	Email      string `json:"email" validate:"email,required"`
	ProviderID uid.ID `json:"providerID" validate:"required"`
}

type Destination

type Destination struct {
	ID       uid.ID `json:"id"`
	UniqueID string `json:"uniqueID" form:"uniqueID"`
	Name     string `json:"name" form:"name"`
	// created time in seconds since 1970-01-01
	Created int64 `json:"created"`
	// updated time in seconds since 1970-01-01
	Updated    int64                 `json:"updated"`
	Connection DestinationConnection `json:"connection"`
}

type DestinationConnection added in v0.5.0

type DestinationConnection struct {
	URL string `json:"url" validate:"required"`
	CA  string `json:"ca"`
}

type EmptyRequest added in v0.5.0

type EmptyRequest struct{}

type EmptyResponse added in v0.5.0

type EmptyResponse struct{}

type Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

type Grant added in v0.5.0

type Grant struct {
	ID uid.ID `json:"id"`

	Created   int64  `json:"created"`    // created time in seconds since 1970-01-01 00:00:00 UTC
	CreatedBy uid.ID `json:"created_by"` // id of user who created the grant
	Updated   int64  `json:"updated"`    // updated time in seconds since 1970-01-01 00:00:00 UTC

	Identity  string `json:"identity"`  // format is "u:<idstr>" for users, "g:<idstr>" for groups
	Privilege string `json:"privilege"` // role or permission
	Resource  string `json:"resource"`  // Universal Resource Notation

	ExpiresAt *int64 `json:"expires_at"` // time this grant expires at in seconds since 1970-01-01 00:00:00 UTC
}

type Group

type Group struct {
	ID         uid.ID `json:"id"`
	Name       string `json:"name"`
	Created    int64  `json:"created"`
	Updated    int64  `json:"updated"`
	ProviderID uid.ID `json:"providerID"`
}

type ListDestinationsRequest added in v0.5.0

type ListDestinationsRequest struct {
	Name     string `form:"name"`
	UniqueID string `form:"unique_id"`
}

type ListGrantsRequest added in v0.5.0

type ListGrantsRequest struct {
	Identity  string `form:"identity"`
	Resource  string `form:"resource"`
	Privilege string `form:"privilege"`
}

type ListGroupsRequest added in v0.5.0

type ListGroupsRequest struct {
	Name       string `form:"name"`
	ProviderID uid.ID `form:"provider_id"`
}

type ListProvidersRequest added in v0.5.0

type ListProvidersRequest struct {
	Name string `form:"name"`
}

type ListUsersRequest added in v0.5.0

type ListUsersRequest struct {
	Email      string `form:"email"`
	ProviderID uid.ID `form:"provider_id"`
}

type LoginRequest

type LoginRequest struct {
	ProviderID uid.ID `json:"providerID" validate:"required"`
	Code       string `json:"code" validate:"required"`
}

type LoginResponse added in v0.2.3

type LoginResponse struct {
	ID    uid.ID `json:"id"`
	Name  string `json:"name"`
	Token string `json:"token"`
}

type Provider added in v0.4.0

type Provider struct {
	ID       uid.ID `json:"id"`
	Name     string `json:"name"`
	Created  int64  `json:"created"`
	Updated  int64  `json:"updated"`
	URL      string `json:"url" validate:"fqdn,required"`
	ClientID string `json:"clientID" validate:"required"`
}

type Resource added in v0.5.0

type Resource struct {
	ID uid.ID `uri:"id" validate:"required"`
}

type UpdateDestinationRequest added in v0.5.0

type UpdateDestinationRequest struct {
	ID         uid.ID                `uri:"id" json:"-" validate:"required"`
	Name       string                `json:"name" validate:"required"`
	UniqueID   string                `json:"uniqueID"`
	Connection DestinationConnection `json:"connection"`
}

type UpdateProviderRequest added in v0.5.0

type UpdateProviderRequest struct {
	ID           uid.ID `uri:"id" json:"-" validate:"required"`
	Name         string `json:"name"`
	URL          string `json:"url"`
	ClientID     string `json:"clientID"`
	ClientSecret string `json:"clientSecret"`
}

type User

type User struct {
	ID          uid.ID   `json:"id"`
	Email       string   `json:"email" validate:"email,required"`
	Created     int64    `json:"created"`
	Updated     int64    `json:"updated"`
	LastSeenAt  int64    `json:"lastSeenAt"`
	ProviderID  uid.ID   `json:"providerID"`
	Permissions []string `json:"permissions"`
}

type Version

type Version struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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