Documentation
¶
Overview ¶
Package types defines common API response types, error codes, and generic range types used across the platform.
Index ¶
- type APIError
- type APIResponse
- type ErrorCode
- type Float32RangeWithOptionalMax
- type Float32RangeWithOptionalMaxUpdateRequestInput
- type NamedID
- type OptionalFloat32Range
- type OptionalRange
- type OptionalRangeUpdateRequestInput
- type OptionalUint32Range
- type RangeWithOptionalUpperBound
- type ResponseDetails
- type Uint16RangeWithOptionalMax
- type Uint16RangeWithOptionalMaxUpdateRequestInput
- type Uint32RangeWithOptionalMax
- type Uint32RangeWithOptionalMaxUpdateRequestInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Message string `json:"message"`
Code ErrorCode `json:"code"`
// contains filtered or unexported fields
}
APIError represents a response we might send to the User in the event of an error.
type APIResponse ¶
type APIResponse[T any] struct { Data T `json:"data,omitempty"` Pagination *filtering.Pagination `json:"pagination,omitempty"` Error *APIError `json:"error,omitempty"` Details ResponseDetails `json:"details"` // contains filtered or unexported fields }
APIResponse represents a response we might send to the user.
func NewAPIErrorResponse ¶
func NewAPIErrorResponse(issue string, code ErrorCode, details ResponseDetails) *APIResponse[any]
NewAPIErrorResponse returns a new APIResponse with an error field.
type ErrorCode ¶
type ErrorCode string
ErrorCode is a string code identifying specific error conditions in API responses.
const ( // ErrNothingSpecific is a catch-all error code for when we just need one. ErrNothingSpecific ErrorCode = "E100" // ErrFetchingSessionContextData is returned when we fail to fetch session context data. ErrFetchingSessionContextData ErrorCode = "E101" // ErrDecodingRequestInput is returned when we fail to decode request input. ErrDecodingRequestInput ErrorCode = "E102" // ErrValidatingRequestInput is returned when the user provides invalid input. ErrValidatingRequestInput ErrorCode = "E103" // ErrDataNotFound is returned when we fail to find data in the database. ErrDataNotFound ErrorCode = "E104" // ErrTalkingToDatabase is returned when we fail to interact with a database. ErrTalkingToDatabase ErrorCode = "E105" // ErrMisbehavingDependency is returned when we fail to interact with a third party. ErrMisbehavingDependency ErrorCode = "E106" // ErrTalkingToSearchProvider is returned when we fail to interact with the search provider. ErrTalkingToSearchProvider ErrorCode = "E107" // ErrSecretGeneration is returned when a user is not authorized. ErrSecretGeneration ErrorCode = "E108" // ErrUserIsBanned is returned when a user is banned. ErrUserIsBanned ErrorCode = "E109" // ErrUserIsNotAuthorized is returned when a user is not authorized. ErrUserIsNotAuthorized ErrorCode = "E110" // ErrEncryptionIssue is returned when encryption fails in the service. ErrEncryptionIssue ErrorCode = "E111" // ErrCircuitBroken is returned when a service is circuit broken. ErrCircuitBroken ErrorCode = "E112" )
type Float32RangeWithOptionalMax ¶
type Float32RangeWithOptionalMax RangeWithOptionalUpperBound[float32]
Float32RangeWithOptionalMax should be replaced with a generic Range type.
func (*Float32RangeWithOptionalMax) ValidateWithContext ¶
type Float32RangeWithOptionalMaxUpdateRequestInput ¶
type Float32RangeWithOptionalMaxUpdateRequestInput OptionalRangeUpdateRequestInput[float32]
Float32RangeWithOptionalMaxUpdateRequestInput should be replaced with a generic Range type.
type NamedID ¶
type NamedID struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
// contains filtered or unexported fields
}
NamedID pairs an identifier with a human-readable name.
type OptionalFloat32Range ¶
type OptionalFloat32Range OptionalRange[float32]
OptionalFloat32Range should be replaced with a generic Range type.
type OptionalRange ¶
type OptionalRange[T comparable] struct { Min *T `json:"min,omitempty"` Max *T `json:"max,omitempty"` }
OptionalRange represents a range where both minimum and maximum are optional.
type OptionalRangeUpdateRequestInput ¶
type OptionalRangeUpdateRequestInput[T comparable] struct { Min *T `json:"min,omitempty"` Max *T `json:"max,omitempty"` }
OptionalRangeUpdateRequestInput represents an update request for an optional range.
type OptionalUint32Range ¶
type OptionalUint32Range OptionalRange[uint32]
OptionalUint32Range should be replaced with a generic Range type.
type RangeWithOptionalUpperBound ¶
type RangeWithOptionalUpperBound[T comparable] struct { Min T `json:"min"` Max *T `json:"max,omitempty"` }
RangeWithOptionalUpperBound represents a range with a required minimum and optional maximum.
func (*RangeWithOptionalUpperBound[T]) ValidateWithContext ¶
type ResponseDetails ¶
type ResponseDetails struct {
CurrentAccountID string `json:"currentAccountID"`
TraceID string `json:"traceID"`
// contains filtered or unexported fields
}
ResponseDetails represents details about the response.
type Uint16RangeWithOptionalMax ¶
type Uint16RangeWithOptionalMax RangeWithOptionalUpperBound[uint16]
Uint16RangeWithOptionalMax should be replaced with a generic Range type.
func (*Uint16RangeWithOptionalMax) ValidateWithContext ¶
type Uint16RangeWithOptionalMaxUpdateRequestInput ¶
type Uint16RangeWithOptionalMaxUpdateRequestInput OptionalRangeUpdateRequestInput[uint16]
Uint16RangeWithOptionalMaxUpdateRequestInput should be replaced with a generic Range type.
type Uint32RangeWithOptionalMax ¶
type Uint32RangeWithOptionalMax RangeWithOptionalUpperBound[uint32]
Uint32RangeWithOptionalMax should be replaced with a generic Range type.
func (*Uint32RangeWithOptionalMax) ValidateWithContext ¶
type Uint32RangeWithOptionalMaxUpdateRequestInput ¶
type Uint32RangeWithOptionalMaxUpdateRequestInput OptionalRangeUpdateRequestInput[uint32]
Uint32RangeWithOptionalMaxUpdateRequestInput should be replaced with a generic Range type.