cloudcoil.models.kyverno


Namecloudcoil.models.kyverno JSON
Version 1.12.7.8 PyPI version JSON
download
home_pageNone
SummaryVersioned kyverno models for cloudcoil
upload_time2025-01-25 22:12:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache-2.0
keywords async cloud-native cloudcoil cloudcoil-models kubernetes kyverno pydantic python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cloudcoil-models-kyverno

Versioned kyverno models for cloudcoil.
## 🔧 Installation

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

```bash
# Install with Kyverno support
uv add cloudcoil.models.kyverno
```

Using pip:

```bash
pip install cloudcoil.models.kyverno
```

## 💡 Examples

### Using Kyverno Models

```python
from cloudcoil import apimachinery
import cloudcoil.models.kyverno.v1 as kyverno

# Create a ClusterPolicy
policy = kyverno.ClusterPolicy(
    metadata=apimachinery.ObjectMeta(name="require-labels"),
    spec=kyverno.ClusterPolicySpec(
        rules=[
            kyverno.Rule(
                name="require-team-label",
                match=kyverno.Match(
                    resources=kyverno.Resources(
                        kinds=["Deployment", "StatefulSet"]
                    )
                ),
                validate=kyverno.Validate(
                    message="The label 'team' is required",
                    pattern={
                        "metadata": {
                            "labels": {
                                "team": "*"
                            }
                        }
                    }
                )
            )
        ]
    )
).create()

# List Policies
for pol in kyverno.ClusterPolicy.list():
    print(f"Found policy: {pol.metadata.name}")

# Update a Policy
policy.spec.rules[0].validate.message = "The 'team' label is mandatory"
policy.save()

# Delete a Policy
kyverno.ClusterPolicy.delete("require-labels")
```

### Using the Fluent Builder API

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

```python
from cloudcoil.models.kyverno.v1 import ClusterPolicy

# Create a ClusterPolicy using the builder
policy = (
    ClusterPolicy.builder()
    .metadata(lambda m: m
        .name("require-labels")
    )
    .spec(lambda s: s
        .rules([
            lambda r: r
            .name("require-team-label")
            .match(lambda m: m
                .resources(lambda res: res
                    .kinds(["Deployment", "StatefulSet"])
                )
            )
            .validate(lambda v: v
                .message("The label 'team' is required")
                .pattern({
                    "metadata": {
                        "labels": {
                            "team": "*"
                        }
                    }
                })
            )
        ])
    )
    .build()
)
```

The fluent builder 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

### 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:

```python
from cloudcoil.models.kyverno.v1 import ClusterPolicy

# Create a policy using context managers
with ClusterPolicy.new() as policy:
    with policy.metadata() as metadata:
        metadata.name("require-labels")
        metadata.labels({"app": "kyverno"})
    
    with policy.spec() as spec:
        with spec.rules() as rules:
            with rules.add() as rule:
                rule.name("require-team-label")
                
                with rule.match() as match:
                    with match.resources() as resources:
                        resources.kinds(["Deployment", "StatefulSet"])
                
                with rule.validate() as validate:
                    validate.message("The label 'team' is required")
                    validate.pattern({
                        "metadata": {
                            "labels": {
                                "team": "*"
                            }
                        }
                    })

final_policy = policy.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:

```python
from cloudcoil.models.kyverno.v1 import ClusterPolicy
from cloudcoil import apimachinery

# Mixing styles lets you choose the best approach for each part
with ClusterPolicy.new() as policy:
    # Direct object initialization with full type checking
    policy.metadata(apimachinery.ObjectMeta(
        name="require-labels",
        labels={"app": "kyverno"}
    ))
    
    with policy.spec() as spec:
        # Fluent style for rules
        spec.rules([
            lambda r: r
            .name("require-team-label")
            .match(lambda m: m
                .resources(lambda res: res
                    .kinds(["Deployment", "StatefulSet"])
                )
            )
            # Context manager style for validate
            .validate(lambda v: v
                .message("The label 'team' is required")
                .pattern({
                    "metadata": {
                        "labels": {
                            "team": "*"
                        }
                    }
                })
            )
        ])

