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.3.tar.gz (24.9 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.3-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for port_experience-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6adf04735e055f5d2c8d8d18e8350c1c0319efadf8bed6c9270b3eee39d550cb
MD5 71a20a5b6c49258fb8eb2abb159526ec
BLAKE2b-256 707dea8255d4ed32d92f23b2b14c2feb94e3c7b464fd5b3d338dacc2364d1c9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for port_experience-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e60bfb3b1ad083c963e11404bc5b6757efb4beade2090fbe71ddc9a0abd001a8
MD5 d36f29f74ef0bac17d47eacf7bae5c6a
BLAKE2b-256 f69370153355cdfc392e3fd39e599ed34dd6e180e869958999271d31103d0af7

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