Documentation ¶
Overview ¶
Package resource contains code common to all resources (orgs, workspaces, runs, etc)
Index ¶
Constants ¶
const ( DefaultPageNumber = 1 DefaultPageSize = 20 MaxPageSize = 100 )
Variables ¶
var ( // EmptyID for use in comparisons to check whether ID has been // uninitialized. EmptyID = ID{} // ReStringID is a regular expression used to validate common string ID patterns. ReStringID = regexp.MustCompile(`^[a-zA-Z0-9\-\._]+$`) )
var ErrInfinitePaginationDetected = errors.New("infinite pagination detected")
Functions ¶
func GenerateRandomStringFromAlphabet ¶ added in v0.3.6
GenerateRandomStringFromAlphabet generates a random string of a given size using characters from the given alphabet.
func ListAll ¶
ListAll is a helper for retrieving all pages. The provided fn should perform an operation that retrieves a page at a time.
func ValidateName ¶ added in v0.1.8
Types ¶
type ID ¶ added in v0.3.6
type ID struct {
// contains filtered or unexported fields
}
ID uniquely identifies an OTF resource.
func ConvertID ¶ added in v0.3.6
ConvertID converts an ID for use with a different resource kind, e.g. convert run-123 to plan-123.
func MustHardcodeID ¶ added in v0.3.6
func (ID) MarshalText ¶ added in v0.3.6
func (*ID) UnmarshalText ¶ added in v0.3.6
type Kind ¶ added in v0.3.6
type Kind string
const ( OrganizationKind Kind = "org" WorkspaceKind Kind = "ws" RunKind Kind = "run" ConfigVersionKind Kind = "cv" IngressAttributesKind Kind = "ia" JobKind Kind = "job" ChunkKind Kind = "chunk" UserKind Kind = "user" TeamKind Kind = "team" ModuleKind Kind = "mod" ModuleVersionKind Kind = "modver" NotificationConfigurationKind Kind = "nc" AgentPoolKind Kind = "apool" RunnerKind Kind = "runner" StateVersionKind Kind = "sv" StateVersionOutputKind Kind = "wsout" VariableSetKind Kind = "varset" VariableKind Kind = "var" OrganizationTokenKind Kind = "ot" UserTokenKind Kind = "ut" TeamTokenKind Kind = "tt" AgentTokenKind Kind = "at" )
type Page ¶
type Page[T any] struct { Items []T *Pagination }
Page is a segment of a result set.
func NewPage ¶
NewPage constructs a page from a list of resources. If the list argument represents the full result set then count should be nil; if count is non-nil then the list is deemed to be a segment of a result set and count is the size of the full result set. This latter case is useful, say, if a database has already produced a segment of a full result set, e.g. using LIMIT and OFFSET.
type PageOptions ¶
type PageOptions struct { // The page number to request. The results vary based on the PageSize. PageNumber int `schema:"page[number],omitempty"` // The number of elements returned in a single page. PageSize int `schema:"page[size],omitempty"` }
PageOptions are used to request a specific page.