# coding: utf-8

"""
    

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ApiKeyResponse(BaseModel):
    """
    API key metadata without sensitive information.
    """ # noqa: E501
    api_key_id: Optional[StrictStr] = Field(default=None, description="Unique identifier for the API key.", alias="apiKeyId")
    user_id: Optional[StrictStr] = Field(default=None, description="ID of the user that owns this API key.", alias="userId")
    key_prefix: Optional[StrictStr] = Field(default=None, description="First few characters of the key for display/identification purposes.", alias="keyPrefix")
    status: Optional[StrictStr] = Field(default=None, description="Current status of the API key: ACTIVE, INACTIVE, or STATUS_UNSPECIFIED.")
    labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="User-defined labels for organization and filtering.")
    expires_at: Optional[StrictInt] = Field(default=None, description="Expiration timestamp in milliseconds since epoch. If not provided, the key does not expire.", alias="expiresAt")
    last_used_at: Optional[StrictInt] = Field(default=None, description="Last time this API key was used, in milliseconds since epoch.", alias="lastUsedAt")
    created_at: Optional[StrictInt] = Field(default=None, description="When the API key was created, in milliseconds since epoch.", alias="createdAt")
    updated_at: Optional[StrictInt] = Field(default=None, description="When the API key was last updated, in milliseconds since epoch.", alias="updatedAt")
    created_by_id: Optional[StrictStr] = Field(default=None, description="ID of the user that created this API key.", alias="createdById")
    updated_by_id: Optional[StrictStr] = Field(default=None, description="ID of the user that last updated this API key.", alias="updatedById")
    __properties: ClassVar[List[str]] = ["apiKeyId", "userId", "keyPrefix", "status", "labels", "expiresAt", "lastUsedAt", "createdAt", "updatedAt", "createdById", "updatedById"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of ApiKeyResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if key_prefix (nullable) is None
        # and model_fields_set contains the field
        if self.key_prefix is None and "key_prefix" in self.model_fields_set:
            _dict['keyPrefix'] = None

        # set to None if labels (nullable) is None
        # and model_fields_set contains the field
        if self.labels is None and "labels" in self.model_fields_set:
            _dict['labels'] = None

        # set to None if expires_at (nullable) is None
        # and model_fields_set contains the field
        if self.expires_at is None and "expires_at" in self.model_fields_set:
            _dict['expiresAt'] = None

        # set to None if last_used_at (nullable) is None
        # and model_fields_set contains the field
        if self.last_used_at is None and "last_used_at" in self.model_fields_set:
            _dict['lastUsedAt'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ApiKeyResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "apiKeyId": obj.get("apiKeyId"),
            "userId": obj.get("userId"),
            "keyPrefix": obj.get("keyPrefix"),
            "status": obj.get("status"),
            "labels": obj.get("labels"),
            "expiresAt": obj.get("expiresAt"),
            "lastUsedAt": obj.get("lastUsedAt"),
            "createdAt": obj.get("createdAt"),
            "updatedAt": obj.get("updatedAt"),
            "createdById": obj.get("createdById"),
            "updatedById": obj.get("updatedById")
        })
        return _obj


