api

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartialPermissions = "Partial"
	FullPermissions    = "Full"
)

Variables

View Source
var (
	ErrOrganizationIDRequired = errors.New("organization id is required for this endpoint")
	ErrAPIKeyIDRequired       = errors.New("apikey id is required for this endpoint")
	ErrMemberIDRequired       = errors.New("member id is required for this endpoint")
	ErrProjectIDRequired      = errors.New("project id is required for this endpoint")
	ErrTenantIDRequired       = errors.New("tenant id is required for this endpoint")
	ErrTopicIDRequired        = errors.New("topic id is required for this endpoint")
	ErrEmailRequired          = errors.New("email is required for this endpoint")
	ErrTokenRequired          = errors.New("token is required for this endpoint")
	ErrPasswordRequired       = errors.New("password is required for this endpoint")
	ErrPasswordMismatch       = errors.New("passwords do not match")
	ErrPasswordTooWeak        = errors.New("password is too weak; use a combination of upper and lower case letters, numbers, and special characters")
	ErrMustAgreeTerms         = errors.New("you must agree to the terms of service")
	ErrMustAgreePrivacy       = errors.New("you must agree to the privacy policy")
	ErrInvalidTenantField     = errors.New("invalid tenant field")
	ErrMissingQueryField      = errors.New("missing query field")
	ErrQueryTooLong           = errors.New("query string is too long, please use the SDKs for complex queries")
	ErrInvalidUserClaims      = errors.New("user claims invalid or unavailable")
	ErrUnparsable             = errors.New("could not parse request")
	ErrNoCookies              = errors.New("no cookies available")
	ErrNoRefreshToken         = errors.New("refresh token not found in cookies")
	ErrNoAccessToken          = errors.New("access token not found in cookies")
	ErrNoCSRFToken            = errors.New("csrf token not found in cookies")
	ErrNoCSRFReferenceToken   = errors.New("csrf reference token not found in cookies")
)

Functions

func FieldTypeError added in v0.7.0

func FieldTypeError(field string, t string) error

func InvalidFieldError added in v0.7.0

func InvalidFieldError(field string) error

func NotAllowed

func NotAllowed(c *gin.Context)

NotAllowed returns a JSON 405 response for the API.

func NotFound

func NotFound(c *gin.Context)

NotFound returns a JSON response for the API. NOTE: we know it's weird to put server-side handlers like NotFound and NotAllowed here in the client/api side package but it unifies where we keep our error handling mechanisms.

func ReplyQuarterdeckError added in v0.5.0

func ReplyQuarterdeckError(c *gin.Context, err error)

ReplyQuarterdeckError returns a JSON response for a Quarterdeck error by attempting to decode a generic error into a StatusError. If the error is not a StatusError, then a JSON 500 response is returned. TODO: Does this need to have more user-friendly error messaging? :point-down:

Types

type APIKey added in v0.2.0

type APIKey struct {
	ID           string   `json:"id,omitempty"`
	ClientID     string   `json:"client_id"`
	ClientSecret string   `json:"client_secret,omitempty"`
	Name         string   `json:"name"`
	Owner        string   `json:"owner,omitempty"`
	Permissions  []string `json:"permissions,omitempty"`
	Created      string   `json:"created,omitempty"`
}

type APIKeyPage added in v0.2.0

type APIKeyPage struct {
	APIKeys       []*APIKey `json:"api_keys"`
	PrevPageToken string    `json:"prev_page_token"`
	NextPageToken string    `json:"next_page_token"`
}

type APIKeyPreview added in v0.5.0

type APIKeyPreview struct {
	ID          string `json:"id"`
	ClientID    string `json:"client_id"`
	Name        string `json:"name,omitempty"`
	Permissions string `json:"permissions"`
	Status      string `json:"status"`
	LastUsed    string `json:"last_used,omitempty"`
	Created     string `json:"created"`
	Modified    string `json:"modified"`
}

