Python client for Alfresco Content Services
Project description
alfresco-rest-client
Python client for Alfresco Content Services REST API, modelled after nuxeo-python-client.
Quick start
from alfresco import Alfresco, BasicAuth
client = Alfresco(url="http://localhost:8080", auth=BasicAuth("admin", "admin"))
# Nodes (files & folders)
root = client.nodes.get("-root-")
children = client.nodes.list_children("-root-")
folder = client.nodes.create_folder("-root-", "Reports")
uploaded = client.nodes.upload(folder.id, file_path="/tmp/q1.pdf")
content = client.nodes.get_content(uploaded.id)
client.nodes.copy(uploaded.id, root.id, name="q1-copy.pdf")
client.nodes.delete(uploaded.id)
# People (users)
me = client.people.get("-me-")
# Groups
groups = client.groups.list()
# Sites
sites = client.sites.list()
site = client.sites.create("eng", "Engineering", visibility="PRIVATE")
# Search (AFTS or CMIS)
results = client.search.search("cm:name:'budget*'")
results = client.search.search("SELECT * FROM cmis:document", language="cmis")
# Trashcan
deleted = client.trashcan.list()
# Comments
client.comments.create(uploaded.id, "LGTM!")
# Tags
client.tags.add_to_node(uploaded.id, ["reviewed"])
# Favorites
client.favorites.add("-me-", uploaded.id)
# Context-manager support
with Alfresco(url="http://localhost:8080", auth=BasicAuth("admin", "admin")) as c:
c.nodes.get("-root-")
client.close()
Authentication
| Method | Class | Notes |
|---|---|---|
| HTTP Basic | alfresco.BasicAuth(user, password) |
Simple, works everywhere |
| Ticket | alfresco.TicketAuth(user, password) |
Obtains a login ticket automatically |
| OAuth 2.0 | alfresco.OAuth2Auth(...) |
Bearer-token auth (Keycloak / Alfresco Identity Service) |
OAuth 2.0 example
Password (Resource Owner Password Credentials) grant:
from alfresco import Alfresco, OAuth2Auth
auth = OAuth2Auth(
token_url="http://localhost:8081/auth/realms/alfresco/protocol/openid-connect/token",
client_id="alfresco",
username="admin",
password="admin",
)
client = Alfresco("http://localhost:8080", auth=auth)
me = client.people.get("-me-")
Client-credentials grant (service account):
auth = OAuth2Auth(
token_url="https://idp/realms/r/protocol/openid-connect/token",
client_id="my-service",
client_secret="…",
grant_type="client_credentials",
)
Pre-fetched access token (e.g. from a browser-based auth code flow):
auth = OAuth2Auth.from_token(
access_token="eyJhbGciOi…",
refresh_token="…",
token_url="…",
client_id="…",
)
The handler caches the token, refreshes automatically before expiry (with a
30 s skew), and falls back to a full re-authentication if the refresh token
is rejected. Call auth.invalidate() to force a re-auth.
Local development
# Create & activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install build / dev tools
make install-dev
# Install the package in editable mode
pip install -e .
# Run smoke test
python3 tests/test_smoke.py
# Build wheel + sdist (PEP 517)
make build
# Remove build artifacts
make clean
Built packages are placed in dist/.
Releasing
Publishing is automated with GitHub Actions. Both publishing workflows use PyPI Trusted Publishing (OIDC) — there are no API tokens stored in the repo.
Release → PyPI (.github/workflows/release.yml)
Triggered by a push to main whose commit message contains [release], or
manually via Run workflow (workflow_dispatch).
Before releasing, set the correct release version. The version that gets tagged and published is read from
__version__inalfresco/__init__.py, so edit that value to the version you intend to release before triggering the workflow. Thecheckjob fails if the matchingv<version>git tag already exists, so you cannot accidentally re-release an existing version.
- check — reads the version from
alfresco/__init__.py(__version__) and fails if thev<version>git tag already exists. - tests — runs the full suite (
tests.yml). Add[skip test]to the commit message (or setskip_tests=trueon a manual run) to bypass this step. - build — builds the wheel + sdist (PEP 517).
- publish — uploads to PyPI from the
pypienvironment. - tag — creates the
v<version>git tag and a GitHub Release with the built artifacts attached. - bump — after a successful release, advances
__version__onmainto the next development version (auto-increments the patch, e.g.0.1.0 → 0.1.1, or uses thenext_versioninput on a manual run) and pushes aBump version to … [skip ci]commit.
To cut a release: set __version__ to the release version, then land a commit on
main, e.g. git commit -m "Release 0.1.0 [release]". The next development
version is set automatically by the bump step.
Snapshot → TestPyPI (.github/workflows/snapshot.yml)
Publishes dev builds versioned X.Y.Z.dev<run-number> to
TestPyPI from the testpypi environment. It runs when:
- any push lands on
main(automatic), or - a push on a working branch (
feature/**,fix/**,release/**) has a commit message containing[snapshot].
Release commits ([release]) are always skipped here to avoid double-publishing,
and the test suite must pass before a snapshot is published.
Install a snapshot with:
pip install -i https://test.pypi.org/simple/ --pre alfresco-rest-client
All third-party actions are pinned to commit SHAs, and each publishing job runs in a dedicated protected GitHub Environment (
pypi/testpypi).
Project details
Release history Release notifications | RSS feed
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 alfresco_rest_client-1.0.0.tar.gz.
File metadata
- Download URL: alfresco_rest_client-1.0.0.tar.gz
- Upload date:
- Size: 51.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9752bacf6e292f111ce43219d3fd8f0bf2d2e00250b2c101a17c2f966592b98
|
|
| MD5 |
847253f067beee361ce704deff6ba171
|
|
| BLAKE2b-256 |
7d9f2deaa8cc39cb13ecbfc9f0a94c7a031be337acd98bb0e5f18ac15f8ef314
|
Provenance
The following attestation bundles were made for alfresco_rest_client-1.0.0.tar.gz:
Publisher:
release.yml on Alfresco/alfresco-python-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alfresco_rest_client-1.0.0.tar.gz -
Subject digest:
b9752bacf6e292f111ce43219d3fd8f0bf2d2e00250b2c101a17c2f966592b98 - Sigstore transparency entry: 2136132971
- Sigstore integration time:
-
Permalink:
Alfresco/alfresco-python-client@c49bb53d26ea59188445dc2f8613f7fcd48fc52b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Alfresco
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c49bb53d26ea59188445dc2f8613f7fcd48fc52b -
Trigger Event:
push
-
Statement type:
File details
Details for the file alfresco_rest_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: alfresco_rest_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d82ed6048dd5188d7ab1200b0f16d132f0c8bbb046ecaf4075c4e48ef9752794
|
|
| MD5 |
cf6f24b8b613caeddde9a537c830a9cc
|
|
| BLAKE2b-256 |
690250ccf9f208edd076e1491e7be73c5684e419e87c8e6040e7ba66e0fe2ce5
|
Provenance
The following attestation bundles were made for alfresco_rest_client-1.0.0-py3-none-any.whl:
Publisher:
release.yml on Alfresco/alfresco-python-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alfresco_rest_client-1.0.0-py3-none-any.whl -
Subject digest:
d82ed6048dd5188d7ab1200b0f16d132f0c8bbb046ecaf4075c4e48ef9752794 - Sigstore transparency entry: 2136132980
- Sigstore integration time:
-
Permalink:
Alfresco/alfresco-python-client@c49bb53d26ea59188445dc2f8613f7fcd48fc52b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Alfresco
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c49bb53d26ea59188445dc2f8613f7fcd48fc52b -
Trigger Event:
push
-
Statement type: