### Quickstart Example with UserTokenAuth Source: https://github.com/palantir/foundry-platform-python/blob/develop/README.md A basic quickstart example demonstrating FoundryClient initialization using UserTokenAuth. Ensure you have followed the installation and chosen an appropriate authentication method. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # DatasetRid dataset_rid = None # BranchName name = "master" ``` -------------------------------- ### Install Foundry Platform SDK Source: https://context7.com/palantir/foundry-platform-python/llms.txt Install the SDK using pip. Optional extras are available for tabular data support with libraries like PyArrow, Pandas, Polars, or DuckDB. ```bash pip install foundry-platform-sdk # Optional extras for tabular data support pip install foundry-platform-sdk[pyarrow] pip install foundry-platform-sdk[pandas] pip install foundry-platform-sdk[polars] pip install foundry-platform-sdk[duckdb] ``` -------------------------------- ### Get User API Example Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Admin/User.md Shows how to retrieve a user's information by their ID, with an optional status filter. Includes error handling for API calls. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # UserId user_id = None # Optional[UserStatus] status = None try: api_response = client.admin.User.get(user_id, status=status) print("The get response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling User.get: %s\n" % e) ``` -------------------------------- ### Get Users in Batch API Example Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Admin/User.md Illustrates how to fetch multiple users efficiently by providing a list of user IDs and their statuses. Note the maximum batch size of 500. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # List[GetUsersBatchRequestElement] | Body of the request body = [{"userId": "0d1fe74e-2b70-4a93-9b1a-80070637788b", "status": "ACTIVE"}] try: api_response = client.admin.User.get_batch(body) print("The get_batch response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling User.get_batch: %s\n" % e) ``` -------------------------------- ### Install Foundry Platform SDK Source: https://github.com/palantir/foundry-platform-python/blob/develop/README.md Install the Foundry Platform SDK using pip. This is the primary method for adding the SDK to your Python environment. ```sh pip install foundry-platform-sdk ``` -------------------------------- ### Get Dataset Jobs Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Datasets/Dataset.md Retrieves the RIDs of the Jobs for a given dataset. By default, returned Jobs are sorted in descending order by the Job start time. ```APIDOC ## GET /datasets/Dataset/jobs ### Description Get the RIDs of the Jobs for the given dataset. By default, returned Jobs are sorted in descending order by the Job start time. ### Method GET ### Endpoint /datasets/Dataset/jobs ### Parameters #### Query Parameters - **dataset_rid** (DatasetRid) - Required - The unique identifier for the dataset. - **order_by** (List[GetDatasetJobsSort]) - Required - Specifies the sorting order for the jobs. - **branch_name** (Optional[BranchName]) - Optional - The name of the Branch. If none is provided, the default Branch name - `master` for most enrollments - will be used. - **page_size** (Optional[PageSize]) - Optional - Max number of results to return. A limit of 1000 on if no limit is supplied in the search request. - **page_token** (Optional[PageToken]) - Optional - Token for pagination. - **preview** (Optional[PreviewMode]) - Optional - Enables the use of preview functionality. - **where** (Optional[GetDatasetJobsQuery]) - Optional - Filters the jobs based on specified criteria. ### Return type **GetJobResponse** ### Authorization See [README](../../../README.md#authorization) ``` -------------------------------- ### Initialize Foundry Client and Set Parameters Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/OntologyInterface.md Sets up the FoundryClient with authentication and hostname, and defines parameters for querying ontology interfaces. Ensure you replace placeholder values with your actual credentials and identifiers. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # OntologyIdentifier | The API name of the ontology. To find the API name, use the **List ontologies** endpoint or check the **Ontology Manager**. ontology = "palantir" # InterfaceTypeApiName | The API name of the interface type. To find the API name, use the **List interface types** endpoint or check the **Ontology Manager** application. interface_type = "Employee" # ObjectTypeApiName | The API name of the object type. To find the API name, use the **List object types** endpoint or check the **Ontology Manager**. object_type = "employee" # PropertyValueEscapedString | The primary key of the object from which to **start** the interface link traversal. To look up the expected primary key for your object type, use the `Get object type` endpoint or the **Ontology Manager**. primary_key = None # InterfaceLinkTypeApiName | The API name of the outgoing interface link. To find the API name for your interface link type, check the **Ontology Manager** page for the parent interface. interface_link_type = "worksAt" # Optional[FoundryBranch] | The Foundry branch to get the outgoing link types for an object type from. If not specified, the default branch will be used. Branches are an experimental feature and not all workflows are supported. branch = None # Optional[bool] | A flag to exclude the retrieval of the `__rid` property. Setting this to true may improve performance of this endpoint for object types in OSV2. exclude_rid = None # Optional[OrderBy] order_by = None # Optional[PageSize] | The desired size of the page to be returned. Defaults to 1,000. See [page sizes](https://palantir.com/docs/foundry/api/general/overview/paging/#page-sizes) for details. page_size = None # Optional[PageToken] page_token = None # Optional[PreviewMode] | A boolean flag that, when set to true, enables the use of beta features in preview mode. preview = None ``` -------------------------------- ### Initialize Foundry Client and Search Objects Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/OntologyInterface.md Demonstrates how to initialize the FoundryClient and set up parameters for searching objects by interface type. Ensure you replace placeholder values with your actual credentials and desired parameters. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # OntologyIdentifier ontology = "palantir" # InterfaceTypeApiName | The API name of the interface type. To find the API name, use the **List interface types** endpoint or check the **Ontology Manager**. interface_type = "Employee" # Dict[InterfaceTypeApiName, List[InterfacePropertyApiName]] | A map from interface type API name to a list of interface property type API names. For each returned object, if the object implements an interface that is a key in the map, then we augment the response for that object type with the list of properties specified in the value. augmented_interface_property_types = None # Dict[ObjectTypeApiName, List[PropertyApiName]] | A map from object type API name to a list of property type API names. For each returned object, if the object’s object type is a key in the map, then we augment the response for that object type with the list of properties specified in the value. augmented_properties = None # Dict[InterfaceTypeApiName, List[SharedPropertyTypeApiName]] | A map from interface type API name to a list of shared property type API names. For each returned object, if the object implements an interface that is a key in the map, then we augment the response for that object type with the list of properties specified in the value. augmented_shared_property_types = None # List[InterfaceTypeApiName] | A list of interface type API names. Object types must implement all the mentioned interfaces in order to be included in the response. other_interface_types = None ``` -------------------------------- ### Replace Group Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Admin/Group.md Replaces an existing group with updated attributes. All attributes starting with `multipass:` must be sent exactly as they appear when calling the Get Group endpoint. ```APIDOC ## replace ### Description Replaces an existing group with updated attributes. All attributes starting with `multipass:` must be sent exactly as they appear when calling the Get Group endpoint. ### Method PUT ### Endpoint /api/v2/admin/groups/{group_id} ### Parameters #### Path Parameters - **group_id** (GroupId) - Required - The ID of the group to replace. #### Request Body - **attributes** (Dict[AttributeName, AttributeValues]) - Required - A map of the Group's attributes. Attributes prefixed with "multipass:" are reserved for internal use by Foundry and are subject to change. - **name** (GroupName) - Required - The name of the Group. - **organizations** (List[OrganizationRid]) - Required - The RIDs of the Organizations whose members can see this group. At least one Organization RID must be listed. - **description** (Optional[str]) - Optional - A description of the Group. ### Response #### Success Response (200) - **Group** - The replaced Group ### Response Example { "example": "{\"id\": \"group_id_1\", \"name\": \"Updated Group Name\", \"description\": \"Updated description\", \"organizations\": [\"org_rid_1\"], \"attributes\": {\"multipass:realm\": [\"eab0a251-ca1a-4a84-a482-200edfb8026f\"]}}" } ``` -------------------------------- ### Initialize FoundryClient from Environment Variables Source: https://context7.com/palantir/foundry-platform-python/llms.txt Initialize the FoundryClient using environment variables FOUNDRY_TOKEN and FOUNDRY_HOSTNAME. This is a convenient option for quick setup. ```python # Option 3: From environment variables FOUNDRY_TOKEN + FOUNDRY_HOSTNAME client = FoundryClient() ``` -------------------------------- ### Search Builds with Parameters Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Orchestration/Build.md Demonstrates how to search for builds using various parameters like filters, ordering, pagination, and preview mode. Handles potential PalantirRPCException errors. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # SearchBuildsFilter where = None # Optional[SearchBuildsOrderBy] order_by = {"fields": [{"field": "STARTED_TIME", "direction": "ASC"}]} # Optional[PageSize] | The page size for the search request. If no value is provided, a default of `100` will be used. page_size = 100 # Optional[PageToken] page_token = "v1.QnVpbGQgdGhlIEZ1dHVyZTogaHR0cHM6Ly93d3cucGFsYW50aXIuY29tL2NhcmVlcnMvP2xldmVyLXNvdXJjZSU1YiU1ZD1BUElEb2NzI29wZW4tcG9zaXRpb25z" # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: api_response = client.orchestration.Build.search( where=where, order_by=order_by, page_size=page_size, page_token=page_token, preview=preview ) print("The search response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Build.search: %s\n" % e) ``` -------------------------------- ### Get CBAC Marking Restrictions Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Admin/CbacMarkingRestrictions.md Retrieves disallowed, implied, and required markings for a given set of marking IDs. Use this method when you need to understand the constraints applied to specific markings within the system. Ensure you have the necessary authentication and client setup. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # Optional[List[MarkingId]] | The marking IDs for which to get restrictions. marking_ids = None # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: api_response = client.admin.CbacMarkingRestrictions.get( marking_ids=marking_ids, preview=preview ) print("The get response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling CbacMarkingRestrictions.get: %s\n" % e) ``` -------------------------------- ### Get Records from Stream Partition Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Streams/Stream.md Retrieves a batch of records from a specified partition within a stream. Binary field values are returned as base64-encoded strings. You can control the number of records, specify a starting offset, and optionally use preview mode or a specific view RID. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # DatasetRid dataset_rid = None # BranchName stream_branch_name = None ``` -------------------------------- ### create Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Models/ModelStudio.md Creates a new Model Studio with the specified name and parent folder. Optionally enables preview functionality. ```APIDOC ## POST /v2/models/modelStudios ### Description Creates a new Model Studio. ### Method POST ### Endpoint /v2/models/modelStudios ### Parameters #### Request Body - **name** (str) - Required - The name of the Model Studio. - **parent_folder_rid** (FolderRid) - Required - The RID of the parent folder where the studio will be created. - **preview** (Optional[PreviewMode]) - Optional - Enables the use of preview functionality. ### Response #### Success Response (200) - **ModelStudio** (ModelStudio) - The created ModelStudio ### Request Example ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # str | The name of the Model Studio. name = None # FolderRid | The RID of the parent folder where the studio will be created. parent_folder_rid = "ri.compass.main.folder.c410f510-2937-420e-8ea3-8c9bcb3c1791" # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: api_response = client.models.ModelStudio.create( name=name, parent_folder_rid=parent_folder_rid, preview=preview ) print("The create response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling ModelStudio.create: %s\n" % e) ``` ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Get Query Status Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/SqlQueries/SqlQuery.md Gets the status of a query. ```APIDOC ## get_status ### Description Gets the status of a query. ### Parameters Name | Type | Description | Notes | ------------- | ------------- | ------------- | ------------- | **sql_query_id** | SqlQueryId | The unique identifier for a query. Note that query IDs are not URL-safe and must be URL-encoded when used in API endpoints. | | ### Return type **QueryStatus** ``` -------------------------------- ### Launch a Model Studio training run Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Models/ModelStudio.md Initiate a training run for a Model Studio using its latest configuration. The preview mode can optionally be enabled. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # ModelStudioRid model_studio_rid = None # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: api_response = client.models.ModelStudio.launch(model_studio_rid, preview=preview) print("The launch response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling ModelStudio.launch: %s\n" % e) ``` -------------------------------- ### Project Create Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Filesystem/Project.md Creates a new project with specified configurations. ```APIDOC ## Project.create ### Description Creates a new project with specified configurations. ### Method POST ### Endpoint /v2/filesystem/projects ### Parameters #### Request Body - **default_roles** (List[RoleId]) - Optional - - **display_name** (str) - Required - - **organization_rids** (List[OrganizationRid]) - Optional - - **role_grants** (Dict[str, List[str]]) - Optional - - **space_rid** (SpaceRid) - Required - - **description** (str) - Optional - - **preview** (PreviewMode) - Optional - Enables the use of preview functionality. - **resource_level_role_grants_allowed** (Optional[bool]) - Optional - Whether role grants should be allowed on individual resources within the Project. When not specified, defaults to true. ### Request Example ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # List[RoleId] default_roles = ["8bf49052-dc37-4528-8bf0-b551cfb71268"] # str display_name = "My Project" # List[OrganizationRid] organization_rids = ["ri.multipass..organization.c30ee6ad-b5e4-4afe-a74f-fe4a289f2faa"] # Dict[str, List[str]] role_grants = { "role_name": ["user_rid"] } # SpaceRid space_rid = "ri.foundry.main.space.a1b2c3d4-e5f6-7890-1234-567890abcdef" # str description = "This is a sample project." # Optional[PreviewMode] preview = None # Optional[bool] resource_level_role_grants_allowed = None try: api_response = client.filesystem.Project.create( default_roles=default_roles, display_name=display_name, organization_rids=organization_rids, role_grants=role_grants, space_rid=space_rid, description=description, preview=preview, resource_level_role_grants_allowed=resource_level_role_grants_allowed, ) print("The create response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Project.create: %s\n" % e) ``` ### Response #### Success Response (200) - **Project** (Project) - #### Response Example { "example": "{\"rid\": \"ri.compass.main.project.abcdef12-3456-7890-abcd-ef1234567890\", \"displayName\": \"My Project\", \"description\": \"This is a sample project.\", \"spaceRid\": \"ri.foundry.main.space.a1b2c3d4-e5f6-7890-1234-567890abcdef\", \"organizationRids\": [\"ri.multipass..organization.c30ee6ad-b5e4-4afe-a74f-fe4a289f2faa\"], \"defaultRoles\": [\"8bf49052-dc37-4528-8bf0-b551cfb71268\"], \"createdAt\": \"2023-01-01T12:00:00Z\", \"modifiedAt\": \"2023-01-01T12:00:00Z\", \"resourceLevelRoleGrantsAllowed\": true}" } ``` -------------------------------- ### get Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/OntologyObjectSet.md Gets the definition of the ObjectSet with the given RID. ```APIDOC ## get ### Description Gets the definition of the `ObjectSet` with the given RID. ### Parameters #### Path Parameters - **ontology** (OntologyIdentifier) - Required - - **object_set_rid** (ObjectSetRid) - Required - The RID of the object set. ### Return type **ObjectSet** ### Authorization See [README](../../../README.md#authorization) ### HTTP response details | Status Code | Type | Description | Content Type | |-------------|-------------|-------------|------------------| **200** | ObjectSet | Success response. | application/json | ``` -------------------------------- ### List All Model Studio Configuration Versions Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Models/ModelStudioConfigVersion.md Lists all configuration versions for a given Model Studio, supporting pagination with page size and token. It iterates through the response and prints each version, also handling potential HTTP errors. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # ModelStudioRid model_studio_rid = None # Optional[PageSize] | The page size to use for the endpoint. page_size = None # Optional[PageToken] | The page token indicates where to start paging. This should be omitted from the first page's request. To fetch the next page, clients should take the value from the `nextPageToken` field of the previous response and use it to populate the `pageToken` field of the next request. page_token = None # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: for model_studio_config_version in client.models.ModelStudio.ConfigVersion.list( model_studio_rid, page_size=page_size, page_token=page_token, preview=preview ): pprint(model_studio_config_version) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling ConfigVersion.list: %s\n" % e) ``` -------------------------------- ### Timeseries Property Examples Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/models/PropertyValue.md Examples of JSON encoding for TimeseriesProperty objects or seriesId strings. ```json {"seriesId": "wellPressureSeriesId", "syncRid": ri.time-series-catalog.main.sync.04f5ac1f-91bf-44f9-a51f-4f34e06e42df"} ``` ```json {"templateRid": "ri.codex-emu.main.template.367cac64-e53b-4653-b111-f61856a63df9", "templateVersion": "0.0.0"} ``` ```string "wellPressureSeriesId" ``` -------------------------------- ### Initiate AIP Agent Session Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/AipAgents/Session.md Demonstrates how to initialize a FoundryClient and set up parameters for an agent session. Ensure you replace placeholder values with your actual Agent RID, Session RID, and other relevant inputs. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # AgentRid | An RID identifying an Agent created in [AIP Chatbot Studio](https://palantir.com/docs/foundry/chatbot-studio/overview/). agent_rid = "ri.aip-agents..agent.732cd5b4-7ca7-4219-aabb-6e976faf63b1" # SessionRid | The Resource Identifier (RID) of the conversation session. session_rid = "ri.aip-agents..session.292db3b2-b653-4de6-971c-7e97a7b881d6" # Dict[ParameterId, ParameterValue] | Any supplied values for [application variables](https://palantir.com/docs/foundry/chatbot-studio/application-state/) to pass to the Agent for the exchange. parameter_inputs = { "currentCustomerOrders": { "type": "objectSet", "ontology": "example-ontology", "objectSet": { "type": "filter", "objectSet": {"type": "base", "objectType": "customerOrder"}, "where": {"type": "eq", "field": "customerId", "value": "123abc"}, }, } } # UserTextInput | The user message for the Agent to respond to. user_input = {"text": "What is the status of my order?"} # Optional[List[InputContext]] | If set, automatic [context](https://palantir.com/docs/foundry/chatbot-studio/retrieval-context/) retrieval is skipped and the list of specified context is provided to the Agent instead. If omitted, relevant context for the user message is automatically retrieved and included in the prompt, based on data sources configured on the Agent for the session. contexts_override = None # Optional[MessageId] | A client-generated Universally Unique Identifier (UUID) to identify the message, which the client can use to cancel the exchange before the streaming response is complete. message_id = "00f8412a-c29d-4063-a417-8052825285a5" # Optional[PreviewMode] | Enables the use of preview functionality. preview = None ``` -------------------------------- ### Get Batch Jobs Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Orchestration/Job.md Executes multiple 'get' requests for Jobs in a single batch operation. ```APIDOC ## POST /v2/orchestration/jobs/getBatch ### Description Execute multiple get requests on Job. Users are allowed to make a maximum of 4 requests per second and 25 concurrent requests. The maximum batch size for this endpoint is 500. ### Method POST ### Endpoint /v2/orchestration/jobs/getBatch ### Parameters #### Request Body - **body** (List[GetJobsBatchRequestElement]) - Required - Body of the request #### Query Parameters - **preview** (Optional[PreviewMode]) - Optional - Enables the use of preview functionality. ### Response #### Success Response (200) - **GetJobsBatchResponse** (GetJobsBatchResponse) - Description of the batch response object. ### Authorization See [README](../../../README.md#authorization) ### HTTP response details | Status Code | Type | Description | Content Type | |-------------|-------------|-------------|------------------| **200** | GetJobsBatchResponse | | application/json | ``` -------------------------------- ### Streaming Query Execution with Foundry SDK Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Functions/Query.md Demonstrates how to execute a query using the streaming_execute method of the Foundry SDK. This example shows how to set up the client and call the function with various parameters, including branch and ontology. It also includes error handling for potential PalantirRPCExceptions. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # QueryApiName query_api_name = None # Dict[ParameterId, Optional[DataValue]] parameters = None # Optional[Attribution] attribution = None # Optional[FoundryBranch] | The Foundry branch to execute the query from. If not specified, the default branch is used. When provided without `version`, the latest version on this branch is used. When provided with `version`, the specified version must exist on the branch. branch = "ri.branch..branch.d827184f-ee0e-4351-8b70-efbe51e07252" # Optional[OntologyIdentifier] | Optional ontology identifier (RID or API name). When provided, executes an ontology-scoped function. When omitted, executes a global function. ontology = "example-ontology" # Optional[PreviewMode] | Enables the use of preview functionality. preview = None # Optional[TraceParent] trace_parent = None # Optional[TraceState] trace_state = None # Optional[TransactionId] | The ID of a transaction to read from. Transactions are an experimental feature and all workflows may not be supported. transaction_id = None # Optional[FunctionVersion] | The version of the query to execute. When used with `branch`, the specified version must exist on the branch. version = None try: api_response = client.functions.Query.streaming_execute( query_api_name, parameters=parameters, attribution=attribution, branch=branch, ontology=ontology, preview=preview, trace_parent=trace_parent, trace_state=trace_state, transaction_id=transaction_id, version=version, ) print("The streaming_execute response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Query.streaming_execute: %s\n" % e) ``` -------------------------------- ### Configure FoundryClient with Custom HTTP Session Settings Source: https://github.com/palantir/foundry-platform-python/blob/develop/README.md Shows how to initialize the `FoundryClient` with custom HTTP session configurations, including default headers, timeout, and proxies. Requires importing `Config`, `UserTokenAuth`, and `FoundryClient`. ```python from foundry_sdk import Config from foundry_sdk import UserTokenAuth from foundry_sdk import FoundryClient client = FoundryClient( auth=UserTokenAuth(...), hostname="example.palantirfoundry.com", config=Config( # Set the default headers for every request default_headers={"Foo": "Bar"}, # Default to a 60 second timeout timeout=60, # Create a proxy for the https protocol proxies={"https": "https://10.10.1.10:1080"}, ), ) ``` -------------------------------- ### Get Build Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Orchestration/Build.md Get the Build with the specified rid. Users are allowed to make a maximum of 4 requests per second and 25 concurrent requests. ```APIDOC ## GET /v2/orchestration/builds/{buildRid} ### Description Get the Build with the specified rid. Users are allowed to make a maximum of **4 requests per second** and **25 concurrent requests**. ### Method GET ### Endpoint /v2/orchestration/builds/{buildRid} ### Parameters #### Path Parameters - **buildRid** (BuildRid) - Required - The RID of a Build. ### Response #### Success Response (200) - **Build** (Build) - ### Authorization See [README](../../../README.md#authorization) ### HTTP response details | Status Code | Type | Description | Content Type | |-------------|-------------|-------------|------------------| **200** | Build | | application/json | ``` -------------------------------- ### Get Media Metadata Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/MediaReferenceProperty.md Retrieves metadata for a media reference associated with an object. Use this to get information about an existing media item linked to an ontology object. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # ObjectTypeApiName | The API name of the object type. To find the API name, use the **List object types** endpoint or check the **Ontology Manager**. object_type = "employee" # PropertyValueEscapedString | The primary key of the object with the media reference property. primary_key = 50030 # PropertyApiName | The API name of the media reference backed property. To find the API name, check the **Ontology Manager** or use the **Get object type** endpoint. property = None # Optional[PreviewMode] | A boolean flag that, when set to true, enables the use of beta features in preview mode. preview = None # Optional[SdkPackageRid] | The package rid of the generated SDK. sdk_package_rid = None # Optional[SdkVersion] | The version of the generated SDK. sdk_version = None try: api_response = client.ontologies.MediaReferenceProperty.get_media_metadata( ontology, object_type, primary_key, property, preview=preview, sdk_package_rid=sdk_package_rid, sdk_version=sdk_version, ) print("The get_media_metadata response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling MediaReferenceProperty.get_media_metadata: %s\n" % e) ``` -------------------------------- ### Create a Project using Foundry SDK Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Filesystem/Project.md Use this method to create a new project. Ensure the FoundryClient is initialized with appropriate authentication and hostname. The `resource_level_role_grants_allowed` parameter is optional and defaults to true if not specified. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # Optional[bool] | Whether role grants should be allowed on individual resources within the Project. When not specified, defaults to true. resource_level_role_grants_allowed = None try: api_response = client.filesystem.Project.create( default_roles=default_roles, display_name=display_name, organization_rids=organization_rids, role_grants=role_grants, space_rid=space_rid, description=description, preview=preview, resource_level_role_grants_allowed=resource_level_role_grants_allowed, ) print("The create response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Project.create: %s\n" % e) ``` -------------------------------- ### Installing Data Frame Dependencies Source: https://github.com/palantir/foundry-platform-python/blob/develop/README.md Install optional dependencies for data frame integration using pip. Choose the specific package for the library you intend to use. ```bash # For pyarrow support pip install foundry-platform-sdk[pyarrow] # For pandas support pip install foundry-platform-sdk[pandas] # For polars support pip install foundry-platform-sdk[polars] # For duckdb support pip install foundry-platform-sdk[duckdb] ``` -------------------------------- ### Create Live Deployment Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Models/LiveDeployment.md Use this to create a new live deployment for a model version. Specify the target model and runtime configuration. Ensure you have the necessary authentication and hostname configured. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # CreateLiveDeploymentTarget | The target model source for the live deployment. Determines which model and version selection strategy to use when creating the deployment. deployment_type = None # LiveDeploymentRuntimeConfiguration | The compute resource configuration for the deployment. runtime_configuration = { "minReplicas": 1, "maxReplicas": 3, "cpu": 1.0, "memory": "256MiB", "threadCount": 32, } # Optional[PreviewMode] | Enables the use of preview functionality. preview = None try: api_response = client.models.LiveDeployment.create( deployment_type=deployment_type, runtime_configuration=runtime_configuration, preview=preview, ) print("The create response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling LiveDeployment.create: %s\n" % e) ``` -------------------------------- ### Get File Import Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Connectivity/FileImport.md Retrieves a specific file import by its RID. Use this to get details about a particular file import. Requires connection and file import RIDs. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # ConnectionRid connection_rid = None # FileImportRid file_import_rid = None try: api_response = client.connectivity.Connection.FileImport.get(connection_rid, file_import_rid) print("The get response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling FileImport.get: %s\n" % e) ``` -------------------------------- ### Apply Action with Overrides - Python Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/Action.md Demonstrates how to apply an action to an ontology using the `apply_with_overrides` method. This includes setting up the Foundry client, specifying the ontology and action, defining overrides, and constructing the request payload. It also shows basic error handling for `PalantirRPCException`. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # OntologyIdentifier ontology = "palantir" # ActionTypeApiName | The API name of the action to apply. To find the API name for your action, use the **List action types** endpoint or check the **Ontology Manager**. action = "rename-employee" # ApplyActionOverrides overrides = { "uniqueIdentifierLinkIdValues": { "fd28fa5c-3028-4eca-bdc8-3be2c7949cd9": "4efdb11f-c1e3-417c-89fb-2225118b65e3" }, "actionExecutionTime": "2025-10-25T13:00:00Z", } # ApplyActionRequestV2 request = {"parameters": {"id": 80060, "newName": "Anna Smith-Doe"}} # Optional[FoundryBranch] | The Foundry branch to apply the action against. If not specified, the default branch is used. Branches are an experimental feature and not all workflows are supported. branch = None # Optional[SdkPackageRid] | The package rid of the generated SDK. sdk_package_rid = None # Optional[SdkVersion] | The version of the generated SDK. sdk_version = None # Optional[OntologyTransactionId] | The ID of an Ontology transaction to apply the action against. Transactions are an experimental feature and all workflows may not be supported. transaction_id = None try: api_response = client.ontologies.Action.apply_with_overrides( ontology, action, overrides=overrides, request=request, branch=branch, sdk_package_rid=sdk_package_rid, sdk_version=sdk_version, transaction_id=transaction_id, ) print("The apply_with_overrides response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Action.apply_with_overrides: %s\n" % e) ``` -------------------------------- ### List All Configuration Versions Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Models/ModelStudioConfigVersion.md Lists all configuration versions for a specified Model Studio. Supports pagination and enabling preview functionality. ```APIDOC ## list Model Studio Configuration Versions ### Description Lists all configuration versions for a Model Studio. This endpoint allows you to retrieve a paginated list of all configuration versions associated with a Model Studio, with options for controlling page size and enabling preview features. ### Method GET ### Endpoint /models/v2/model_studios/{model_studio_rid}/config_versions ### Parameters #### Path Parameters - **model_studio_rid** (ModelStudioRid) - Required - The unique identifier for the Model Studio. #### Query Parameters - **page_size** (Optional[PageSize]) - Optional - The page size to use for the endpoint. Defaults to a system-defined value. - **page_token** (Optional[PageToken]) - Optional - The page token indicates where to start paging. This should be omitted from the first page's request. To fetch the next page, clients should take the value from the `nextPageToken` field of the previous response and use it to populate the `pageToken` field of the next request. - **preview** (Optional[PreviewMode]) - Optional - Enables the use of preview functionality. ### Response #### Success Response (200) - **ListModelStudioConfigVersionsResponse** - A response object containing a list of configuration versions and a potential next page token. ### Authorization See [README](../../../README.md#authorization) ### HTTP response details | Status Code | Type | Description | Content Type | |-------------|-------------|-------------|------------------| **200** | ListModelStudioConfigVersionsResponse | | application/json | ``` -------------------------------- ### Create a Build Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Orchestration/Build.md Initiates a new build with specified targets and optional configurations. This method allows setting fallback branches, retry policies, and notification preferences. Ensure all required parameters like `fallback_branches` and `target` are correctly provided. ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # FallbackBranches fallback_branches = [] # BuildTarget | The targets of the schedule. target = { "type": "manual", "targetRids": [ "ri.foundry.main.dataset.4263bdd9-d6bc-4244-9cca-893c1a2aef62", "ri.foundry.main.dataset.86939c1e-4256-41db-9fe7-e7ee9e0f752a", ], } # Optional[AbortOnFailure] abort_on_failure = False # Optional[BranchName] | The target branch the build should run on. branch_name = "master" # Optional[ForceBuild] force_build = None # Optional[NotificationsEnabled] notifications_enabled = None # Optional[RetryBackoffDuration] retry_backoff_duration = {"unit": "SECONDS", "value": 30} # Optional[RetryCount] | The number of retry attempts for failed jobs. retry_count = 1 try: api_response = client.orchestration.Build.create( fallback_branches=fallback_branches, target=target, abort_on_failure=abort_on_failure, branch_name=branch_name, force_build=force_build, notifications_enabled=notifications_enabled, retry_backoff_duration=retry_backoff_duration, retry_count=retry_count, ) print("The create response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling Build.create: %s\n" % e) ``` -------------------------------- ### Get Last Point Source: https://github.com/palantir/foundry-platform-python/blob/develop/docs/v2/Ontologies/TimeSeriesPropertyV2.md Retrieves the last recorded point for a specified time series property of an object. This is useful for getting the most recent data point without fetching the entire series. ```APIDOC ## get_last_point ### Description Retrieves the last point of a time series property. ### Method client.ontologies.TimeSeriesPropertyV2.get_last_point ### Parameters #### Path Parameters - **ontology** (OntologyIdentifier) - Required - The ontology name. - **object_type** (ObjectTypeApiName) - Required - The API name of the object type. - **primary_key** (PropertyValueEscapedString) - Required - The primary key of the object with the time series property. - **property** (PropertyApiName) - Required - The API name of the time series property. #### Query Parameters - **sdk_package_rid** (Optional[SdkPackageRid]) - Optional - The package rid of the generated SDK. - **sdk_version** (Optional[SdkVersion]) - Optional - The version of the generated SDK. ### Response #### Success Response (200) - **Optional[TimeSeriesPoint]** - Success response. ### Request Example ```python from foundry_sdk import FoundryClient import foundry_sdk from pprint import pprint client = FoundryClient(auth=foundry_sdk.UserTokenAuth(...), hostname="example.palantirfoundry.com") # OntologyIdentifier ontology = "palantir" # ObjectTypeApiName | The API name of the object type. To find the API name, use the **List object types** endpoint or check the **Ontology Manager**. object_type = "employee" # PropertyValueEscapedString | The primary key of the object with the time series property. primary_key = 50030 # PropertyApiName | The API name of the time series property. To find the API name for your time series property, check the **Ontology Manager** or use the **Get object type** endpoint. property = "performance" # Optional[SdkPackageRid] | The package rid of the generated SDK. sdk_package_rid = None # Optional[SdkVersion] | The version of the generated SDK. sdk_version = None try: api_response = client.ontologies.TimeSeriesPropertyV2.get_last_point( ontology, object_type, primary_key, property, sdk_package_rid=sdk_package_rid, sdk_version=sdk_version, ) print("The get_last_point response:\n") pprint(api_response) except foundry_sdk.PalantirRPCException as e: print("HTTP error when calling TimeSeriesPropertyV2.get_last_point: %s\n" % e) ``` ```