Skip to main content

A Python middleware service for managing Port.io guides (blueprints, actions, mappings, widgets)

Project description

Port OneClick Middleware

A Python middleware service for managing Port.io resources including blueprints, actions, mappings, and widgets.

Installation

From PyPI (Recommended)

pip install port-oneclick-mw

From Source

git clone https://github.com/yourusername/port-oneclick-mw.git
cd port-oneclick-mw
pip install -e .

Quick Start

1. Create Your Configuration

After installation, you need to provide two things:

a. Environment Variables (.env file)

Create a .env file in your project directory with your Port.io credentials:

PORT_CLIENT_ID=your_client_id_here
PORT_CLIENT_SECRET=your_client_secret_here

# Optional: Custom directory paths (defaults shown)
BLUEPRINTS_DIR=setup/blueprints
ACTIONS_DIR=setup/actions
MAPPINGS_DIR=setup/mappings
WIDGETS_DIR=setup/widgets

# Optional: Specify what to process (all, blueprints, actions, mappings, widgets)
ACTION=all

b. Setup Directory Structure

Create a setup/ directory with your Port.io resource definitions:

setup/
├── blueprints/     # Blueprint JSON files
├── actions/        # Action JSON files
├── mappings/       # Mapping JSON files
└── widgets/        # Widget/Dashboard JSON files

Example structure:

my-project/
├── .env
├── setup/
│   ├── blueprints/
│   │   ├── service.json
│   │   └── deployment.json
│   ├── actions/
│   │   └── deploy-service.json
│   ├── mappings/
│   │   └── github-mapping.json
│   └── widgets/
│       └── services-dashboard.json

2. Use Example Templates

The package includes example files to help you get started. Check the examples/ directory:

# Copy examples to your setup directory
cp -r examples/blueprints setup/blueprints
cp -r examples/actions setup/actions
cp -r examples/widgets setup/widgets

Or view them in the package installation:

python -c "import site; print(site.getsitepackages())"
# Then navigate to port-oneclick-mw/examples/

3. Run the Middleware

# Run from command line
port-oneclick

# Or run the Python module directly
python main.py

Configuration Options

Environment Variables

Variable Description Default
PORT_CLIENT_ID Your Port.io client ID Required
PORT_CLIENT_SECRET Your Port.io client secret Required
BLUEPRINTS_DIR Path to blueprints directory setup/blueprints
ACTIONS_DIR Path to actions directory setup/actions
MAPPINGS_DIR Path to mappings directory setup/mappings
WIDGETS_DIR Path to widgets directory setup/widgets
ACTION What to process: all, blueprints, actions, mappings, or widgets all

Directory Structure

Each directory should contain JSON files defining your Port.io resources:

  • blueprints/: Blueprint definitions
  • actions/: Self-service action definitions
  • mappings/: Integration mapping configurations
  • widgets/: Dashboard widget definitions

JSON File Format

Blueprint Example (setup/blueprints/service.json)

{
  "identifier": "service",
  "title": "Service",
  "icon": "Microservice",
  "schema": {
    "properties": {
      "name": {
        "type": "string",
        "title": "Service Name"
      },
      "status": {
        "type": "string",
        "enum": ["active", "inactive"],
        "title": "Status"
      }
    },
    "required": ["name"]
  }
}

Action Example (setup/actions/deploy.json)

{
  "identifier": "deploy_service",
  "title": "Deploy Service",
  "icon": "Deployment",
  "trigger": {
    "type": "self-service",
    "operation": "DAY-2",
    "userInputs": {
      "properties": {
        "environment": {
          "type": "string",
          "title": "Environment",
          "enum": ["development", "staging", "production"]
        }
      }
    },
    "blueprintIdentifier": "service"
  }
}

See the examples/ directory for more complete examples.

Features

  • Blueprint Management: Create and update Port.io blueprints
  • Action Management: Configure self-service actions
  • Mapping Management: Set up integration mappings
  • Widget Management: Create dashboard widgets
  • Merge Strategy: Safely updates existing resources without overwriting
  • Confirmation Prompts: Review changes before applying
  • Detailed Logging: Clear feedback on all operations

Development

For Package Development

# Clone the repository
git clone https://github.com/yourusername/port-oneclick-mw.git
cd port-oneclick-mw

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black .

Important Notes

⚠️ Security: Never commit your .env file or Port.io credentials to version control!

⚠️ Setup Directory: The setup/ directory is specific to your organization and should NOT be included in the PyPI package. Keep it in your private repository.

Getting Port.io Credentials

  1. Log in to your Port.io account
  2. Navigate to Settings → Credentials
  3. Create a new client ID and secret
  4. Copy these values to your .env file

Support & Documentation

  • Examples: See the examples/ directory in the package
  • Configuration Guide: See CONFIG.md for detailed configuration options
  • Issues: Report issues on GitHub

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

port_oneclick_mw-0.1.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

port_oneclick_mw-0.1.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file port_oneclick_mw-0.1.0.tar.gz.

File metadata

  • Download URL: port_oneclick_mw-0.1.0.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for port_oneclick_mw-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57e6a89ecad803db47873c84bb1b446209c9d55a1ae613b0e9878ed2d5ea8c8d
MD5 4d8f925b5b990d61b463fcb0f95af148
BLAKE2b-256 95fd84c767f22426d3dc1c1421245485e498e6d49325ca4d232705e890cf3c1f

See more details on using hashes here.

File details

Details for the file port_oneclick_mw-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for port_oneclick_mw-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 632e1f1da9137973ff9c9710430f18edafce47ea0b1d09e8ff50085128439b78
MD5 a33032e43d73e8b726c5d32db09c691f
BLAKE2b-256 27b8edd61eb91ff3718953b321ed07e781f250785c473ff1743c51400129af39

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