googlecloudcommon_contract

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormBasePriority is the base priority for Google Cloud common forms.
	FormBasePriority = 100000
	// PriorityForQueryTimeGroup is the priority for the query time group.
	PriorityForQueryTimeGroup = FormBasePriority + 50000
	// PriorityForResourceIdentifierGroup is the priority for the resource identifier group.
	PriorityForResourceIdentifierGroup = FormBasePriority + 40000
	// PriorityForK8sResourceFilterGroup is the priority for the k8s resource filter group.
	PriorityForK8sResourceFilterGroup = FormBasePriority + 30000
)

Variables

View Source
var APICallOptionsInjectorContextKey = typedmap.NewTypedKey[*[]googlecloud.CallOptionInjectorOption]("api-call-option-injector-options")

APICallOptionsInjectorContextKey is the key to retrieve the list of googlecloud.CallOptionInjectorOption from task context. The value is injected on the task server during the initialization.

View Source
var APIClientCallOptionsInjectorTaskID = taskid.NewDefaultImplementationID[*googlecloud.CallOptionInjector](GoogleCloudCommonTaskIDPrefix + "api-client-option-injector")

APIClientCallOptionsInjectorTaskID is the task ID to inject CallOptionInjector reference.

View Source
var APIClientFactoryOptionsContextKey = typedmap.NewTypedKey[*[]googlecloud.ClientFactoryOption]("api-client-factory-options")

APIClientFactoryOptionsContextKey is the key to retrieve googlecloud.ClientFactoryOption from task context. The value is injected on the task server during the initialization.

View Source
var APIClientFactoryOptionsTaskID = taskid.NewDefaultImplementationID[[]googlecloud.ClientFactoryOption](GoogleCloudCommonTaskIDPrefix + "api-client-factory-options")

APIClientFactoryOptionsTaskID is the task ID to generate options list for the ClientFactory. This can be overridden with the selection priority label defined in the coretask package.

APIClientFactoryTaskID is the task ID to generate the ClientFactory. This factory is instantiated with the options generated from the task with APIClientFactoryOptionsTaskID.

View Source
var AutocompleteLocationTaskID taskid.TaskImplementationID[[]string] = taskid.NewDefaultImplementationID[[]string](GoogleCloudCommonTaskIDPrefix + "autocomplete-location")

AutocompleteLocationTaskID is the task ID for the location autocomplete.

View Source
var DefaultAPIClientOptionTasksPriority = 1000

DefaultAPIClientOptionTasksPriority is the selection priority of the default implementation for APIClientFactoryOptionsTaskID and APICallOptionsInjectorTask. Users can define another task for the task ID with higher priority to override the options.

View Source
var GoogleCloudCommonTaskIDPrefix = "cloud.google.com/common/"

GoogleCloudCommonTaskIDPrefix is the prefix for Google Cloud common task IDs.

InputDurationTaskID is the task ID for the duration of the log query.

InputEndTimeTaskID is the task ID for the end time of the log query.

View Source
var InputLocationsTaskID = taskid.NewDefaultImplementationID[string](GoogleCloudCommonTaskIDPrefix + "input-location")

InputLocationsTaskID is the task ID for the locations of the target resource.

View Source
var InputLoggingFilterResourceNameTaskID = taskid.NewDefaultImplementationID[*ResourceNamesInput](GoogleCloudCommonTaskIDPrefix + "input-logging-filter-resource-name")

InputLoggingFilterResourceNameTaskID is the task ID to get log query target resource names.

View Source
var InputProjectIdTaskID = taskid.NewDefaultImplementationID[string](GoogleCloudCommonTaskIDPrefix + "input-project-id")

InputProjectIdTaskID is the task ID for the Google Cloud project ID.

View Source
var InputStartTimeTaskID = taskid.NewDefaultImplementationID[time.Time](GoogleCloudCommonTaskIDPrefix + "input-start-time")

