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
-
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
-
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 -
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:
- Project-specific: When using
--my-project, looks formy-project/.envfirst - Current directory: Falls back to
.envin the current working directory - 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
- Log in to your Port.io account
- Navigate to Settings → Credentials
- Create a new API client or use existing credentials
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb166fe046c46f05dcfadaeda37a01800e17a7bbb03f0ed6c352c3dff985a3b
|
|
| MD5 |
3611ace4cf461180640576528ec06bff
|
|
| BLAKE2b-256 |
18b1bc9608e4150526af3ea2b7186ee04e87a3a5a7dc327d15ffeb3e2671c5a0
|
File details
Details for the file port_experience-0.1.4-py3-none-any.whl.
File metadata
- Download URL: port_experience-0.1.4-py3-none-any.whl
- Upload date:
- Size: 35.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40ff9566b0711615322166b6ebef517f72965208755c81b570bfc725262d6388
|
|
| MD5 |
7f880d2cb2f681cfbac524144f3aa030
|
|
| BLAKE2b-256 |
fc0411509200db129c8e7e36c701b30945a3514af6c51e59be2cfb91dd0ded6e
|