Skip to main content

Unified package for infrastructure connectors (ArgoCD, Git, Vault) and FastAPI template utilities

Project description

Tashtiot APIs Library

A unified Python package that consolidates infrastructure connectors and FastAPI utilities for building production-ready APIs.

🎯 What's Inside

This package combines two powerful toolsets:

  1. Infrastructure Connectors - Async clients for AWX, ArgoCD, Bitbucket Server, and HashiCorp Vault
  2. FastAPI Template - A reusable FastAPI application factory with built-in middleware, monitoring, and documentation

🚀 Quick Start

Installation

pip install tashtiot-apis-library

Using Infrastructure Connectors

from tashtiot_apis_library import AWX, ArgoCD, Git, Vault

awx = AWX(
	base_url="https://awx.example.com",
    token="token",
)

# ArgoCD client
argo = ArgoCD(
    base_url="https://argo.example.com",
    api_key="token",
    application_set_timeout=30, # The time client waits for argo application to be synced/deleted
)

# Git client (Bitbucket Server)
git = Git(
    base_url="https://bitbucket.example.com", # The base Bitbucket URL
    token="token", # HTTP token with write permissions to bitbucket repo
    username_or_email="user@example.com", # Username or email that would connect to the bitbucket (svc account)
    project_key="PROJ", # The project key in bitbucket world
    repo_slug="repo-name", # The repo name in lower cases
    default_ref="default_ref", # The default branch the git would commuincate with
    ssh_key_file_path="/path/to/ssh/private/key", # Path to SSH private key with write permissions (for delete operations)
)

# Vault client
vault = Vault(
    base_url="https://vault.example.com", # The base Vault URL
    token="token", # Vault token with write permissions
)

Example: Reading a yaml file from Bitbucket Server and print as json

import asyncio
from tashtiot_apis_library import Git

async def main():
    git = Git(
        base_url="https://bitbucket.example.com",
        token="token",
        username_or_email="user@example.com",
        project_key="PROJ",
        repo_slug="repo-name",
        default_ref="default_ref",
        ssh_key_file_path="/path/to/ssh/private/key",
    )
    values_file = await git.get_file_content("/hapoel/ole/ole/values.yaml")
    json_values = yaml.safe_load(response)
    print(json_values)
    
asyncio.run(main())

Using FastAPI Template

from tashtiot_apis_library import general_create_app
from tashtiot_apis_library.fastapi_template.utils import settings

app = general_create_app()

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=settings.PORT)

📦 Components

Infrastructure Connectors

from tashtiot_apis_library.connectors import ArgoCD, Git, Vault
from tashtiot_apis_library.connectors.errors import (
    ExternalServiceError,
    ArgoCDError,
    GitError,
    VaultError,
)

Features:

  • ✅ Async clients that validate responses and raise typed exceptions
  • ✅ High-level helpers for ArgoCD apps, Bitbucket Server repo manipulation, and Vault secrets
  • ✅ Shared logging configuration with Loguru
  • ✅ Minimal dependency footprint

Standardized Return Types

Key operations in ArgoCD and AWX connectors return standardized response models:

  • Base Schema: OperationResponse (status, status_code, stdout)
  • AWX: AWXOperationResponse (includes job_id)
  • ArgoCD: ArgoOperationResponse (includes app_name)

Example Usage:

response = await awx.launch_job(job_template_id=1)
if response.status == "successful":
    print(f"Job {response.job_id} finished!")

FastAPI Template

from tashtiot_apis_library.fastapi_template import general_create_app

Features:

  • ✅ Structured logging powered by Loguru
  • ✅ Prometheus-compatible metrics endpoint
  • ✅ Swagger UI and ReDoc with customizable static assets
  • ✅ Built-in middleware for request timing, exception handling, and logging
  • ✅ Health check endpoints for Kubernetes readiness/liveness probes
  • ✅ Utilities for HTTP, FTP, and Kubernetes interactions

🔧 Configuration

The FastAPI template uses environment variables for configuration:

Variable Description Default
PORT Application port 8000
LOG_LEVEL Logging level INFO
APP_NAME Application name MyApp
DEBUG Debug mode false

Create a .env file for configuration:

PORT=8000
LOG_LEVEL=INFO
APP_NAME=MyFastAPIApp

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

tashtiot_apis_library-0.1.0.tar.gz (752.3 kB view details)

Uploaded Source

Built Distribution

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

tashtiot_apis_library-0.1.0-py3-none-any.whl (767.0 kB view details)

Uploaded Python 3

File details

Details for the file tashtiot_apis_library-0.1.0.tar.gz.

File metadata

  • Download URL: tashtiot_apis_library-0.1.0.tar.gz
  • Upload date:
  • Size: 752.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for tashtiot_apis_library-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b46226f3f4d63cba27ebfdf22c3d63d63b67273122f12fbb851173f02cfcdcd
MD5 0a95e0366b81446af8d1d4761b7e716c
BLAKE2b-256 1af3b53b34a4f17682c64045926e08c9f4f18cfb3e729d4f104d64d9703c97b9

See more details on using hashes here.

File details

Details for the file tashtiot_apis_library-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tashtiot_apis_library-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af699deb4f3fc195788afa1a0d7940dc818b74bd4ce03056c8a672b67825ce80
MD5 185a5baa5d42f8ca3e6f087b20ba2fc6
BLAKE2b-256 cc7eb47aa77b1cb77c27c1b6abe8df78f1475504dd101550e92ec9e5198ef3ef

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