type APIv1

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

APIv1 implements the TenantClient interface

func (*APIv1) APIKeyCreate added in v0.3.0

func (s *APIv1) APIKeyCreate(ctx context.Context, in *APIKey) (out *APIKey, err error)

func (*APIv1) APIKeyDelete added in v0.2.0

func (s *APIv1) APIKeyDelete(ctx context.Context, id string) (err error)

func (*APIv1) APIKeyDetail added in v0.2.0

func (s *APIv1) APIKeyDetail(ctx context.Context, id string) (out *APIKey, err error)

func (*APIv1) APIKeyList added in v0.2.0

func (s *APIv1) APIKeyList(ctx context.Context, in *PageQuery) (out *APIKeyPage, err error)

func (*APIv1) APIKeyPermissions added in v0.5.0

func (s *APIv1) APIKeyPermissions(ctx context.Context) (out []string, err error)

func (*APIv1) APIKeyUpdate added in v0.2.0

func (s *APIv1) APIKeyUpdate(ctx context.Context, in *APIKey) (out *APIKey, err error)

func (*APIv1) AccessToken added in v0.10.0

func (c *APIv1) AccessToken() (_ string, err error)

AccessToken returns the access token cached on the client or an error if it is not available. This method is primarily used for testing but can be used to fetch the access token for debugging or inspection if necessary.

func (*APIv1) ClearAuthTokens added in v0.10.0

func (c *APIv1) ClearAuthTokens()

ClearAuthTokens clears the access and refresh tokens on the client Jar.

func (*APIv1) Cookies added in v0.10.0

func (c *APIv1) Cookies() (_ []*http.Cookie, err error)

Returns the cookies set from the previous request(s) on the client Jar.

func (*APIv1) Do

func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)

Do executes an http request against the server, performs error checking, and deserializes response data into the specified struct.

func (*APIv1) ForgotPassword added in v0.11.0

func (s *APIv1) ForgotPassword(ctx context.Context, in *ForgotPasswordRequest) (err error)

func (*APIv1) GetCSRFTokens added in v0.11.0

func (c *APIv1) GetCSRFTokens() (token, referenceToken string, err error)

GetCSRFTokens returns the CSRF tokens cached on the client or an error if they are not available. This method is primarily used for testing.

func (*APIv1) InviteAccept added in v0.10.0

func (s *APIv1) InviteAccept(ctx context.Context, in *MemberInviteToken) (out *AuthReply, err error)

func (*APIv1) InvitePreview added in v0.5.2

func (s *APIv1) InvitePreview(ctx context.Context, token string) (out *MemberInvitePreview, err error)

func (*APIv1) Login added in v0.3.0

func (s *APIv1) Login(ctx context.Context, in *LoginRequest) (out *AuthReply, err error)

func (*APIv1) MemberCreate added in v0.2.0

func (s *APIv1) MemberCreate(ctx context.Context, in *Member) (out *Member, err error)

func (*APIv1) MemberDelete added in v0.2.0

func (s *APIv1) MemberDelete(ctx context.Context, id string) (out *MemberDeleteReply, err error)

func (*APIv1) MemberDetail added in v0.2.0

func (s *APIv1) MemberDetail(ctx context.Context, id string) (out *Member, err error)

func (*APIv1) MemberList added in v0.2.0

func (s *APIv1) MemberList(ctx context.Context, in *PageQuery) (out *MemberPage, err error)

func (*APIv1) MemberRoleUpdate added in v0.5.2

func (s *APIv1) MemberRoleUpdate(ctx context.Context, id string, in *UpdateRoleParams) (out *Member, err error)

func (*APIv1) MemberUpdate added in v0.2.0

func (s *APIv1) MemberUpdate(ctx context.Context, in *Member) (out *Member, err error)

func (*APIv1) NewRequest

func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)

func (*APIv1) OrganizationDetail added in v0.4.0