InputStartTimeTaskID is the task ID for the start time of the log query. This is computed from InputDurationTask and InputEndTimeTask.

LocationFetcherTaskID is the task ID to inject the instance of LocationFetcher.

LoggingFetcherTaskID is the task ID to inject the instance of LogFetcher.

View Source
var RequestOptionalInputResourceNameTaskLabel = typedmap.NewTypedKey[string]("request-optional-input-resource-name")

RequestOptionalInputResourceNameTaskLabel is a label assigned to a task that requests the Cloud Logging resource name optionally. The value is the query ID.

Functions

func NewLegacyCloudLoggingListLogTask

func NewLegacyCloudLoggingListLogTask(taskId taskid.TaskImplementationID[[]*log.Log], readableQueryName string, logType enum.LogType, dependencies []taskid.UntypedTaskReference, resourceNamesGenerator DefaultResourceNamesGenerator, generator QueryGeneratorFunc, sampleQuery string) coretask.Task[[]*log.Log]

NewLegacyCloudLoggingListLogTask creates a new task that lists log entries from Cloud Logging.

func NewListLogEntriesTask

func NewListLogEntriesTask(taskSetting ListLogEntriesTaskSetting) coretask.Task[[]*log.Log]

NewListLogEntriesTask creates a new task that lists log entries from Cloud Logging based on the provided settings.

Types

type DefaultResourceNamesGenerator

type DefaultResourceNamesGenerator interface {
	// GetDependentTasks returns the list of task references needed for generating resource names.
	GetDependentTasks() []taskid.UntypedTaskReference
	// GenerateResourceNames returns the list of resource names.
	GenerateResourceNames(ctx context.Context) ([]string, error)
}

DefaultResourceNamesGenerator is an interface for generating the default resource names used for querying Cloud Logging.

type GCPAccessLogFieldSet

type GCPAccessLogFieldSet struct {
	Method       string
	RequestURL   string
	RequestSize  int64
	Status       int
	ResponseSize int64
	UserAgent    string
	RemoteIP     string
	ServerIP     string
	Referer      string
	Latency      string
	Protocol     string
}

func (*GCPAccessLogFieldSet) Kind

func (g *GCPAccessLogFieldSet) Kind() string

Kind implements log.FieldSet.

type GCPAccessLogFieldSetReader

type GCPAccessLogFieldSetReader struct {
}

func (*GCPAccessLogFieldSetReader) FieldSetKind

func (g *GCPAccessLogFieldSetReader) FieldSetKind() string

FieldSetKind implements log.FieldSetReader.

func (*GCPAccessLogFieldSetReader) Read

Read implements log.FieldSetReader.

type GCPAuditLogFieldSet

type GCPAuditLogFieldSet struct {
	OperationID    string
	OperationFirst bool
	OperationLast  bool
	MethodName     string
	ResourceName   string
	PrincipalEmail string
	Status         int
	Request        *structured.NodeReader
	Response       *structured.NodeReader
}

func (*GCPAuditLogFieldSet) Ending

func (g *GCPAuditLogFieldSet) Ending() bool

Ending returns true when the operation is long running operation and the log entry is for the ending timing.

func (*GCPAuditLogFieldSet) ImmediateOperation

func (g *GCPAuditLogFieldSet) ImmediateOperation() bool

ImmediateOperation returns true when the log represents an operation completes immediately.

func (*GCPAuditLogFieldSet) Kind

func (g *GCPAuditLogFieldSet) Kind() string

Kind implements log.FieldSet.

func (*GCPAuditLogFieldSet) OperationPath

OperationPath returns the resource path for the operation.

func (*GCPAuditLogFieldSet) RequestString

func (g *GCPAuditLogFieldSet) RequestString() (string, error)

RequestString returns the request body as a YAML string.

func (*GCPAuditLogFieldSet) ResponseString

func (g *GCPAuditLogFieldSet) ResponseString() (string, error)

