Skip to main content

Cloudflare client library for kiarina namespace

Project description

kiarina-lib-cloudflare

PyPI version Python License: MIT

English | 日本語

[!NOTE] What is this? A package for managing Cloudflare account credentials with pydantic-settings-manager.

Dependencies

Package Version License
Pydantic Settings >=2.10.1 MIT
pydantic-settings-manager >=3.2.0 MIT

A Cloudflare SDK is not included as a dependency. Add one to the application that uses the credentials.

Installation

pip install kiarina-lib-cloudflare

Features

  • Configuring Cloudflare Authentication Store an account ID and API token as typed settings.
  • Managing Multiple Accounts Switch between named settings for multiple accounts.
  • Loading Environment Variables Load environment variables with the KIARINA_LIB_CLOUDFLARE_ prefix.
  • Protecting API Tokens Store the API token as SecretStr.

Configuring Cloudflare Authentication

from kiarina.lib.cloudflare import CloudflareSettings

settings = CloudflareSettings(
    account_id="0123456789abcdef",
    api_token="secret-token",
)

Extract the token where it is needed to create a Cloudflare client.

account_id = settings.account_id
api_token = settings.api_token.get_secret_value()

Managing Multiple Accounts

settings_manager uses multiple-settings mode. Place named settings under configs.

kiarina.lib.cloudflare:
  default: production
  configs:
    development:
      account_id: development-account
      api_token: development-token
    production:
      account_id: production-account
      api_token: production-token
import yaml
from pydantic_settings_manager import load_user_configs

from kiarina.lib.cloudflare import settings_manager

with open("config.yaml", encoding="utf-8") as file:
    load_user_configs(yaml.safe_load(file) or {})

settings = settings_manager.get_settings("production")

To configure only this package directly, assign settings_manager.user_config.

from kiarina.lib.cloudflare import settings_manager

settings_manager.user_config = {
    "default": "development",
    "configs": {
        "development": {
            "account_id": "development-account",
            "api_token": "development-token",
        },
        "production": {
            "account_id": "production-account",
            "api_token": "production-token",
        },
    },
}

Loading Environment Variables

Load a single configuration from environment variables.

export KIARINA_LIB_CLOUDFLARE_ACCOUNT_ID="0123456789abcdef"
export KIARINA_LIB_CLOUDFLARE_API_TOKEN="secret-token"
from kiarina.lib.cloudflare import CloudflareSettings

settings = CloudflareSettings()

Protecting API Tokens

api_token is a SecretStr. Extract its value explicitly only where required.

api_token = settings.api_token.get_secret_value()

API Reference

kiarina.lib.cloudflare

from kiarina.lib.cloudflare import (
    CloudflareSettings,
    settings_manager,
)

CloudflareSettings

class CloudflareSettings(BaseSettings):
    def __init__(
        self,
        *,
        account_id: str,
        api_token: SecretStr,
    ) -> None: ...

Cloudflare account settings.

Fields

  • account_id (str): Cloudflare account ID.
  • api_token (SecretStr): Cloudflare API token.

settings_manager

settings_manager: SettingsManager[CloudflareSettings]

Global instance that manages named Cloudflare account settings.

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

kiarina_lib_cloudflare-2.3.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

kiarina_lib_cloudflare-2.3.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file kiarina_lib_cloudflare-2.3.1.tar.gz.

File metadata

  • Download URL: kiarina_lib_cloudflare-2.3.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiarina_lib_cloudflare-2.3.1.tar.gz
Algorithm Hash digest
SHA256 99d162c8eb22d98ab1d6c7a98b094bd638445563f08426d8d18b59a8e179ec2c
MD5 21d0e08ce1083568ed2927868a3c5311
BLAKE2b-256 9fe5a58b9d62d28ced963a685799e1069a337eb09c040034d25c7ed05888c695

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiarina_lib_cloudflare-2.3.1.tar.gz:

Publisher: release-pypi.yml on kiarina/kiarina-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kiarina_lib_cloudflare-2.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kiarina_lib_cloudflare-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a217d3087f5189ef1a14030bfa071a51ef4d3f8f31548ee1d97417556b12a8d
MD5 3e5d104e229f8d876e6ca0dc93c80058
BLAKE2b-256 72f7d5367e6f23fcbfa8e65b5031e867f6cdf17967a83645334269848a0bf6ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiarina_lib_cloudflare-2.3.1-py3-none-any.whl:

Publisher: release-pypi.yml on kiarina/kiarina-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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