跳转至

freebusy

feishu.calendar.freebusy

FreebusyNamespace

Bases: Namespace

忙闲接口命名空间。

通过 client.calendar.freebusy 访问,封装飞书日历中忙闲(freebusy)查询相关的服务端接口。

通常无需直接实例化,应通过 client.calendar.freebusy 访问。

飞书文档

查询主日历忙闲信息

源代码位于: feishu/calendar/freebusy.py
Python
class FreebusyNamespace(Namespace):
    r"""
    忙闲接口命名空间。

    通过 `client.calendar.freebusy` 访问,封装飞书日历中忙闲(freebusy)查询相关的服务端接口。

    通常无需直接实例化,应通过 `client.calendar.freebusy` 访问。

    飞书文档:
        [查询主日历忙闲信息](https://open.feishu.cn/document/server-docs/calendar-v4/calendar-event/list-2)
    """

    async def query(self, body: dict[str, Any]) -> NestedDict:
        r"""
        查询主日历忙闲信息。

        `body` 是描述查询条件的请求体,原样作为 JSON 发送,常见键包括 `time_min`、
        `time_max`(均为 RFC 3339 时间),以及 `user_id`、`room_id` 二者择一的被查询对象标识。

        Args:
            body: 忙闲查询请求体,原样作为 JSON 发送,例如
                `{"time_min": "...", "time_max": "...", "user_id": "ou_xxx"}`。

        Returns:
            忙闲查询结果数据,含 `freebusy_list`(每项含 `start_time`、`end_time`)。

        Raises:
            feishu.errors.FeishuError: 请求失败或返回错误码时抛出。

        飞书文档:
            [查询主日历忙闲信息](https://open.feishu.cn/document/server-docs/calendar-v4/calendar-event/list-2)

        Examples:
            >>> await client.calendar.freebusy.query({"time_min": "...", "time_max": "...", "user_id": "ou_xxx"})  # doctest:+SKIP
            {'freebusy_list': [{'start_time': '...', 'end_time': '...'}, ...]}  # noqa: E501
        """
        return await self._request_data("POST", "calendar/v4/freebusy/list", json=body)

query async

Python
query(body: dict[str, Any]) -> NestedDict

查询主日历忙闲信息。

body 是描述查询条件的请求体,原样作为 JSON 发送,常见键包括 time_mintime_max(均为 RFC 3339 时间),以及 user_idroom_id 二者择一的被查询对象标识。

参数:

名称 类型 描述 默认
body
dict[str, Any]

忙闲查询请求体,原样作为 JSON 发送,例如 {"time_min": "...", "time_max": "...", "user_id": "ou_xxx"}

必需

返回:

类型 描述
NestedDict

忙闲查询结果数据,含 freebusy_list(每项含 start_timeend_time)。

引发:

类型 描述
FeishuError

请求失败或返回错误码时抛出。

飞书文档

查询主日历忙闲信息

示例:

Python Console Session
>>> await client.calendar.freebusy.query({"time_min": "...", "time_max": "...", "user_id": "ou_xxx"})
{'freebusy_list': [{'start_time': '...', 'end_time': '...'}, ...]}  # noqa: E501
源代码位于: feishu/calendar/freebusy.py
Python
async def query(self, body: dict[str, Any]) -> NestedDict:
    r"""
    查询主日历忙闲信息。

    `body` 是描述查询条件的请求体,原样作为 JSON 发送,常见键包括 `time_min`、
    `time_max`(均为 RFC 3339 时间),以及 `user_id`、`room_id` 二者择一的被查询对象标识。

    Args:
        body: 忙闲查询请求体,原样作为 JSON 发送,例如
            `{"time_min": "...", "time_max": "...", "user_id": "ou_xxx"}`。

    Returns:
        忙闲查询结果数据,含 `freebusy_list`(每项含 `start_time`、`end_time`)。

    Raises:
        feishu.errors.FeishuError: 请求失败或返回错误码时抛出。

    飞书文档:
        [查询主日历忙闲信息](https://open.feishu.cn/document/server-docs/calendar-v4/calendar-event/list-2)

    Examples:
        >>> await client.calendar.freebusy.query({"time_min": "...", "time_max": "...", "user_id": "ou_xxx"})  # doctest:+SKIP
        {'freebusy_list': [{'start_time': '...', 'end_time': '...'}, ...]}  # noqa: E501
    """
    return await self._request_data("POST", "calendar/v4/freebusy/list", json=body)