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

# Environments

> SDK methods to list, create, and manage deployment environments in TrueFoundry.

## Methods

<Accordion title="list">
  List environments, if no environments are found, default environments are created and returned. 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>

  #### Returns

  <ResponseField name="SyncPager[Environment, ListEnvironmentsResponse]" type="SyncPager[Environment, ListEnvironmentsResponse]">
    [🔗 ListEnvironmentsResponse](/docs/truefoundry_sdk/types#listenvironmentsresponse)

    Returns a list of environment. 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.environments.list(
      limit=10,
      offset=10,
  )

  # 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">
  Creates a new Environment or updates an existing Environment.

  #### Parameters

  <ParamField body="manifest" type="EnvironmentManifest" required>
    [🔗 EnvironmentManifest](/docs/truefoundry_sdk/types#environmentmanifest)

    Environment Manifest
  </ParamField>

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

  #### Returns

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

    Returns the created or updated Environment
  </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.environments.create_or_update(
      manifest={"key": "value"},
      dry_run=False,
  )
  ```
</Accordion>

<Accordion title="get">
  Get Environment associated with the provided id.

  #### Parameters

  <ParamField body="id" type="str" required>
    Environment id
  </ParamField>

  #### Returns

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

    Returns the Environment associated with the provided id
  </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.environments.get(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Delete Environment associated with the provided id.

  #### Parameters

  <ParamField body="id" type="str" required>
    Environment id
  </ParamField>

  #### Returns

  <ResponseField name="bool" type="bool">
    Returns true if the Environment is deleted 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.environments.delete(
      id="id_value",
  )
  ```
</Accordion>
