### Install Caprover API from Source using Setup.py Source: https://caprover-api.readthedocs.io/en/latest/installation Installs Caprover API after downloading the source code. This command should be run from the root directory of the source code. ```python $ python setup.py install ``` -------------------------------- ### Install Caprover API Stable Release using Pip Source: https://caprover-api.readthedocs.io/en/latest/installation Installs the latest stable release of Caprover API using pip. This is the recommended installation method. Ensure pip is installed. ```bash $ pip install caprover_api ``` -------------------------------- ### Clone Caprover API Repository using Git Source: https://caprover-api.readthedocs.io/en/latest/installation Clones the public repository of Caprover API from GitHub. This allows for installation from source code. ```bash $ git clone git://github.com/ak4zh/caprover_api ``` -------------------------------- ### Install Caprover API from source (Shell) Source: https://caprover-api.readthedocs.io/en/latest/_sources/installation Installs Caprover API after obtaining the source code (e.g., via git clone or tarball download). Requires Python and setup.py to be present in the source directory. ```shell python setup.py install ``` -------------------------------- ### Download Caprover API Source Tarball Source: https://caprover-api.readthedocs.io/en/latest/installation Downloads the source code tarball for Caprover API from its master branch on GitHub. This is an alternative to cloning the repository. ```bash $ curl -OJL https://github.com/ak4zh/caprover_api/tarball/master ``` -------------------------------- ### Set Up Virtual Environment and Install Dependencies Source: https://caprover-api.readthedocs.io/en/latest/contributing Sets up a virtual environment named 'caprover_api' and installs the project locally in development mode. This ensures that your changes are isolated and the project is runnable. ```bash mkvirtualenv caprover_api cd caprover_api/ python setup.py develop ``` -------------------------------- ### Install Caprover API using pip (Shell) Source: https://caprover-api.readthedocs.io/en/latest/_sources/installation Installs the most recent stable release of Caprover API using pip. This is the recommended installation method. Requires pip to be installed. ```shell pip install caprover_api ``` -------------------------------- ### Clone Caprover API repository (Shell) Source: https://caprover-api.readthedocs.io/en/latest/_sources/installation Clones the public Git repository of Caprover API. This allows for installation directly from the source code. Requires Git to be installed. ```shell git clone git://github.com/ak4zh/caprover_api ``` -------------------------------- ### Download Caprover API tarball (Shell) Source: https://caprover-api.readthedocs.io/en/latest/_sources/installation Downloads the source code of Caprover API as a tarball from the master branch. This is an alternative to cloning the repository for source installation. Requires curl to be installed. ```shell curl -OJL https://github.com/ak4zh/caprover_api/tarball/master ``` -------------------------------- ### Create App and Add Custom Domain - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Combines the creation of a new application with the addition of a custom domain. This is a convenient method for setting up an app with a specific URL from the start. ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, custom_domain="my-app.example.com" ) ``` -------------------------------- ### Start a Temporarily Stopped App - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Restarts an application that was previously stopped. This is typically done by setting the instance count back to its desired state (e.g., 1). ```python cap.update_app(app_name="new-app", instance_count=1) ``` -------------------------------- ### Create App, Add Domain, and Enable SSL - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Creates a new application, assigns a custom domain, and immediately enables SSL for that domain. This ensures the app is set up securely from its creation. ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, custom_domain="my-app.example.com", enable_ssl=True ) ``` -------------------------------- ### Create a New Application (Python) Source: https://caprover-api.readthedocs.io/en/latest/readme Creates a new application on Caprover. This function can be used to set up a new app instance, with an option to specify if it requires persistent data storage. ```python cap.create_app( app_name="new-app", has_persistent_data=False ) ``` -------------------------------- ### Deploy One-Click App (Manual) Source: https://caprover-api.readthedocs.io/en/latest/usage Initiates the deployment of a one-click application. If variables are required, the user will be prompted during runtime. ```python cap.deploy_one_click_app( one_click_app_name='redis', namespace='new-app' ) ``` -------------------------------- ### Clone Caprover API Repository Source: https://caprover-api.readthedocs.io/en/latest/contributing Clones the Caprover API repository to your local machine. This is the first step in setting up your local development environment. ```bash $ git clone git@github.com:your_name_here/caprover_api.git ``` -------------------------------- ### Deploy One-Click App with Variables (Python) Source: https://caprover-api.readthedocs.io/en/latest/readme Deploys a one-click application (e.g., Redis) to Caprover with specified application variables for automated configuration. This method allows pre-setting environment variables required by the application. ```python app_variables = { "$$cap_redis_password": "REDIS-PASSWORD-HERE" } cap.deploy_one_click_app( one_click_app_name='redis', namespace='new-app', app_variables=app_variables, automated=True ) ``` -------------------------------- ### Usage Source: https://caprover-api.readthedocs.io/en/latest/usage Initialize the Caprover API client with dashboard credentials. ```APIDOC ## Initialize Caprover API ### Description Initialize the Caprover API client with your dashboard URL and password. ### Method Initialization (not an HTTP method) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **dashboard_url** (string) - Required - The URL of your Caprover dashboard. * **password** (string) - Required - The password for your Caprover dashboard. ### Request Example ```python from caprover_api import caprover_api cap = caprover_api.CaproverAPI( dashboard_url="cap-dashboard-url", password="cap-dashboard-password" ) ``` ### Response None (object initialization) ``` -------------------------------- ### Create App and Deploy Redis from Docker Hub - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Creates a new application and deploys it using a Redis Docker image. It also configures a persistent directory for Redis data storage. ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, image_name='redis:5', persistent_directories=['new-app-redis-data:/data', ] ) ``` -------------------------------- ### Initialize Caprover API Client (Python) Source: https://caprover-api.readthedocs.io/en/latest/readme Initializes the Caprover API client with the dashboard URL and password. This is the first step to interact with the Caprover API in a Python project. ```python from caprover_api import caprover_api cap = caprover_api.CaproverAPI( dashboard_url="cap-dashboard-url", password="cap-dashboard-password" ) ``` -------------------------------- ### Deploy One-Click App Manually (Python) Source: https://caprover-api.readthedocs.io/en/latest/readme Deploys a one-click application to Caprover without pre-defined variables. The user will be prompted to enter required variables during runtime, allowing for interactive configuration. ```python cap.deploy_one_click_app( one_click_app_name='redis', namespace='new-app', ) ``` -------------------------------- ### Create CapRover Configuration Backup - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Generates a backup of CapRover's server configuration, including app names, domains, and SSL certificates. This backup does not include application data or images. An optional file name can be provided. ```python cap.create_backup() # With optional file name: # cap.create_backup(file_name='my-caprover-backup.rar') ``` -------------------------------- ### Deploy App from Docker Hub - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Deploys an existing application using a specified Docker image. The application must already be created in CapRover before this deployment step. It requires the app name and the image name (e.g., 'redis:5'). ```python # app must already exists cap.deploy_app( app_name="new-app", image_name='redis:5' ) ``` -------------------------------- ### Custom Apps Creation Source: https://caprover-api.readthedocs.io/en/latest/usage Create a new application instance or deploy an application from a Docker Hub image. ```APIDOC ## Create App ### Description Creates a new application instance. You can specify whether the application requires persistent data storage. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name for the new application. * **has_persistent_data** (boolean) - Optional - Set to `True` if the app requires persistent data, `False` otherwise. Defaults to `False`. ### Request Example ```python cap.create_app( app_name="new-app", has_persistent_data=False ) ``` ### Response None (Function execution) ``` ```APIDOC ## Deploy App from Docker Hub ### Description Deploys an existing application using a specified Docker image. Ensure the app has already been created. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the existing application to deploy. * **image_name** (string) - Required - The name and tag of the Docker image to use (e.g., 'redis:5'). ### Request Example ```python # app must already exists cap.deploy_app( app_name="new-app", image_name='redis:5' ) ``` ### Response None (Function execution) ``` -------------------------------- ### Create and Update App from Docker Hub (Python) Source: https://caprover-api.readthedocs.io/en/latest/readme Creates a new application on Caprover and updates it with configuration details, including the Docker image to use and persistent directory mappings. This is useful for deploying custom applications from Docker Hub. ```python cap.create_and_update_app( app_name="new-app-redis", has_persistent_data=False, image_name='redis:5', persistent_directories=['new-app-redis-data:/data', ] ) ``` -------------------------------- ### One Click Apps Deployment Source: https://caprover-api.readthedocs.io/en/latest/usage Deploy applications using one-click app configurations, with options for automated variable injection or interactive input. ```APIDOC ## Deploy One Click App ### Description Deploys an application using a predefined one-click app configuration. You can either provide application variables automatically or let the system prompt you for them during runtime. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **one_click_app_name** (string) - Required - The name of the one-click app to deploy (e.g., 'redis'). * **namespace** (string) - Required - The namespace where the app will be deployed. * **app_variables** (dict) - Optional - A dictionary of variables to be automatically injected into the app configuration. Keys are variable names (e.g., '$$cap_redis_password'), and values are their corresponding settings. * **automated** (boolean) - Optional - If set to `True`, variables will be automatically injected using `app_variables`. If `False` or omitted, the user will be prompted for required variables during runtime. ### Request Example (Automated) ```python app_variables = { "$$cap_redis_password": "REDIS-PASSWORD-HERE" } cap.deploy_one_click_app( one_click_app_name='redis', namespace='new-app', app_variables=app_variables, automated=True ) ``` ### Request Example (Manual Prompt) ```python cap.deploy_one_click_app( one_click_app_name='redis', namespace='new-app' ) ``` ### Response None (Function execution) ``` -------------------------------- ### Add Env Vars, Volumes, and Port Mapping - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Updates an application with environment variables, persistent directories, and port mappings. This allows configuring network ports for the application. ```python environment_variables = { "key1": "val1", "key2": "val2" } persistent_directories = [ "volumeName:/pathInApp", "volumeNameTwo:/pathTwoInApp" ] port_mapping = [ "serverPort:containerPort", ] cap.update_app( app_name='new-app', environment_variables=environment_variables, persistent_directories=persistent_directories, port_mapping=port_mapping ) ``` -------------------------------- ### Create Backup of Caprover Configs Source: https://caprover-api.readthedocs.io/en/latest/usage Initiates a backup of Caprover's server configuration. This backup does not include application data (volumes, images). ```python cap.create_backup() ``` -------------------------------- ### Backup Configuration Source: https://caprover-api.readthedocs.io/en/latest/usage Create a backup of CapRover server configurations, excluding application data. ```APIDOC ## Create Backup ### Description Creates a backup of CapRover server configurations. This backup includes details like root domains, app names, and SSL certificates, but does not include application data (volumes, images). ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **file_name** (string) - Optional - A custom file name for the backup archive. If not provided, a default name in the format '{captain_namespace}-bck-%Y-%m-%d %H:%M:%S.rar' will be used. ### Request Example ```python cap.create_backup() ``` ### Request Example with Custom Filename ```python cap.create_backup(file_name="my-caprover-backup.rar") ``` ### Response None (Function execution) ``` -------------------------------- ### Deploy Project Version Source: https://caprover-api.readthedocs.io/en/latest/contributing Updates the project version using bump2version and pushes the changes and tags to GitHub. This is part of the release process, after which Travis CI may deploy to PyPI. ```bash bump2version patch # possible: major / minor / patch git push git push --tags ``` -------------------------------- ### Add Env Vars and Persistent Directories - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Updates an application by adding both environment variables and persistent directories (volumes). Persistent directories ensure data is saved across container restarts. ```python environment_variables = { "key1": "val1", "key2": "val2" } persistent_directories = [ "volumeName:/pathInApp", "volumeNameTwo:/pathTwoInApp" ] cap.update_app( app_name='new-app', environment_variables=environment_variables, persistent_directories=persistent_directories ) ``` -------------------------------- ### Commit and Push Changes Source: https://caprover-api.readthedocs.io/en/latest/contributing Stages all changes, commits them with a descriptive message, and pushes the branch to your GitHub repository. This prepares your contribution for a pull request. ```bash git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Run Code Quality and Tests Source: https://caprover-api.readthedocs.io/en/latest/contributing Checks if your changes pass the project's code style (flake8) and unit tests, including tests for multiple Python versions using tox. This ensures code quality and compatibility. ```bash flake8 caprover_api tests python setup.py test or pytest tox ``` -------------------------------- ### Run Specific Unit Tests Source: https://caprover-api.readthedocs.io/en/latest/contributing Executes a specific subset of unit tests for the caprover_api module. This is useful for quickly verifying changes related to a particular test file. ```bash python -m unittest tests.test_caprover_api ``` -------------------------------- ### Enable SSL for App Domain - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Configures SSL (HTTPS) for a custom domain associated with an application. This secures communication to the application via the specified domain. ```python cap.enable_ssl( app_name='new-app', custom_domain='my-app.example.com' ) ``` -------------------------------- ### App CRUD Operations Source: https://caprover-api.readthedocs.io/en/latest/usage Manage existing applications by adding domains, enabling SSL, updating environment variables, persistent directories, and port mappings. ```APIDOC ## Add Domain to App ### Description Adds a custom domain to an existing application. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the application to which the domain will be added. * **custom_domain** (string) - Required - The custom domain name to add (e.g., 'my-app.example.com'). ### Request Example ```python cap.add_domain( app_name="new-app", custom_domain="my-app.example.com" ) ``` ### Response None (Function execution) ``` ```APIDOC ## Enable SSL for App ### Description Enables SSL (HTTPS) for a custom domain associated with an application. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the application. * **custom_domain** (string) - Required - The custom domain for which to enable SSL. ### Request Example ```python cap.enable_ssl( app_name='new-app', custom_domain='my-app.example.com' ) ``` ### Response None (Function execution) ``` ```APIDOC ## Update App Configuration ### Description Updates an existing application's configuration, including environment variables, persistent directories, and port mappings. This function can be called multiple times to add different configuration types. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the application to update. * **environment_variables** (dict) - Optional - A dictionary of environment variables to set for the application. * **persistent_directories** (list of strings) - Optional - A list of strings defining persistent volume mappings in the format 'volumeName:/pathInApp'. * **port_mapping** (list of strings) - Optional - A list of strings defining port mappings in the format 'serverPort:containerPort'. * **instance_count** (integer) - Optional - Sets the number of instances for the application. Use `instance_count=1` to start a stopped app. ### Request Example (Environment Variables) ```python environment_variables = { "key1": "val1", "key2": "val2" } cap.update_app( app_name='new-app', environment_variables=environment_variables ) ``` ### Request Example (Environment Variables and Volumes) ```python environment_variables = { "key1": "val1", "key2": "val2" } persistent_directories = [ "volumeName:/pathInApp", "volumeNameTwo:/pathTwoInApp" ] cap.update_app( app_name='new-app', environment_variables=environment_variables, persistent_directories=persistent_directories ) ``` ### Request Example (Environment Variables, Volumes, and Ports) ```python environment_variables = { "key1": "val1", "key2": "val2" } persistent_directories = [ "volumeName:/pathInApp", "volumeNameTwo:/pathTwoInApp" ] port_mapping = [ "serverPort:containerPort", ] cap.update_app( app_name='new-app', environment_variables=environment_variables, persistent_directories=persistent_directories, port_mapping=port_mapping ) ``` ### Request Example (Start App) ```python cap.update_app(app_name="new-app", instance_count=1) ``` ### Request Example (Scale App) ```python cap.update_app(app_name="new-app", instance_count=3) ``` ### Response None (Function execution) ``` ```APIDOC ## Create and Update App ### Description Combines the creation of an application with immediate updates, such as adding a custom domain, enabling SSL, or deploying from a Docker image with persistent storage. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name for the new application. * **has_persistent_data** (boolean) - Optional - Set to `True` if the app requires persistent data, `False` otherwise. Defaults to `False`. * **custom_domain** (string) - Optional - The custom domain name to associate with the app. * **enable_ssl** (boolean) - Optional - Set to `True` to enable SSL for the custom domain. * **image_name** (string) - Optional - The Docker image to use for deployment. * **persistent_directories** (list of strings) - Optional - Defines persistent volume mappings for the app. ### Request Example (Create App with Domain) ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, custom_domain="my-app.example.com" ) ``` ### Request Example (Create App with Domain and SSL) ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, custom_domain="my-app.example.com", enable_ssl=True ) ``` ### Request Example (Create App and Deploy Redis from Docker Hub) ```python cap.create_and_update_app( app_name="new-app", has_persistent_data=False, image_name='redis:5', persistent_directories=['new-app-redis-data:/data', ] ) ``` ### Response None (Function execution) ``` ```APIDOC ## Delete App ### Description Deletes a specified application. You can choose to also delete its associated volumes. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the application to delete. * **delete_volumes** (boolean) - Optional - If `True`, all volumes associated with the app will also be deleted. Defaults to `False`. ### Request Example (Delete App Only) ```python cap.delete_app(app_name="new-app") ``` ### Request Example (Delete App and Volumes) ```python cap.delete_app( app_name="new-app", delete_volumes=True ) ``` ### Response None (Function execution) ``` ```APIDOC ## Delete Apps Matching Pattern ### Description Deletes applications whose names match a given regular expression pattern. This operation can be performed with or without confirmation. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name_pattern** (string) - Required - A regular expression pattern to match application names. * **delete_volumes** (boolean) - Optional - If `True`, associated volumes will also be deleted. Defaults to `False`. * **automated** (boolean) - Optional - If `True`, the deletion proceeds without user confirmation. Defaults to `False` (requires confirmation). ### Request Example (With Confirmation) ```python cap.delete_app_matching_pattern( app_name_pattern=".*new-app.*", delete_volumes=True ) ``` ### Request Example (Without Confirmation - ☠️) ```python cap.delete_app_matching_pattern( app_name_pattern=".*new-app.*", delete_volumes=True, automated=True ) ``` ### Response None (Function execution) ``` ```APIDOC ## Stop App ### Description Temporarily stops a running application. ### Method N/A (Function call) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **app_name** (string) - Required - The name of the application to stop. ### Request Example ```python cap.stop_app(app_name="new-app") ``` ### Response None (Function execution) ``` -------------------------------- ### Delete Apps Matching Regex Pattern (with confirmation) - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Deletes multiple applications that match a given regular expression pattern. This operation requires user confirmation before proceeding with the deletion. ```python cap.delete_app_matching_pattern( app_name_pattern=".*new-app.*", delete_volumes=True ) ``` -------------------------------- ### Add Domain to Existing App - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Associates a custom domain name with an existing application in CapRover. This is essential for accessing the application via a specific URL. ```python cap.add_domain( app_name="new-app", custom_domain="my-app.example.com" ) ``` -------------------------------- ### Delete App and its Volumes - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Deletes an application along with all its associated persistent volumes. This ensures a complete removal of the app and its data. ```python cap.delete_app( app_name="new-app", delete_volumes=True ) ``` -------------------------------- ### Delete Apps Matching Regex Pattern (automated) - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Automated deletion of applications matching a regex pattern, without requiring user confirmation. Use with caution to avoid accidental data loss. ```python cap.delete_app_matching_pattern( app_name_pattern=".*new-app.*", delete_volumes=True, automated=True ) ``` -------------------------------- ### Delete an Application - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Removes a specified application from CapRover. This action permanently deletes the application and its associated configurations. ```python cap.delete_app(app_name="new-app") ``` -------------------------------- ### Add Environment Variables to App - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Updates an existing application by adding or modifying environment variables. These variables are accessible within the application's runtime environment. ```python environment_variables = { "key1": "val1", "key2": "val2" } cap.update_app( app_name='new-app', environment_variables=environment_variables ) ``` -------------------------------- ### Scale App Instances - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Adjusts the number of running instances for a specific application. This is useful for scaling the application's capacity to handle more load. ```python cap.update_app(app_name="new-app", instance_count=3) ``` -------------------------------- ### Create a New Branch for Development Source: https://caprover-api.readthedocs.io/en/latest/contributing Creates a new Git branch for your bug fix or feature development. This helps in organizing changes and managing contributions. ```bash git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Stop an Application Temporarily - CapRover API (Python) Source: https://caprover-api.readthedocs.io/en/latest/_sources/usage Temporarily stops a running application. The application's configuration is preserved, and it can be restarted later. ```python cap.stop_app(app_name="new-app") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.