Skip to main content

A Python client for interacting with the Znuny ticketing system API.

Project description

pyznuny

A Python client for interacting with the Znuny ticketing system API.

Features

  • Simple, typed client built on httpx
  • Ticket create, update, and get routes
  • Easy custom endpoint configuration

Installation

pip install pyznuny

Or with uv:

uv add pyznuny

Quick start

Create a client and authenticate using environment variables.

from pyznuny import TicketClient
from dotenv import load_dotenv
import os

load_dotenv()

client = TicketClient(
    base_url=os.getenv("HOST"),
    username=os.getenv("USER_LOGIN"),
    password=os.getenv("PASSWORD"),
)

Example .env:

HOST=https://your-znuny-instance.com
USER_LOGIN=your-username
PASSWORD=your-password

Usage examples

Create a ticket

from pyznuny.ticket.models import (
    TicketCreateArticle,
    TicketCreatePayload,
    TicketCreateTicket,
)

payload = TicketCreatePayload(
    Ticket=TicketCreateTicket(
        Title="Ticket Title",
        Queue="Ticket queue",
        State="Ticket state",
        Priority="Ticket priority",
        CustomerUser="customer@example.com",
    ),
    Article=TicketCreateArticle(
        Subject="Ticket subject",
        Body="Ticket body...",
        ContentType="text/plain; charset=utf-8",
        From_="customer@example.com",
    ),
)

response = client.ticket.create(payload=payload)
print(response.json())

Get a ticket by ID

# default endpoint is GET /Ticket/{ticket_id}
response = client.ticket.get(ticket_id=1234)
print(response.json())

Update a ticket

response = client.ticket.update(
    ticket_id=1234,
    Ticket={"State": "open"},
)
print(response.json())

Customize endpoints

If your Znuny instance uses different paths, set them with the endpoint setter.

# Example: custom ticket get endpoint and identifier
client.set_endpoint.ticket_get(endpoint="Tickets/{id}", identifier="id")

response = client.ticket.get(ticket_id=1234)

Notes

  • When username and password are provided, the client logs in and stores session_id automatically.
  • You can pass a pre-configured httpx.Client via client=... if needed.

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

pyznuny-0.0.6.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyznuny-0.0.6-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pyznuny-0.0.6.tar.gz.

File metadata

  • Download URL: pyznuny-0.0.6.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pyznuny-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2792a455e49efb5959d66dcf3b688fa39d80b08486686d81db4053aeb14d29a0
MD5 bc11531a7bb6f3659e01cae383af45fa
BLAKE2b-256 fe75016d986b2eddf6c2f136cc829ee0840125ffeb154785a04e04e704064a88

See more details on using hashes here.

File details

Details for the file pyznuny-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyznuny-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pyznuny-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a20f289c2cc4bcee4ebe3efac70806a71051157f857ffe593441902b29d4ec5f
MD5 bad568925e3dbf242ae2bee2b432f9c0
BLAKE2b-256 af993a7015a24223953df51c06ce4cf58d9e10b28c79db8b73d017d0a1be77f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page