func (s *APIv1) OrganizationDetail(ctx context.Context, id string) (out *Organization, err error)

func (*APIv1) OrganizationList added in v0.5.2

func (s *APIv1) OrganizationList(ctx context.Context, in *PageQuery) (out *OrganizationPage, err error)

func (*APIv1) ProfileDetail added in v0.10.0

func (s *APIv1) ProfileDetail(ctx context.Context) (out *Member, err error)

func (*APIv1) ProfileUpdate added in v0.10.0

func (s *APIv1) ProfileUpdate(ctx context.Context, in *Member) (out *Member, err error)

func (*APIv1) ProjectAPIKeyCreate added in v0.2.0

func (s *APIv1) ProjectAPIKeyCreate(ctx context.Context, id string, in *APIKey) (out *APIKey, err error)

func (*APIv1) ProjectAPIKeyList added in v0.2.0

func (s *APIv1) ProjectAPIKeyList(ctx context.Context, id string, in *PageQuery) (out *ProjectAPIKeyPage, err error)

func (*APIv1) ProjectCreate added in v0.2.0

func (s *APIv1) ProjectCreate(ctx context.Context, in *Project) (out *Project, err error)

func (*APIv1) ProjectDelete added in v0.2.0

func (s *APIv1) ProjectDelete(ctx context.Context, id string) (err error)

func (*APIv1) ProjectDetail added in v0.2.0

func (s *APIv1) ProjectDetail(ctx context.Context, id string) (out *Project, err error)

func (*APIv1) ProjectList added in v0.2.0

func (s *APIv1) ProjectList(ctx context.Context, in *PageQuery) (out *ProjectPage, err error)

func (*APIv1) ProjectPatch added in v0.7.0

func (s *APIv1) ProjectPatch(ctx context.Context, id string, in *Project) (out *Project, err error)

func (*APIv1) ProjectQuery added in v0.9.0

func (s *APIv1) ProjectQuery(ctx context.Context, in *ProjectQueryRequest) (out *ProjectQueryResponse, err error)

func (*APIv1) ProjectTopicCreate added in v0.2.0

func (s *APIv1) ProjectTopicCreate(ctx context.Context, id string, in *Topic) (out *Topic, err error)

func (*APIv1) ProjectTopicList added in v0.2.0

func (s *APIv1) ProjectTopicList(ctx context.Context, id string, in *PageQuery) (out *ProjectTopicPage, err error)

func (*APIv1) ProjectUpdate added in v0.2.0

func (s *APIv1) ProjectUpdate(ctx context.Context, in *Project) (out *Project, err error)

func (*APIv1) Refresh added in v0.3.0

func (s *APIv1) Refresh(ctx context.Context, in *RefreshRequest) (out *AuthReply, err error)

func (*APIv1) RefreshToken added in v0.10.0

func (c *APIv1) RefreshToken() (_ string, err error)

RefreshToken returns the refresh token cached on the client or an error if it is not available. This method is primarily used for testing but can be used to fetch the refresh token for debugging or inspection if necessary.

func (*APIv1) Register added in v0.3.0

func (s *APIv1) Register(ctx context.Context, in *RegisterRequest) (err error)

func (*APIv1) ResendEmail added in v0.10.0

func (s *APIv1) ResendEmail(ctx context.Context, in *ResendRequest) (err error)

func (*APIv1) ResetPassword added in v0.11.0

func (s *APIv1) ResetPassword(ctx context.Context, in *ResetPasswordRequest) (err error)

func (*APIv1) SetAuthTokens added in v0.10.0

func (c *APIv1) SetAuthTokens(access, refresh string) error

SetAuthTokens is a helper function to set the access and refresh tokens on the client cookie jar.

func (*APIv1) SetCSRFProtect added in v0.2.0

func (c *APIv1) SetCSRFProtect(protect bool) error

