Documentation
¶
Overview ¶
Package output provides structured output formatting for gpd.
Index ¶
- type Format
- type Manager
- type Metadata
- type Result
- func (r *Result) WithDuration(d time.Duration) *Result
- func (r *Result) WithNoOp(reason string) *Result
- func (r *Result) WithPagination(pageToken, nextPageToken string) *Result
- func (r *Result) WithPartial(scanned, filtered, total int) *Result
- func (r *Result) WithRequestID(id string) *Result
- func (r *Result) WithRetries(count int) *Result
- func (r *Result) WithServices(services ...string) *Result
- func (r *Result) WithWarnings(warnings ...string) *Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format string
Format represents the output format type.
func ParseFormat ¶
ParseFormat parses a format string into a Format type.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles output formatting and writing.
type Metadata ¶
type Metadata struct {
// Core fields (always present)
NoOp bool `json:"noop"`
DurationMs int64 `json:"durationMs"`
Services []string `json:"services"`
// Optional pagination fields
RequestID string `json:"requestId,omitempty"`
PageToken string `json:"pageToken,omitempty"`
NextPageToken string `json:"nextPageToken,omitempty"`
HasMorePages *bool `json:"hasMorePages,omitempty"`
// Optional warning/info fields
Warnings []string `json:"warnings,omitempty"`
// Extended fields for specific operations
Partial bool `json:"partial,omitempty"`
ScannedCount int `json:"scannedCount,omitempty"`
FilteredCount int `json:"filteredCount,omitempty"`
TotalAvailable int `json:"totalAvailable,omitempty"`
Retries int `json:"retries,omitempty"`
DataFreshnessUTC *time.Time `json:"dataFreshnessUtc,omitempty"`
NoOpReason string `json:"noopReason,omitempty"`
}
Metadata contains response metadata.
type Result ¶
type Result struct {
Data interface{} `json:"data"`
Error *errors.APIError `json:"error"`
Meta *Metadata `json:"meta"`
ExitCode int `json:"-"` // Process state only, not in JSON
}
Result represents the standard JSON envelope structure.
func NewEmptyResult ¶
func NewEmptyResult() *Result
NewEmptyResult creates a result with no data (for operations that don't return data).
func NewErrorResult ¶
NewErrorResult creates an error result.
func NewResult ¶
func NewResult(data interface{}) *Result
NewResult creates a successful result with data.
func (*Result) WithDuration ¶
WithDuration sets the duration metadata.
func (*Result) WithPagination ¶
WithPagination sets pagination metadata.
func (*Result) WithPartial ¶
WithPartial marks the result as partial with scan metadata.
func (*Result) WithRequestID ¶
WithRequestID sets the request ID metadata.
func (*Result) WithRetries ¶
WithRetries sets the retry count metadata.
func (*Result) WithServices ¶
WithServices sets the services metadata.
func (*Result) WithWarnings ¶
WithWarnings adds warnings to the result.