# akamai/cli-onboard architecture

> Architecture diagram of the GitHub repository akamai/cli-onboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akamai/cli-onboard
- Repository: https://github.com/akamai/cli-onboard

## Overview

##### Project type and purpose
- This is a Python-based Akamai CLI extension (“cli-onboard”) that provides a set of subcommands under `akamai onboard` to automate the creation and activation of Akamai Property Manager configurations and WAF policies.
- It is a specialized CLI tool (not a web app or microservice) that reads user-provided JSON/CSV templates, constructs appropriate API calls, and orchestrates a sequence of Akamai API interactions.

##### File structure
Top-level:
- `.gitignore`, `LICENSE`, `CHANGELOG.md`, `README.md`, `requirements.txt` – project metadata.
- `bin/` – all Python modules and scripts providing core functionality and subcommands.
- `config/` – JSON/YAML logging configuration.
- `templates/` – JSON rule templates and sample setup files for each onboard mode.
- `cli.json` – CLI metadata for Akamai CLI integration.

Under `bin/`:
- `_logging.py`, `exceptions.py` – shared utilities.
- `wrapper_api.py` – thin wrapper over Akamai Open APIs (PAPI, HAPI, CPS, AppSec).
- `utility*.py` – helper functions for JSON loading, environment substitution, CSV parsing.
- `model/` – data models for each onboard type (appsec, multi_hosts, single_host).
- `onboard*.py` – entry points for each subcommand (create, single_host, multi_hosts, batch_create, appsec commands).
- `steps.py` – orchestrates the sequential steps (validation, creation, activation).
- `poll.py` – waits for asynchronous Akamai operations to complete.

