Skip to main content

Versioned cert-manager models for cloudcoil

Project description

cloudcoil-models-cert-manager

Versioned cert-manager models for cloudcoil.

🔧 Installation

Using uv (recommended):

# Install with cert-manager support
uv add cloudcoil.models.cert_manager

Using pip:

pip install cloudcoil.models.cert_manager

💡 Examples

Using cert-manager Models

from cloudcoil import apimachinery
import cloudcoil.models.cert_manager.v1 as cm

# Create a Certificate
certificate = cm.Certificate(
    metadata=apimachinery.ObjectMeta(name="example-cert", namespace="default"),
    spec=cm.CertificateSpec(
        secret_name="example-cert-tls",
        issuer_ref=cm.IssuerRef(name="example-issuer"),
        dns_names=["example.com"]
    )
).create()

# List Certificates
for cert in cm.Certificate.list(namespace="default"):
    print(f"Found certificate: {cert.metadata.name}")

# Update a Certificate
certificate.spec.dns_names.append("www.example.com")
certificate.save()

# Delete a Certificate
cm.Certificate.delete("example-cert", namespace="default")

Using the Fluent Builder API

Cloudcoil provides a powerful fluent builder API for cert-manager resources with full IDE support and rich autocomplete capabilities:

from cloudcoil.models.cert_manager.v1 import Certificate, ClusterIssuer

# Create a Certificate using the fluent builder
# The fluent style is great for one-liners and simple configurations
certificate = (
    Certificate.builder()
    .metadata(lambda metadata: metadata
        .name("example-cert")
        .namespace("default")
        .labels({"env": "prod"})
    )
    .spec(lambda cert_spec: cert_spec
        .secret_name("example-cert-tls")
        .issuer_ref(lambda issuer: issuer
            .name("example-issuer")
            .kind("ClusterIssuer")
        )
        .dns_names(["example.com", "www.example.com"])
        .subject(lambda subject: subject
            .organizations(["Example Corp"])
        )
    )
    .build()
)

# Create a ClusterIssuer using the builder
cluster_issuer = (
    ClusterIssuer.builder()
    .metadata(lambda m: m.name("letsencrypt-prod"))
    .spec(
        lambda s: s.acme(
            lambda acme: acme.email("admin@example.com")
            .server("https://acme-v02.api.letsencrypt.org/directory")
            .private_key_secret_ref(lambda ref: ref.name("letsencrypt-account-key"))
            .solvers(
                lambda solvers: solvers.add(
                    lambda solver: solver.http01(
                        lambda http: http.ingress(lambda ing: ing.class_("nginx"))
                    )
                )
            )
        )
    )
    .build()
)

Using the Context Manager Builder API

For complex nested resources, Cloudcoil also provides a context manager-based builder pattern that can make the structure more clear:

from cloudcoil.models.cert_manager.v1 import Certificate, ClusterIssuer

# Create a certificate using context managers
with Certificate.new() as cert:
    with cert.metadata() as metadata:
        metadata.name("example-cert")
        metadata.namespace("default")
        metadata.labels({"env": "prod"})
    
    with cert.spec() as spec:
        spec.secret_name("example-cert-tls")
        
        with spec.issuer_ref() as issuer_ref:
            issuer_ref.name("example-issuer")
            issuer_ref.kind("ClusterIssuer")
        
        spec.dns_names(["example.com", "www.example.com"])
        
        with spec.subject() as subject:
            subject.organizations(["Example Corp"])

final_cert = cert.build()

# Create a ClusterIssuer using context managers
with ClusterIssuer.new() as issuer:
    with issuer.metadata() as metadata:
        metadata.name("letsencrypt-prod")
    
    with issuer.spec() as spec:
        with spec.acme() as acme:
            acme.email("admin@example.com")
            acme.server("https://acme-v02.api.letsencrypt.org/directory")
            
            with acme.private_key_secret_ref() as key_ref:
                key_ref.name("letsencrypt-account-key")
            
            with acme.solvers() as solvers:
                with solvers.add() as solver:
                    with solver.http01() as http:
                        with http.ingress() as ingress:
                            ingress.class_("nginx")

final_issuer = issuer.build()

The context manager builder provides:

  • 🎭 Clear visual nesting of resource structure
  • 🔒 Automatic resource cleanup
  • 🎯 Familiar Python context manager pattern
  • ✨ Same great IDE support as the fluent builder

Mixing Builder Styles

CloudCoil's intelligent builder system automatically detects which style you're using and provides appropriate IDE support:

from cloudcoil.models.cert_manager.v1 import Certificate
from cloudcoil import apimachinery

# Mixing styles lets you choose the best approach for each part
with Certificate.new() as cert:
    # Direct object initialization with full type checking
    cert.metadata(apimachinery.ObjectMeta(
        name="example-cert",
        namespace="default",
        labels={"env": "prod"}
    ))
    
    with cert.spec() as spec:
        # Simple fields directly
        spec.secret_name("example-cert-tls")
        # Fluent style
        spec.issuer_ref(lambda ref: ref
            .name("example-issuer")
            .kind("ClusterIssuer")
        )
        # Direct assignment
        spec.dns_names(["example.com", "www.example.com"])
        # Context manager style
        with spec.subject() as subject:
            subject.organizations(["Example Corp"])

final_cert = cert.build()

This flexibility allows you to:

  • 🔀 Choose the most appropriate style for each part of your configuration
  • 📖 Maximize readability for both simple and complex structures
  • 🎨 Format your code according to your team's preferences
  • 🧠 Get full IDE support with automatic style detection
  • ✨ Enjoy rich autocomplete in all styles
  • ⚡ Benefit from type checking across mixed styles
  • 🎯 Receive immediate feedback on type errors
  • 🔍 See documentation for all fields regardless of style

📚 Documentation

For complete documentation, visit cloudcoil.github.io/cloudcoil

📜 License

Apache License, Version 2.0 - see LICENSE

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

cloudcoil_models_cert_manager-1.16.3.4.tar.gz (158.1 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file cloudcoil_models_cert_manager-1.16.3.4.tar.gz.

File metadata

File hashes

Hashes for cloudcoil_models_cert_manager-1.16.3.4.tar.gz
Algorithm Hash digest
SHA256 e776cb0aca3e0f3878a343a4d8c573ae248ea2e3498fbe354f317952d7c492cc
MD5 6ea19236470479735cdf92bd5eaeb1b2
BLAKE2b-256 dbce5384092753cffbfd313b4e65a90afa4fd0e16d37c3bc1dce39c2613d4989

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_cert_manager-1.16.3.4.tar.gz:

Publisher: pypi_publish.yml on cloudcoil/models-cert-manager

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

File details

Details for the file cloudcoil_models_cert_manager-1.16.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcoil_models_cert_manager-1.16.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2fef5e07b70100ca2f0b4cdc57aa3ef795bf547ff3b6a3841900ed8f611b8cd1
MD5 a6099b125b67efbd67857d173e545a53
BLAKE2b-256 9bc9f83ebe1251e4f5ba790086b1918a694c7aaba66f248808554bc627a3120a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_cert_manager-1.16.3.4-py3-none-any.whl:

Publisher: pypi_publish.yml on cloudcoil/models-cert-manager

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