# generated by fastapi-codegen:
#   filename:  /Users/ivasylen/Code/contracts/guardicore/connector
#   timestamp: 2026-01-26T10:59:30+00:00

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, RootModel

from centra_sdk.utils.gc_serializer import GcSerializer


class ScriptsRequest(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    subscriptions: Optional[List[UUID]] = Field(
        None, description='List of subscription IDs required for role actions'
    )
    managementGroups: Optional[Dict[str, Any]] = Field(
        None,
        description='Dictionary of management groups (optional alternative to subscriptions)',
    )
    storageAccounts: Optional[List[str]] = Field(
        None, description='List of storage account resource IDs for storage actions'
    )


class ServicePrincipalValidationRequest1(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    subscriptions: List[UUID] = Field(..., description='List of subscription IDs')


class ServicePrincipalValidationRequest2(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    managementGroups: Dict[str, Any] = Field(
        ..., description='Dictionary of management groups'
    )


class ServicePrincipalValidationRequest(
    RootModel[
        Union[ServicePrincipalValidationRequest1, ServicePrincipalValidationRequest2]
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    root: Union[ServicePrincipalValidationRequest1, ServicePrincipalValidationRequest2]

    def __getattr__(self, attr: str):
        return getattr(self.root, attr)

    def __iter__(self):
        for item in self.root:
            yield item


class AZURECLIENTID(Enum):
    FIELD_ = ''


class AZURETENANTID(Enum):
    FIELD_ = ''


class AzureServicePrincipal(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    AZURE_CLIENT_ID: Union[UUID, AZURECLIENTID] = Field(
        ..., description='Azure Application (Client) ID (UUID or empty string)'
    )
    AZURE_CLIENT_SECRET: str = Field(..., description='Azure Client Secret')
    AZURE_TENANT_ID: Union[UUID, AZURETENANTID] = Field(
        ..., description='Azure Tenant ID (UUID or empty string)'
    )


class ServicePrincipalSuccess(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    message: str = Field(
        ..., description='Acknowledgement message, e.g. "OK" or a short status'
    )
    subscriptions: Optional[List[UUID]] = Field(
        None, description='Optional list of subscription IDs returned by validation'
    )
    managementGroups: Optional[Dict[str, Any]] = Field(
        None, description='Optional management group tree returned by validation'
    )


class Detail(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    field: Optional[str] = None
    issue: Optional[str] = None


class ValidationError(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    code: str = Field(
        ..., description='Error code (e.g. invalid_credentials, missing_field)'
    )
    message: str = Field(..., description='Error message suitable for UI display')
    details: Optional[List[Detail]] = Field(
        None,
        description='Optional array with field-level issues to display in UI. Each item should include `field` and `issue`.',
    )


class Action(Enum):
    VISIBILITY_ROLES = 'visibility-roles'
    ENFORCEMENT_ROLES = 'enforcement-roles'
    STORAGE_ROLES = 'storage-roles'
    VISIBILITY_ROLES_REVIEW = 'visibility-roles-review'
    ENFORCEMENT_ROLES_REVIEW = 'enforcement-roles-review'
    STORAGE_ROLES_REVIEW = 'storage_roles-review'
    SERVICE_PRINCIPAL_CREATION = 'service-principal-creation'


class V1OperationsAzureScriptsPostResponse(BaseModel, GcSerializer):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )


class Action7(Enum):
    VALIDATE_AND_STORE = 'validate-and-store'
    VALIDATE_AND_UPDATE = 'validate-and-update'
    VALIDATE_VISIBILITY_ROLES = 'validate-visibility-roles'
    VALIDATE_ENFORCEMENT_ROLES = 'validate-enforcement-roles'


class ServicePrincipalRequest(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    key: str = Field(..., description='Name of the service principal secret')
    value: AzureServicePrincipal


class V1OperationsAzureServicePrincipalPostRequest(
    RootModel[Union[ServicePrincipalRequest, ServicePrincipalValidationRequest]]
):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    root: Union[ServicePrincipalRequest, ServicePrincipalValidationRequest]

    def __getattr__(self, attr: str):
        return getattr(self.root, attr)

    def __iter__(self):
        for item in self.root:
            yield item
