Skip to content
module

rsconnect.api

RStudio Connect API client and utility functions

Classes
  • RSConnectException Common base class for all non-exit exceptions.</>
  • RSConnectServer A simple class to encapsulate the information needed to interact with an instance of the Connect server.</>
  • RSConnect This class provides the means to simply and directly invoke HTTP requests against a server.</>
Functions
  • do_bundle_deploy(connect_server, app_id, name, title, title_is_default, bundle) Deploys the specified bundle.</>
  • emit_task_log(connect_server, app_id, task_id, log_callback, timeout) Helper for spooling the deployment log for an app.</>
  • find_unique_name(connect_server, name) Poll through existing apps to see if anything with a similar name exists. If so, start appending numbers until a unique name is found.</>
  • get_app_config(connect_server, app_id) Return the configuration information for an application that has been created in Connect.</>
  • get_app_info(connect_server, app_id) Return information about an application that has been created in Connect.</>
  • get_python_info(connect_server) Return information about versions of Python that are installed on the indicated Connect server.</>
  • override_title_search(connect_server, app_id, app_title) Returns a list of abbreviated app data that contains apps with a title that matches the given one and/or the specific app noted by its ID.</>
  • retrieve_matching_apps(connect_server, filters, limit, mapping_function) Retrieves all the app names that start with the given default name. The main point for this function is that it handles all the necessary paging logic.</>
  • verify_api_key(connect_server) Verify that an API Key may be used to authenticate with the given RStudio Connect server. If the API key verifies, we return the username of the associated user.</>
  • verify_server(connect_server) Verify that the given server information represents a Connect instance that is reachable, active and appears to be actually running RStudio Connect. If the check is successful, the server settings for the Connect server is returned.</>
class

rsconnect.api.RSConnectException(message)

Bases
Exception BaseException

Common base class for all non-exit exceptions.

class

rsconnect.api.RSConnectServer(url, api_key, insecure=False, ca_data=None)

A simple class to encapsulate the information needed to interact with an instance of the Connect server.

class

rsconnect.api.RSConnect(server, cookies=None, timeout=30)

This class provides the means to simply and directly invoke HTTP requests against a server.

Methods
  • output_task_log(task_status, last_status, log_callback) Pipe any new output through the log_callback.</>
staticmethod

output_task_log(task_status, last_status, log_callback)

Pipe any new output through the log_callback.

Returns an updated last_status which should be passed into the next call to output_task_log.

Raises RSConnectException on task failure.

function

rsconnect.api.verify_server(connect_server)

Verify that the given server information represents a Connect instance that is reachable, active and appears to be actually running RStudio Connect. If the check is successful, the server settings for the Connect server is returned.

:param connect_server: the Connect server information. :return: the server settings from the Connect server.

function

rsconnect.api.verify_api_key(connect_server)

Verify that an API Key may be used to authenticate with the given RStudio Connect server. If the API key verifies, we return the username of the associated user.

:param connect_server: the Connect server information, including the API key to test. :return: the username of the user to whom the API key belongs.

function

rsconnect.api.get_python_info(connect_server)

Return information about versions of Python that are installed on the indicated Connect server.

:param connect_server: the Connect server information. :return: the Python installation information from Connect.

function

rsconnect.api.get_app_info(connect_server, app_id)

Return information about an application that has been created in Connect.

:param connect_server: the Connect server information. :param app_id: the ID (numeric or GUID) of the application to get info for. :return: the Python installation information from Connect.

function

rsconnect.api.get_app_config(connect_server, app_id)

Return the configuration information for an application that has been created in Connect.

:param connect_server: the Connect server information. :param app_id: the ID (numeric or GUID) of the application to get the info for. :return: the Python installation information from Connect.

function

rsconnect.api.do_bundle_deploy(connect_server, app_id, name, title, title_is_default, bundle)

Deploys the specified bundle.

:param connect_server: the Connect server information. :param app_id: the ID of the app to deploy, if this is a redeploy. :param name: the name for the deploy. :param title: the title for the deploy. :param title_is_default: a flag noting whether the title carries a defaulted value. :param bundle: the bundle to deploy. :return: application information about the deploy. This includes the ID of the task that may be queried for deployment progress.

function

rsconnect.api.emit_task_log(connect_server, app_id, task_id, log_callback, timeout=None)

Helper for spooling the deployment log for an app.

:param connect_server: the Connect server information. :param app_id: the ID of the app that was deployed. :param task_id: the ID of the task that is tracking the deployment of the app.. :param log_callback: the callback to use to write the log to. If this is None (the default) the lines from the deployment log will be returned as a sequence. If a log callback is provided, then None will be returned for the log lines part of the return tuple. :param timeout: an optional timeout for the wait operation. :return: the ultimate URL where the deployed app may be accessed and the sequence of log lines. The log lines value will be None if a log callback was provided.

function

rsconnect.api.retrieve_matching_apps(connect_server, filters=None, limit=None, mapping_function=None)

Retrieves all the app names that start with the given default name. The main point for this function is that it handles all the necessary paging logic.

If a mapping function is provided, it must be a callable that accepts 2 arguments. The first will be an RSConnect client, in the event extra calls per app are required. The second will be the current app. If the function returns None, then the app will be discarded and not appear in the result.

:param connect_server: the Connect server information. :param filters: the filters to use for isolating the set of desired apps. :param limit: the maximum number of apps to retrieve. If this is None, then all matching apps are returned. :param mapping_function: an optional function that may transform or filter each app to return to something the caller wants. :return: the list of existing names that start with the proposed one.

function

rsconnect.api.find_unique_name(connect_server, name)

Poll through existing apps to see if anything with a similar name exists. If so, start appending numbers until a unique name is found.

:param connect_server: the Connect server information. :param name: the default name for an app. :return: the name, potentially with a suffixed number to guarantee uniqueness.