SetCSRFProtect is a helper function to set CSRF cookies on the client. This is not possible in a browser because of the HttpOnly flag. This method should only be used for testing purposes and an error is returned if the URL is not localhost. For live clients - the server should set these cookies. If protect is false, then the cookies are removed from the client by setting the cookies to an empty slice.

func (*APIv1) SetCredentials added in v0.2.0

func (c *APIv1) SetCredentials(token string)

SetCredentials is a helper function for external users to override credentials at runtime by directly passing in the token, which is useful for testing. TODO: Pass in a credentials interface instead of the token string.

func (*APIv1) SignUp

func (s *APIv1) SignUp(ctx context.Context, in *ContactInfo) (err error)

func (*APIv1) Status

func (s *APIv1) Status(ctx context.Context) (out *StatusReply, err error)

func (*APIv1) Switch added in v0.5.2

func (s *APIv1) Switch(ctx context.Context, in *SwitchRequest) (out *AuthReply, err error)

func (*APIv1) TenantCreate added in v0.1.1

func (s *APIv1) TenantCreate(ctx context.Context, in *Tenant) (out *Tenant, err error)

func (*APIv1) TenantDelete added in v0.2.0

func (s *APIv1) TenantDelete(ctx context.Context, id string) (err error)

func (*APIv1) TenantDetail added in v0.2.0

func (s *APIv1) TenantDetail(ctx context.Context, id string) (out *Tenant, err error)

func (*APIv1) TenantList added in v0.1.1

func (s *APIv1) TenantList(ctx context.Context, in *PageQuery) (out *TenantPage, err error)

func (*APIv1) TenantProjectCreate added in v0.2.0

func (s *APIv1) TenantProjectCreate(ctx context.Context, id string, in *Project) (out *Project, err error)

func (*APIv1) TenantProjectList added in v0.2.0

func (s *APIv1) TenantProjectList(ctx context.Context, id string, in *PageQuery) (out *TenantProjectPage, err error)

func (*APIv1) TenantProjectPatch added in v0.7.0

func (s *APIv1) TenantProjectPatch(ctx context.Context, tenantID, projectID string, in *Project) (out *Project, err error)

func (*APIv1) TenantProjectStats added in v0.7.0

func (s *APIv1) TenantProjectStats(ctx context.Context, id string) (out []*StatValue, err error)

func (*APIv1) TenantStats added in v0.3.0

func (s *APIv1) TenantStats(ctx context.Context, id string) (out []*StatValue, err error)

func (*APIv1) TenantUpdate added in v0.2.0

func (s *APIv1) TenantUpdate(ctx context.Context, in *Tenant) (out *Tenant, err error)

func (*APIv1) TopicDelete

func (s *APIv1) TopicDelete(ctx context.Context, in *Confirmation) (out *Confirmation, err error)

func (*APIv1) TopicDetail

func (s *APIv1) TopicDetail(ctx context.Context, id string) (out *Topic, err error)

func (*APIv1) TopicEvents added in v0.9.0

func (s *APIv1) TopicEvents(ctx context.Context, id string) (out []*EventTypeInfo, err error)

func (*APIv1) TopicList

func (s *APIv1) TopicList(ctx context.Context, in *PageQuery) (out *TopicPage, err error)

func (*APIv1) TopicStats added in v0.8.0

func (s *APIv1) TopicStats(ctx context.Context, id string) (out []*StatValue, err error)

func (*APIv1) TopicUpdate added in v0.2.0

func (s *APIv1) TopicUpdate(ctx context.Context, in *Topic) (out *Topic, err error)

func (*APIv1) VerifyEmail added in v0.5.0

func (s *APIv1) VerifyEmail(ctx context.Context, in *VerifyRequest) (out *AuthReply, err error)

type AuthReply added in v0.3.0

type AuthReply struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	LastLogin    string `json:"last_login,omitempty"`
}

type ClientOption

type ClientOption func(c *APIv1) error

ClientOptions allows us to configure the APIv1 client when it is created.

