# Custom Application Sources
URL: https://docs.datarobot.com/en/docs/api/reference/sdk/custom-application-sources.html

# Custom Application Sources

### class datarobot.CustomApplicationSource

A DataRobot custom application source that serves as a template for creating custom applications.

Custom application sources define the code, configuration, and resource requirements
used when creating custom applications. They can have resource configurations
that determine the default resource allocation for applications created from this source.

- Variables:

> [!NOTE] Notes
> Resource configuration is stored in the latest_version field and can be accessed
> via the get_resources() method.

#### classmethod list(offset=None, limit=None)

Retrieve a list of custom application sources.

- Parameters:
- Returns: sources – The requested list of custom application sources.
- Return type: List[CustomApplicationSource]

#### classmethod get(source_id)

Retrieve a single custom application source with full details.

- Parameters: source_id ( str ) – The ID of the custom application source to retrieve.
- Returns: source – The requested custom application source.
- Return type: CustomApplicationSource

#### classmethod create(name)

Create a new custom application source.

- Parameters: name ( str ) – The name for the new custom application source.
- Returns: source – The newly created custom application source.
- Return type: CustomApplicationSource

#### update(name=None)

Update this custom application source.

- Parameters: name ( Optional[str] ) – New name for the source. If None, name will not be changed.
- Returns: source – The updated custom application source.
- Return type: CustomApplicationSource

#### delete(hard_delete=False)

Delete this custom application source.

- Parameters: hard_delete ( bool , optional ) – If True, permanently delete the source and all its data.
  If False (default), soft delete the source (can be recovered).
- Return type: None

#### NOTE

Deleting a source will affect all its versions. Applications created from this
source will continue to run but cannot be recreated from the source.

> [!NOTE] Examples
> ```
> from datarobot import CustomApplicationSource
> 
> source = CustomApplicationSource.get("source_id")
> source.delete()  # Soft delete
> source.delete(hard_delete=True)  # Permanent delete
> ```

#### get_resources()

Get resource configuration for applications created from this source.

- Returns: resources – Resource configuration including replicas, resource bundle, and other settings.
  Returns None if no resources are configured.
- Return type: Optional[Dict[str , Any]]

#### get_resource_summary()

Get a human-readable summary of resource configuration.

- Returns: summary – A summary of resource configuration with readable descriptions.
  Returns None if no resources are configured.
- Return type: Optional[Dict[str , Any]]

#### property has_resources_configured : bool

Check if this source has resource configuration.

- Returns: True if resources are configured, False otherwise.
- Return type: bool

#### get_details()

Get comprehensive details about this custom application source.

- Returns: details – Comprehensive source details including metadata, version info, and resources.
- Return type: Dict[str , Any]

#### classmethod get_by_name(name)

Find a custom application source by name.

- Parameters: name ( str ) – The name of the custom application source to find.
- Returns: source – The custom application source if found, None otherwise.
- Return type: Optional[CustomApplicationSource]

#### create_application(name, resources=None, environment_id=None)

Create a Custom Application from this source.

- Parameters:
- Returns: application – The newly created Custom Application.
- Return type: CustomApplication

> [!NOTE] Examples
> ```
> from datarobot import CustomApplicationSource
> 
> source = CustomApplicationSource.get("source_id")
> 
> # Create with default settings
> app1 = source.create_application("My App")
> 
> # Create with custom resources and environment
> app2 = source.create_application(
>     "My App",
>     resources={"replicas": 2, "resourceLabel": "cpu.large"},
>     environment_id="env_id_123"
> )
> ```

#### get_versions()

Get all versions of this custom application source.

- Returns: versions – List of version information for this source.
- Return type: List[Dict[str , Any]]

#### get_version(version_id)

Get details of a specific version of this source.

- Parameters: version_id ( str ) – The ID of the version to retrieve.
- Returns: version – Version details including files, environment, and configuration.
- Return type: Dict[str , Any]

#### update_resources(resource_label=None, replicas=None, session_affinity=None, service_web_requests_on_root_path=None)

Update resource configuration for this source.

- Parameters:
- Returns: source – The updated custom application source.
- Return type: CustomApplicationSource

#### get_file(version_id, item_id)

Retrieve a specific file from a version of this custom application source.

- Parameters:
- Returns: file_data – The file information and content as a JSON object.
- Return type: Dict[str , Any]

> [!NOTE] Examples
> ```
> from datarobot import CustomApplicationSource
> 
> source = CustomApplicationSource.get("source_id")
> 
> # Get the latest version
> versions = source.get_versions()
> version_id = versions[0]["id"]
> 
> # Get a file from that version
> version_info = source.get_version(version_id)
> item_id = version_info["items"][0]["id"]
> file_data = source.get_file(version_id, item_id)
> 
> print(f"File name: {file_data.get('fileName', 'Unknown')}")
> if 'content' in file_data:
>     print(f"Content: {file_data['content']}")
> ```

---
