Skip to content

GabrielPalmar/API-Import-CloudConnexa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Exporting CloudConnexa Settings with a Script

You can export most of your current CloudConnexa settings using a custom bash script that runs GET API calls.

Note: CyberShield settings are not yet available through the API. Any CyberShield-related information will not appear in the exported data.

Before You Begin

This process requires your CloudConnexa API credentials. To learn how to create API credentials, see Creating API Credentials.

Important: This script must be run on a Linux machine or any system that supports Bash, such as macOS or Windows Subsystem for Linux (WSL).

Requirements

Make sure the following tools are installed on your system before running the script:

  • curl
  • jq

These tools are preinstalled on most Linux distributions and macOS. If not, install them using your system's package manager (for example, sudo apt install jq curl).

Step 1: Set Up API Credentials

Export your CloudConnexa API credentials as environment variables on your system:

export OPENVPN_CLIENT_ID='CLIENT-ID'
export OPENVPN_CLIENT_SECRET='CLIENT-SECRET'

Step 2: Run the Script

Run the following command to download and execute the import script:

curl -fsSL https://raw.githubusercontent.com/GabrielPalmar/API-Import-CloudConnexa/refs/heads/main/import.sh | bash

Step 3: Review the Results

The script creates a new folder named cloudconnexa_api_data in the directory where it's executed. Inside, you'll find JSON files containing raw snapshots of your CloudConnexa configuration.

These files are useful for:

  • Backups and auditing.
  • Preparing data for migration or restore tools.

Note: The JSON files are raw API responses. They may need formatting or adjustments before being used in POST or PUT API requests.

API Endpoints

The script fetches data from the following CloudConnexa API endpoints:

Category Endpoints
Access Management access-groups, access-visibility/enabled
Devices devices, device-postures
DNS dns-records, dns-log/user-dns-resolutions/enabled
Networks networks, networks/routes, networks/ip-services, networks/applications
Hosts hosts, hosts/ip-services, hosts/applications
Location location-contexts
Users users, user-groups
Auth Settings settings/auth/ldap/group-mappings, settings/auth/saml/group-mappings, settings/auth/trusted-devices-allowed, settings/auth/two-factor-auth
DNS Settings settings/dns/custom-servers, settings/dns/default-suffix, settings/dns/proxy-enabled, settings/dns/zones
User Settings settings/user/connect-auth, settings/user/device-allowance, settings/user/device-allowance-force-update, settings/user/device-enforcement, settings/user/profile-distribution, settings/users/connection-timeout
WPC Settings settings/wpc/client-options, settings/wpc/default-region, settings/wpc/domain-routing-subnet, settings/wpc/routes-advanced-configuration-enabled, settings/wpc/snat, settings/wpc/subnet, settings/wpc/topology

Process Flow

flowchart TD
    A[Start] --> B{OPENVPN_CLIENT_ID and<br>OPENVPN_CLIENT_SECRET set?}
    B -->|No| C[Exit with Error]
    B -->|Yes| D[Generate OAuth Token]
    D --> E{Token Valid?}
    E -->|No| F[Exit with Error]
    E -->|Yes| G[Create cloudconnexa_api_data Directory]
    G --> H[Loop Through API Endpoints]

    H --> I[Fetch Endpoint Data]
    I --> J{Valid JSON Response?}
    J -->|No| K[Save Raw Response]
    J -->|Yes| L{Empty or Error Response?}
    L -->|Yes| M[Skip Endpoint]
    L -->|No| N{Multiple Pages?}

    N -->|No| O[Extract Items]
    N -->|Yes| P[Fetch All Pages]
    P --> O

    O --> Q{Items Found?}
    Q -->|No| M
    Q -->|Yes| R[Save to JSON File]

    K --> S{More Endpoints?}
    M --> S
    R --> S

    S -->|Yes| H
    S -->|No| T[Generate Summary Report]
    T --> U[Display Statistics]
    U --> V[End]
Loading

Summary Report

After execution, the script displays a summary report showing:

  • Status of each endpoint (saved, skipped, or error)
  • Number of items retrieved per endpoint
  • Total counts for saved, skipped, and error endpoints

Example output:

==========================================
           IMPORT SUMMARY REPORT
           2024-01-15 10:30:00
==========================================

ENDPOINT                                       STATUS               ITEMS
---------------------------------------------- -------------------- ----------
access-groups                                  saved                5
devices                                        saved                12
dns-records                                    skipped              0
...

==========================================
Total endpoints processed: 38
  - Saved: 25
  - Skipped (empty): 12
  - Errors: 1

Data saved in: ./cloudconnexa_api_data/
==========================================

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages