connect.content
connect.content
Content resources.
Classes
Name | Description |
---|---|
Content | Content resource. |
ContentItem | |
ContentItemOAuth | |
ContentItemOwner | |
ContentItemRepository | Content items GitHub repository information. |
Content
connect.content.Content(self, params, *, owner_guid=None)
Content resource.
Parameters
Name | Type | Description | Default |
---|---|---|---|
config | Config |
Configuration object. | required |
session | Session |
Requests session object. | required |
owner_guid | str | Content item owner identifier. Filters results to those owned by a specific user (the default is None, which implies not filtering results on owner identifier). | None |
Attributes
Name | Description |
---|---|
owner_guid |
Methods
Name | Description |
---|---|
count | Count the number of content items. |
create | Create content. |
find | Find content matching the specified conditions. |
find_by | Find the first content record matching the specified attributes. |
find_one | Find first content result matching the specified conditions. |
get | Get a content item. |
count
connect.content.Content.count()
Count the number of content items.
Returns
Name | Type | Description |
---|---|---|
int |
create
connect.content.Content.create(**attrs)
Create content.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | URL-friendly identifier. Allows alphanumeric characters, hyphens (“-”), and underscores (“_“). | required |
title | str | Content title. Default is None. | required |
description | str | Content description. Default is None. | required |
access_type | Literal['all', 'acl', 'logged_in'] | How content manages viewers. Default is ‘acl’. Options: ‘all’, ‘logged_in’, ‘acl’. | required |
connection_timeout | int | Max seconds without data exchange. Default is None. Falls back to server setting ‘Scheduler.ConnectionTimeout’. | required |
read_timeout | int | Max seconds without data received. Default is None. Falls back to server setting ‘Scheduler.ReadTimeout’. | required |
init_timeout | int | Max startup time for interactive apps. Default is None. Falls back to server setting ‘Scheduler.InitTimeout’. | required |
idle_timeout | int | Max idle time before process termination. Default is None. Falls back to server setting ‘Scheduler.IdleTimeout’. | required |
max_processes | int | Max concurrent processes allowed. Default is None. Falls back to server setting ‘Scheduler.MaxProcesses’. | required |
min_processes | int | Min concurrent processes required. Default is None. Falls back to server setting ‘Scheduler.MinProcesses’. | required |
max_conns_per_process | int | Max client connections per process. Default is None. Falls back to server setting ‘Scheduler.MaxConnsPerProcess’. | required |
load_factor | float | Aggressiveness in spawning new processes (0.0 - 1.0). Default is None. Falls back to server setting ‘Scheduler.LoadFactor’. | required |
cpu_request | float | Min CPU units required (1 unit = 1 core). Default is None. Falls back to server setting ‘Scheduler.CPURequest’. | required |
cpu_limit | float | Max CPU units allowed. Default is None. Falls back to server setting ‘Scheduler.CPULimit’. | required |
memory_request | int | Min memory (bytes) required. Default is None. Falls back to server setting ‘Scheduler.MemoryRequest’. | required |
memory_limit | int | Max memory (bytes) allowed. Default is None. Falls back to server setting ‘Scheduler.MemoryLimit’. | required |
amd_gpu_limit | int | Number of AMD GPUs allocated. Default is None. Falls back to server setting ‘Scheduler.AMDGPULimit’. | required |
nvidia_gpu_limit | int | Number of NVIDIA GPUs allocated. Default is None. Falls back to server setting ‘Scheduler.NvidiaGPULimit’. | required |
run_as | str | UNIX user to execute the content. Default is None. Falls back to server setting ‘Applications.RunAs’. | required |
run_as_current_user | bool | Run process as the visiting user (for app content). Default is False. | required |
default_image_name | str | Default image for execution if not defined in the bundle. Default is None. | required |
default_r_environment_management | bool | Manage R environment for the content. Default is None. | required |
default_py_environment_management | bool | Manage Python environment for the content. Default is None. | required |
service_account_name | str | Kubernetes service account name for running content. Default is None. | required |
**attributes | Any | Additional attributes. | required |
Returns
Name | Type | Description |
---|---|---|
ContentItem |
find
connect.content.Content.find(include=None, **conditions)
Find content matching the specified conditions.
Returns
Name | Type | Description |
---|---|---|
List[ContentItem] |
find_by
connect.content.Content.find_by(**attrs)
Find the first content record matching the specified attributes.
There is no implied ordering so if order matters, you should find it yourself.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | URL-friendly identifier. Allows alphanumeric characters, hyphens (“-”), and underscores (“_“). | required |
title | str | Content title. Default is None | required |
description | str | Content description. | required |
access_type | Literal['all', 'acl', 'logged_in'] | How content manages viewers. | required |
owner_guid | str | The unique identifier of the user who owns this content item. | required |
connection_timeout | int | Max seconds without data exchange. | required |
read_timeout | int | Max seconds without data received. | required |
init_timeout | int | Max startup time for interactive apps. | required |
idle_timeout | int | Max idle time before process termination. | required |
max_processes | int | Max concurrent processes allowed. | required |
min_processes | int | Min concurrent processes required. | required |
max_conns_per_process | int | Max client connections per process. | required |
load_factor | float | Aggressiveness in spawning new processes (0.0 - 1.0). | required |
cpu_request | float | Min CPU units required (1 unit = 1 core). | required |
cpu_limit | float | Max CPU units allowed. | required |
memory_request | int | Min memory (bytes) required. | required |
memory_limit | int | Max memory (bytes) allowed. | required |
amd_gpu_limit | int | Number of AMD GPUs allocated. | required |
nvidia_gpu_limit | int | Number of NVIDIA GPUs allocated. | required |
run_as | str | UNIX user to execute the content. | required |
run_as_current_user | bool | Run process as the visiting user (for app content). Default is False. | required |
default_image_name | str | Default image for execution if not defined in the bundle. | required |
default_r_environment_management | bool | Manage R environment for the content. | required |
default_py_environment_management | bool | Manage Python environment for the content. | required |
service_account_name | str | Kubernetes service account name for running content. | required |
Returns
Name | Type | Description |
---|---|---|
Optional[ContentItem] |
Example
find_by(name=“example-content-name”)
find_one
connect.content.Content.find_one(**conditions)
Find first content result matching the specified conditions.
Returns
Name | Type | Description |
---|---|---|
Optional[ContentItem] |
get
connect.content.Content.get(guid)
Get a content item.
Parameters
Name | Type | Description | Default |
---|---|---|---|
guid | str | required |
Returns
Name | Type | Description |
---|---|---|
ContentItem |
ContentItem
connect.content.ContentItem(self, /, params, guid, **kwargs)
Attributes
Name | Description |
---|---|
bundles | |
environment_variables | |
is_interactive | |
is_rendered | |
oauth | |
owner | |
permissions | |
repository |
Methods
Name | Description |
---|---|
create_repository | Create repository. |
delete | Delete the content item. |
deploy | Deploy the content. |
render | Render the content. |
restart | Mark for restart. |
update | Update the content item. |
create_repository
connect.content.ContentItem.create_repository(**attrs)
Create repository.
Parameters
Name | Type | Description | Default |
---|---|---|---|
repository | str | URL for the respository. | required |
branch | str | The tracked Git branch. Default is ‘main’. | required |
directory | str | Directory containing the content. Default is ‘.’. | required |
polling | bool | Indicates that the Git repository is regularly polled. Default is False. | required |
Returns
Name | Type | Description |
---|---|---|
ContentItemRepository |
delete
connect.content.ContentItem.delete()
Delete the content item.
deploy
connect.content.ContentItem.deploy()
Deploy the content.
Spawns an asynchronous task, which activates the latest bundle.
Returns
Name | Type | Description |
---|---|---|
tasks.Task | The task for the deployment. |
Examples
>>> task = content.deploy()
>>> task.wait_for()
None
render
connect.content.ContentItem.render()
Render the content.
Submit a render request to the server for the content. After submission, the server executes an asynchronous process to render the content. This is useful when content is dependent on external information, such as a dataset.
See Also
restart
Examples
>>> render()
restart
connect.content.ContentItem.restart()
Mark for restart.
Sends a restart request to the server for the content. Once submitted, the server performs an asynchronous process to restart the content. This is particularly useful when the content relies on external information loaded into application memory, such as datasets. Additionally, restarting can help clear memory leaks or reduce excessive memory usage that might build up over time.
See Also
render
Examples
>>> restart()
update
connect.content.ContentItem.update(**attrs)
Update the content item.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name | str | URL-friendly identifier. Allows alphanumeric characters, hyphens (“-”), and underscores (“_“). | required |
title | str | Content title. Default is None. | required |
description | str | Content description. Default is None. | required |
access_type | Literal['all', 'acl', 'logged_in'] | How content manages viewers. Default is ‘acl’. Options: ‘all’, ‘logged_in’, ‘acl’. | required |
owner_guid | str | The unique identifier of the user who owns this content item. Default is None. | required |
connection_timeout | int | Max seconds without data exchange. Default is None. Falls back to server setting ‘Scheduler.ConnectionTimeout’. | required |
read_timeout | int | Max seconds without data received. Default is None. Falls back to server setting ‘Scheduler.ReadTimeout’. | required |
init_timeout | int | Max startup time for interactive apps. Default is None. Falls back to server setting ‘Scheduler.InitTimeout’. | required |
idle_timeout | int | Max idle time before process termination. Default is None. Falls back to server setting ‘Scheduler.IdleTimeout’. | required |
max_processes | int | Max concurrent processes allowed. Default is None. Falls back to server setting ‘Scheduler.MaxProcesses’. | required |
min_processes | int | Min concurrent processes required. Default is None. Falls back to server setting ‘Scheduler.MinProcesses’. | required |
max_conns_per_process | int | Max client connections per process. Default is None. Falls back to server setting ‘Scheduler.MaxConnsPerProcess’. | required |
load_factor | float | Aggressiveness in spawning new processes (0.0 - 1.0). Default is None. Falls back to server setting ‘Scheduler.LoadFactor’. | required |
cpu_request | float | Min CPU units required (1 unit = 1 core). Default is None. Falls back to server setting ‘Scheduler.CPURequest’. | required |
cpu_limit | float | Max CPU units allowed. Default is None. Falls back to server setting ‘Scheduler.CPULimit’. | required |
memory_request | int | Min memory (bytes) required. Default is None. Falls back to server setting ‘Scheduler.MemoryRequest’. | required |
memory_limit | int | Max memory (bytes) allowed. Default is None. Falls back to server setting ‘Scheduler.MemoryLimit’. | required |
amd_gpu_limit | int | Number of AMD GPUs allocated. Default is None. Falls back to server setting ‘Scheduler.AMDGPULimit’. | required |
nvidia_gpu_limit | int | Number of NVIDIA GPUs allocated. Default is None. Falls back to server setting ‘Scheduler.NvidiaGPULimit’. | required |
run_as | str | UNIX user to execute the content. Default is None. Falls back to server setting ‘Applications.RunAs’. | required |
run_as_current_user | bool | Run process as the visiting user (for app content). Default is False. | required |
default_image_name | str | Default image for execution if not defined in the bundle. Default is None. | required |
default_r_environment_management | bool | Manage R environment for the content. Default is None. | required |
default_py_environment_management | bool | Manage Python environment for the content. Default is None. | required |
service_account_name | str | Kubernetes service account name for running content. Default is None. | required |
Returns
Name | Type | Description |
---|---|---|
None |
ContentItemOAuth
connect.content.ContentItemOAuth(self, params, content_guid)
Attributes
Name | Description |
---|---|
associations |
ContentItemOwner
connect.content.ContentItemOwner(self, /, params, **kwargs)
ContentItemRepository
connect.content.ContentItemRepository(self, ctx, /, *, content_guid, **attrs)
Content items GitHub repository information.
See Also
- Get info: https://docs.posit.co/connect/api/#get-/v1/content/-guid-/repository
- Delete info: https://docs.posit.co/connect/api/#delete-/v1/content/-guid-/repository
- Update info: https://docs.posit.co/connect/api/#patch-/v1/content/-guid-/repository
Methods
Name | Description |
---|---|
destroy | Delete the content’s git repository location. |
update | Update the content’s repository. |
destroy
connect.content.ContentItemRepository.destroy()
Delete the content’s git repository location.
See Also
- https://docs.posit.co/connect/api/#delete-/v1/content/-guid-/repository
update
connect.content.ContentItemRepository.update(**attrs)
Update the content’s repository.
Parameters
Name | Type | Description | Default |
---|---|---|---|
repository | URL for the repository. Default is None. | required | |
branch | The tracked Git branch. Default is ‘main’. | required | |
directory | Directory containing the content. Default is ‘.’ | required | |
polling | Indicates that the Git repository is regularly polled. Default is False. | required |
Returns
Name | Type | Description |
---|---|---|
None |
See Also
- https://docs.posit.co/connect/api/#patch-/v1/content/-guid-/repository