from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, BinaryIO, TextIO, TYPE_CHECKING, Generator

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

from typing import cast

if TYPE_CHECKING:
  from ..models.agent_workspace_key import AgentWorkspaceKey





T = TypeVar("T", bound="CreateAgentSessionRequest")



@_attrs_define
class CreateAgentSessionRequest:
    """ Delegate current session to an OpenClaw bot.

        Attributes:
            ttl (int):
            workspaces (list[AgentWorkspaceKey]):
     """

    ttl: int
    workspaces: list[AgentWorkspaceKey]





    def to_dict(self) -> dict[str, Any]:
        from ..models.agent_workspace_key import AgentWorkspaceKey
        ttl = self.ttl

        workspaces = []
        for workspaces_item_data in self.workspaces:
            workspaces_item = workspaces_item_data.to_dict()
            workspaces.append(workspaces_item)




        field_dict: dict[str, Any] = {}

        field_dict.update({
            "ttl": ttl,
            "workspaces": workspaces,
        })

        return field_dict



    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.agent_workspace_key import AgentWorkspaceKey
        d = dict(src_dict)
        ttl = d.pop("ttl")

        workspaces = []
        _workspaces = d.pop("workspaces")
        for workspaces_item_data in (_workspaces):
            workspaces_item = AgentWorkspaceKey.from_dict(workspaces_item_data)



            workspaces.append(workspaces_item)


        create_agent_session_request = cls(
            ttl=ttl,
            workspaces=workspaces,
        )

        return create_agent_session_request

