operations

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package operations hosts shared operation helpers and configuration utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDecodeConfigTargetNil indicates DecodeConfig was called with a nil target
	ErrDecodeConfigTargetNil = errors.New("operations: decode config target is nil")
	// ErrOperationTemplateRequired indicates the operation requires a stored template configuration
	ErrOperationTemplateRequired = errors.New("operations: operation template required")
	// ErrOperationTemplateOverridesNotAllowed indicates overrides are not permitted for a template
	ErrOperationTemplateOverridesNotAllowed = errors.New("operations: operation template overrides not allowed")
	// ErrOperationTemplateOverrideNotAllowed indicates a provided override key is not permitted
	ErrOperationTemplateOverrideNotAllowed = errors.New("operations: operation template override not allowed")
	// ErrUnsupportedTokenType indicates the token type is not supported
	ErrUnsupportedTokenType = errors.New("operations: unsupported token type")
)

Functions

func AddPayloadIf

func AddPayloadIf(details map[string]any, include bool, key string, payload any) map[string]any

AddPayloadIf attaches payloads to a details map when requested

func ApplyOperationTemplate

func ApplyOperationTemplate(template OperationTemplate, overrides map[string]any) (map[string]any, error)

ApplyOperationTemplate merges a template with optional overrides

func DecodeConfig

func DecodeConfig(config map[string]any, target any) error

DecodeConfig decodes a config map into a target struct, respecting defaults on the target

func EnsureIncludePayloads

func EnsureIncludePayloads(config map[string]any) map[string]any

EnsureIncludePayloads forces include_payloads to true.

func HealthCheckRunner

func HealthCheckRunner[T any](tokenType TokenType, endpoint string, failureMsg string, resultFn func(T) (string, map[string]any)) types.OperationFunc

HealthCheckRunner creates a health check operation function using the common pattern.

func HealthOperation

func HealthOperation(name types.OperationName, description string, client types.ClientName, run types.OperationFunc) types.OperationDescriptor

HealthOperation builds a standard health check descriptor.

func OperationFailure

func OperationFailure(summary string, err error) types.OperationResult

OperationFailure builds a failed operation result with an error detail

func OperationSuccess

func OperationSuccess(summary string, details map[string]any) types.OperationResult

OperationSuccess builds a successful operation result.

func ResolveOperationConfig

func ResolveOperationConfig(config *openapi.IntegrationConfig, operation string, overrides map[string]any) (map[string]any, error)

ResolveOperationConfig merges stored templates with optional overrides

func SanitizeClientDescriptors

func SanitizeClientDescriptors(provider types.ProviderType, descriptors []types.ClientDescriptor) []types.ClientDescriptor

SanitizeClientDescriptors filters out invalid client descriptors and assigns provider type

func SanitizeOperationDescriptors

func SanitizeOperationDescriptors(provider types.ProviderType, descriptors []types.OperationDescriptor) []types.OperationDescriptor

SanitizeOperationDescriptors filters and cleans a slice of OperationDescriptor

func SchemaFrom

func SchemaFrom[T any]() map[string]any

SchemaFrom reflects a JSON schema from a Go type and returns it as a map

Types

type OperationTemplate

type OperationTemplate struct {
	// Config is the base configuration for the operation
	Config map[string]any
	// AllowedOverrides contains keys that may be overridden at runtime
	AllowedOverrides map[string]struct{}
}

OperationTemplate captures a stored configuration and optional override keys

func OperationTemplateFor

func OperationTemplateFor(config *openapi.IntegrationConfig, operation string) (OperationTemplate, bool)

OperationTemplateFor loads an operation template from integration config

type Pagination

type Pagination struct {
	// PerPage sets the number of items to request per page
	PerPage int `json:"per_page"`
	// PageSize provides an alternate page size input
	PageSize int `json:"page_size"`
	// Page selects the page index to request
	Page int `json:"page"`
}

Pagination captures common paging controls

func (Pagination) EffectivePageSize

func (p Pagination) EffectivePageSize(defaultValue int) int

EffectivePageSize returns the configured page size or the provided default

type PayloadOptions

type PayloadOptions struct {
	// IncludePayloads controls whether raw payloads are returned
	IncludePayloads bool `json:"include_payloads"`
}

PayloadOptions captures optional payload controls

type RepositorySelector

type RepositorySelector struct {
	// Repositories lists repository names to include
	Repositories []types.TrimmedString `json:"repositories"`
	// Repos lists repository names using a shorter alias
	Repos []types.TrimmedString `json:"repos"`
	// Repository selects a single repository name
	Repository types.TrimmedString `json:"repository"`
	// Owner filters repositories by owner
	Owner types.TrimmedString `json:"owner"`
}

RepositorySelector captures repository selection settings

func (RepositorySelector) List

func (r RepositorySelector) List() []string

List returns a merged, de-duplicated repository list

type TokenType

type TokenType int

TokenType indicates whether to use OAuth or API token extraction

const (
	// TokenTypeOAuth extracts OAuth access tokens
	TokenTypeOAuth TokenType = iota
	// TokenTypeAPI extracts API tokens
	TokenTypeAPI
)

Jump to

Keyboard shortcuts

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