# Code generated by stigmer-codegen. DO NOT EDIT.

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any

from ai.stigmer.agentic.environment.v1 import spec_pb2 as environment_spec_pb2
from ai.stigmer.commons.apiresource import io_pb2 as apiresource_io_pb2
from ai.stigmer.search.v1 import io_pb2 as search_io_pb2


@dataclass
class DeleteResourceInput:
    """Arguments for deleting a resource."""

    resource_id: str = ""
    version_message: str = ""
    force: bool = False

    def _to_proto(self) -> apiresource_io_pb2.ApiResourceDeleteInput:
        return apiresource_io_pb2.ApiResourceDeleteInput(
            resource_id=self.resource_id,
            version_message=self.version_message,
            force=self.force,
        )


@dataclass
class ResourceRef:
    """Identifies an API resource by org, slug, and optional version."""

    org: str = ""
    slug: str = ""
    version: str = ""
    kind: int = 0

    def _to_proto(self) -> apiresource_io_pb2.ApiResourceReference:
        return apiresource_io_pb2.ApiResourceReference(
            org=self.org,
            slug=self.slug,
            version=self.version,
            kind=self.kind,
        )


@dataclass
class Page:
    """Offset-based pagination parameters."""

    num: int = 1
    size: int = 20


@dataclass
class ListParams:
    """Parameters for SearchService-backed list queries."""

    org: str = ""
    query: str = ""
    exclude_public: bool = False
    page: Page | None = None


@dataclass
class ListResult:
    """Response from a SearchService-backed list query."""

    entries: list[search_io_pb2.SearchResult] = field(default_factory=list)
    total_count: int = 0
    total_pages: int = 0


@dataclass
class EnvVarInput:
    """A single environment variable."""

    value: str = ""
    is_secret: bool = False
    description: str = ""


@dataclass
class EnvSpecInput:
    """Environment variable configuration."""

    variables: dict[str, EnvVarInput] = field(default_factory=dict)

    def _to_proto(self) -> environment_spec_pb2.EnvironmentSpec:
        spec = environment_spec_pb2.EnvironmentSpec()
        for name, var in self.variables.items():
            spec.data[name].CopyFrom(
                environment_spec_pb2.EnvironmentValue(
                    value=var.value,
                    is_secret=var.is_secret,
                    description=var.description,
                )
            )
        return spec
