conflKV


NameconflKV JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryConflKV is a Python library for managing key-value pairs stored in Confluence Pages through the REST API.
upload_time2024-11-29 04:36:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords confluence key-value
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```python
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_INSTANCE`
- `CONFLUENCE_USERNAME`
- `CONFLUENCE_TOKEN`

---

## Trademarks

Confluence is a registered trademark of Atlassian. This library is not affiliated with, endorsed by, or sponsored by Atlassian.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "conflKV",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "confluence, key-value",
    "author": null,
    "author_email": "David Moruzzi <confl.kv@dmoruzi.com>",
    "download_url": "https://files.pythonhosted.org/packages/02/03/5b868f0c05e4ac78b3eb6c536f0f743ca28a3e80d26bb897f8ea81b7ced4/conflkv-0.0.2.tar.gz",
    "platform": null,
    "description": "# ConflKV\n\n**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.\n\nThis can be especially useful for automating documentation updates from a CI/CD pipelines to proactively preventing documentation drift. \n\n---\n\n## Features\n\n- Fetch all key-value pairs from a Confluence page.\n- Insert new key-value pairs while avoiding duplicates.\n- Update or replace existing key-value pairs.\n- Delete key-value pairs with optional error handling for missing keys.\n- Search for specific keys with configurable error handling.\n- Set a custom HTML header with an associated key-value table.\n\n---\n\n## Usage\n\nBelow is an example of how to use **ConflKV** to manage key-value pairs in a Confluence page.\n\n```python\nimport os  # For managing environment variables\nfrom conflkv import PageManager\n\n# Initialize the PageManager with your Confluence credentials and page details\napp1_config_page = PageManager(\n    page_id=\"25559043\",  # Replace with your Confluence page ID\n    server_url=f'https://{os.environ[\"CONFLUENCE_INSTANCE\"]}.atlassian.net',\n    auth_username=os.environ[\"CONFLUENCE_USERNAME\"],\n    auth_token=os.environ[\"CONFLUENCE_TOKEN\"],\n)\n\n# Set up the page with an HTML header and a key-value table\napp1_config_page.set_html_header(\n    header=\"About\",\n    paragraph=\"This page describes each configuration flag of the App1 application.\",\n    table_key=\"Configuration Flag\",\n    table_value=\"Description\",\n)\n\ndata = app1_config_page.fetchall()  # Retrieve all key-value pairs as a dictionary\napp1_config_page.replaceall(data)  # Replace all key-value pairs with a new dictionary\n\nkey_data = app1_config_page.search(\"key\", ok_if_missing=True)  # Search for a key; ignores missing keys if 'ok_if_missing' is True\n\napp1_config_page.insert(\"key\", \"value\")  # Insert a new pair; raises an error if the key exists\napp1_config_page.replace(\"key\", \"new_value\")  # Replace an existing pair; raises an error if the key doesn't exist\napp1_config_page.upsert(\"key\", \"value\")  # Insert or update a key-value pair\napp1_config_page.delete(\"key\", ok_if_missing=True)  # Delete a key; ignores missing keys if 'ok_if_missing' is True\n\n# Close the connection when done\napp1_config_page.close()\n```\n\n---\n\n## Configuration\n\n### Required Parameters\n- **`page_id`**: The ID of the Confluence page to manage.\n- **`server_url`**: The base URL of your Confluence instance (e.g., `https://your-instance.atlassian.net`).\n- **`auth_username`**: Your Confluence username or email.\n- **`auth_token`**: A personal access token generated in Confluence for API access.\n\n### Environment Variables (Optional)\nFor secure handling of credentials, it is recommended to set the following environment variables:\n- `CONFLUENCE_INSTANCE`\n- `CONFLUENCE_USERNAME`\n- `CONFLUENCE_TOKEN`\n\n---\n\n## Trademarks\n\nConfluence is a registered trademark of Atlassian. This library is not affiliated with, endorsed by, or sponsored by Atlassian.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "ConflKV is a Python library for managing key-value pairs stored in Confluence Pages through the REST API.",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "confluence",
        " key-value"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1bb1c79971257671e927696aa8274f272d93096edb9e4de1b5a9105a61e46d5",
                "md5": "516cc88ba3128581ebd48839f97d10af",
                "sha256": "20a4a059d18b500ce6aa234771e6ef4926995e3ae5492db5e2b75dadd4831997"
            },
            "downloads": -1,
            "filename": "conflkv-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "516cc88ba3128581ebd48839f97d10af",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 6063,
            "upload_time": "2024-11-29T04:36:33",
            "upload_time_iso_8601": "2024-11-29T04:36:33.909376Z",
            "url": "https://files.pythonhosted.org/packages/b1/bb/1c79971257671e927696aa8274f272d93096edb9e4de1b5a9105a61e46d5/conflkv-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02035b868f0c05e4ac78b3eb6c536f0f743ca28a3e80d26bb897f8ea81b7ced4",
                "md5": "fb4bbd352037a411371a500238f4a721",
                "sha256": "107fb0a9a22c68b62c76258d813bab8ecb1512203a375ddba5eaa5aa194f433e"
            },
            "downloads": -1,
            "filename": "conflkv-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fb4bbd352037a411371a500238f4a721",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 5884,
            "upload_time": "2024-11-29T04:36:35",
            "upload_time_iso_8601": "2024-11-29T04:36:35.914170Z",
            "url": "https://files.pythonhosted.org/packages/02/03/5b868f0c05e4ac78b3eb6c536f0f743ca28a3e80d26bb897f8ea81b7ced4/conflkv-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-29 04:36:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "conflkv"
}
        
Elapsed time: 4.48674s