Skip to main content

Versioned istio models for cloudcoil

Project description

cloudcoil-models-istio

Versioned istio models for cloudcoil.

[!WARNING]
This repository is auto-generated from the cloudcoil repository. Please do not submit pull requests here. Instead, submit them to the main repository at https://github.com/cloudcoil/cloudcoil.

🔧 Installation

[!NOTE] For versioning information and compatibility, see the Versioning Guide.

Using uv (recommended):

# Install with Istio support
uv add cloudcoil.models.istio

Using pip:

pip install cloudcoil.models.istio

💡 Examples

Using Istio Models

from cloudcoil import apimachinery
from cloudcoil.models.istio import networking

# Create a Gateway
gateway = networking.v1.Gateway(
    metadata=apimachinery.ObjectMeta(name="main-gateway"),
    spec=networking.v1.GatewaySpec(
        selector={"istio": "ingressgateway"},
        servers=[networking.v1.Server(
            port=networking.v1.PortModel(
                number=80,
                name="http",
                protocol="HTTP"
            ),
            hosts=["*.example.com"]
        )]
    )
).create()

# Create a VirtualService
virtual_service = networking.v1.VirtualService(
    metadata=apimachinery.ObjectMeta(name="website"),
    spec=networking.v1.VirtualServiceSpec(
        hosts=["website.example.com"],
        gateways=["main-gateway"],
        http=[networking.v1.HttpModel(
            route=[networking.v1.Route(
                destination=networking.v1.Destination(
                    host="website-svc",
                    port=networking.v1.Port(number=8080)
                )
            )]
        )]
    )
).create()

# List Virtual Services
for vs in networking.v1.VirtualService.list():
    print(f"Found VirtualService: {vs.metadata.name}")

Using the Fluent Builder API

from cloudcoil.models.istio import networking

# Create a Gateway using the fluent builder
gateway = (
    networking.v1.Gateway.builder()
    .metadata(lambda metadata: metadata
        .name("main-gateway")
        .namespace("default")
    )
    .spec(lambda gateway_spec: gateway_spec
        .selector({"istio": "ingressgateway"})
        .servers(lambda servers: servers.add(
            lambda server: server
            .port(lambda port: port
                .number(80)
                .name("http")
                .protocol("HTTP")
            )
            .hosts(["*.example.com"])
        ))
    )
    .build()
)

Using the Context Manager Builder API

from cloudcoil.models.istio import networking

# Create a Gateway using context managers
with networking.v1.Gateway.new() as gateway:
    with gateway.metadata() as metadata:
        metadata.name("main-gateway")
        metadata.namespace("default")
    
    with gateway.spec() as spec:
        spec.selector({"istio": "ingressgateway"})
        
        with spec.servers() as server_list:
            with server_list.add() as server:
                with server.port() as port:
                    port.number(80)
                    port.name("http")
                    port.protocol("HTTP")
                server.hosts(["*.example.com"])

# Create a VirtualService using context managers
with networking.v1.VirtualService.new() as vs:
    with vs.metadata() as metadata:
        metadata.name("website")
        metadata.namespace("default")
    
    with vs.spec() as vs_spec:
        vs_spec.hosts(["website.example.com"])
        vs_spec.gateways(["main-gateway"])
        
        with vs_spec.http() as http_list:
            with http_list.add() as route:
                with route.route() as route_list:
                    with route_list.add() as weight:
                        with weight.destination() as dest:
                            dest.host("website-svc")
                            with dest.port() as dest_port:
                                dest_port.number(8080)

final_vs = vs.build()

Mixing Builder Styles

from cloudcoil.models.istio import networking
from cloudcoil import apimachinery

# Create a Gateway mixing different builder styles
with networking.v1.Gateway.new() as gateway:
    # Direct object initialization
    gateway.metadata(apimachinery.ObjectMeta(
        name="main-gateway",
        namespace="default"
    ))
    
    with gateway.spec() as spec:
        # Simple field assignment
        spec.selector({"istio": "ingressgateway"})
        
        # Fluent style for complex structures
        spec.servers([
            networking.v1.Server(
                port=networking.v1.Port(
                    number=80,
                    name="http",
                    protocol="HTTP"
                ),
                hosts=["*.example.com"]
            )
        ])

final_gateway = gateway.build()

# Create a VirtualService mixing styles
with networking.v1.VirtualService.new() as vs:
    vs.metadata(lambda m: m
        .name("website")
        .namespace("default")
    )
    
    with vs.spec() as spec:
        # Simple assignments
        spec.hosts(["website.example.com"])
        spec.gateways(["main-gateway"])
        
        # Context managers for deep nesting
        with spec.http() as http_list:
            with http_list.add() as route:
                # Fluent style for route configuration
                route.route(lambda routes: routes
                    .add(lambda w: w
                        .destination(lambda d: d
                            .host("website-svc")
                            .port(lambda p: p.number(8080))
                        )
                    )
                )

final_vs = vs.build()

The builder system provides:

  • ✨ Full IDE support with detailed type information
  • 🔍 Rich autocomplete for all fields and nested objects
  • ⚡ Compile-time validation of your configuration
  • 🎯 Clear and chainable API that guides you through resource creation
  • 🔀 Flexibility to mix different builder styles

📚 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_istio-1.24.2.1.tar.gz (217.8 kB view details)

Uploaded Source

Built Distribution

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

cloudcoil_models_istio-1.24.2.1-py3-none-any.whl (165.4 kB view details)

Uploaded Python 3

File details

Details for the file cloudcoil_models_istio-1.24.2.1.tar.gz.

File metadata

File hashes

Hashes for cloudcoil_models_istio-1.24.2.1.tar.gz
Algorithm Hash digest
SHA256 eddf7cf765b2c1f9568f35b84b274fc6b3358293baa1e3c119815f3df9edeea7
MD5 4733d47c349ee124b2d58e78b84e0739
BLAKE2b-256 00df7600b156c5ea479ad8f5bc3bcb68b17214caa05bc3c3ecdc982cb923baf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_istio-1.24.2.1.tar.gz:

Publisher: pypi_publish.yml on cloudcoil/models-istio

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_istio-1.24.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcoil_models_istio-1.24.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9cfa7deae64861c6e002ddd3208c5bd4d1dd905eaf62171c1f5f03d2161cae1
MD5 ec9b25b4c87daca8f6a420b42b989d54
BLAKE2b-256 a1dfbd6d1b4cc0340ec1f3feecb2f3f5131dac793a78502b284db264863ccc97

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudcoil_models_istio-1.24.2.1-py3-none-any.whl:

Publisher: pypi_publish.yml on cloudcoil/models-istio

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