# generated by fastapi-codegen:
#   filename:  /Users/apuvvadi/Workspace/guardicore-SO-contracts/contracts/guardicore/connector
#   timestamp: 2026-04-01T10:27:26+00:00

from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Union

from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel, conint

from centra_sdk.utils.gc_serializer import GcSerializer


class Severity(Enum):
    INFO = 'INFO'
    WARNING = 'WARNING'
    ERROR = 'ERROR'


class FlowlogMessage(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    details: Dict[str, Any] = Field(
        ...,
        description='Generic key-value map of contextual details for this message. For flowlog messages, contains `flowlog-id` (the AWS Flow Log ID).',
        examples=[{'flowlog-id': 'fl-0abc123def456789'}],
    )
    title: str = Field(
        ...,
        description='Short human-readable title for the message.',
        examples=['Prefix Mismatch'],
    )
    severity: Severity = Field(
        ..., description='Severity level of the message.', examples=['ERROR']
    )
    message: str = Field(
        ...,
        description='Full human-readable message describing the validation result or error.',
        examples=[
            "The prefix in the flowlog configuration ('logs/') does not match the expected prefix ('vpc-logs/')."
        ],
    )
    timestamp: AwareDatetime = Field(
        ...,
        description='ISO 8601 timestamp (with timezone) of when this message was generated.',
        examples=['2026-03-03T10:00:00+00:00'],
    )


class AwsNetworkInfo(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    network_name: str = Field(
        ...,
        alias='network-name',
        description='The human-readable name of the VPC. If no name is provided, defaults to the VPC ID.',
        examples=['my-production-vpc'],
    )
    network_id: str = Field(
        ...,
        alias='network-id',
        description='The AWS VPC ARN, which encodes the VPC ID, account ID, and region. Format: `arn:aws:ec2:<region>:<account-id>:vpc/<vpc-id>`',
        examples=['arn:aws:ec2:us-east-1:123456789012:vpc/vpc-0abc123def456789'],
    )
    account: str = Field(
        ...,
        description='The AWS account ID that owns this VPC.',
        examples=['123456789012'],
    )
    region: str = Field(
        ...,
        description='The AWS region where this VPC is located.',
        examples=['us-east-1'],
    )
    is_valid: bool = Field(
        ...,
        alias='is-valid',
        description='Whether the VPC has at least one valid flowlog configuration. `true` means at least one flowlog passed all validation checks. `false` means no valid flowlog was found (or no flowlogs exist).\n',
        examples=[True],
    )
    assets: conint(ge=0) = Field(
        ...,
        description='Number of assets (EC2 instances, etc.) present in this VPC.',
        examples=[12],
    )
    messages: List[FlowlogMessage] = Field(
        ...,
        description='List of warning/error messages for the flowlog(s) associated with this VPC. When `is-valid` is `true`, this list is empty. When `is-valid` is `false`, contains WARNING and/or ERROR messages from invalid flowlog configurations.\n',
    )


class AzureNetworkInfo(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    network_name: str = Field(
        ...,
        alias='network-name',
        description='The human-readable name of the VNet. If no name is provided, defaults to the VNet ID.',
        examples=['my-production-vnet'],
    )
    network_id: str = Field(
        ...,
        alias='network-id',
        description='The Azure VNet resource ID. Format: `/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Network/virtualNetworks/<vnet-name>`',
        examples=[
            '/subscriptions/a1b2c3d4-e5f6-7890-abcd-ef1234567890/resourceGroups/my-resource-group/providers/Microsoft.Network/virtualNetworks/my-production-vnet'
        ],
    )
    subscription: str = Field(
        ...,
        description='The Azure subscription ID that owns this VNet.',
        examples=['a1b2c3d4-e5f6-7890-abcd-ef1234567890'],
    )
    resource_group: str = Field(
        ...,
        alias='resource-group',
        description='The Azure resource group that contains this VNet.',
        examples=['my-resource-group'],
    )
    region: str = Field(
        ...,
        description='The Azure region where this VNet is located.',
        examples=['eastus'],
    )
    is_valid: bool = Field(
        ...,
        alias='is-valid',
        description='Whether the VNet has at least one valid flowlog configuration. `true` means at least one flowlog passed all validation checks. `false` means no valid flowlog was found (or no flowlogs exist).\n',
        examples=[True],
    )
    assets: conint(ge=0) = Field(
        ...,
        description='Number of assets (VMs, etc.) present in this VNet.',
        examples=[12],
    )
    messages: List[FlowlogMessage] = Field(
        ...,
        description='List of warning/error messages for the flowlog(s) associated with this VNet. When `is-valid` is `true`, this list is empty. When `is-valid` is `false`, contains WARNING and/or ERROR messages from invalid flowlog configurations.\n',
    )


class GCPNetworkInfo(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    network_name: str = Field(
        ...,
        alias='network-name',
        description='The human-readable name of the VPC network.',
        examples=['my-production-network'],
    )
    network_id: str = Field(
        ...,
        alias='network-id',
        description='The GCP VPC network resource name. Format: `projects/<project-id>/global/networks/<network-name>`',
        examples=['projects/my-gcp-project/global/networks/my-production-network'],
    )
    project: str = Field(
        ...,
        description='The GCP project ID that owns this VPC network.',
        examples=['my-gcp-project'],
    )
    region: str = Field(
        ...,
        description='The GCP region where this VPC network is located.',
        examples=['us-central1'],
    )
    is_valid: bool = Field(
        ...,
        alias='is-valid',
        description='Whether the VPC network has at least one valid flowlog configuration. `true` means at least one flowlog passed all validation checks. `false` means no valid flowlog was found (or no flowlogs exist).\n',
        examples=[True],
    )
    assets: conint(ge=0) = Field(
        ...,
        description='Number of assets (GCE instances, etc.) present in this VPC network.',
        examples=[12],
    )
    messages: List[FlowlogMessage] = Field(
        ...,
        description='List of warning/error messages for the flowlog(s) associated with this VPC network. When `is-valid` is `true`, this list is empty. When `is-valid` is `false`, contains WARNING and/or ERROR messages from invalid flowlog configurations.\n',
    )


class ErrorResponse(BaseModel, GcSerializer):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    error: str = Field(
        ...,
        description='Human-readable error description.',
        examples=['Internal error'],
    )


class Networks(
    RootModel[List[Union[AwsNetworkInfo, AzureNetworkInfo, GCPNetworkInfo]]]
):
    model_config = ConfigDict(
        populate_by_name=True,
        from_attributes=True,
    )
    root: List[Union[AwsNetworkInfo, AzureNetworkInfo, GCPNetworkInfo]]

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

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