> ## 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.

# Applications

> SDK methods to deploy, list, retrieve, and delete services, jobs, and other applications.

## Methods

<Accordion title="list">
  Retrieves a list of all latest applications. Supports filtering by application ID, name, type, and other parameters. Pagination is available based on query parameters.

  #### Parameters

  <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="application_id" type="typing.Optional[str]">
    Application id of the application
  </ParamField>

  <ParamField body="workspace_id" type="typing.Optional[str]">
    Workspace id of the application (comma separated for multiple)
  </ParamField>

  <ParamField body="application_name" type="typing.Optional[str]">
    Name of application
  </ParamField>

  <ParamField body="fqn" type="typing.Optional[str]">
    Fully qualified name (FQN) of the application
  </ParamField>

  <ParamField body="workspace_fqn" type="typing.Optional[str]">
    Fully qualified name (FQN) of the workspace
  </ParamField>

  <ParamField body="application_type" type="typing.Optional[str]">
    Type of application (comma separated for multiple). Allowed Values: async-service, service, job, spark-job, helm, notebook, spark-notebook, codeserver, rstudio, ssh-server, volume, application, application-set, intercept, workflow
  </ParamField>

  <ParamField body="name_search_query" type="typing.Optional[str]">
    Search query for application name
  </ParamField>

  <ParamField body="environment_id" type="typing.Optional[str]">
    Filter by Environment ids of the application (comma separated for multiple)
  </ParamField>

  <ParamField body="cluster_id" type="typing.Optional[str]">
    Filter by Cluster ids of the application (comma separated for multiple)
  </ParamField>

  <ParamField body="application_set_id" type="typing.Optional[str]">
    Filter by Application Set id of the application
  </ParamField>

  <ParamField body="paused" type="typing.Optional[bool]">
    Filter by Application Paused status
  </ParamField>

  <ParamField body="device_type_filter" type="typing.Optional[ApplicationsListRequestDeviceTypeFilter]">
    [🔗 ApplicationsListRequestDeviceTypeFilter](/docs/truefoundry_sdk/enums#applicationslistrequestdevicetypefilter)

    Filter by device type of the application. Allowed values: cpu, nvidia\_gpu, aws\_inferentia, nvidia\_mig\_gpu, nvidia\_timeslicing\_gpu, gcp\_tpu
  </ParamField>

  <ParamField body="last_deployed_by_subjects" type="typing.Optional[str]">
    Filter by last deployed by specific users
  </ParamField>

  <ParamField body="lifecycle_stage" type="typing.Optional[ApplicationsListRequestLifecycleStage]">
    [🔗 ApplicationsListRequestLifecycleStage](/docs/truefoundry_sdk/enums#applicationslistrequestlifecyclestage)

    Filter by application lifecycle state
  </ParamField>

  <ParamField body="is_recommendation_present_and_visible" type="typing.Optional[bool]">
    Filter out applications with recommendations that are allowed to be shown
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[Application, ListApplicationsResponse]" type="SyncPager[Application, ListApplicationsResponse]">
    [🔗 ListApplicationsResponse](/docs/truefoundry_sdk/types#listapplicationsresponse)

    Retrieve latest applications based on the specified query parameters. If pagination parameters are provided, the response includes paginated data.
  </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.applications.list(
      limit=10,
      offset=10,
      application_id="application_id_value",
      workspace_id="workspace_id_value",
      application_name="value",
      fqn="value",
      workspace_fqn="value",
      application_type="value",
      name_search_query="value",
      environment_id="value",
      cluster_id="cluster_id_value",
      application_set_id="value",
      paused="value",
      device_type_filter="value",
      last_deployed_by_subjects="value",
      lifecycle_stage="value",
      is_recommendation_present_and_visible="value",
  )

  # Iterate through results
  for item in response:
      print(item.name)

  # Or paginate page by page
  for page in response.iter_pages():
      for item in page:
          print(item.name)
  ```
</Accordion>

<Accordion title="create_or_update">
  Create a new Application Deployment based on the provided manifest.

  #### Parameters

  <ParamField body="manifest" type="typing.Dict[str, typing.Any]" required>
    Manifest of application
  </ParamField>

  <ParamField body="dry_run" type="typing.Optional[bool]">
    Dry run
  </ParamField>

  <ParamField body="force_deploy" type="typing.Optional[bool]">
    Cancels any ongoing deployments
  </ParamField>

  <ParamField body="trigger_on_deploy" type="typing.Optional[bool]">
    Trigger on deploy
  </ParamField>

  <ParamField body="workspace_id" type="typing.Optional[str]">
    workspace id of the workspace
  </ParamField>

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

  <ParamField body="name" type="typing.Optional[str]">
    Name of application
  </ParamField>

  <ParamField body="application_set_id" type="typing.Optional[str]">
    Application Set Id
  </ParamField>

  #### Returns

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

    Returns new deployment on successful creation

    * It also creates an application if not already present
    * validates third party requirements
    * updates application, version
  </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.applications.create_or_update(
      manifest={"key": "value"},
      dry_run=False,
      force_deploy=False,
      trigger_on_deploy=False,
      workspace_id="workspace_id_value",
      application_id="application_id_value",
      name="value",
      application_set_id="value",
  )
  ```
</Accordion>

<Accordion title="get">
  Get Application associated with the provided application ID.

  #### Parameters

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

  #### Returns

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

    Application details retrieved successfully
  </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.applications.get(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Delete Application associated with the provided application ID.

  #### Parameters

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

  #### Returns

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

    Delete application response.
  </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.applications.delete(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="redeploy">
  Creates a new deployment with the same manifest as the given deployment.

  #### Parameters

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

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

  #### Returns

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

    Returns the new deployment.
  </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.applications.redeploy(
      id="id_value",
      deployment_id="value",
  )
  ```
</Accordion>

<Accordion title="scale_to_zero">
  Pause a running application by scaling to 0 replicas

  #### Parameters

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

  #### Returns

  <ResponseField name="None" type="None" />

  #### 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.applications.scale_to_zero(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="scale_to_original">
  Resume a paused application by scaling back to the original number of replicas

  #### Parameters

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

  #### Returns

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

    Scales back a paused applicaion to the original number of replicas
  </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.applications.scale_to_original(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="cancel_deployment">
  Cancel an ongoing deployment associated with the provided application ID and deployment ID.

  #### Parameters

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

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

  #### Returns

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

    Deployment cancelled successfully.
  </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.applications.cancel_deployment(
      id="id_value",
      deployment_id="value",
  )
  ```
</Accordion>

<Accordion title="get_by_fqn">
  Get Application by FQN.

  #### Parameters

  <ParamField body="fqn" type="str" required>
    FQN of the application
  </ParamField>

  #### Returns

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

    Application details
  </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.applications.get_by_fqn(
      fqn="value",
  )
  ```
</Accordion>
