Class: Hatchet::Features::Workflows

Inherits:
Object
  • Object
show all
Defined in:
lib/hatchet/features/workflows.rb

Overview

Workflows client for managing workflow definitions within Hatchet

Note that workflows are the declaration, not the individual runs. If you’re looking for runs, use the Runs client instead.

Examples:

Getting a workflow

workflow = workflows_client.get("workflow-id")

Listing workflows

workflows = workflows_client.list(workflow_name: "my-workflow", limit: 10)

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(rest_client, config) ⇒ void

Initializes a new Workflows client instance

Parameters:

  • rest_client (Object)

    The configured REST client for API communication

  • config (Hatchet::Config)

    The Hatchet configuration containing tenant_id and other settings

Since:

  • 0.1.0



24
25
26
27
28
# File 'lib/hatchet/features/workflows.rb', line 24

def initialize(rest_client, config)
  @rest_client = rest_client
  @config = config
  @workflow_api = HatchetSdkRest::WorkflowApi.new(rest_client)
end

Instance Method Details

#delete(workflow_id) ⇒ void

This method returns an undefined value.

Permanently delete a workflow

**DANGEROUS: This will delete a workflow and all of its data**

Examples:

workflows_client.delete("workflow-123")

Parameters:

  • workflow_id (String)

    The ID of the workflow to delete

Raises:

Since:

  • 0.1.0



82
83
84
# File 'lib/hatchet/features/workflows.rb', line 82

def delete(workflow_id)
  @workflow_api.workflow_delete(workflow_id)
end

#get(workflow_id) ⇒ Object

Get a workflow by its ID

Examples:

workflow = workflows_client.get("workflow-123")

Parameters:

  • workflow_id (String)

    The ID of the workflow to retrieve

Returns:

  • (Object)

    The workflow details

Raises:

Since:

  • 0.1.0



37
38
39
# File 'lib/hatchet/features/workflows.rb', line 37

def get(workflow_id)
  @workflow_api.workflow_get(workflow_id)
end

#get_version(workflow_id, version: nil) ⇒ Object

Get a workflow version by the workflow ID and an optional version

Examples:

version = workflows_client.get_version("workflow-123", version: "v2")

Parameters:

  • workflow_id (String)

    The ID of the workflow to retrieve the version for

  • version (String, nil) (defaults to: nil)

    The version to retrieve. If nil, the latest version is returned

Returns:

  • (Object)

    The workflow version

Raises:

Since:

  • 0.1.0



69
70
71
# File 'lib/hatchet/features/workflows.rb', line 69

def get_version(workflow_id, version: nil)
  @workflow_api.workflow_version_get(workflow_id, { version: version })
end

#list(workflow_name: nil, limit: nil, offset: nil) ⇒ Object

List all workflows in the tenant matching optional filters

Examples:

workflows = workflows_client.list(workflow_name: "my-workflow", limit: 10, offset: 0)

Parameters:

  • workflow_name (String, nil) (defaults to: nil)

    The name of the workflow to filter by (namespace will be applied)

  • limit (Integer, nil) (defaults to: nil)

    The maximum number of items to return

  • offset (Integer, nil) (defaults to: nil)

    The offset to start the list from

Returns:

  • (Object)

    A list of workflows

Raises:

Since:

  • 0.1.0



50
51
52
53
54
55
56
57
58
59
# File 'lib/hatchet/features/workflows.rb', line 50

def list(workflow_name: nil, limit: nil, offset: nil)
  @workflow_api.workflow_list(
    @config.tenant_id,
    {
      limit: limit,
      offset: offset,
      name: workflow_name ? @config.apply_namespace(workflow_name) : nil,
    },
  )
end