client

package
v0.0.0-...-b6bfac1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package client provides a Go client for the Prefect Server API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminService

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

AdminService handles administrative operations.

func (*AdminService) Health

func (a *AdminService) Health(ctx context.Context) error

Health checks the health of the Prefect server.

func (*AdminService) Version

func (a *AdminService) Version(ctx context.Context) (string, error)

Version retrieves the server version.

type ArtifactsService

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

ArtifactsService handles operations related to artifacts.

func (*ArtifactsService) Count

func (s *ArtifactsService) Count(ctx context.Context, filter *models.ArtifactFilter) (int, error)

Count returns the number of artifacts matching the filter.

func (*ArtifactsService) CountLatest

func (s *ArtifactsService) CountLatest(ctx context.Context, filter *models.ArtifactCollectionFilter) (int, error)

CountLatest returns the number of latest artifact collections matching the filter.

func (*ArtifactsService) Create

Create creates a new artifact.

func (*ArtifactsService) Delete

func (s *ArtifactsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes an artifact by ID.

func (*ArtifactsService) Get

Get retrieves an artifact by ID.

func (*ArtifactsService) GetLatest

func (s *ArtifactsService) GetLatest(ctx context.Context, key string) (*models.Artifact, error)

GetLatest retrieves the latest artifact for a given key.

func (*ArtifactsService) List

List retrieves a list of artifacts with optional filtering.

func (*ArtifactsService) ListAll

ListAll returns an iterator for all artifacts matching the filter.

func (*ArtifactsService) ListLatest

ListLatest retrieves the latest artifact collections with optional filtering.

func (*ArtifactsService) Update

Update updates an artifact.

type AutomationsService

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

AutomationsService handles operations related to automations.

func (*AutomationsService) Count

Count returns the number of automations matching the filter.

func (*AutomationsService) Create

Create creates a new automation.

func (*AutomationsService) Delete

func (s *AutomationsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes an automation by ID.

func (*AutomationsService) DeleteOwnedBy

func (s *AutomationsService) DeleteOwnedBy(ctx context.Context, resourceID string) error

DeleteOwnedBy deletes automations owned by a specific resource.

func (*AutomationsService) Get

Get retrieves an automation by ID.

func (*AutomationsService) GetRelatedTo

func (s *AutomationsService) GetRelatedTo(ctx context.Context, resourceID string) ([]models.Automation, error)

GetRelatedTo retrieves automations related to a specific resource.

func (*AutomationsService) List

List retrieves automations with optional filtering.

func (*AutomationsService) Patch

Patch partially updates an automation.

func (*AutomationsService) Update

Update fully replaces an automation.

func (*AutomationsService) ValidateTemplate

func (s *AutomationsService) ValidateTemplate(ctx context.Context, template string) error

ValidateTemplate validates an automation template.

type BlockCapabilitiesService

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

BlockCapabilitiesService handles operations related to block capabilities.

func (*BlockCapabilitiesService) List

List retrieves all available block capabilities.

type BlockDocumentsService

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

BlockDocumentsService handles operations related to block documents.

func (*BlockDocumentsService) Count

Count returns the number of block documents matching the filter.

func (*BlockDocumentsService) Create

Create creates a new block document.

func (*BlockDocumentsService) Delete

func (s *BlockDocumentsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a block document by ID.

func (*BlockDocumentsService) Get

func (s *BlockDocumentsService) Get(ctx context.Context, id uuid.UUID, includeSecrets bool) (*models.BlockDocument, error)

Get retrieves a block document by ID.

func (*BlockDocumentsService) List

func (s *BlockDocumentsService) List(ctx context.Context, filter *models.BlockDocumentFilter, includeSecrets bool, sort models.BlockDocumentSort, offset, limit int) ([]models.BlockDocument, error)

List retrieves block documents with optional filtering.

func (*BlockDocumentsService) Update

Update updates a block document's data.

type BlockSchemasService

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

BlockSchemasService handles operations related to block schemas.

func (*BlockSchemasService) Create

Create creates a new block schema.

func (*BlockSchemasService) Delete

func (s *BlockSchemasService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a block schema by ID.

func (*BlockSchemasService) Get

Get retrieves a block schema by ID.

func (*BlockSchemasService) GetByChecksum

func (s *BlockSchemasService) GetByChecksum(ctx context.Context, checksum string, version string) (*models.BlockSchema, error)

GetByChecksum retrieves a block schema by checksum and optional version.

func (*BlockSchemasService) List

func (s *BlockSchemasService) List(ctx context.Context, filter *models.BlockSchemaFilter, offset, limit int) ([]models.BlockSchema, error)

List retrieves block schemas with optional filtering.

type BlockTypesService

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

BlockTypesService handles operations related to block types.

func (*BlockTypesService) Create

Create creates a new block type.

func (*BlockTypesService) Delete

func (s *BlockTypesService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a block type by ID.

func (*BlockTypesService) Get

Get retrieves a block type by ID.

func (*BlockTypesService) GetBlockDocumentByName

func (s *BlockTypesService) GetBlockDocumentByName(ctx context.Context, slug, name string, includeSecrets bool) (*models.BlockDocument, error)

GetBlockDocumentByName retrieves a block document by name for a given block type slug.

func (*BlockTypesService) GetBySlug

func (s *BlockTypesService) GetBySlug(ctx context.Context, slug string) (*models.BlockType, error)

GetBySlug retrieves a block type by slug.

func (*BlockTypesService) InstallSystemBlockTypes

func (s *BlockTypesService) InstallSystemBlockTypes(ctx context.Context) error

InstallSystemBlockTypes installs the system block types.

func (*BlockTypesService) List

func (s *BlockTypesService) List(ctx context.Context, filter *models.BlockTypeFilter, offset, limit int) ([]models.BlockType, error)

List retrieves block types with optional filtering.

func (*BlockTypesService) ListBlockDocumentsBySlug

func (s *BlockTypesService) ListBlockDocumentsBySlug(ctx context.Context, slug string, includeSecrets bool) ([]models.BlockDocument, error)

ListBlockDocumentsBySlug retrieves all block documents for a block type identified by slug.

func (*BlockTypesService) Update

Update updates a block type.

type Client

type Client struct {

	// Services
	Flows               *FlowsService
	FlowRuns            *FlowRunsService
	Deployments         *DeploymentsService
	TaskRuns            *TaskRunsService
	WorkPools           *WorkPoolsService
	WorkQueues          *WorkQueuesService
	Variables           *VariablesService
	Logs                *LogsService
	Admin               *AdminService
	BlockTypes          *BlockTypesService
	BlockSchemas        *BlockSchemasService
	BlockDocuments      *BlockDocumentsService
	BlockCapabilities   *BlockCapabilitiesService
	Artifacts           *ArtifactsService
	Automations         *AutomationsService
	Events              *EventsService
	SavedSearches       *SavedSearchesService
	ConcurrencyLimits   *ConcurrencyLimitsService
	ConcurrencyLimitsV2 *ConcurrencyLimitsV2Service
	TaskWorkers         *TaskWorkersService
	FlowRunStates       *FlowRunStatesService
	TaskRunStates       *TaskRunStatesService
	// contains filtered or unexported fields
}

Client is the main client for interacting with the Prefect API.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new Prefect API client with the given options.

type ConcurrencyLimitsService

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

ConcurrencyLimitsService handles operations related to v1 concurrency limits.

func (*ConcurrencyLimitsService) Create

Create creates a new concurrency limit.

func (*ConcurrencyLimitsService) Decrement

func (s *ConcurrencyLimitsService) Decrement(ctx context.Context, names []string, slots int) error

Decrement decrements concurrency limit slots.

func (*ConcurrencyLimitsService) Delete

Delete deletes a concurrency limit by ID.

func (*ConcurrencyLimitsService) DeleteByTag

func (s *ConcurrencyLimitsService) DeleteByTag(ctx context.Context, tag string) error

DeleteByTag deletes a concurrency limit by tag.

func (*ConcurrencyLimitsService) Get

Get retrieves a concurrency limit by ID.

func (*ConcurrencyLimitsService) GetByTag

GetByTag retrieves a concurrency limit by tag.

func (*ConcurrencyLimitsService) Increment

Increment increments concurrency limit slots.

func (*ConcurrencyLimitsService) List

List retrieves concurrency limits with optional filtering.

func (*ConcurrencyLimitsService) ResetByTag

func (s *ConcurrencyLimitsService) ResetByTag(ctx context.Context, tag string) error

ResetByTag resets a concurrency limit by tag.

type ConcurrencyLimitsV2Service

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

ConcurrencyLimitsV2Service handles operations related to v2 concurrency limits.

func (*ConcurrencyLimitsV2Service) Create

Create creates a new v2 concurrency limit.

func (*ConcurrencyLimitsV2Service) Decrement

func (s *ConcurrencyLimitsV2Service) Decrement(ctx context.Context, names []string, slots int) error

Decrement decrements active slots for v2 concurrency limits.

func (*ConcurrencyLimitsV2Service) DecrementWithLease

func (s *ConcurrencyLimitsV2Service) DecrementWithLease(ctx context.Context, names []string, slots int, leaseID uuid.UUID) error

DecrementWithLease decrements active slots using a lease ID.

func (*ConcurrencyLimitsV2Service) Delete

func (s *ConcurrencyLimitsV2Service) Delete(ctx context.Context, idOrName string) error

Delete deletes a v2 concurrency limit by ID or name.

func (*ConcurrencyLimitsV2Service) Get

Get retrieves a v2 concurrency limit by ID or name.

func (*ConcurrencyLimitsV2Service) Increment

func (s *ConcurrencyLimitsV2Service) Increment(ctx context.Context, names []string, slots int, mode string) error

Increment increments active slots for v2 concurrency limits.

func (*ConcurrencyLimitsV2Service) IncrementWithLease

func (s *ConcurrencyLimitsV2Service) IncrementWithLease(ctx context.Context, names []string, slots int, mode string) (*models.ConcurrencyLimitWithLeaseResponse, error)

IncrementWithLease increments active slots and returns a lease.

func (*ConcurrencyLimitsV2Service) List

List retrieves all v2 concurrency limits.

func (*ConcurrencyLimitsV2Service) RenewLease

func (s *ConcurrencyLimitsV2Service) RenewLease(ctx context.Context, leaseID uuid.UUID) error

RenewLease renews a concurrency lease.

func (*ConcurrencyLimitsV2Service) Update

Update updates a v2 concurrency limit.

type DeploymentsService

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

DeploymentsService handles operations related to deployments.

func (*DeploymentsService) Count

Count returns the number of deployments matching the filter.

func (*DeploymentsService) Create

Create creates a new deployment.

func (*DeploymentsService) CreateFlowRun

func (s *DeploymentsService) CreateFlowRun(ctx context.Context, id uuid.UUID, params map[string]interface{}) (*models.FlowRun, error)

CreateFlowRun creates a flow run from a deployment.

func (*DeploymentsService) CreateSchedules

CreateSchedules creates schedules for a deployment.

func (*DeploymentsService) Delete

func (s *DeploymentsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a deployment by ID.

func (*DeploymentsService) DeleteSchedule

func (s *DeploymentsService) DeleteSchedule(ctx context.Context, deploymentID, scheduleID uuid.UUID) error

DeleteSchedule deletes a specific schedule from a deployment.

func (*DeploymentsService) Get

Get retrieves a deployment by ID.

func (*DeploymentsService) GetByName

func (s *DeploymentsService) GetByName(ctx context.Context, flowName, deploymentName string) (*models.Deployment, error)

GetByName retrieves a deployment by flow name and deployment name.

func (*DeploymentsService) GetSchedules

func (s *DeploymentsService) GetSchedules(ctx context.Context, id uuid.UUID) ([]models.DeploymentSchedule, error)

GetSchedules retrieves all schedules for a deployment.

func (*DeploymentsService) List

List retrieves a list of deployments with optional filtering.

func (*DeploymentsService) ListAll

ListAll returns an iterator for all deployments matching the filter.

func (*DeploymentsService) Pause

func (s *DeploymentsService) Pause(ctx context.Context, id uuid.UUID) error

Pause pauses a deployment's schedule.

func (*DeploymentsService) Resume

func (s *DeploymentsService) Resume(ctx context.Context, id uuid.UUID) error

Resume resumes a deployment's schedule.

func (*DeploymentsService) Update

Update updates a deployment.

func (*DeploymentsService) UpdateSchedule

func (s *DeploymentsService) UpdateSchedule(ctx context.Context, deploymentID, scheduleID uuid.UUID, req *models.DeploymentScheduleUpdate) error

UpdateSchedule updates a specific schedule for a deployment.

type EventsService

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

EventsService handles operations related to events.

func (*EventsService) CountBy

func (s *EventsService) CountBy(ctx context.Context, countable string, filter *models.EventFilter) ([]models.EventCount, error)

CountBy counts events grouped by a countable field.

func (*EventsService) Create

func (s *EventsService) Create(ctx context.Context, events []models.Event) error

Create creates new events.

func (*EventsService) List

List retrieves events with filtering.

func (*EventsService) NextPage

func (s *EventsService) NextPage(ctx context.Context) (*models.EventPage, error)

NextPage retrieves the next page of events using a page token.

type FlowRunStatesService

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

FlowRunStatesService handles operations related to flow run states.

func (*FlowRunStatesService) Get

Get retrieves a flow run state by ID.

func (*FlowRunStatesService) List

List retrieves all flow run states.

type FlowRunsService

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

FlowRunsService handles operations related to flow runs.

func (*FlowRunsService) Count

func (s *FlowRunsService) Count(ctx context.Context, filter *models.FlowRunFilter) (int, error)

Count returns the number of flow runs matching the filter.

func (*FlowRunsService) Create

Create creates a new flow run.

func (*FlowRunsService) Delete

func (s *FlowRunsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a flow run by ID.

func (*FlowRunsService) Get

Get retrieves a flow run by ID.

func (*FlowRunsService) List

List retrieves a list of flow runs with optional filtering.

func (*FlowRunsService) ListAll

ListAll returns an iterator for all flow runs matching the filter.

func (*FlowRunsService) SetState

func (s *FlowRunsService) SetState(ctx context.Context, id uuid.UUID, state *models.StateCreate) (*models.FlowRun, error)

SetState sets the state of a flow run.

func (*FlowRunsService) Update

Update updates a flow run.

func (*FlowRunsService) Wait

func (s *FlowRunsService) Wait(ctx context.Context, id uuid.UUID, pollInterval time.Duration) (*models.FlowRun, error)

Wait waits for a flow run to complete by polling its state. It returns the final flow run state or an error if the context is cancelled.

type FlowsService

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

FlowsService handles operations related to flows.

func (*FlowsService) Count

func (s *FlowsService) Count(ctx context.Context, filter *models.FlowFilter) (int, error)

Count returns the number of flows matching the filter.

func (*FlowsService) Create

func (s *FlowsService) Create(ctx context.Context, req *models.FlowCreate) (*models.Flow, error)

Create creates a new flow.

func (*FlowsService) Delete

func (s *FlowsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a flow by ID.

func (*FlowsService) Get

func (s *FlowsService) Get(ctx context.Context, id uuid.UUID) (*models.Flow, error)

Get retrieves a flow by ID.

func (*FlowsService) GetByName

func (s *FlowsService) GetByName(ctx context.Context, name string) (*models.Flow, error)

GetByName retrieves a flow by name.

func (*FlowsService) List

func (s *FlowsService) List(ctx context.Context, filter *models.FlowFilter, offset, limit int) (*pagination.PaginatedResponse[models.Flow], error)

List retrieves a list of flows with optional filtering.

func (*FlowsService) ListAll

ListAll returns an iterator for all flows matching the filter.

func (*FlowsService) Update

func (s *FlowsService) Update(ctx context.Context, id uuid.UUID, req *models.FlowUpdate) (*models.Flow, error)

Update updates a flow.

type LogsService

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

LogsService handles operations related to logs.

func (*LogsService) Create

func (l *LogsService) Create(ctx context.Context, logs []*models.LogCreate) error

Create creates new log entries.

func (*LogsService) List

func (l *LogsService) List(ctx context.Context, filter interface{}, offset, limit int) (*pagination.PaginatedResponse[models.Log], error)

List retrieves logs with filtering.

type Option

type Option func(*Client) error

Option is a functional option for configuring the client.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key for authentication with Prefect Cloud.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets the base URL for the Prefect API.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithRetry

func WithRetry(config retry.Config) Option

WithRetry sets the retry configuration.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the HTTP client timeout.

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent sets a custom user agent string.

type SavedSearchesService

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

SavedSearchesService handles operations related to saved searches.

func (*SavedSearchesService) Create

Create creates a new saved search.

func (*SavedSearchesService) Delete

func (s *SavedSearchesService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a saved search by ID.

func (*SavedSearchesService) Get

Get retrieves a saved search by ID.

func (*SavedSearchesService) List

List retrieves all saved searches.

type TaskRunStatesService

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

TaskRunStatesService handles operations related to task run states.

func (*TaskRunStatesService) Get

Get retrieves a task run state by ID.

func (*TaskRunStatesService) List

List retrieves all task run states.

type TaskRunsService

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

TaskRunsService handles operations related to task runs.

func (*TaskRunsService) Count

func (t *TaskRunsService) Count(ctx context.Context, filter *models.TaskRunFilter) (int, error)

Count returns the number of task runs matching the filter.

func (*TaskRunsService) Create

Create creates a new task run.

func (*TaskRunsService) Delete

func (t *TaskRunsService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a task run by ID.

func (*TaskRunsService) Get

Get retrieves a task run by ID.

func (*TaskRunsService) List

List retrieves a list of task runs with optional filtering.

func (*TaskRunsService) ListAll

ListAll returns an iterator for all task runs matching the filter.

func (*TaskRunsService) SetState

func (t *TaskRunsService) SetState(ctx context.Context, id uuid.UUID, state *models.StateCreate) (*models.TaskRun, error)

SetState sets the state of a task run.

func (*TaskRunsService) Update

Update updates a task run.

type TaskWorkersService

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

TaskWorkersService handles operations related to task workers.

func (*TaskWorkersService) List

List retrieves task workers matching the filter.

type VariablesService

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

VariablesService handles operations related to variables.

func (*VariablesService) Count

func (v *VariablesService) Count(ctx context.Context, filter *models.VariableFilter) (int, error)

Count returns the number of variables matching the filter.

func (*VariablesService) Create

Create creates a new variable.

func (*VariablesService) Delete

func (v *VariablesService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a variable by ID.

func (*VariablesService) Get

Get retrieves a variable by ID.

func (*VariablesService) GetByName

func (v *VariablesService) GetByName(ctx context.Context, name string) (*models.Variable, error)

GetByName retrieves a variable by name.

func (*VariablesService) List

List retrieves a list of variables with optional filtering.

func (*VariablesService) ListAll

ListAll returns an iterator for all variables matching the filter.

func (*VariablesService) Update

Update updates a variable.

type WorkPoolsService

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

WorkPoolsService handles operations related to work pools.

func (*WorkPoolsService) Count

func (w *WorkPoolsService) Count(ctx context.Context, filter *models.WorkPoolFilter) (int, error)

Count returns the number of work pools matching the filter.

func (*WorkPoolsService) Create

Create creates a new work pool.

func (*WorkPoolsService) Delete

func (w *WorkPoolsService) Delete(ctx context.Context, name string) error

Delete deletes a work pool by name.

func (*WorkPoolsService) Get

func (w *WorkPoolsService) Get(ctx context.Context, name string) (*models.WorkPool, error)

Get retrieves a work pool by name.

func (*WorkPoolsService) List

func (w *WorkPoolsService) List(ctx context.Context, filter *models.WorkPoolFilter, offset, limit int) ([]models.WorkPool, error)

List retrieves work pools with optional filtering.

func (*WorkPoolsService) Update

func (w *WorkPoolsService) Update(ctx context.Context, name string, req *models.WorkPoolUpdate) error

Update updates a work pool.

type WorkQueuesService

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

WorkQueuesService handles operations related to work queues.

func (*WorkQueuesService) Create

Create creates a new work queue.

func (*WorkQueuesService) Delete

func (w *WorkQueuesService) Delete(ctx context.Context, id uuid.UUID) error

Delete deletes a work queue by ID.

func (*WorkQueuesService) Get

Get retrieves a work queue by ID.

func (*WorkQueuesService) GetByName

func (w *WorkQueuesService) GetByName(ctx context.Context, name string) (*models.WorkQueue, error)

GetByName retrieves a work queue by name.

func (*WorkQueuesService) List

func (w *WorkQueuesService) List(ctx context.Context, filter *models.WorkQueueFilter, offset, limit int) ([]models.WorkQueue, error)

List retrieves work queues with optional filtering.

func (*WorkQueuesService) Update

Update updates a work queue.

Jump to

Keyboard shortcuts

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