ConflKV is a Python library for managing key-value pairs stored in Confluence Pages through the REST API.
Project description
ConflKV
ConflKV is a Python library for managing key-value pairs stored in Confluence pages using the Confluence REST API. It simplifies working with the storage format of Confluence pages, enabling operations like fetching, updating, inserting, deleting, and searching for key-value pairs.
This can be especially useful for automating documentation updates from a CI/CD pipelines to proactively preventing documentation drift.
Features
- Fetch all key-value pairs from a Confluence page.
- Insert new key-value pairs while avoiding duplicates.
- Update or replace existing key-value pairs.
- Delete key-value pairs with optional error handling for missing keys.
- Search for specific keys with configurable error handling.
- Set a custom HTML header with an associated key-value table.
Usage
Below is an example of how to use ConflKV to manage key-value pairs in a Confluence page.
import os # For managing environment variables
from conflkv import PageManager
# Initialize the PageManager with your Confluence credentials and page details
app1_config_page = PageManager(
page_id="25559043", # Replace with your Confluence page ID
server_url=f'https://{os.environ["CONFLUENCE_INSTANCE"]}.atlassian.net',
auth_username=os.environ["CONFLUENCE_USERNAME"],
auth_token=os.environ["CONFLUENCE_TOKEN"],
)
# Set up the page with an HTML header and a key-value table
app1_config_page.set_html_header(
header="About",
paragraph="This page describes each configuration flag of the App1 application.",
table_key="Configuration Flag",
table_value="Description",
)
data = app1_config_page.fetchall() # Retrieve all key-value pairs as a dictionary
app1_config_page.replaceall(data) # Replace all key-value pairs with a new dictionary
key_data = app1_config_page.search("key", ok_if_missing=True) # Search for a key; ignores missing keys if 'ok_if_missing' is True
app1_config_page.insert("key", "value") # Insert a new pair; raises an error if the key exists
app1_config_page.replace("key", "new_value") # Replace an existing pair; raises an error if the key doesn't exist
app1_config_page.upsert("key", "value") # Insert or update a key-value pair
app1_config_page.delete("key", ok_if_missing=True) # Delete a key; ignores missing keys if 'ok_if_missing' is True
# Close the connection when done
app1_config_page.close()
Configuration
Required Parameters
page_id: The ID of the Confluence page to manage.server_url: The base URL of your Confluence instance (e.g.,https://your-instance.atlassian.net).auth_username: Your Confluence username or email.auth_token: A personal access token generated in Confluence for API access.
Environment Variables (Optional)
For secure handling of credentials, it is recommended to set the following environment variables:
CONFLUENCE_INSTANCECONFLUENCE_USERNAMECONFLUENCE_TOKEN
Trademarks
Confluence is a registered trademark of Atlassian. This library is not affiliated with, endorsed by, or sponsored by Atlassian.
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 conflkv-0.0.3.tar.gz.
File metadata
- Download URL: conflkv-0.0.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7547290a328f5a98db2acef5541a69a6de8a272366acfec7ab6bf49da2b293fc
|
|
| MD5 |
1ec42c39a9033b2a79fda3ffe188e408
|
|
| BLAKE2b-256 |
7a7578cbed80c50508a1b4faa51e8fb307b63116ed4f134640d8fa0220aaf924
|
Provenance
The following attestation bundles were made for conflkv-0.0.3.tar.gz:
Publisher:
publish.yml on dmoruzzi/conflKV
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
conflkv-0.0.3.tar.gz -
Subject digest:
7547290a328f5a98db2acef5541a69a6de8a272366acfec7ab6bf49da2b293fc - Sigstore transparency entry: 152680836
- Sigstore integration time:
-
Permalink:
dmoruzzi/conflKV@46a80943b937250b6e9856c58ee95cc2dc3eab5e -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/dmoruzzi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@46a80943b937250b6e9856c58ee95cc2dc3eab5e -
Trigger Event:
release
-
Statement type:
File details
Details for the file conflkv-0.0.3-py3-none-any.whl.
File metadata
- Download URL: conflkv-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5426366651e97af21c94bd9f5d648a97ca6170bff03d77b7b2efa321b07c36bd
|
|
| MD5 |
cf2e8aaf0d6bf7fcaf127ab132649453
|
|
| BLAKE2b-256 |
2fdf7f0b3cfb5c63a1410354576ef024039c2ad30c4165d3f7689a4591475b0f
|
Provenance
The following attestation bundles were made for conflkv-0.0.3-py3-none-any.whl:
Publisher:
publish.yml on dmoruzzi/conflKV
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
conflkv-0.0.3-py3-none-any.whl -
Subject digest:
5426366651e97af21c94bd9f5d648a97ca6170bff03d77b7b2efa321b07c36bd - Sigstore transparency entry: 152680837
- Sigstore integration time:
-
Permalink:
dmoruzzi/conflKV@46a80943b937250b6e9856c58ee95cc2dc3eab5e -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/dmoruzzi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@46a80943b937250b6e9856c58ee95cc2dc3eab5e -
Trigger Event:
release
-
Statement type: