View Source Lightning.Workflows.Job (Lightning v2.10.4)

Ecto model for Jobs.

A Job contains the fields for defining a job.

  • body The expression/javascript code
  • name A plain text identifier
  • adaptor An NPM style string that contains both the module name and it's version. E.g. @openfn/language-http@v1.2.3 or @openfn/language-foo@latest. While the version suffix isn't enforced here as it's not strictly necessary in this context, the front end will ensure a version is stated (@latest being the default).

Summary

Functions

Attaches a workflow to a job, this is useful when you have an unpersisted Workflow changeset - and want it to be created at the same time as a Job.

Types

@type t() :: %Lightning.Workflows.Job{
  __meta__: Ecto.Schema.Metadata.t(),
  adaptor: String.t() | nil,
  body: String.t() | nil,
  credential:
    nil | Lightning.Credentials.Credential.t() | Ecto.Association.NotLoaded.t(),
  delete: term(),
  id: Ecto.UUID.t() | nil,
  inserted_at: term(),
  name: String.t() | nil,
  project: term(),
  project_credential: term(),
  project_credential_id: term(),
  steps: term(),
  updated_at: term(),
  workflow:
    nil | Lightning.Workflows.Workflow.t() | Ecto.Association.NotLoaded.t(),
  workflow_id: term()
}

Functions

Link to this function

put_project_credential(job, project_credential)

View Source
Link to this function

put_workflow(changeset, workflow)

View Source

Attaches a workflow to a job, this is useful when you have an unpersisted Workflow changeset - and want it to be created at the same time as a Job.

Example:

workflow =
  Ecto.Changeset.cast(
    %Lightning.Workflows.Workflow{},
    %{ "project_id" => attrs[:project_id], "id" => Ecto.UUID.generate() },
    [:project_id, :id]
  )

job =
  %Job{}
  |> Ecto.Changeset.change()
  |> Job.put_workflow(workflow)
  |> Job.changeset(attrs)