func WithClient

func WithClient(client *http.Client) ClientOption

type Confirmation added in v0.5.0

type Confirmation struct {
	ID     string `json:"id,omitempty"`
	Name   string `json:"name,omitempty"`
	Token  string `json:"token,omitempty"`
	Status string `json:"status,omitempty"`
}

Confirmation allows APIs to protect users from unintended actions such as deleting data by including a confirmation token in the request.

type ContactInfo

type ContactInfo struct {
	FirstName            string `json:"firstName"`
	LastName             string `json:"lastName"`
	Email                string `json:"email"`
	Country              string `json:"country"`
	Title                string `json:"title"`
	Organization         string `json:"organization"`
	CloudServiceProvider string `json:"cloudServiceProvider"`
}

ContactInfo allows users to sign up for email notifications from SendGrid and is specifically used to allow users to request Ensign Private Beta access.

type EventTypeInfo added in v0.9.0

type EventTypeInfo struct {
	Type       string     `json:"type"`
	Version    string     `json:"version"`
	Mimetype   string     `json:"mimetype"`
	Events     *StatValue `json:"events"`
	Duplicates *StatValue `json:"duplicates"`
	Storage    *StatValue `json:"storage"`
}

type FieldValidationError added in v0.10.0

type FieldValidationError struct {
	Field string `json:"field"`
	Err   string `json:"error"`
	Index int    `json:"index"`
}

FieldValidationError represents a validation error for a specific field, when the frontend needs to know which field is in error, and includes the name of the field and the index if the field is a list along with the error string.

func (*FieldValidationError) Error added in v0.10.0

func (e *FieldValidationError) Error() string

type FieldValidationErrors added in v0.10.0

type FieldValidationErrors []*FieldValidationError

func (FieldValidationErrors) Error added in v0.10.0

func (e FieldValidationErrors) Error() string

type ForgotPasswordRequest added in v0.11.0

type ForgotPasswordRequest struct {
	Email string `json:"email"`
}

type LoginRequest added in v0.3.0

type LoginRequest struct {
	Email       string `json:"email"`
	Password    string `json:"password"`
	OrgID       string `json:"org_id,omitempty"`
	InviteToken string `json:"invite_token,omitempty"`
}

type Member added in v0.2.0

type Member struct {
	ID                string   `json:"id,omitempty" uri:"id"`
	Email             string   `json:"email"`
	Name              string   `json:"name"`
	Organization      string   `json:"organization"`
	Workspace         string   `json:"workspace"`
	ProfessionSegment string   `json:"profession_segment"`
	DeveloperSegment  []string `json:"developer_segment"`
	Picture           string   `json:"picture"`
	Role              string   `json:"role"`
	Invited           bool     `json:"invited"`
	OnboardingStatus  string   `json:"onboarding_status"`
	Created           string   `json:"created,omitempty"`
	DateAdded         string   `json:"date_added,omitempty"`
	LastActivity      string   `json:"last_activity,omitempty"`
}

ID must be omitempty so that project owners can be updated on patch.

func (*Member) Normalize added in v0.10.0

func (m *Member) Normalize()

Normalize performs some cleanup on the Member fields to ensure that fields provided in the JSON request can be used in comparisons and uniqueness checks.

type MemberDeleteReply added in v0.7.0

type MemberDeleteReply struct {
	APIKeys []string `json:"api_keys,omitempty"`
	Token   string   `json:"token,omitempty"`
	Deleted bool     `json:"deleted,omitempty"`
}

type MemberInvitePreview added in v0.5.2

type MemberInvitePreview struct {
	Email       string `json:"email"`
	OrgName     string `json:"org_name"`
	InviterName string `json:"inviter_name"`
	Role        string `json:"role"`
	HasAccount  bool   `json:"has_account"`
}

type MemberInviteToken added in v0.10.0

type MemberInviteToken struct {
	Token string `json:"token"`
}

