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

# Secret Groups

> SDK methods to create, list, and manage secret groups and their associated secrets in TrueFoundry.

## Methods

<Accordion title="list">
  List the secret groups associated with a user along with the associated secrets for each group. Filtered with the options passed in the query fields. Note: This method does not return the secret values of the <em>associatedSecrets</em> in the response. A separate API call to `/v1/secrets/{id}` should be made to fetch the associated secret value.

  #### 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="fqn" type="typing.Optional[str]">
    Fqn of secret group.
  </ParamField>

  <ParamField body="search" type="typing.Optional[str]">
    Search query - filters by secret group names that contain the search string
  </ParamField>

  #### Returns

  <ResponseField name="SyncPager[SecretGroup, ListSecretGroupResponse]" type="SyncPager[SecretGroup, ListSecretGroupResponse]">
    [🔗 ListSecretGroupResponse](/docs/truefoundry_sdk/types#listsecretgroupresponse)

    Returns all the secret groups associated with a user along with the associated secrets for each group.
  </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.secret_groups.list(
      limit=10,
      offset=10,
      fqn="value",
      search="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">
  Creates a secret group with secrets in it. A secret version for each of the created secret is created with version number as 1. The returned secret group does not have any secret values in the <em>associatedSecrets</em> field. A separate API call to `/v1/secrets/{id}` should be made to fetch the associated secret value.

  #### Parameters

  <ParamField body="name" type="str" required>
    Name of the secret group.
  </ParamField>

  <ParamField body="integration_id" type="str" required>
    Id of the provider integration.
  </ParamField>

  <ParamField body="secrets" type="typing.Sequence[SecretInput]" required>
    [🔗 SecretInput](/docs/truefoundry_sdk/types#secretinput)

    The secrets to be associated with the secret group
  </ParamField>

  #### Returns

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

    Returns the created secret group without the associated secrets.
  </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.secret_groups.create(
      name="value",
      integration_id="value",
      secrets="value",
  )
  ```
</Accordion>

<Accordion title="create_or_update">
  Creates a new secret group or updates an existing one based on the provided manifest.

  #### Parameters

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

    Secret Group Manifest
  </ParamField>

  <ParamField body="dry_run" type="typing.Optional[bool]">
    Validate the manifest and collaborators without persisting or updating authorizations and secret groups
  </ParamField>

  #### Returns

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

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

<Accordion title="get">
  Get Secret Group by id. This method does not return the secret values of the <em>associatedSecrets</em> in the response. A separate API call to `/v1/secrets/{id}` should be made to fetch the associated secret value.

  #### Parameters

  <ParamField body="id" type="str" required>
    Secret Id of the secret group.
  </ParamField>

  #### Returns

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

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

<Accordion title="update">
  Updates the secrets in a secret group with new values. A new secret version is created for every secret that has a modified value and any omitted secrets are deleted. The returned updated secret group does not have any secret values in the <em>associatedSecrets</em> field. A separate API call to `/v1/secrets/{id}` should be made to fetch the associated secret value.

  #### Parameters

  <ParamField body="id" type="str" required>
    Secret Id of the secret group.
  </ParamField>

  <ParamField body="secrets" type="typing.Sequence[UpdateSecretInput]" required>
    [🔗 UpdateSecretInput](/docs/truefoundry_sdk/types#updatesecretinput)
  </ParamField>

  #### Returns

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

    Returns the updated secret group without associated secrets.
  </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.secret_groups.update(
      id="id_value",
      secrets="value",
  )
  ```
</Accordion>

<Accordion title="delete">
  Deletes the secret group, its associated secrets and secret versions of those secrets.

  #### Parameters

  <ParamField body="id" type="str" required>
    Secret Id of the secret group.
  </ParamField>

  #### Returns

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

    Deletes Secret Group.
  </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.secret_groups.delete(
      id="id_value",
  )
  ```
</Accordion>

<Accordion title="get_by_fqn">
  Get Secret Group by FQN.

  #### Parameters

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

  #### Returns

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

    Secret group 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.secret_groups.get_by_fqn(
      fqn="value",
  )
  ```
</Accordion>
