Skip to main content

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

Project description

Port Experience

A Python CLI tool for managing Port.io resources including blueprints, actions, mappings, and widgets from local JSON files.

Installation

pip install port-experience

Quick Start

  1. Set up your Port.io credentials:

    # Option 1: Environment variables
    export PORT_CLIENT_ID="your_client_id_here"
    export PORT_CLIENT_SECRET="your_client_secret_here"
    
    # Option 2: Using .env file (recommended)
    echo "PORT_CLIENT_ID=your_client_id_here" > .env
    echo "PORT_CLIENT_SECRET=your_client_secret_here" >> .env
    
  2. Create your resource files in JSON format in a setup/ directory:

    your-project/
    ├── setup/
    │   ├── blueprints/
    │   │   └── my_blueprint.json
    │   ├── actions/
    │   │   └── my_action.json
    │   ├── mappings/
    │   │   └── my_mapping.json
    │   └── widgets/
    │       └── my_widget.json
    └── .env
    
  3. Apply your configurations:

    # Apply the changes directly
    experience apply --sample-experience
    
    # Apply the changes from the experience directory
    cd sample-experience
    experience apply
    

Features

  • 🎯 Multi-Resource Management: Handle blueprints, actions, mappings, and widgets
  • 🔄 Smart Sync: Compare and merge local resources with existing Port.io resources
  • Interactive Confirmation: Review changes before applying them
  • 🛡️ Safe Updates: Preserve existing data while adding new configurations
  • 📊 Detailed Reporting: Clear summary of all operations

Usage

CLI Commands

# Apply all configurations (looks for setup/ directory)
experience apply

# Use a custom project directory
experience apply --my-project  # looks for my-project/.env and my-project/setup/

# Get help
experience --help

Setup Directory Structure

The CLI automatically looks for your configuration files in this structure:

your-project/
├── setup/                    # Default directory
│   ├── blueprints/
│   ├── actions/
│   ├── mappings/
│   └── widgets/
└── .env                      # Your credentials

Or with a custom project name:

your-project/
├── .env                     # Default credentials (fallback)
├── my-project/
│   ├── .env                 # Project-specific credentials (preferred)
│   └── setup/               # Setup folder inside the project
│       ├── blueprints/
│       ├── actions/
│       ├── mappings/
│       └── widgets/

Note: When using --my-project, the CLI will look for my-project/.env and my-project/setup/ directory structure.

Programmatic Usage

from port_experience import PortBlueprintManager

manager = PortBlueprintManager(
    client_id="your_client_id",
    client_secret="your_client_secret"
)

# Setup all blueprints from directory
results = manager.setup_all_blueprints("setup/blueprints")

Resource JSON Examples

Blueprint (setup/blueprints/service.json):

{
  "identifier": "service",
  "title": "Service",
  "icon": "Microservice",
  "schema": {
    "properties": {
      "name": {"type": "string", "title": "Name"},
      "version": {"type": "string", "title": "Version"}
    }
  }
}

Action (setup/actions/deploy.json):

{
  "identifier": "deploy",
  "title": "Deploy Service",
  "icon": "Rocket",
  "blueprint": "service",
  "invocationMethod": {
    "type": "WEBHOOK"
  }
}

Configuration

Required Environment Variables

Variable Description
PORT_CLIENT_ID Your Port.io API Client ID
PORT_CLIENT_SECRET Your Port.io API Client Secret

Optional Environment Variables

Variable Description Default
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
LOG_LEVEL Logging verbosity (DEBUG, INFO, WARNING, ERROR) INFO

Using .env Files

Create a .env file in your project root for easier credential management:

# .env (in your current working directory)
PORT_CLIENT_ID=your_client_id_here
PORT_CLIENT_SECRET=your_client_secret_here
BLUEPRINTS_DIR=my-custom/blueprints
LOG_LEVEL=DEBUG

Environment File Priority:

  1. Project-specific: When using --my-project, looks for my-project/.env first
  2. Current directory: Falls back to .env in the current working directory
  3. Environment variables: Uses system environment variables as final fallback

Directory Structure: Each project should have its own folder containing both the .env file and a setup/ subdirectory with the configuration files.

Getting Port.io Credentials

  1. Log in to your Port.io account
  2. Navigate to SettingsCredentials
  3. Create a new API client or use existing credentials
  4. Copy the Client ID and Client Secret

License

MIT

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_experience-0.1.4.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

port_experience-0.1.4-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: port_experience-0.1.4.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for port_experience-0.1.4.tar.gz
Algorithm Hash digest
SHA256 aeb166fe046c46f05dcfadaeda37a01800e17a7bbb03f0ed6c352c3dff985a3b
MD5 3611ace4cf461180640576528ec06bff
BLAKE2b-256 18b1bc9608e4150526af3ea2b7186ee04e87a3a5a7dc327d15ffeb3e2671c5a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for port_experience-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 40ff9566b0711615322166b6ebef517f72965208755c81b570bfc725262d6388
MD5 7f880d2cb2f681cfbac524144f3aa030
BLAKE2b-256 fc0411509200db129c8e7e36c701b30945a3514af6c51e59be2cfb91dd0ded6e

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