##### README for additional insights
- Confirms the CLI subcommands, required Akamai API credentials (`.edgerc`), and the supported workflows (create, single-host, multi-hosts, batch-create, appsec-policy/create/update/remove).
- Describes the JSON/CSV payloads and how the commands map to Akamai PAPI/HAPI/CPS/AppSec endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Input Layer
    CLI["CLI Entry Point\n(bin/akamai-onboard.py)"]:::internal
    CLI --> CLI_META
    CLI_META["CLI Metadata\n(cli.json)"]:::config

    %% Dispatcher & Subcommands
    CLI --> Dispatcher
    Dispatcher["Command Dispatcher & Parser\n(bin/onboard.py)"]:::internal

    subgraph "Subcommand Modules"
        direction TB
        Create["Create Workflow\n(bin/onboard.py)"]:::internal
        SingleHost["Single-Host Onboard\n(bin/onboard_single_host.py)"]:::internal
        MultiHosts["Multi-Hosts Onboard\n(bin/onboard_multi_hosts.py)"]:::internal
        BatchCreate["Batch Create Workflow\n(bin/onboard_batch_create.py)"]:::internal
        AppSecUpdate["AppSec Policy Update\n(bin/onboard_appsec_update.py)"]:::internal
        Convert["Conversion Utility\n(bin/onboard_convert.py)"]:::internal
    end

    Dispatcher --> Create
    Dispatcher --> SingleHost
    Dispatcher --> MultiHosts
    Dispatcher --> BatchCreate
    Dispatcher --> AppSecUpdate
    Dispatcher --> Convert

    %% Core Orchestration
    Create --> Steps
    SingleHost --> Steps
    MultiHosts --> Steps
    BatchCreate --> Steps
    AppSecUpdate --> Steps
    Convert --> Steps

    Steps["Core Orchestrator\n(bin/steps.py)"]:::internal
    Steps --> Models
    Steps --> Utils
    Steps --> Wrapper
    Steps --> Poll

    %% Data Models
    subgraph "Data Models"
        direction TB
        ModelInit["Model Package Init\n(bin/model/__init__.py)"]:::internal
        AppSecModel["AppSec Model\n(bin/model/appsec.py)"]:::internal
        MultiModel["Multi-Hosts Model\n(bin/model/multi_hosts.py)"]:::internal
        SingleModel["Single-Host Model\n(bin/model/single_host.py)"]:::internal
    end
    Models["Data Models"]:::internal --> ModelInit
    ModelInit --> AppSecModel
    ModelInit --> MultiModel
    ModelInit --> SingleModel

    %% Utilities & Logging
    subgraph "Utilities"
        direction TB
        UtilGen["General Helpers\n(bin/utility.py)"]:::internal
        UtilPAPI["PAPI Helpers\n(bin/utility_papi.py)"]:::internal
        UtilWAF["WAF Helpers\n(bin/utility_waf.py)"]:::internal
        LogWrap["Logging Wrappers\n(bin/_logging.py)"]:::internal
        Exceptions["Exceptions\n(bin/exceptions.py)"]:::internal
    end
    Utils["Utilities"]:::internal --> UtilGen
    UtilGen --> UtilPAPI
    UtilGen --> UtilWAF
    UtilGen --> LogWrap
    UtilGen --> Exceptions

    %% API Wrapper & Polling
    Wrapper["API Wrapper\n(bin/wrapper_api.py)"]:::internal
    Poll["Async Polling\n(bin/poll.py)"]:::internal
    Wrapper --> External
    Poll --> External

    %% Config & Templates
    subgraph "Configuration"
        direction TB
        LogYAML["YAML Logging Config\n(config/logging.yaml)"]:::config
        LogJSON["JSON Logging Config\n(config/logging.json)"]:::config
        Edgerc["Credentials Store\n(~/.edgerc)"]:::config
    end
    Steps --> LogYAML
    Steps --> LogJSON
    Steps --> Edgerc

    subgraph "Template Loader"
        direction TB
        TemplatesCore["Core Templates\n(templates/akamai_product_templates)"]:::template
        TemplatesSample["Sample Setup Files\n(templates/sample_setup_files)"]:::template
    end
    Steps --> TemplatesCore
    Steps --> TemplatesSample

    %% External Services
    External["Akamai APIs\n(PAPI, HAPI, CPS, AppSec)"]:::external

    %% Relationships
    CLI --> Dispatcher
    Dispatcher --> Steps
    Steps --> Wrapper
    Wrapper --> External
    Wrapper --> Poll
    Poll --> External

    %% Click Events
    click CLI "https://github.com/akamai/cli-onboard/blob/master/bin/akamai-onboard.py"
    click CLI_META "https://github.com/akamai/cli-onboard/blob/master/cli.json"
    click Dispatcher "https://github.com/akamai/cli-onboard/blob/master/bin/onboard.py"
    click Create "https://github.com/akamai/cli-onboard/blob/master/bin/onboard.py"
    click SingleHost "https://github.com/akamai/cli-onboard/blob/master/bin/onboard_single_host.py"
    click MultiHosts "https://github.com/akamai/cli-onboard/blob/master/bin/onboard_multi_hosts.py"
    click BatchCreate "https://github.com/akamai/cli-onboard/blob/master/bin/onboard_batch_create.py"
    click AppSecUpdate "https://github.com/akamai/cli-onboard/blob/master/bin/onboard_appsec_update.py"
    click Convert "https://github.com/akamai/cli-onboard/blob/master/bin/onboard_convert.py"
    click Steps "https://github.com/akamai/cli-onboard/blob/master/bin/steps.py"
    click Poll "https://github.com/akamai/cli-onboard/blob/master/bin/poll.py"
    click ModelInit "https://github.com/akamai/cli-onboard/blob/master/bin/model/__init__.py"
    click AppSecModel "https://github.com/akamai/cli-onboard/blob/master/bin/model/appsec.py"
    click MultiModel "https://github.com/akamai/cli-onboard/blob/master/bin/model/multi_hosts.py"
    click SingleModel "https://github.com/akamai/cli-onboard/blob/master/bin/model/single_host.py"
    click UtilGen "https://github.com/akamai/cli-onboard/blob/master/bin/utility.py"
    click UtilPAPI "https://github.com/akamai/cli-onboard/blob/master/bin/utility_papi.py"
    click UtilWAF "https://github.com/akamai/cli-onboard/blob/master/bin/utility_waf.py"
    click LogWrap "https://github.com/akamai/cli-onboard/blob/master/bin/_logging.py"
    click Exceptions "https://github.com/akamai/cli-onboard/blob/master/bin/exceptions.py"
    click Wrapper "https://github.com/akamai/cli-onboard/blob/master/bin/wrapper_api.py"
    click LogYAML "https://github.com/akamai/cli-onboard/blob/master/config/logging.yaml"
    click LogJSON "https://github.com/akamai/cli-onboard/blob/master/config/logging.json"

    %% Styles
    classDef internal fill:#D6EAF8,stroke:#3498DB,color:#154360
    classDef external fill:#D5F5E3,stroke:#27AE60,color:#1E8449
    classDef config fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
    classDef template fill:#FADBD8,stroke:#E74C3C,color:#641E16
```
