segment

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = sdksegment.ErrNotFound

ErrNotFound is returned when a segment is not found (HTTP 404).

Functions

func FilterFromAST

func FilterFromAST(ast string) (string, error)

FilterFromAST converts a JSON AST string back to a DQL filter expression. If the input is not a JSON AST (doesn't start with '{'), it is returned as-is.

func FilterToAST

func FilterToAST(dql string) (string, error)

FilterToAST converts a DQL filter expression to a JSON AST string. If the input is already a JSON AST (starts with '{'), it is returned as-is.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error indicates a segment was not found (404).

Types

type FilterSegment

type FilterSegment struct {
	UID               string     `json:"uid" table:"UID"`
	Name              string     `json:"name" table:"NAME"`
	Description       string     `json:"description,omitempty" table:"DESCRIPTION,wide"`
	IsPublic          bool       `json:"isPublic" table:"PUBLIC"`
	VariablesDisplay  string     `json:"-" yaml:"-" table:"VARIABLES,wide"`
	Owner             string     `json:"owner,omitempty" table:"OWNER,wide"`
	Version           int        `json:"version,omitempty" table:"-"`
	IsReadyMade       bool       `json:"isReadyMade,omitempty" table:"-"`
	Includes          []Include  `json:"includes,omitempty" table:"-"`
	Variables         *Variables `json:"variables,omitempty" table:"-"`
	AllowedOperations []string   `json:"allowedOperations,omitempty" table:"-"`
}

FilterSegment is the read model for a Grail filter segment. It extends the SDK type with VariablesDisplay for CLI table output.

type FilterSegmentList

type FilterSegmentList struct {
	FilterSegments []FilterSegment `json:"filterSegments"`
	TotalCount     int             `json:"totalCount,omitempty"`
}

FilterSegmentList represents a list of filter segments. The filter-segments API does not support pagination; all segments are returned in a single response.

type Handler

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

Handler handles Grail filter segment resources. It delegates HTTP calls to the SDK handler and wraps them with DQL↔AST conversion.

func NewHandler

func NewHandler(c *client.Client) *Handler

NewHandler creates a new segment handler.

func (*Handler) Create

func (h *Handler) Create(data []byte) (*FilterSegment, error)

Create creates a new filter segment from raw JSON/YAML bytes.

func (*Handler) Delete

func (h *Handler) Delete(uid string) error

Delete deletes a filter segment by UID.

func (*Handler) Get

func (h *Handler) Get(uid string) (*FilterSegment, error)

Get gets a specific filter segment by UID.

func (*Handler) GetRaw

func (h *Handler) GetRaw(uid string) ([]byte, error)

GetRaw gets a segment as pretty-printed JSON bytes (for edit command). Note: the returned JSON contains DQL filter expressions (not raw API AST) because it delegates to Get, which converts AST filters to DQL.

func (*Handler) List

func (h *Handler) List() (*FilterSegmentList, error)

List lists all filter segments. Variables are requested so the wide table view can show whether each segment requires variable bindings.

func (*Handler) Update

func (h *Handler) Update(uid string, version int, data []byte) error

Update updates an existing filter segment. The version parameter is required for optimistic locking.

type Include

type Include = sdksegment.Include

Include represents a single include rule within a segment.

type Variables

type Variables = sdksegment.Variables

Variables holds the variable configuration for a segment.

Jump to

Keyboard shortcuts

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