ResponseString returns the response body as a YAML string.

func (*GCPAuditLogFieldSet) Starting

func (g *GCPAuditLogFieldSet) Starting() bool

Starting returns true when the operation is long running operation and the log entry is for the starting timing.

type GCPOperationAuditLogFieldSetReader

type GCPOperationAuditLogFieldSetReader struct {
}

func (*GCPOperationAuditLogFieldSetReader) FieldSetKind

func (g *GCPOperationAuditLogFieldSetReader) FieldSetKind() string

FieldSetKind implements log.FieldSetReader.

func (*GCPOperationAuditLogFieldSetReader) Read

Read implements log.FieldSetReader.

type ListLogEntriesTaskDescription

type ListLogEntriesTaskDescription struct {
	DefaultLogType enum.LogType
	QueryName      string
	ExampleQuery   string
}

ListLogEntriesTaskDescription holds descriptive information for a task to list log entries from CloudLogging.

type ListLogEntriesTaskSetting

type ListLogEntriesTaskSetting interface {
	// TaskID returns the task ID for the Cloud Logging list log entries task.
	TaskID() taskid.TaskImplementationID[[]*log.Log]

	// Dependencies returns the list of dependencies for the Cloud Logging list log entries task.
	// Return the dependency task reference IDs when the result is used in DefaultResourceNames(), LogFilters() or TimePartitionCount().
	Dependencies() []taskid.UntypedTaskReference

	// DefaultResourceNames returns the list of resource names for the Cloud Logging list log entries task.
	// This is just a default value for the resource name. Users can override this value with the form field.
	// Return the list of resource names. ref: https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
	DefaultResourceNames(ctx context.Context) ([]string, error)

	// LogFilters returns the list of log filters for the Cloud Logging list log entries task.
	// When generated logging filter can exceed the 20,000 character maximum limit in Cloud Logging, return multiple subset query.
	// Result includes the logs for all log filters.
	LogFilters(ctx context.Context, taskMode inspectioncore_contract.InspectionTaskModeType) ([]string, error)

	// TimePartitionCount returns the number of time partitions for the Cloud Logging list log entries task.
	// ListLogEntriesTask split the duration into the number of partition count to gather logs in parallel.
	// Return 1 - 16 values depending on the expected log volume by the log filter.
	TimePartitionCount(ctx context.Context) (int, error)

	// Description returns the description for the Cloud Logging filter task.
	Description() *ListLogEntriesTaskDescription
}

ListLogEntriesTaskSetting defines the settings for a Cloud Logging list log entries task.

type LocationFetcher

type LocationFetcher interface {
	FetchRegions(ctx context.Context, projectId string) ([]string, error)
}

func NewLocationFetcher

func NewLocationFetcher(client *compute.RegionsClient, callOptionInjector *googlecloud.CallOptionInjector) LocationFetcher

type LogFetchProgress

type LogFetchProgress struct {
	// LogCount is the total number of logs fetched so far.
	LogCount int
	// Progress indicates the completion status, ranging from 0.0 to 1.0.
	Progress float32
}

LogFetchProgress represents the progress of a log fetching operation.

type LogFetcher

type LogFetcher interface {
	FetchLogs(dest chan<- *loggingpb.LogEntry, ctx context.Context, filter string, container googlecloud.ResourceContainer, resourceContainers []string) error
}

LogFetcher is an interface for fetching logs from Cloud Logging with a given filter and sending them to a specified channel. The implementation must close the destination channel after the query is done.

func NewLogFetcher

func NewLogFetcher(clientFactory *googlecloud.ClientFactory, callOptionInjector *googlecloud.CallOptionInjector, pageSize int32) LogFetcher

NewLogFetcher returns the instance of LogFetcher initialized with the given *googlecloud.ClientFactory.

type ProgressReportableLogFetcher