type MemberPage added in v0.2.0

type MemberPage struct {
	Members       []*Member `json:"members"`
	NextPageToken string    `json:"next_page_token,omitempty"`
}

type Organization added in v0.4.0

type Organization struct {
	ID        string `json:"id" uri:"id"`
	Name      string `json:"name"`
	Owner     string `json:"owner"`
	Domain    string `json:"domain"`
	Projects  int    `json:"projects"`
	LastLogin string `json:"last_login"`
	Created   string `json:"created"`
	Modified  string `json:"modified"`
}

type OrganizationPage added in v0.5.2

type OrganizationPage struct {
	Organizations []*Organization `json:"organizations"`
	NextPageToken string          `json:"next_page_token,omitempty"`
}

type PageQuery added in v0.1.1

type PageQuery struct {
	PageSize      uint32 `json:"page_size" url:"page_size,omitempty" form:"page_size"`
	NextPageToken string `json:"next_page_token" url:"next_page_token,omitempty" form:"next_page_token"`
}

type Project added in v0.2.0

type Project struct {
	ID           string    `json:"id,omitempty" uri:"id"`
	TenantID     string    `json:"tenant_id,omitempty"`
	Name         string    `json:"name,omitempty"`
	Description  string    `json:"description,omitempty"`
	Owner        Member    `json:"owner,omitempty"`
	Status       string    `json:"status,omitempty"`
	ActiveTopics uint64    `json:"active_topics,omitempty"`
	DataStorage  StatValue `json:"data_storage,omitempty"`
	Created      string    `json:"created,omitempty"`
	Modified     string    `json:"modified,omitempty"`
}

Omitempty should be set on all fields to make sure the project patch endpoints only parse fields that were provided in the JSON request.

type ProjectAPIKeyPage added in v0.2.0

type ProjectAPIKeyPage struct {
	ProjectID     string           `json:"project_id"`
	APIKeys       []*APIKeyPreview `json:"api_keys"`
	PrevPageToken string           `json:"prev_page_token"`
	NextPageToken string           `json:"next_page_token"`
}

type ProjectPage added in v0.2.0

type ProjectPage struct {
	Projects      []*Project `json:"projects"`
	NextPageToken string     `json:"next_page_token,omitempty"`
}

type ProjectQueryRequest added in v0.9.0

type ProjectQueryRequest struct {
	ProjectID  string            `json:"project_id"`
	Query      string            `json:"query"`
	Parameters []*QueryParameter `json:"parameters"`
}

type ProjectQueryResponse added in v0.9.0

type ProjectQueryResponse struct {
	Results     []*QueryResult `json:"results"`
	TotalEvents uint64         `json:"total_events"`
	Error       string         `json:"error,omitempty"`
}

type ProjectTopicPage added in v0.2.0

type ProjectTopicPage struct {
	ProjectID     string   `json:"project_id"`
	Topics        []*Topic `json:"topics"`
	NextPageToken string   `json:"next_page_token,omitempty"`
}

type QueryParameter added in v0.9.0

type QueryParameter struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

type QueryResult added in v0.9.0

type QueryResult struct {
	Metadata        map[string]string `json:"metadata"`
	Mimetype        string            `json:"mimetype"`
	Version         string            `json:"version"`
	IsBase64Encoded bool              `json:"is_base64_encoded"`
	Data            string            `json:"data"`
	Created         string            `json:"created"`
	Error           string            `json:"error,omitempty"`
}

type RefreshRequest added in v0.3.0

type RefreshRequest struct {
	RefreshToken string `json:"refresh_token"`
	OrgID        string `json:"org_id,omitempty"`
}

type RegisterRequest added in v0.3.0

type RegisterRequest struct {
	Email        string `json:"email"`
	Password     string `json:"password"`
	PwCheck      string `json:"pwcheck"`
	AgreeToS     bool   `json:"terms_agreement"`
	AgreePrivacy bool   `json:"privacy_agreement"`
}

