### Install Truefoundry Python SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/README.md Installs the Truefoundry Python SDK using pip. This is the first step to integrate with the TrueFoundry API. ```shell pip install truefoundry-sdk ``` -------------------------------- ### Get Artifact using TrueFoundry Python SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This example shows how to retrieve an artifact using the TrueFoundry Python SDK. It requires the client to be initialized with an API key and base URL. The `get` method is used to fetch artifact details. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) # Assuming you have artifact details or an ID to fetch # response = client.artifacts.get(artifact_id="your_artifact_id") ``` -------------------------------- ### List Cluster Addons Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt List all addons installed on a specific cluster, with pagination. ```APIDOC ## GET /clusters/{id}/addons ### Description List addons installed on a cluster. ### Method GET ### Endpoint `/clusters/{id}/addons` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the cluster. #### Query Parameters - **limit** (integer) - Optional - The maximum number of addons to return. - **offset** (integer) - Optional - The number of addons to skip. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) addons = client.clusters.get_addons( id="cluster-123", limit=10, offset=0, ) ``` ### Response #### Success Response (200) - **name** (string) - The name of the addon. - **version** (string) - The version of the addon. #### Response Example ```json [ { "name": "monitoring-addon", "version": "1.2.0" } ] ``` ``` -------------------------------- ### Get User Teams with TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This code example demonstrates how to fetch all manual teams associated with a user. The `get_teams` method is used, which requires the user's ID. The TrueFoundry client needs to be instantiated with the API key and base URL. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.users.get_teams( id="id", ) ``` -------------------------------- ### Initialize and Use Asynchronous Truefoundry Client Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/README.md Shows how to initialize the asynchronous TrueFoundry client and make non-blocking API calls to list applications. It includes examples for iterating through results and paginating pages asynchronously. ```python import asyncio from truefoundry_sdk import AsyncTrueFoundry from truefoundry_sdk.applications import ( ApplicationsListRequestDeviceTypeFilter, ApplicationsListRequestLifecycleStage, ) client = AsyncTrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) async def main() -> None: response = await client.applications.list( limit=10, offset=0, application_id="applicationId", workspace_id="workspaceId", application_name="applicationName", fqn="fqn", workspace_fqn="workspaceFqn", application_type="applicationType", name_search_query="nameSearchQuery", environment_id="environmentId", cluster_id="clusterId", application_set_id="applicationSetId", paused=True, device_type_filter=ApplicationsListRequestDeviceTypeFilter.CPU, last_deployed_by_subjects="lastDeployedBySubjects", lifecycle_stage=ApplicationsListRequestLifecycleStage.ACTIVE, is_recommendation_present_and_visible=True, ) async for item in response: yield item # alternatively, you can paginate page-by-page async for page in response.iter_pages(): yield page asyncio.run(main()) ``` -------------------------------- ### Get Application Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Retrieve application details by its unique identifier. ```APIDOC ## GET /applications/{id} ### Description Retrieve application details by ID. ### Method GET ### Endpoint `/applications/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the application. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) app = client.applications.get(id="app-123") print(f"Application: {app.name}") ``` ### Response #### Success Response (200) - **name** (string) - The name of the application. - **id** (string) - The unique identifier of the application. #### Response Example ```json { "name": "my-application", "id": "app-123" } ``` ``` -------------------------------- ### Create or Update Model using TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This example shows how to create or update a model using the TrueFoundry SDK. It requires initializing the client and providing necessary parameters for model creation or update. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.models.create_or_update( # Parameters for creating or updating a model would go here ) ``` -------------------------------- ### Applications API Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This section covers the core functionalities for interacting with applications, including getting, deleting, scaling, and managing deployments. ```APIDOC ## GET /applications/{id} ### Description Get Application associated with the provided application ID. ### Method GET ### Endpoint `/applications/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - Id of the application #### Query Parameters None #### Request Body None ### Request Example ```python client.applications.get(id="id") ``` ### Response #### Success Response (200) - **Application details** (object) - Details of the retrieved application. #### Response Example ```json { "example": "response body" } ``` ``` ```APIDOC ## DELETE /applications/{id} ### Description Delete Application associated with the provided application ID. ### Method DELETE ### Endpoint `/applications/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - Id of the application #### Query Parameters None #### Request Body None ### Request Example ```python client.applications.delete(id="id") ``` ### Response #### Success Response (200) - **Deletion status** (object) - Confirmation of the application deletion. #### Response Example ```json { "example": "response body" } ``` ``` ```APIDOC ## POST /applications/{id}/scale-to-zero ### Description Pause a running application by scaling to 0 replicas. ### Method POST ### Endpoint `/applications/{id}/scale-to-zero` ### Parameters #### Path Parameters - **id** (str) - Required - Id of the application #### Query Parameters None #### Request Body None ### Request Example ```python client.applications.scale_to_zero(id="id") ``` ### Response #### Success Response (200) - **Scaling status** (object) - Confirmation of the scaling operation. #### Response Example ```json { "example": "response body" } ``` ``` ```APIDOC ## POST /applications/{id}/scale-to-original ### Description Resume a paused application by scaling back to the original number of replicas. ### Method POST ### Endpoint `/applications/{id}/scale-to-original` ### Parameters #### Path Parameters - **id** (str) - Required - Id of the application #### Query Parameters None #### Request Body None ### Request Example ```python client.applications.scale_to_original(id="id") ``` ### Response #### Success Response (200) - **Deployment details** (object) - Details of the resumed deployment. #### Response Example ```json { "example": "response body" } ``` ``` ```APIDOC ## POST /applications/{id}/cancel-deployment ### Description Cancel an ongoing deployment associated with the provided application ID and deployment ID. ### Method POST ### Endpoint `/applications/{id}/cancel-deployment` ### Parameters #### Path Parameters - **id** (str) - Required - Id of the application #### Query Parameters None #### Request Body - **deployment_id** (str) - Required - The ID of the deployment to cancel. ### Request Example ```python client.applications.cancel_deployment(id="id", deployment_id="deploymentId") ``` ### Response #### Success Response (200) - **Cancellation status** (object) - Confirmation of the deployment cancellation. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### List Cluster Addons with Pagination using TrueFoundry SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Fetches a list of addons installed on a specific cluster, identified by its ID. Supports pagination using limit and offset. Requires the TrueFoundry SDK and an initialized client. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) addons = client.clusters.get_addons( id="cluster-123", limit=10, offset=0, ) ``` -------------------------------- ### Get Deployment Builds (Python) Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Fetches all build details associated with a specific deployment in an application. Requires initializing the TrueFoundry client with API key and base URL. Takes application ID and deployment ID as arguments. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.deployments.get_builds( id="id", deployment_id="deploymentId", ) ``` -------------------------------- ### Get Suggested Endpoint for Deployments Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Generates a deployment endpoint based on provided query parameters. Requires an initialized TrueFoundry client with API key and base URL. ```python from truefoundry_sdk import ApplicationType, TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.deployments.get_suggested_endpoint( application_type=ApplicationType.ASYNC_SERVICE, application_name="applicationName", workspace_id="workspaceId", base_domain="baseDomain", port="port", prefer_wildcard=True, ) ``` -------------------------------- ### Internal Deployments: Get Code Upload URL Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Generates a presigned URL to upload code for a given service name and workspace FQN. ```APIDOC ## POST /internal/deployments/code/upload-url ### Description Generate presigned URL to upload code for given serviceName and workspaceFqn. ### Method POST ### Endpoint /internal/deployments/code/upload-url ### Parameters #### Request Body - **service_name** (str) - Required - The name of the service. - **workspace_fqn** (str) - Required - The fully qualified name of the workspace. #### Query Parameters - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.deployments.get_code_upload_url( service_name="serviceName", workspace_fqn="workspaceFqn", ) ``` ### Response #### Success Response (200) - **[Response Fields]** (PresignedUrlObject) - An object containing the presigned URL. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize and Use Synchronous Truefoundry Client Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/README.md Demonstrates how to initialize the synchronous TrueFoundry client with API key and base URL, and then use it to list applications with various filtering options. It also shows how to iterate through the results or paginate through pages. ```python from truefoundry_sdk import TrueFoundry from truefoundry_sdk.applications import ( ApplicationsListRequestDeviceTypeFilter, ApplicationsListRequestLifecycleStage, ) client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.applications.list( limit=10, offset=0, application_id="applicationId", workspace_id="workspaceId", application_name="applicationName", fqn="fqn", workspace_fqn="workspaceFqn", application_type="applicationType", name_search_query="nameSearchQuery", environment_id="environmentId", cluster_id="clusterId", application_set_id="applicationSetId", paused=True, device_type_filter=ApplicationsListRequestDeviceTypeFilter.CPU, last_deployed_by_subjects="lastDeployedBySubjects", lifecycle_stage=ApplicationsListRequestLifecycleStage.ACTIVE, is_recommendation_present_and_visible=True, ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page ``` -------------------------------- ### Get Application Logs using TrueFoundry SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Retrieves logs for various TrueFoundry resources like services, jobs, workflows, and pods. It requires an application ID and a time range (start and end timestamps) for filtering the logs. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) logs = client.logs.get( application_id="app-123", start_ts="2024-01-01T00:00:00Z", end_ts="2024-01-02T00:00:00Z", ) ``` -------------------------------- ### Get Metrics Charts for Application Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Lists charts for a given application based on provided parameters. Requires workspace ID, application ID, start and end timestamps, and optionally filter entity and query. Initializes with API key and base URL. ```python from truefoundry_sdk import TrueFoundry from truefoundry_sdk.internal.metrics import MetricsGetChartsRequestFilterEntity client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.metrics.get_charts( workspace_id="workspaceId", application_id="applicationId", start_ts="startTs", end_ts="endTs", filter_entity=MetricsGetChartsRequestFilterEntity.APPLICATION, filter_query="filterQuery", ) ``` -------------------------------- ### List Application Versions/Deployments with TrueFoundry SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Fetches all deployments for a given application, supporting filtering by ID, limit, offset, and version. Requires the TrueFoundry SDK and initialized client. Returns a list of deployment objects. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.application_versions.list( id="app-123", limit=10, offset=0, version="1", ) for deployment in response: print(f"Version: {deployment.version}, Status: {deployment.status}") ``` -------------------------------- ### List Application Versions Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Fetch all deployments for an application, with support for filtering. ```APIDOC ## GET /applications/{id}/versions ### Description Fetch all deployments for an application with optional filters. ### Method GET ### Endpoint `/applications/{id}/versions` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the application. #### Query Parameters - **limit** (integer) - Optional - The maximum number of deployments to return. - **offset** (integer) - Optional - The number of deployments to skip. - **version** (string) - Optional - Filter deployments by a specific version string. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.application_versions.list( id="app-123", limit=10, offset=0, version="1", ) for deployment in response: print(f"Version: {deployment.version}, Status: {deployment.status}") ``` ### Response #### Success Response (200) - **version** (string) - The version of the deployment. - **status** (string) - The status of the deployment. #### Response Example ```json [ { "version": "1.0.0", "status": "succeeded" } ] ``` ``` -------------------------------- ### Get Events for Pod, Job Run, Application using TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves events from Kubernetes and TrueFoundry for specified components. Supports filtering by start and end timestamps, application ID, application FQN, and job run name. Requires initialization of the TrueFoundry client with API key and base URL. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.events.get( start_ts="startTs", end_ts="endTs", application_id="applicationId", application_fqn="applicationFqn", job_run_name="jobRunName", ) ``` -------------------------------- ### Invite New User using TrueFoundry Python SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Invites a new user to the tenant by providing an email address and a client URL for accepting the invitation. Initializes the client with API key and base URL. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.users.invite_user( accept_invite_client_url="https://app.example.com/invite-accept", email="newuser@example.com", ) ``` -------------------------------- ### Internal Get ID from FQN Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Get IDs associated with the FQN for various entity types, such as deployment, application, workspace, or cluster. ```APIDOC ## GET /internal/get_id_from_fqn ### Description Get IDs associated with the FQN for various entity types, such as deployment, application, workspace, or cluster. ### Method GET ### Endpoint /internal/get_id_from_fqn ### Parameters #### Query Parameters - **type** (str) - Required - Entity Type. - **fqn** (str) - Required - Entity FQN. - **request_options** (Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ``` GET /internal/get_id_from_fqn?type=deployment&fqn=your.entity.fqn ``` ### Response #### Success Response (200) - **result** (Dict[str, Any]) - A dictionary containing the ID associated with the FQN. #### Response Example ```json { "result": { "id": "some-uuid" } } ``` ``` -------------------------------- ### List Environments with Pagination using TrueFoundry SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Fetches a list of all environments configured in the system, with support for pagination. Requires the TrueFoundry SDK and an initialized client. Returns a list of environment objects. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.environments.list(limit=10, offset=0) for env in response: print(f"Environment: {env.name}, Production: {env.is_production}") ``` -------------------------------- ### Create or Update Application (Python) Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Creates or updates an application deployment using a provided manifest. It supports options like `dry_run` and `force_deploy` for managing the deployment process. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) deployment = client.applications.create_or_update( manifest={ "name": "my-service", "type": "service", "image": { "type": "image", "image_uri": "nginx:latest", }, "ports": [{"port": 80, "protocol": "TCP"}], "resources": { "cpu_request": 0.5, "cpu_limit": 1.0, "memory_request": 512, "memory_limit": 1024, }, }, workspace_id="workspace-123", dry_run=False, force_deploy=True, ) ``` -------------------------------- ### Get Prompt using TrueFoundry Python SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This snippet demonstrates how to retrieve a specific prompt by its ID. It involves initializing the TrueFoundry client and then using the `get` method from the prompts client. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.prompts.get( id="id", ) ``` -------------------------------- ### Get Model using TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This snippet illustrates how to retrieve a specific model by its ID using the TrueFoundry SDK. It involves initializing the client and calling the get method with the model's ID. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.models.get( id="id", ) ``` -------------------------------- ### Get Artifact Version Details with Truefoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This code snippet illustrates how to retrieve details of a specific artifact version using its ID. The `get` method requires the artifact version's ID and can optionally accept `request_options` for configuration. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.artifact_versions.get( id="id", ) ``` -------------------------------- ### List Artifact Versions with Truefoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This example demonstrates how to list artifact versions with various filtering options such as tag, fqn, artifact ID, ML repo ID, name, and version. It also shows how to paginate through the results. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.artifact_versions.list( tag="tag", fqn="fqn", artifact_id="artifact_id", ml_repo_id="ml_repo_id", name="name", version=1, offset=1, limit=1, include_internal_metadata=True, ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page ``` -------------------------------- ### List Environments Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt List all available environments, with support for pagination. ```APIDOC ## GET /environments ### Description List environments with pagination support. ### Method GET ### Endpoint `/environments` ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of environments to return. - **offset** (integer) - Optional - The number of environments to skip. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.environments.list(limit=10, offset=0) for env in response: print(f"Environment: {env.name}, Production: {env.is_production}") ``` ### Response #### Success Response (200) - **name** (string) - The name of the environment. - **is_production** (boolean) - True if the environment is a production environment, false otherwise. #### Response Example ```json [ { "name": "production", "is_production": true }, { "name": "staging", "is_production": false } ] ``` ``` -------------------------------- ### Promote Application Rollout Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Promotes an application rollout for canary and blue-green deployments. Requires the application ID and an optional flag to promote to full. Initializes with API key and base URL. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.applications.promote_rollout( id="id", full=True, ) ``` -------------------------------- ### Models API Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Endpoints for getting, deleting, listing, and creating/updating models. ```APIDOC ## GET /models/{id} ### Description Retrieves a specific model by its ID. ### Method GET ### Endpoint /models/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the model to retrieve. ### Request Example ```python client.models.get(id="id") ``` ### Response #### Success Response (200) - **GetModelResponse** - Details of the requested model. #### Response Example ```json { "model_details": "..." } ``` ## DELETE /models/{id} ### Description Deletes a specific model by its ID. ### Method DELETE ### Endpoint /models/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the model to delete. ### Request Example ```python client.models.delete(id="id") ``` ### Response #### Success Response (200) - **EmptyResponse** - Indicates successful deletion. #### Response Example ```json { "message": "Model deleted successfully." } ``` ## GET /models ### Description Retrieves a list of models with optional filtering. ### Method GET ### Endpoint /models ### Parameters #### Query Parameters - **fqn** (string) - Optional - Filter models by FQN. - **ml_repo_id** (string) - Optional - Filter models by ML repository ID. - **name** (string) - Optional - Filter models by name. - **offset** (integer) - Optional - Offset for pagination. - **limit** (integer) - Optional - Limit for pagination. - **run_id** (string) - Optional - Filter models by run ID. - **include_empty_models** (boolean) - Optional - Whether to include empty models. ### Request Example ```python response = client.models.list( fqn="fqn", ml_repo_id="ml_repo_id", name="name", offset=1, limit=1, run_id="run_id", include_empty_models=True, ) ``` ### Response #### Success Response (200) - **ListModelsResponse** - Contains a list of model objects. #### Response Example ```json { "models": [ { "model_object": "..." } ] } ``` ## POST /models ### Description Creates or updates a model. ### Method POST ### Endpoint /models ### Parameters #### Request Body - **manifest** (ModelManifest) - Required - The model manifest to create or update. - **name** (string) - Required - The name of the model. - **metadata** (object) - Optional - Metadata for the model. - **ml_repo** (string) - Required - The ML repository the model belongs to. - **run_id** (string) - Optional - The run ID associated with the model. - **artifact_path** (string) - Optional - The artifact path for the model. ### Request Example ```python client.models.create_or_update( manifest=ModelManifest( name="name", metadata={"key": "value"}, ml_repo="ml_repo", run_id="run_id", artifact_path="artifact/path", ) ) ``` ### Response #### Success Response (200) - **GetModelVersionResponse** - Details of the created or updated model version. #### Response Example ```json { "model_version_details": "..." } ``` ``` -------------------------------- ### POST /users/invite Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Invites a user to the tenant. ```APIDOC ## POST /users/invite ### Description Invite a user to the tenant ### Method POST ### Endpoint /users/invite ### Parameters #### Request Body - **email** (str) - Required - Email of the user to invite - **roles** (Sequence[str]) - Optional - Roles to assign to the invited user - **resource_type** (str) - Optional - Resource type for the roles ### Request Example ```json { "email": "invitee@example.com", "roles": ["member"], "resource_type": "project" } ``` ### Response #### Success Response (200) - **message** (str) - Success message indicating the user has been invited. #### Response Example ```json { "message": "Invitation sent successfully." } ``` ``` -------------------------------- ### Get User Resources Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves all resources associated with a specific user. ```APIDOC ## GET /users/{id}/resources ### Description Retrieves all resources associated with a specific user. ### Method GET ### Endpoint /users/{id}/resources ### Parameters #### Path Parameters - **id** (str) - Required - User Id #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **resources** (list) - A list of resources associated with the user. #### Response Example ```json { "resources": [ { "resource_id": "res-123", "resource_name": "Example Resource" } ] } ``` ``` -------------------------------- ### Pre-register Users with TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Allows tenant administrators to register users within their tenant. It takes the user's email and optional parameters like whether to send an invite email, skip if the user exists, perform a dry run, or specify a client URL for invite acceptance. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.users.pre_register_users( email="email", ) ``` -------------------------------- ### List ML Repositories Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Lists ML repositories, supporting filtering by name and pagination using limit and offset parameters. This helps in managing and discovering existing ML repositories. Requires client initialization. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.ml_repos.list( name="my-repo", limit=10, offset=0, ) for repo in response: print(f"ML Repo: {repo.name}") ``` -------------------------------- ### Get User Teams Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves all manual teams associated with a specific user. ```APIDOC ## GET /users/{id}/teams ### Description Retrieves all manual teams associated with a specific user. ### Method GET ### Endpoint /users/{id}/teams ### Parameters #### Path Parameters - **id** (str) - Required - User Id #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **teams** (list) - A list of teams associated with the user. #### Response Example ```json { "teams": [ { "team_id": "team-abc", "team_name": "Example Team" } ] } ``` ``` -------------------------------- ### Internal Clusters: Get Auto-provisioning State Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves the auto-provisioning status for a given cluster. ```APIDOC ## GET /internal/clusters/{id}/autoprovisioning/state ### Description Get the auto provisioning status for the provided cluster. ### Method GET ### Endpoint /internal/clusters/{id}/autoprovisioning/state ### Parameters #### Path Parameters - **id** (str) - Required - Cluster id of the cluster #### Query Parameters - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.clusters.get_autoprovisioning_state( id="id", ) ``` ### Response #### Success Response (200) - **[Response Fields]** (object) - Details of the auto-provisioning state. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### List Prompts using TrueFoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md This snippet shows how to list prompts using the TrueFoundry SDK. It initializes the client with API key and base URL, then calls the list method with optional filters. The response can be iterated directly or paginated. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.prompts.list( fqn="fqn", ml_repo_id="ml_repo_id", name="name", offset=1, limit=1, include_empty_prompts=True, ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page ``` -------------------------------- ### Get Virtual Account by ID Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves a specific virtual account by its unique identifier. ```APIDOC ## GET /virtual_accounts/{id} ### Description Get virtual account by id. ### Method GET ### Endpoint /virtual_accounts/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the virtual account. #### Query Parameters - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```python client.virtual_accounts.get( id="id", ) ``` ### Response #### Success Response (200) - **id** (str) - The ID of the virtual account. - **name** (str) - The name of the virtual account. - **created_at** (str) - Timestamp of creation. - **updated_at** (str) - Timestamp of last update. #### Response Example ```json { "id": "va_123", "name": "Example VA", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### GET /users/{id} Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves user details associated with the provided User ID. ```APIDOC ## GET /users/{id} ### Description Get User associated with provided User id ### Method GET ### Endpoint /users/{id} ### Parameters #### Path Parameters - **id** (str) - Required - User Id ### Response #### Success Response (200) - **user_id** (str) - The ID of the user - **email** (str) - The email of the user - **roles** (Array) - The roles assigned to the user #### Response Example ```json { "user_id": "user-123", "email": "user@example.com", "roles": ["viewer"] } ``` ``` -------------------------------- ### Check Cluster Connection Status Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Get the current connection status of a specified cluster. ```APIDOC ## GET /clusters/{id}/connection-status ### Description Get the connection status of a cluster. ### Method GET ### Endpoint `/clusters/{id}/connection-status` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the cluster. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) status = client.clusters.is_connected(id="cluster-123") print(f"Connected: {status.is_connected}") ``` ### Response #### Success Response (200) - **is_connected** (boolean) - True if the cluster is connected, false otherwise. #### Response Example ```json { "is_connected": true } ``` ``` -------------------------------- ### Invite User Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Invites a new user to the tenant by sending them an invitation email. ```APIDOC ## Invite User ### Description Invites a new user to the tenant by sending them an invitation email. ### Method POST ### Endpoint /users/invite ### Parameters #### Request Body - **accept_invite_client_url** (string) - Required - The URL the user should be redirected to after accepting the invite. - **email** (string) - Required - The email address of the user to invite. ### Request Example ```json { "accept_invite_client_url": "https://app.example.com/invite-accept", "email": "newuser@example.com" } ``` ### Response #### Success Response (200) - (No specific response body mentioned, typically indicates success) #### Response Example (Empty or success status indicator) ``` -------------------------------- ### Paginate User List with Truefoundry SDK Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/README.md Demonstrates how to use the `SyncPager` to paginate through a list of users returned by the TrueFoundry SDK. This allows for efficient retrieval of large datasets by processing them page by page. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.users.list( limit=10, offset=0, query="query", show_invalid_users=True, include_virtual_accounts="includeVirtualAccounts", ) for item in response: yield item ``` -------------------------------- ### Get Token for Virtual Account Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves an authentication token for a specific virtual account by its ID. ```APIDOC ## GET /virtual_accounts/{id}/token ### Description Get token for a virtual account by id. ### Method GET ### Endpoint /virtual_accounts/{id}/token ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the virtual account. #### Query Parameters - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```python client.virtual_accounts.get_token( id="id", ) ``` ### Response #### Success Response (200) - **token** (str) - The authentication token for the virtual account. #### Response Example ```json { "token": "your_virtual_account_token" } ``` ``` -------------------------------- ### Internal Deployments: Get Deployment Statuses Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves all statuses for a specific deployment within a given application. ```APIDOC ## GET /internal/deployments/{id}/statuses ### Description This endpoint returns all statuses for a specific deployment in a given application. ### Method GET ### Endpoint /internal/deployments/{id}/statuses ### Parameters #### Path Parameters - **id** (str) - Required - Application id of the application - **deployment_id** (str) - Required - Deployment id of the deployment #### Query Parameters - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) client.internal.deployments.get_deployment_statuses( id="id", deployment_id="deploymentId", ) ``` ### Response #### Success Response (200) - **[Response Fields]** (list[DeploymentStatus]) - A list of deployment statuses. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Create or Update Environment using TrueFoundry Python SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Creates or updates an environment with specified manifest details. Requires API key and base URL for client initialization. Supports configuration for color, production status, and optimization strategy. ```python from truefoundry_sdk import ( TrueFoundry, EnvironmentManifest, EnvironmentColor, EnvironmentOptimizeFor, ) client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) env = client.environments.create_or_update( manifest=EnvironmentManifest( name="production", color=EnvironmentColor(), is_production=True, optimize_for=EnvironmentOptimizeFor.COST, ), dry_run=False, ) ``` -------------------------------- ### Customize HTTP Client (Proxies, Transports) Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/README.md Demonstrates how to provide a custom `httpx.Client` instance to the TrueFoundry SDK. This allows for advanced configurations such as setting up proxies or custom network transports. ```python import httpx from truefoundry_sdk import TrueFoundry client = TrueFoundry( ..., httpx_client=httpx.Client( proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0"), ), ) ``` -------------------------------- ### GET /data_directories/{id}/files Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Lists files within a specific data directory. Supports pagination. ```APIDOC ## GET /data_directories/{id}/files ### Description List files in a dataset. ### Method GET ### Endpoint /data_directories/{id}/files ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the dataset. #### Query Parameters - **request_dto** (object) - Required - Request containing dataset ID, path, page token and limit. - **path** (str) - Optional - The path within the dataset to list files from. - **page_token** (str) - Optional - Token for paginating results. - **limit** (int) - Optional - Maximum number of files to return per page. #### Request Body - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.data_directories.list_files( id="id", ) for item in response: yield item ``` ### Response #### Success Response (200) - **ListFilesResponse** - Response containing files and pagination info. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### List Users with Filtering using TrueFoundry Python SDK Source: https://context7.com/truefoundry/truefoundry-python-sdk/llms.txt Lists all users within the tenant, supporting pagination and filtering by query string and a flag to show invalid users. Initializes the client with API key and base URL. ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.users.list( limit=10, offset=0, query="john", show_invalid_users=False, ) for user in response: print(f"User: {user.email}") ``` -------------------------------- ### GET /data_directories Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Lists all data directories. Supports filtering by ML repository ID, name, and pagination. ```APIDOC ## GET /data_directories ### Description Lists all data directories with optional filtering and pagination. ### Method GET ### Endpoint /data_directories ### Parameters #### Query Parameters - **fqn** (str) - Optional - Filter data directories by FQN. - **ml_repo_id** (str) - Optional - Filter data directories by ml repo ID. - **name** (str) - Optional - Filter data directories by name. - **limit** (int) - Optional - Maximum number of data directories to return. - **offset** (int) - Optional - Number of data directories to skip. #### Request Body - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```python from truefoundry_sdk import TrueFoundry client = TrueFoundry( api_key="YOUR_API_KEY", base_url="https://yourhost.com/path/to/api", ) response = client.data_directories.list( fqn="fqn", ml_repo_id="ml_repo_id", name="name", limit=1, offset=1, ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page ``` ### Response #### Success Response (200) - **ListDataDirectoriesResponse** - List of data directories and pagination info. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### GET /jobs/{job_id}/runs/{job_run_name} Source: https://github.com/truefoundry/truefoundry-python-sdk/blob/main/reference.md Retrieves a specific job run by its name and job ID. ```APIDOC ## GET /jobs/{job_id}/runs/{job_run_name} ### Description Retrieves a specific job run by its name and job ID. ### Method GET ### Endpoint /jobs/{job_id}/runs/{job_run_name} ### Parameters #### Path Parameters - **job_id** (str) - Required - Application Id of JOB - **job_run_name** (str) - Required - Job run name of the application #### Query Parameters - **request_options** (Optional[RequestOptions]) - Request-specific configuration. ### Response #### Success Response (200) - **job_run** (JobRun) - The requested job run details #### Response Example { "job_run": { "id": "run-123", "job_id": "job-abc", "status": "completed", "created_at": "2023-10-27T10:00:00Z" } } ```