Skip to content
module

rsconnect.metadata

Metadata management objects and utility functions

Classes
  • DataStore Defines a base class for a persistent store. The store supports a primary location and an optional secondary one.</>
  • ServerStore Defines a metadata store for server information.</>
  • AppStore Defines a metadata store for information about where the app has been deployed. Each instance of this store represents one application as represented by its entry point file.</>
Functions
  • config_dirname(platform, env) Get the user's configuration directory path for this platform.</>
  • makedirs(filepath) Create the parent directories of filepath.</>
function

rsconnect.metadata.config_dirname(platform='linux', env=environ({'PATH': '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOSTNAME': 'cefa3a44761f', 'PYTHONPATH': '/rsconnect_python', 'VERSION': '1.6.0', 'LANG': 'C.UTF-8', 'GPG_KEY': 'E3FF2839C048B25C084DEBE9B26995E310250568', 'PYTHON_VERSION': '3.8.11', 'PYTHON_PIP_VERSION': '21.2.4', 'PYTHON_GET_PIP_URL': 'https://github.com/pypa/get-pip/raw/c20b0cfd643cd4a19246ccf204e2997af70f6b21/public/get-pip.py', 'PYTHON_GET_PIP_SHA256': 'fa6f3fb93cce234cd4e8dd2beb54a51ab9c247653b52855a48dd44e6b21ff28b', 'LC_ALL': 'C.UTF-8', 'HOME': '/'}))

Get the user's configuration directory path for this platform.

function

rsconnect.metadata.makedirs(filepath)

Create the parent directories of filepath.

filepath itself is not created. It is not an error if the directories already exist.

class

rsconnect.metadata.DataStore(primary_path, secondary_path=None, chmod=False)

Defines a base class for a persistent store. The store supports a primary location and an optional secondary one.

Methods
  • count() Return the number of items in the data store.</>
  • load() Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.</>
  • save(open) Save our data to a file.</>
  • save_to(path, data, open) Save our data to the specified file.</>
method

count()

Return the number of items in the data store.

:return: the number of items currently in the data store.

method

load()

Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.

method

save_to(path, data, open=<built-in function open>)

Save our data to the specified file.

method

save(open=<built-in function open>)

Save our data to a file.

The app directory is tried first. If that fails, then we write to the global config location.

class

rsconnect.metadata.ServerStore(base_dir='/.rsconnect-python')

Defines a metadata store for server information.

Servers consist of a user-supplied name, URL, and API key. Data is stored in the customary platform-specific location (typically a subdirectory of the user's home directory).

Methods
  • count() Return the number of items in the data store.</>
  • get_all_servers() Returns a list of all known servers sorted by nickname.</>
  • get_by_name(name) Get the server information for the given nickname..</>
  • get_by_url(url) Get the server information for the given URL..</>
  • load() Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.</>
  • remove_by_name(name) Remove the server information for the given nickname.</>
  • remove_by_url(url) Remove the server information for the given URL..</>
  • resolve(name, url, api_key, insecure, ca_data) This function will resolve the given inputs into a set of server information. It assumes that either name or url is provided.</>
  • save(open) Save our data to a file.</>
  • save_to(path, data, open) Save our data to the specified file.</>
  • set(name, url, api_key, insecure, ca_data) Add (or update) information about a Connect server</>
method

count()

Return the number of items in the data store.

:return: the number of items currently in the data store.

method

load()

Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.

method

save_to(path, data, open=<built-in function open>)

Save our data to the specified file.

method

save(open=<built-in function open>)

Save our data to a file.

The app directory is tried first. If that fails, then we write to the global config location.

method

get_by_name(name)

Get the server information for the given nickname..

:param name: the nickname of the server to get information for.

method

get_by_url(url)

Get the server information for the given URL..

:param url: the Connect URL of the server to get information for.

method

get_all_servers()

Returns a list of all known servers sorted by nickname.

:return: the sorted list of known servers.

method

set(name, url, api_key, insecure=False, ca_data=None)

Add (or update) information about a Connect server

:param name: the nickname for the Connect server. :param url: the full URL for the Connect server. :param apikey: the API key to use to authenticate with the Connect server. :param insecure: a flag to disable TLS verification. :param ca_data: client side certificate data to use for TLS.

method

remove_by_name(name)

Remove the server information for the given nickname.

:param name: the nickname of the server to remove.

method

remove_by_url(url)

Remove the server information for the given URL..

:param url: the Connect URL of the server to remove.

method

resolve(name, url, api_key, insecure, ca_data)

This function will resolve the given inputs into a set of server information. It assumes that either name or url is provided.

If name is provided, the server information is looked up by its nickname and an error is produced if the nickname is not known.

If url is provided, the server information is looked up by its URL. If that is found, the stored information is returned. Otherwise the corresponding arguments are returned as-is.

If neither 'name' nor 'url' is provided and there is only one stored server, that information is returned. In this case, the last value in the tuple returned notes this situation. It is False in all other cases.

:param name: the nickname to look for. :param url: the Connect server URL to look for. :param apikey: the API key provided on the command line. :param insecure: the insecure flag provided on the command line. :param ca_data: the CA certification data provided on the command line. :return: the information needed to interact with the resolved server and whether it came from the store or the arguments.

class

rsconnect.metadata.AppStore(app_file)

Defines a metadata store for information about where the app has been deployed. Each instance of this store represents one application as represented by its entry point file.

Metadata for an app consists of one entry for each server where it was deployed, containing:

  • Server URL
  • Entry point file name
  • App URL
  • App ID
  • App GUID
  • Title
  • App mode

The metadata file for an app is written in the same directory as the app's entry point file, if that directory is writable. Otherwise, it is stored in the user's config directory under applications/{hash}.json where the hash is derived from the entry point file name.

Methods
  • count() Return the number of items in the data store.</>
  • get(server_url) Get the metadata for the last app deployed to the given server.</>
  • get_all() Get all metadata for this app.</>
  • load() Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.</>
  • save(open) Save our data to a file.</>
  • save_to(path, data, open) Save our data to the specified file.</>
  • set(server_url, filename, app_url, app_id, app_guid, title, app_mode) Remember the metadata for the app last deployed to the specified server.</>
method

count()

Return the number of items in the data store.

:return: the number of items currently in the data store.

method

load()

Load the data from a file. If the primary file doesn't exist, load it from the secondary one (if there is one.

method

save_to(path, data, open=<built-in function open>)

Save our data to the specified file.

method

save(open=<built-in function open>)

Save our data to a file.

The app directory is tried first. If that fails, then we write to the global config location.

method

get(server_url)

Get the metadata for the last app deployed to the given server.

:param server_url: the Connect URL to get the metadata for.

method

get_all()

Get all metadata for this app.

method

set(server_url, filename, app_url, app_id, app_guid, title, app_mode)

Remember the metadata for the app last deployed to the specified server.

:param server_url: the URL of the server the app was deployed to. :param filename: the name of the deployed manifest file. :param app_url: the URL of the application itself. :param app_id: the ID of the application. :param app_guid: the UUID of the application. :param title: the title of the application. :param app_mode: the mode of the application. .