func (*RegisterRequest) DefaultOrganization added in v0.10.0

func (r *RegisterRequest) DefaultOrganization() string

Create a default organization name based on the email address in the request.

func (*RegisterRequest) Validate added in v0.3.0

func (r *RegisterRequest) Validate() error

Validate ensures that all required fields are present without performing complete validation checks such as the password strength.

type Reply

type Reply struct {
	Success          bool                  `json:"success"`
	Error            string                `json:"error,omitempty"`
	ValidationErrors FieldValidationErrors `json:"validation_errors,omitempty"`
}

Reply contains standard fields that are used for generic API responses and errors.

func ErrorResponse

func ErrorResponse(err interface{}) Reply

Constructs a new response for an error or returns unsuccessful.

type ResendRequest added in v0.10.0

type ResendRequest struct {
	Email string `json:"email"`
	OrgID string `json:"org_id,omitempty"`
}

type ResetPasswordRequest added in v0.11.0

type ResetPasswordRequest struct {
	Token    string `json:"token"`
	Password string `json:"password"`
	PwCheck  string `json:"pwcheck"`
}

func (*ResetPasswordRequest) Validate added in v0.11.0

func (r *ResetPasswordRequest) Validate() error

type StatValue added in v0.5.0

type StatValue struct {
	Name    string  `json:"name"`
	Value   float64 `json:"value"`
	Units   string  `json:"units,omitempty"`
	Percent float64 `json:"percent,omitempty"`
}

StatValue contains a value for a named statistic which is meant to support a variety of statistics endpoints.

type StatusReply

type StatusReply struct {
	Status  string `json:"status"`
	Uptime  string `json:"uptime,omitempty"`
	Version string `json:"version,omitempty"`
}

Returned on status requests.

type SwitchRequest added in v0.5.2

type SwitchRequest struct {
	OrgID string `json:"org_id"`
}

type Tenant added in v0.1.1

type Tenant struct {
	ID              string `json:"id" uri:"id"`
	Name            string `json:"name"`
	EnvironmentType string `json:"environment_type"`
	Created         string `json:"created,omitempty"`
	Modified        string `json:"modified,omitempty"`
}

type TenantClient

