sysml-api-client
A Python client for the OMG Systems Modeling API and Services, specifically tested against the OpenMBEE Flexo implementation. The PyPI name is sysml-api-client; Python imports remain sysmlv2_client and sysml_api.
Installation
Requires Python 3.10 or newer. Once published on PyPI:
python -m pip install sysml-api-client
from sysmlv2_client import SysMLV2Client
See RELEASING.md for build validation and publisher setup.
Features
- Provides methods for core SysML v2 operations:
- Projects: Get List, Create, Get by ID
- Commits: Create (handles element create/update/delete), Get by ID, List
- Branches: List, Create, Get by ID, Delete
- Tags: List, Create, Get by ID, Delete
- Elements: Get by ID, List All in Commit, Get Owned by Element
- Relationships: List for Element
- Handles authentication using Bearer tokens.
- Includes basic error handling and custom exceptions.
Setup
1. Run Flexo SysMLv2 Service Locally
Follow instructions here
2. Install Client (Development)
python -m pip install -e ".[test]"
Basic Usage
from sysmlv2_client import SysMLV2Client, SysMLV2Error
from pprint import pprint
import uuid # For element IDs
BASE_URL = "http://localhost:8083"
# Replace with the actual token from flexo-setup/docker-compose/env/flexo-sysmlv2.env
BEARER_TOKEN = "Bearer YOUR_TOKEN_HERE"
try:
client = SysMLV2Client(base_url=BASE_URL, bearer_token=BEARER_TOKEN)
print("Client initialized.")
# Get projects
print("\\n--- Getting Projects ---")
projects = client.get_projects()
print(f"Found {len(projects)} projects.")
for project in projects:
print(f" - Name: {project.get('name', 'N/A')}, ID: {project.get('@id', 'N/A')}")
# Create a project (example data)
print("\\n--- Creating Project ---")
new_proj_data = {"@type": "Project", "name": "Client README Example"}
created_proj = client.create_project(new_proj_data)
print(f"Created project:")
pprint(created_proj)
project_id = created_proj.get('@id')
if project_id:
# Create a commit that also creates an element
print(f"\\n--- Creating Commit with Element in Project {project_id} ---")
element_id = str(uuid.uuid4())
commit_data = {
"@type": "Commit",
"description": "Add initial block",
"change": [{
"@type": "DataVersion",
"payload": {
"@id": element_id,
"@type": "PartDefinition", # Example type
"name": "MyExamplePartDefinition"
}
}]
}
created_commit = client.create_commit(project_id, commit_data)
print("Commit created:")
pprint(created_commit)
commit_id = created_commit.get('@id')
if commit_id:
# List elements in the new commit
print(f"\\n--- Listing Elements in Commit {commit_id} ---")
elements = client.list_elements(project_id, commit_id)
print(f"Found {len(elements)} elements:")
pprint(elements)
except SysMLV2Error as e:
print(f"An API error occurred: {e}")
except ValueError as e:
print(f"Initialization error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Running Tests
Unit tests are implemented using pytest and requests-mock.
- Install Dependencies:
python -m pip install -e ".[test]"
- Run Tests: Navigate to the project root directory in your terminal and run:
pytest
API
Basic v2 API
- get_projects
- create_project
- delete_project
- get_project_by_id
- get_element
- get_owned_elements
- create_commit
- get_commit_by_id
- list_commits
- list_branches
- create_branch
- get_branch_by_id
- list_tags
- create_tag
- get_tag_by_id
- list_elements
- list_relationships
Convenience functions
- create_sysml_project
- get_project_by_name
- commit_to_project
- get_last_commit_from_project
- create_branch
Metadata
Release files for sysml-api-client 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sysml_api_client-0.1.0.tar.gz | 16.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sysml_api_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.5 kB
Release files / sysml_api_client-0.1.0.tar.gz
| Download URL | sysml_api_client-0.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07e2327b9fa8d7c4381a5990feee30c791e71a50945f79f0f5b3db1b72970932
|
|
BLAKE2b-256 checksum How to use checksums |
39c1215aaa9da9160feff09cfe320fcd9b2fa3ea54cb1f180dfee0af1800dc6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logRelease files / sysml_api_client-0.1.0-py3-none-any.whl
| Download URL | sysml_api_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a5cdf49d90afbb519bf3c09cd824ade140c0dd165e3dc75b8b38c2591996fa3
|
|
BLAKE2b-256 checksum How to use checksums |
35fcc5a5e0bed78242c647b65d8dcc93c198b90fcb3a1f21f41e783a3e9c1914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logSecurity for sysml-api-client 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sysml_api_client-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.