final_policy = policy.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](https://cloudcoil.github.io/cloudcoil)

## 📜 License

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cloudcoil.models.kyverno",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
    "keywords": "async, cloud-native, cloudcoil, cloudcoil-models, kubernetes, kyverno, pydantic, python",
    "author": null,
    "author_email": "Sambhav Kothari <sambhavs.email@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/88/5c/f746752ea6f3f8dc0080d57d73f03208bb59b1001c4dcbbbe231be622b3b/cloudcoil_models_kyverno-1.12.7.8.tar.gz",
    "platform": null,
    "description": "# cloudcoil-models-kyverno\n\nVersioned kyverno models for cloudcoil.\n## \ud83d\udd27 Installation\n\nUsing [uv](https://github.com/astral-sh/uv) (recommended):\n\n```bash\n# Install with Kyverno support\nuv add cloudcoil.models.kyverno\n```\n\nUsing pip:\n\n```bash\npip install cloudcoil.models.kyverno\n```\n\n## \ud83d\udca1 Examples\n\n### Using Kyverno Models\n\n```python\nfrom cloudcoil import apimachinery\nimport cloudcoil.models.kyverno.v1 as kyverno\n\n# Create a ClusterPolicy\npolicy = kyverno.ClusterPolicy(\n    metadata=apimachinery.ObjectMeta(name=\"require-labels\"),\n    spec=kyverno.ClusterPolicySpec(\n        rules=[\n            kyverno.Rule(\n                name=\"require-team-label\",\n                match=kyverno.Match(\n                    resources=kyverno.Resources(\n                        kinds=[\"Deployment\", \"StatefulSet\"]\n                    )\n                ),\n                validate=kyverno.Validate(\n                    message=\"The label 'team' is required\",\n                    pattern={\n                        \"metadata\": {\n                            \"labels\": {\n                                \"team\": \"*\"\n                            }\n                        }\n                    }\n                )\n            )\n        ]\n    )\n).create()\n\n# List Policies\nfor pol in kyverno.ClusterPolicy.list():\n    print(f\"Found policy: {pol.metadata.name}\")\n\n# Update a Policy\npolicy.spec.rules[0].validate.message = \"The 'team' label is mandatory\"\npolicy.save()\n\n# Delete a Policy\nkyverno.ClusterPolicy.delete(\"require-labels\")\n```\n\n### Using the Fluent Builder API\n\nCloudcoil provides a powerful fluent builder API for Kyverno resources with full IDE support and rich autocomplete capabilities:\n\n```python\nfrom cloudcoil.models.kyverno.v1 import ClusterPolicy\n\n# Create a ClusterPolicy using the builder\npolicy = (\n    ClusterPolicy.builder()\n    .metadata(lambda m: m\n        .name(\"require-labels\")\n    )\n    .spec(lambda s: s\n        .rules([\n            lambda r: r\n            .name(\"require-team-label\")\n            .match(lambda m: m\n                .resources(lambda res: res\n                    .kinds([\"Deployment\", \"StatefulSet\"])\n                )\n            )\n            .validate(lambda v: v\n                .message(\"The label 'team' is required\")\n                .pattern({\n                    \"metadata\": {\n                        \"labels\": {\n                            \"team\": \"*\"\n                        }\n                    }\n                })\n            )\n        ])\n    )\n    .build()\n)\n```\n\nThe fluent builder 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\n### Using the Context Manager Builder API\n\nFor complex nested resources, Cloudcoil also provides a context manager-based builder pattern that can make the structure more clear:\n\n```python\nfrom cloudcoil.models.kyverno.v1 import ClusterPolicy\n\n# Create a policy using context managers\nwith ClusterPolicy.new() as policy:\n    with policy.metadata() as metadata:\n        metadata.name(\"require-labels\")\n        metadata.labels({\"app\": \"kyverno\"})\n    \n    with policy.spec() as spec:\n        with spec.rules() as rules:\n            with rules.add() as rule:\n                rule.name(\"require-team-label\")\n                \n                with rule.match() as match:\n                    with match.resources() as resources:\n                        resources.kinds([\"Deployment\", \"StatefulSet\"])\n                \n                with rule.validate() as validate:\n                    validate.message(\"The label 'team' is required\")\n                    validate.pattern({\n                        \"metadata\": {\n                            \"labels\": {\n                                \"team\": \"*\"\n                            }\n                        }\n                    })\n\nfinal_policy = policy.build()\n```\n\nThe context manager builder provides:\n- \ud83c\udfad Clear visual nesting of resource structure\n- \ud83d\udd12 Automatic resource cleanup\n- \ud83c\udfaf Familiar Python context manager pattern\n- \u2728 Same great IDE support as the fluent builder\n\n### Mixing Builder Styles\n\nCloudCoil's intelligent builder system automatically detects which style you're using and provides appropriate IDE support:\n\n```python\nfrom cloudcoil.models.kyverno.v1 import ClusterPolicy\nfrom cloudcoil import apimachinery\n\n# Mixing styles lets you choose the best approach for each part\nwith ClusterPolicy.new() as policy:\n    # Direct object initialization with full type checking\n    policy.metadata(apimachinery.ObjectMeta(\n        name=\"require-labels\",\n        labels={\"app\": \"kyverno\"}\n    ))\n    \n    with policy.spec() as spec:\n        # Fluent style for rules\n        spec.rules([\n            lambda r: r\n            .name(\"require-team-label\")\n            .match(lambda m: m\n                .resources(lambda res: res\n                    .kinds([\"Deployment\", \"StatefulSet\"])\n                )\n            )\n            # Context manager style for validate\n            .validate(lambda v: v\n                .message(\"The label 'team' is required\")\n                .pattern({\n                    \"metadata\": {\n                        \"labels\": {\n                            \"team\": \"*\"\n                        }\n                    }\n                })\n            )\n        ])\n\nfinal_policy = policy.build()\n```\n\nThis flexibility allows you to:\n- \ud83d\udd00 Choose the most appropriate style for each part of your configuration\n- \ud83d\udcd6 Maximize readability for both simple and complex structures\n- \ud83c\udfa8 Format your code according to your team's preferences\n- \ud83e\udde0 Get full IDE support with automatic style detection\n- \u2728 Enjoy rich autocomplete in all styles\n- \u26a1 Benefit from type checking across mixed styles\n- \ud83c\udfaf Receive immediate feedback on type errors\n- \ud83d\udd0d See documentation for all fields regardless of style\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 kyverno models for cloudcoil",
    "version": "1.12.7.8",
    "project_urls": {
        "Changelog": "https://github.com/cloudcoil/models-kyverno/releases",
        "Documentation": "https://cloudcoil.github.io/cloudcoil",
        "Homepage": "https://github.com/cloudcoil/cloudcoil",
        "Issues": "https://github.com/cloudcoil/models-kyverno/issues",
        "Repository": "https://github.com/cloudcoil/models-kyverno"
    },
    "split_keywords": [
        "async",
        " cloud-native",
        " cloudcoil",
        " cloudcoil-models",
        " kubernetes",
        " kyverno",
        " pydantic",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "97b635713f45460bfd866ad5b3bc34643741bb2737aaa5e35e69d18af385dc3e",
                "md5": "11c79381acf1c5da0e9569085136efb1",
                "sha256": "165c718c30db77ed01526198feceef7bedac2fdbf538d398ebf71aa58e16eaa3"
            },
            "downloads": -1,
            "filename": "cloudcoil_models_kyverno-1.12.7.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "11c79381acf1c5da0e9569085136efb1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 177708,
            "upload_time": "2025-01-25T22:12:12",
            "upload_time_iso_8601": "2025-01-25T22:12:12.128809Z",
            "url": "https://files.pythonhosted.org/packages/97/b6/35713f45460bfd866ad5b3bc34643741bb2737aaa5e35e69d18af385dc3e/cloudcoil_models_kyverno-1.12.7.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "885cf746752ea6f3f8dc0080d57d73f03208bb59b1001c4dcbbbe231be622b3b",
                "md5": "9799fc0b554ac626decd5c595b1a3136",
                "sha256": "b1def819c4638ed5556475fd1414c12fc1304744de97d93c51e8cf0047652589"
            },
            "downloads": -1,
            "filename": "cloudcoil_models_kyverno-1.12.7.8.tar.gz",
            "has_sig": false,
            "md5_digest": "9799fc0b554ac626decd5c595b1a3136",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 231757,
            "upload_time": "2025-01-25T22:12:13",
            "upload_time_iso_8601": "2025-01-25T22:12:13.540480Z",
            "url": "https://files.pythonhosted.org/packages/88/5c/f746752ea6f3f8dc0080d57d73f03208bb59b1001c4dcbbbe231be622b3b/cloudcoil_models_kyverno-1.12.7.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-25 22:12:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cloudcoil",
    "github_project": "models-kyverno",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cloudcoil.models.kyverno"
}
        
Elapsed time: 0.72044s