type TenantClient interface {
	Status(context.Context) (*StatusReply, error)

	Register(context.Context, *RegisterRequest) error
	Login(context.Context, *LoginRequest) (*AuthReply, error)
	Refresh(context.Context, *RefreshRequest) (*AuthReply, error)
	Switch(context.Context, *SwitchRequest) (*AuthReply, error)
	VerifyEmail(context.Context, *VerifyRequest) (*AuthReply, error)
	ResendEmail(context.Context, *ResendRequest) error
	ForgotPassword(context.Context, *ForgotPasswordRequest) error
	ResetPassword(context.Context, *ResetPasswordRequest) error

	InvitePreview(context.Context, string) (*MemberInvitePreview, error)
	InviteAccept(context.Context, *MemberInviteToken) (*AuthReply, error)

	OrganizationList(context.Context, *PageQuery) (*OrganizationPage, error)
	OrganizationDetail(context.Context, string) (*Organization, error)

	TenantList(context.Context, *PageQuery) (*TenantPage, error)
	TenantCreate(context.Context, *Tenant) (*Tenant, error)
	TenantDetail(ctx context.Context, id string) (*Tenant, error)
	TenantUpdate(context.Context, *Tenant) (*Tenant, error)
	TenantDelete(ctx context.Context, id string) error

	TenantStats(ctx context.Context, id string) ([]*StatValue, error)

	MemberList(context.Context, *PageQuery) (*MemberPage, error)
	MemberCreate(context.Context, *Member) (*Member, error)
	MemberDetail(ctx context.Context, id string) (*Member, error)
	MemberUpdate(context.Context, *Member) (*Member, error)
	MemberRoleUpdate(ctx context.Context, id string, in *UpdateRoleParams) (*Member, error)
	MemberDelete(ctx context.Context, id string) (*MemberDeleteReply, error)

	ProfileDetail(context.Context) (*Member, error)
	ProfileUpdate(context.Context, *Member) (*Member, error)

	TenantProjectList(ctx context.Context, id string, in *PageQuery) (*TenantProjectPage, error)
	TenantProjectCreate(ctx context.Context, id string, in *Project) (*Project, error)
	TenantProjectPatch(ctx context.Context, tenantID, projectID string, in *Project) (*Project, error)

	TenantProjectStats(ctx context.Context, id string) ([]*StatValue, error)

	ProjectList(context.Context, *PageQuery) (*ProjectPage, error)
	ProjectCreate(context.Context, *Project) (*Project, error)
	ProjectDetail(ctx context.Context, id string) (*Project, error)
	ProjectUpdate(context.Context, *Project) (*Project, error)
	ProjectPatch(ctx context.Context, id string, in *Project) (*Project, error)
	ProjectDelete(ctx context.Context, id string) error

	ProjectTopicList(ctx context.Context, id string, in *PageQuery) (*ProjectTopicPage, error)
	ProjectTopicCreate(ctx context.Context, id string, in *Topic) (*Topic, error)

	ProjectQuery(ctx context.Context, in *ProjectQueryRequest) (*ProjectQueryResponse, error)

	TopicList(context.Context, *PageQuery) (*TopicPage, error)
	TopicDetail(ctx context.Context, id string) (*Topic, error)
	TopicEvents(ctx context.Context, id string) ([]*EventTypeInfo, error)
	TopicStats(ctx context.Context, id string) ([]*StatValue, error)
	TopicUpdate(context.Context, *Topic) (*Topic, error)
	TopicDelete(ctx context.Context, in *Confirmation) (*Confirmation, error)

	ProjectAPIKeyList(ctx context.Context, id string, in *PageQuery) (*ProjectAPIKeyPage, error)
	ProjectAPIKeyCreate(ctx context.Context, id string, in *APIKey) (*APIKey, error)

	APIKeyCreate(context.Context, *APIKey) (*APIKey, error)
	APIKeyList(context.Context, *PageQuery) (*APIKeyPage, error)
	APIKeyDetail(ctx context.Context, id string) (*APIKey, error)
	APIKeyUpdate(context.Context, *APIKey) (*APIKey, error)
	APIKeyDelete(ctx context.Context, id string) error
	APIKeyPermissions(context.Context) ([]string, error)
}

func New

func New(endpoint string, opts ...ClientOption) (_ TenantClient, err error)

New creates a new API v1 client that implements the Tenant Client interface.

type TenantPage added in v0.1.1

type TenantPage struct {
	Tenants       []*Tenant `json:"tenants"`
	NextPageToken string    `json:"next_page_token,omitempty"`
}

type TenantProjectPage added in v0.2.0

type TenantProjectPage struct {
	TenantID       string     `json:"id"`
	TenantProjects []*Project `json:"tenant_projects"`
	NextPageToken  string     `json:"next_page_token,omitempty"`
}

type Topic

type Topic struct {
	ID        string `json:"id" uri:"id"`
	ProjectID string `json:"project_id"`
	Name      string `json:"topic_name"`
	Status    string `json:"status"`
	Created   string `json:"created,omitempty"`
	Modified  string `json:"modified,omitempty"`
}

type TopicPage

type TopicPage struct {
	Topics        []*Topic `json:"topics"`
	NextPageToken string   `json:"next_page_token,omitempty"`
}

type UpdateRoleParams added in v0.5.2

type UpdateRoleParams struct {
	Role string `json:"role"`
}

type VerifyRequest added in v0.5.0

type VerifyRequest struct {
	Token string `json:"token"`
	OrgID string `json:"org_id,omitempty"`
}

Jump to

Keyboard shortcuts

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