type ProgressReportableLogFetcher interface {
	// FetchLogsWithProgress fetches logs while periodically reporting its progress through a separate channel.
	// Implementations must close both the dest and progress channels upon completion.
	FetchLogsWithProgress(dest chan<- *loggingpb.LogEntry, progress chan<- LogFetchProgress, ctx context.Context, beginTime, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error
}

type ProjectIDDefaultResourceNamesGenerator

type ProjectIDDefaultResourceNamesGenerator struct{}

ProjectIDDefaultResourceNamesGenerator generates resource names from the project ID.

func (*ProjectIDDefaultResourceNamesGenerator) GenerateResourceNames

func (p *ProjectIDDefaultResourceNamesGenerator) GenerateResourceNames(ctx context.Context) ([]string, error)

GenerateResourceNames implements DefaultResourceNamesGenerator.

func (*ProjectIDDefaultResourceNamesGenerator) GetDependentTasks

GetDependentTasks implements DefaultResourceNamesGenerator.

type QueryGeneratorFunc

QueryGeneratorFunc is a function type that generates Cloud Logging queries. A query task may return multiple logging filters because a logging filter has a maximum length, and some query tasks need to split a long filter into multiple smaller ones.

type QueryResourceNames

type QueryResourceNames struct {
	QueryID              string
	DefaultResourceNames []string
	CurrentResourceNames []string
}

QueryResourceNames holds the resource names for a specific query.

func (*QueryResourceNames) GetInputID

func (q *QueryResourceNames) GetInputID() string

GetInputID returns the form input ID for the query.

type ResourceNamesInput

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

ResourceNamesInput is a container for resource names used in log queries.

func NewResourceNamesInput

func NewResourceNamesInput() *ResourceNamesInput

NewResourceNamesInput creates a new ResourceNamesInput.

func (*ResourceNamesInput) GetResourceNamesForQuery

func (r *ResourceNamesInput) GetResourceNamesForQuery(ctx context.Context, queryID string) *QueryResourceNames

GetResourceNamesForQuery returns the resource names for a given query ID.

func (*ResourceNamesInput) UpdateDefaultResourceNamesForQuery

func (r *ResourceNamesInput) UpdateDefaultResourceNamesForQuery(queryID string, defaultResourceNames []string)

UpdateDefaultResourceNamesForQuery updates the default resource names for a given query ID.

type StandardProgressReportableLogFetcher

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

StandardProgressReportableLogFetcher is a decorator for a LogFetcher that adds the ability to report the progress of log fetching.

func NewStandardProgressReportableLogFetcher

func NewStandardProgressReportableLogFetcher(fetcher LogFetcher, interval time.Duration) *StandardProgressReportableLogFetcher

NewProgressReportableLogFetcher creates a new instance of ProgressReportableLogFetcher.

func (*StandardProgressReportableLogFetcher) FetchLogsWithProgress

func (s *StandardProgressReportableLogFetcher) FetchLogsWithProgress(dest chan<- *loggingpb.LogEntry, progress chan<- LogFetchProgress, ctx context.Context, beginTime, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error

FetchLogsWithProgress implements FetchLogsWithProgress.

type TimePartitioningProgressReportableLogFetcher

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

func NewTimePartitioningProgressReportableLogFetcher

func NewTimePartitioningProgressReportableLogFetcher(fetcher LogFetcher, interval time.Duration, partitionCount int, maxParallelism int) *TimePartitioningProgressReportableLogFetcher

func (*TimePartitioningProgressReportableLogFetcher) FetchLogsWithProgress

func (t *TimePartitioningProgressReportableLogFetcher) FetchLogsWithProgress(logChan chan<- *loggingpb.LogEntry, progressChan chan<- LogFetchProgress, ctx context.Context, beginTime time.Time, endTime time.Time, filterWithoutTimeRange string, container googlecloud.ResourceContainer, resourceContainers []string) error

FetchLogsWithProgress implements ProgressReportableLogFetcher.

Jump to

Keyboard shortcuts

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