cloudcoil.models.istio


Namecloudcoil.models.istio JSON
Version 1.24.2.0 PyPI version JSON
download
home_pageNone
SummaryVersioned istio models for cloudcoil
upload_time2025-01-28 21:52:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache-2.0
keywords async cloud-native cloudcoil cloudcoil-models istio kubernetes pydantic python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cloudcoil-models-istio

Versioned istio models for cloudcoil.
## 🔧 Installation

Using [uv](https://github.com/astral-sh/uv) (recommended):

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

Using pip:

```bash
pip install cloudcoil.models.istio
```

## 💡 Examples

### Using Istio Models

```python

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

```python
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

```python
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

```python
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](https://cloudcoil.github.io/cloudcoil)

## 📜 License

Apache License, Version 2.0 - see [LICENSE](LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cloudcoil.models.istio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
    "keywords": "async, cloud-native, cloudcoil, cloudcoil-models, istio, kubernetes, pydantic, python",
    "author": null,
    "author_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/e4/a5/d74009ef142dbededdd09fac70bce7adac9234da1a74fe18902ebef9d3c0/cloudcoil_models_istio-1.24.2.0.tar.gz",
    "platform": null,
    "description": "# cloudcoil-models-istio\n\nVersioned istio models for cloudcoil.\n## \ud83d\udd27 Installation\n\nUsing [uv](https://github.com/astral-sh/uv) (recommended):\n\n```bash\n# Install with Istio support\nuv add cloudcoil.models.istio\n```\n\nUsing pip:\n\n```bash\npip install cloudcoil.models.istio\n```\n\n## \ud83d\udca1 Examples\n\n### Using Istio Models\n\n```python\n\nfrom cloudcoil import apimachinery\nfrom cloudcoil.models.istio import networking\n\n# Create a Gateway\ngateway = networking.v1.Gateway(\n    metadata=apimachinery.ObjectMeta(name=\"main-gateway\"),\n    spec=networking.v1.GatewaySpec(\n        selector={\"istio\": \"ingressgateway\"},\n        servers=[networking.v1.Server(\n            port=networking.v1.PortModel(\n                number=80,\n                name=\"http\",\n                protocol=\"HTTP\"\n            ),\n            hosts=[\"*.example.com\"]\n        )]\n    )\n).create()\n\n# Create a VirtualService\nvirtual_service = networking.v1.VirtualService(\n    metadata=apimachinery.ObjectMeta(name=\"website\"),\n    spec=networking.v1.VirtualServiceSpec(\n        hosts=[\"website.example.com\"],\n        gateways=[\"main-gateway\"],\n        http=[networking.v1.HttpModel(\n            route=[networking.v1.Route(\n                destination=networking.v1.Destination(\n                    host=\"website-svc\",\n                    port=networking.v1.Port(number=8080)\n                )\n            )]\n        )]\n    )\n).create()\n\n# List Virtual Services\nfor vs in networking.v1.VirtualService.list():\n    print(f\"Found VirtualService: {vs.metadata.name}\")\n```\n\n### Using the Fluent Builder API\n\n```python\nfrom cloudcoil.models.istio import networking\n\n# Create a Gateway using the fluent builder\ngateway = (\n    networking.v1.Gateway.builder()\n    .metadata(lambda metadata: metadata\n        .name(\"main-gateway\")\n        .namespace(\"default\")\n    )\n    .spec(lambda gateway_spec: gateway_spec\n        .selector({\"istio\": \"ingressgateway\"})\n        .servers(lambda servers: servers.add(\n            lambda server: server\n            .port(lambda port: port\n                .number(80)\n                .name(\"http\")\n                .protocol(\"HTTP\")\n            )\n            .hosts([\"*.example.com\"])\n        ))\n    )\n    .build()\n)\n```\n\n### Using the Context Manager Builder API\n\n```python\nfrom cloudcoil.models.istio import networking\n\n# Create a Gateway using context managers\nwith networking.v1.Gateway.new() as gateway:\n    with gateway.metadata() as metadata:\n        metadata.name(\"main-gateway\")\n        metadata.namespace(\"default\")\n    \n    with gateway.spec() as spec:\n        spec.selector({\"istio\": \"ingressgateway\"})\n        \n        with spec.servers() as server_list:\n            with server_list.add() as server:\n                with server.port() as port:\n                    port.number(80)\n                    port.name(\"http\")\n                    port.protocol(\"HTTP\")\n                server.hosts([\"*.example.com\"])\n\n# Create a VirtualService using context managers\nwith networking.v1.VirtualService.new() as vs:\n    with vs.metadata() as metadata:\n        metadata.name(\"website\")\n        metadata.namespace(\"default\")\n    \n    with vs.spec() as vs_spec:\n        vs_spec.hosts([\"website.example.com\"])\n        vs_spec.gateways([\"main-gateway\"])\n        \n        with vs_spec.http() as http_list:\n            with http_list.add() as route:\n                with route.route() as route_list:\n                    with route_list.add() as weight:\n                        with weight.destination() as dest:\n                            dest.host(\"website-svc\")\n                            with dest.port() as dest_port:\n                                dest_port.number(8080)\n\nfinal_vs = vs.build()\n```\n\n### Mixing Builder Styles\n\n```python\nfrom cloudcoil.models.istio import networking\nfrom cloudcoil import apimachinery\n\n# Create a Gateway mixing different builder styles\nwith networking.v1.Gateway.new() as gateway:\n    # Direct object initialization\n    gateway.metadata(apimachinery.ObjectMeta(\n        name=\"main-gateway\",\n        namespace=\"default\"\n    ))\n    \n    with gateway.spec() as spec:\n        # Simple field assignment\n        spec.selector({\"istio\": \"ingressgateway\"})\n        \n        # Fluent style for complex structures\n        spec.servers([\n            networking.v1.Server(\n                port=networking.v1.Port(\n                    number=80,\n                    name=\"http\",\n                    protocol=\"HTTP\"\n                ),\n                hosts=[\"*.example.com\"]\n            )\n        ])\n\nfinal_gateway = gateway.build()\n\n# Create a VirtualService mixing styles\nwith networking.v1.VirtualService.new() as vs:\n    vs.metadata(lambda m: m\n        .name(\"website\")\n        .namespace(\"default\")\n    )\n    \n    with vs.spec() as spec:\n        # Simple assignments\n        spec.hosts([\"website.example.com\"])\n        spec.gateways([\"main-gateway\"])\n        \n        # Context managers for deep nesting\n        with spec.http() as http_list:\n            with http_list.add() as route:\n                # Fluent style for route configuration\n                route.route(lambda routes: routes\n                    .add(lambda w: w\n                        .destination(lambda d: d\n                            .host(\"website-svc\")\n                            .port(lambda p: p.number(8080))\n                        )\n                    )\n                )\n\nfinal_vs = vs.build()\n```\n\nThe builder system provides:\n- \u2728 Full IDE support with detailed type information\n- \ud83d\udd0d Rich autocomplete for all fields and nested objects\n- \u26a1 Compile-time validation of your configuration\n- \ud83c\udfaf Clear and chainable API that guides you through resource creation\n- \ud83d\udd00 Flexibility to mix different builder styles\n\n## \ud83d\udcda Documentation\n\nFor complete documentation, visit [cloudcoil.github.io/cloudcoil](https://cloudcoil.github.io/cloudcoil)\n\n## \ud83d\udcdc License\n\nApache License, Version 2.0 - see [LICENSE](LICENSE)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Versioned istio models for cloudcoil",
    "version": "1.24.2.0",
    "project_urls": {
        "Changelog": "https://github.com/cloudcoil/models-istio/releases",
        "Documentation": "https://cloudcoil.github.io/cloudcoil",
        "Homepage": "https://github.com/cloudcoil/cloudcoil",
        "Issues": "https://github.com/cloudcoil/models-istio/issues",
        "Repository": "https://github.com/cloudcoil/models-istio"
    },
    "split_keywords": [
        "async",
        " cloud-native",
        " cloudcoil",
        " cloudcoil-models",
        " istio",
        " kubernetes",
        " pydantic",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cf17e73575c6cad5480ce1d774cf2080659ce3287e091792cf96c0cdc488b09c",
                "md5": "8fc3e836b2324c913bd55c64aa649160",
                "sha256": "74914af8553151237614494ac266964f667d7cd22f14190c9257ca9443be6a33"
            },
            "downloads": -1,
            "filename": "cloudcoil_models_istio-1.24.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8fc3e836b2324c913bd55c64aa649160",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 165178,
            "upload_time": "2025-01-28T21:52:55",
            "upload_time_iso_8601": "2025-01-28T21:52:55.741269Z",
            "url": "https://files.pythonhosted.org/packages/cf/17/e73575c6cad5480ce1d774cf2080659ce3287e091792cf96c0cdc488b09c/cloudcoil_models_istio-1.24.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e4a5d74009ef142dbededdd09fac70bce7adac9234da1a74fe18902ebef9d3c0",
                "md5": "f2ddafa0026700ca98d77ba314e609e2",
                "sha256": "4ffbbffed1102b2162739192a1297a0f589997895c47f4183d1fda4830bec8b7"
            },
            "downloads": -1,
            "filename": "cloudcoil_models_istio-1.24.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f2ddafa0026700ca98d77ba314e609e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 217757,
            "upload_time": "2025-01-28T21:52:58",
            "upload_time_iso_8601": "2025-01-28T21:52:58.723234Z",
            "url": "https://files.pythonhosted.org/packages/e4/a5/d74009ef142dbededdd09fac70bce7adac9234da1a74fe18902ebef9d3c0/cloudcoil_models_istio-1.24.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-28 21:52:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudcoil",
    "github_project": "models-istio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudcoil.models.istio"
}
        
Elapsed time: 0.53935s