asset

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeeplinkURL added in v1.2.0

func DeeplinkURL(apiUrl, assetType, assetID string) string

DeeplinkURL constructs a deeplink URL for the given asset type and ID. The base URL is derived from the API URL by extracting the domain suffix (e.g. "dash0.com" from "api.us-west-2.aws.dash0.com") and prepending "app.". Returns an empty string if the API URL is empty or cannot be parsed.

func KindDisplayName added in v1.1.0

func KindDisplayName(kind string) string

KindDisplayName returns the human-readable name for an asset kind. Multi-word kinds like "CheckRule" become "Check rule" and "SyntheticCheck" becomes "Synthetic check".

func LogsExplorerURL added in v1.5.4

func LogsExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string

LogsExplorerURL builds a deep link URL to the Dash0 logs explorer. The URL includes filter criteria, time range, and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.

func PrintDiff added in v1.7.0

func PrintDiff(w io.Writer, displayKind, name string, before, after any) error

PrintDiff computes a unified diff between the before and after states of an asset and writes it to w. If there are no changes, a "no changes" message is printed instead.

func ReadDefinition

func ReadDefinition(path string, target interface{}, stdin io.Reader) error

ReadDefinition reads a YAML or JSON definition from a file or stdin. If path is "-" or empty, it reads from stdin (assumes YAML format). Otherwise, it reads from the file at the given path.

func ReadDefinitionFile

func ReadDefinitionFile(path string, target interface{}) error

ReadDefinitionFile reads a YAML or JSON file and unmarshals into the target. It auto-detects the format based on file extension, falling back to YAML first.

func ReadRawInput added in v1.1.0

func ReadRawInput(path string, stdin io.Reader) ([]byte, error)

ReadRawInput reads raw bytes from a file or stdin without unmarshalling. If path is "-" or empty, it reads from stdin.

func RegisterCommonFlags

func RegisterCommonFlags(cmd *cobra.Command, flags *CommonFlags)

RegisterCommonFlags adds common flags to a command

func RegisterDeleteFlags

func RegisterDeleteFlags(cmd *cobra.Command, flags *DeleteFlags)

RegisterDeleteFlags adds delete-specific flags to a command

func RegisterFileInputFlags

func RegisterFileInputFlags(cmd *cobra.Command, flags *FileInputFlags)

RegisterFileInputFlags adds file input flags to a command and marks -f as required

func RegisterGetFlags

func RegisterGetFlags(cmd *cobra.Command, flags *GetFlags)

RegisterGetFlags adds get-specific flags to a command

func RegisterListFlags

func RegisterListFlags(cmd *cobra.Command, flags *ListFlags)

RegisterListFlags adds list-specific flags to a command

func SpansExplorerURL added in v1.5.4

func SpansExplorerURL(apiUrl string, filters []DeeplinkFilter, from, to string, dataset *string) string

SpansExplorerURL builds a deep link URL to the Dash0 traces explorer. The URL includes optional filter criteria, time range, and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.

func TracesExplorerURL added in v1.5.4

func TracesExplorerURL(apiUrl, traceID string, dataset *string) string

TracesExplorerURL builds a deep link URL to the Dash0 traces explorer for a specific trace. The URL includes the trace ID and optional dataset as query parameters. Returns an empty string if the API URL is empty or cannot be parsed.

func ViewDeeplinkURL added in v1.5.1

func ViewDeeplinkURL(apiUrl, viewType, assetID string) string

ViewDeeplinkURL constructs a deeplink URL for a view, using the view's type to determine the correct path (e.g. /goto/spans for span views, /goto/logs for log views). Returns an empty string if the API URL is empty, cannot be parsed, or the view type is unknown.

func WriteDefinitionFile

func WriteDefinitionFile(path string, data interface{}) error

WriteDefinitionFile writes data to a YAML or JSON file. It auto-detects the format based on file extension, defaulting to YAML.

func WriteToStdout

func WriteToStdout(format string, data interface{}) error

WriteToStdout writes data to stdout in the specified format. Format can be "yaml", "yml", or "json".

Types

type CommonFlags

type CommonFlags struct {
	ApiUrl    string
	AuthToken string
	Dataset   string
	Output    string
}

CommonFlags holds common flag values used across all asset commands

type DeeplinkFilter added in v1.5.4

type DeeplinkFilter struct {
	Key      string `json:"key"`
	Operator string `json:"operator"`
	Value    string `json:"value,omitempty"`
}

DeeplinkFilter represents a single filter criterion for explorer deep links.

func FiltersToDeeplinkFilters added in v1.5.4

func FiltersToDeeplinkFilters(filters *dash0api.FilterCriteria) []DeeplinkFilter

FiltersToDeeplinkFilters converts parsed API filter criteria to deep link filter objects suitable for URL serialization.

type DeleteFlags

type DeleteFlags struct {
	CommonFlags
	Force bool
}

DeleteFlags holds flags specific to delete commands

type FileInputFlags

type FileInputFlags struct {
	CommonFlags
	File   string
	DryRun bool
}

FileInputFlags holds flags for file-based input operations (create, update, apply)

type GetFlags

type GetFlags struct {
	CommonFlags
}

GetFlags holds flags specific to get commands

type ImportAction added in v1.1.0

type ImportAction string

ImportAction indicates whether an asset was created or updated.

const (
	ActionCreated ImportAction = "created"
	ActionUpdated ImportAction = "updated"
)

type ImportResult added in v1.1.0

type ImportResult struct {
	Name   string
	ID     string
	Action ImportAction
	Before any // asset state before update (nil for creates)
	After  any // asset state after update/create
}

ImportResult holds the outcome of importing an asset.

func ImportCheckRule added in v1.1.0

func ImportCheckRule(ctx context.Context, apiClient dash0api.Client, rule *dash0api.PrometheusAlertRule, dataset *string) (ImportResult, error)

ImportCheckRule creates or updates a check rule via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the rule already exists. When the input has no ID, CREATE is used and the server assigns an ID.

func ImportDashboard added in v1.1.0

func ImportDashboard(ctx context.Context, apiClient dash0api.Client, dashboard *dash0api.DashboardDefinition, dataset *string) (ImportResult, error)

ImportDashboard creates or updates a dashboard via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the dashboard already exists. When the input has no ID, CREATE is used and the server assigns an ID.

func ImportNotificationChannel added in v1.9.0

func ImportNotificationChannel(ctx context.Context, apiClient dash0api.Client, channel *dash0api.NotificationChannelDefinition) (ImportResult, error)

ImportNotificationChannel creates or updates a notification channel via the standard CRUD APIs. When the input has a user-defined ID (via dash0.com/origin label), UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the channel already exists. When the input has no origin, CREATE is used and the server assigns an ID.

func ImportSyntheticCheck added in v1.1.0

func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, check *dash0api.SyntheticCheckDefinition, dataset *string) (ImportResult, error)

ImportSyntheticCheck creates or updates a synthetic check via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the check already exists. When the input has no ID, CREATE is used and the server assigns an ID.

func ImportView added in v1.1.0

func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, dataset *string) (ImportResult, error)

ImportView creates or updates a view via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the view already exists. When the input has no ID, CREATE is used and the server assigns an ID.

type ListFlags

type ListFlags struct {
	CommonFlags
	Limit      int
	All        bool
	SkipHeader bool
}

ListFlags holds flags specific to list commands

Jump to

Keyboard shortcuts

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