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: 5 Imported by: 1 module, 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 = errors.New("segment not found")

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

Functions

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"`
	Name              string     `json:"name"`
	Description       string     `json:"description,omitempty"`
	IsPublic          bool       `json:"isPublic"`
	Owner             string     `json:"owner,omitempty"`
	Version           int        `json:"version,omitempty"`
	IsReadyMade       bool       `json:"isReadyMade,omitempty"`
	Includes          []Include  `json:"includes,omitempty"`
	Variables         *Variables `json:"variables,omitempty"`
	AllowedOperations []string   `json:"allowedOperations,omitempty"`
}

FilterSegment is the read model for a Grail filter segment.

type FilterSegmentList

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

FilterSegmentList represents a list of filter segments.

type Handler

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

Handler handles Grail filter segment resources.

func NewHandler

func NewHandler(c *httpclient.Client) *Handler

NewHandler creates a new segment handler.

func (*Handler) Create

func (h *Handler) Create(ctx context.Context, data []byte) (*FilterSegment, error)

Create creates a new filter segment. The data should be JSON with the segment definition in the format the API expects (filter fields as JSON AST strings).

func (*Handler) Delete

func (h *Handler) Delete(ctx context.Context, uid string) error

Delete deletes a filter segment by UID.

func (*Handler) Get

func (h *Handler) Get(ctx context.Context, uid string, addFields ...string) (*FilterSegment, error)

Get gets a specific filter segment by UID. Use addFields to request optional fields (e.g., "INCLUDES", "VARIABLES").

func (*Handler) List

func (h *Handler) List(ctx context.Context, addFields ...string) (*FilterSegmentList, error)

List lists all filter segments. Use addFields to request optional fields (e.g., "VARIABLES", "INCLUDES").

func (*Handler) Update

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

Update updates an existing filter segment. The version parameter is required for optimistic locking. The data should be JSON in the format the API expects.

type Include

type Include struct {
	DataObject string `json:"dataObject"`
	Filter     string `json:"filter"`
}

Include represents a single include rule within a segment.

type Variables

type Variables struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

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