Skip to main content

CLI to enqueue triggers via internal API Gateway → SNS

Project description

AdaptsAPI CLI

A command-line interface for triggering documentation generation via the Adapts API Gateway → SNS.

PyPI version Python 3.10+ License: Proprietary

Features

  • 🚀 Simple CLI for triggering Adapts API endpoints
  • 🔑 Secure token management with environment variables or local config
  • 📄 Flexible payload support via JSON files or inline data
  • 🔧 Configurable endpoints with default endpoint support
  • Built-in payload validation for documentation generation requests
  • 🤖 GitHub Actions integration for automated wiki documentation

Installation

From PyPI

pip install adaptsapi

From Source

git clone https://github.com/adaptsai/adaptsapi.git
cd adaptsapi
pip install -e .

Quick Start

1. Set up your API token

You can provide your API token in three ways (in order of precedence):

  1. Environment variable (recommended for CI/CD):

    export ADAPTS_API_TOKEN="your-api-token-here"
    
  2. Local config file (config.json in current directory):

    {
      "token": "your-api-token-here",
      "endpoint": "https://your-api-endpoint.com/prod/generate_wiki_docs"
    }
    
  3. Interactive prompt (first-time setup):

    adaptsapi --data '{"test": "payload"}'
    # CLI will prompt for token and save to config.json
    

2. Make your first API call

Using inline JSON data:

adaptsapi \
  --endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
  --data '{"email_address": "user@example.com", "user_name": "john_doe", "repo_object": {...}}'

Using a JSON payload file:

adaptsapi \
  --endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
  --payload-file payload.json

Usage

Command Line Options

adaptsapi [OPTIONS]
Option Description Required
--endpoint URL Full URL of the API endpoint Yes (unless set in config.json)
--data JSON Inline JSON payload string Yes (or --payload-file)
--payload-file FILE Path to JSON payload file Yes (or --data)
--timeout SECONDS Request timeout in seconds (default: 30) No

Payload Structure

For documentation generation, your payload should follow this structure:

{
  "email_address": "user@example.com",
  "user_name": "github_username",
  "repo_object": {
    "repository_name": "my-repo",
    "source": "github",
    "repository_url": "https://github.com/user/my-repo",
    "branch": "main",
    "size": "12345",
    "language": "python",
    "is_private": false,
    "git_provider_type": "github",
    "refresh_token": "github_token_here"
  }
}

Required Fields

  • email_address: Valid email address
  • user_name: Username string
  • repo_object.repository_name: Repository name
  • repo_object.repository_url: Full repository URL
  • repo_object.branch: Branch name
  • repo_object.size: Repository size as string
  • repo_object.language: Primary programming language
  • repo_object.source: Source platform (e.g., "github")

Optional Fields

  • repo_object.is_private: Boolean indicating if repo is private
  • repo_object.git_provider_type: Git provider type
  • repo_object.installation_id: Installation ID (for GitHub Apps)
  • repo_object.refresh_token: Refresh token for authentication

GitHub Actions Integration

This package is designed to work seamlessly with GitHub Actions for automated documentation generation. Here's an example workflow:

name: Generate Wiki Docs

on:
  pull_request:
    branches: [ main ]
    types: [ closed ]

jobs:
  call-adapts-api:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
          
      - name: Install adaptsapi
        run: pip install adaptsapi
        
      - name: Generate documentation
        env:
          ADAPTS_API_KEY: ${{ secrets.ADAPTS_API_KEY }}
        run: |
          python -c "
          import os
          from adaptsapi.generate_docs import post
          
          payload = {
              'email_address': '${{ github.actor }}@users.noreply.github.com',
              'user_name': '${{ github.actor }}',
              'repo_object': {
                  'repository_name': '${{ github.event.repository.name }}',
                  'source': 'github',
                  'repository_url': '${{ github.event.repository.html_url }}',
                  'branch': 'main',
                  'size': '0',
                  'language': 'python',
                  'is_private': False,
                  'git_provider_type': 'github',
                  'refresh_token': '${{ secrets.GITHUB_TOKEN }}'
              }
          }
          
          resp = post(
              'https://your-api-endpoint.com/prod/generate_wiki_docs',
              os.environ['ADAPTS_API_KEY'],
              payload
          )
          resp.raise_for_status()
          print('✅ Documentation generated successfully')
          "

Setting up GitHub Secrets

  1. Go to your repository on GitHub
  2. Click SettingsSecrets and variablesActions
  3. Click New repository secret
  4. Add ADAPTS_API_KEY with your API token value

Configuration

Config File Format

The config.json file in your current working directory can contain:

{
  "token": "your-api-token-here",
  "endpoint": "https://your-default-endpoint.com/prod/generate_wiki_docs"
}

Environment Variables

  • ADAPTS_API_TOKEN: Your API authentication token

Error Handling

The CLI provides clear error messages for common issues:

  • Missing token: Prompts for interactive token input
  • Invalid JSON: Shows JSON parsing errors
  • API errors: Displays HTTP status codes and error messages
  • Payload validation: Shows specific validation failures

Development

Prerequisites

  • Python 3.10+
  • pip

Setup Development Environment

git clone https://github.com/adaptsai/adaptsapi.git
cd adaptsapi
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

Running Tests

python -m pytest tests/

API Reference

Functions

post(endpoint, auth_token, payload, timeout=30)

Make a POST request to the Adapts API.

Parameters:

  • endpoint (str): The API endpoint URL
  • auth_token (str): Authentication token
  • payload (dict): JSON payload to send
  • timeout (int): Request timeout in seconds

Returns:

  • requests.Response: The HTTP response object

Raises:

  • PayloadValidationError: If payload validation fails
  • requests.RequestException: If the HTTP request fails

License

This software is licensed under the Adapts API Use-Only License v1.0. See LICENSE for details.

Key restrictions:

  • ✅ Use the software as-is
  • ❌ No modifications allowed
  • ❌ No redistribution allowed
  • ❌ Commercial use restrictions apply

Support

Changelog

v0.1.4 (Latest)

  • Current release

v0.1.3

  • Patch updates

v0.1.2

  • Initial stable release

© 2025 AdaptsAI All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adaptsapi-0.1.4.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adaptsapi-0.1.4-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file adaptsapi-0.1.4.tar.gz.

File metadata

  • Download URL: adaptsapi-0.1.4.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for adaptsapi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d263b863e800df17398e3905c1b61d93462d4529dfc9bc6ad46a83ec38399f6a
MD5 556650f878e0e2cdf1db369439e660b8
BLAKE2b-256 1bb354dc8cfe637d34a59216dd9f373f6ec026b82508ec7a86ac185b57b863ef

See more details on using hashes here.

File details

Details for the file adaptsapi-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: adaptsapi-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for adaptsapi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 71fda8461c03e7ba698bb33949979216e51ddf56df00f0c0ab37c02a77ff4a64
MD5 0f9bf8985c7954eacd5e59612cc9d402
BLAKE2b-256 41ecbfa665e8d56dc9ac01187842835f03dea7d3f03fd2d56ee617a55fcbb4c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page