> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Jobs

> SDK methods to trigger, list, and manage job runs and job executions in TrueFoundry.

## Methods

<Accordion title="list_runs">
  List Job Runs for provided Job Id. Filter the data based on parameters passed in the query

  #### Parameters

  <ParamField body="job_id" type="str" required>
    Job id of the application
  </ParamField>

  <ParamField body="limit" type="typing.Optional[int]">
    Number of items per page
  </ParamField>

  <ParamField body="offset" type="typing.Optional[int]">
    Number of items to skip
  </ParamField>

  <ParamField body="search_prefix" type="typing.Optional[str]">
    Prefix used to search for job runs by name or identifier
  </ParamField>

  <ParamField body="sort_by" type="typing.Optional[JobRunsSortBy]">
    [🔗 JobRunsSortBy](/docs/truefoundry_sdk/enums#jobrunssortby)

    Attribute to sort by
  </ParamField>

  <ParamField body="order" type="typing.Optional[SortDirection]">
    [🔗 SortDirection](/docs/truefoundry_sdk/enums#sortdirection)

    Sorting order
  </ParamField>

  <ParamField body="triggered_by" type="typing.Optional[typing.Union[str, typing.Sequence[str]]]">
    Array of subject slugs
  </ParamField>

  <ParamField body="status" type="typing.Optional[typing.Union[JobRunStatus, typing.Sequence[JobRunStatus]]]">
    [🔗 JobRunStatus](/docs/truefoundry_sdk/enums#jobrunstatus)

    Status of the job run
  </ParamField>

  <ParamField body="version_numbers" type="typing.Optional[typing.Union[float, typing.Sequence[float]]]">
    Version number of the deployment
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[JobRun, ListJobRunResponse]" type="SyncPager[JobRun, ListJobRunResponse]">
    [🔗 ListJobRunResponse](/docs/truefoundry_sdk/types#listjobrunresponse)

    Returns all runs of a Job sorted by creation date in "data" key and total count in "totalCount" key
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.jobs.list_runs(
      job_id="value",
      limit=10,
      offset=10,
      search_prefix="value",
      sort_by="value",
      order="value",
      triggered_by="value",
      status="value",
      version_numbers="value",
  )
  ```
</Accordion>

<Accordion title="get_run">
  Get Job Run for provided jobRunName and jobId

  #### Parameters

  <ParamField body="job_id" type="str" required>
    Application Id of JOB
  </ParamField>

  <ParamField body="job_run_name" type="str" required>
    Job run name of the application
  </ParamField>

  #### Returns

  <ResponseField name="GetJobRunResponse" type="GetJobRunResponse">
    [🔗 GetJobRunResponse](/docs/truefoundry_sdk/types#getjobrunresponse)

    Return JobRun details of the provided jobRunName
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.jobs.get_run(
      job_id="value",
      job_run_name="value",
  )
  ```
</Accordion>

<Accordion title="delete_run">
  Delete Job Run for provided jobRunName and jobId

  #### Parameters

  <ParamField body="job_id" type="str" required>
    Application Id of JOB
  </ParamField>

  <ParamField body="job_run_name" type="str" required>
    Job run name of the application
  </ParamField>

  #### Returns

  <ResponseField name="DeleteJobRunResponse" type="DeleteJobRunResponse">
    [🔗 DeleteJobRunResponse](/docs/truefoundry_sdk/types#deletejobrunresponse)

    Job Run deleted
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.jobs.delete_run(
      job_id="value",
      job_run_name="value",
  )
  ```
</Accordion>

<Accordion title="trigger">
  Trigger Job for provided deploymentId or applicationId

  #### Parameters

  <ParamField body="deployment_id" type="typing.Optional[str]">
    Deployment Id of the job
  </ParamField>

  <ParamField body="application_id" type="typing.Optional[str]">
    Application Id of the job
  </ParamField>

  <ParamField body="input" type="typing.Optional[TriggerJobRequestInput]">
    [🔗 TriggerJobRequestInput](/docs/truefoundry_sdk/types#triggerjobrequestinput)

    Job trigger input
  </ParamField>

  <ParamField body="metadata" type="typing.Optional[Metadata]">
    [🔗 Metadata](/docs/truefoundry_sdk/types#metadata)

    Metadata for the job run including job\_alias\_name
  </ParamField>

  #### Returns

  <ResponseField name="TriggerJobRunResponse" type="TriggerJobRunResponse">
    [🔗 TriggerJobRunResponse](/docs/truefoundry_sdk/types#triggerjobrunresponse)

    Returns object with message, JobRun Name And Job Details on successful creation of Job
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.jobs.trigger(
      deployment_id="value",
      application_id="application_id_value",
      input="value",
      metadata="value",
  )
  ```
</Accordion>

<Accordion title="terminate">
  Terminate Job for provided deploymentId and jobRunName

  #### Parameters

  <ParamField body="deployment_id" type="str" required>
    Deployment Id of the Deployment
  </ParamField>

  <ParamField body="job_run_name" type="str" required>
    Job Run name
  </ParamField>

  #### Returns

  <ResponseField name="TerminateJobResponse" type="TerminateJobResponse">
    [🔗 TerminateJobResponse](/docs/truefoundry_sdk/types#terminatejobresponse)

    Returns object with message and JobRun Status on successful termination of Job
  </ResponseField>

  #### Usage

  ```python lines theme={"dark"}
  from truefoundry import TrueFoundry

  client = TrueFoundry(
      api_key="YOUR_API_KEY",
      base_url="https://yourhost.com/path/to/api",
  )

  client.jobs.terminate(
      deployment_id="value",
      job_run_name="value",
  )
  ```
</Accordion>
