"""Arcade Starter Tools for calendly

DO NOT EDIT THIS MODULE DIRECTLY.

THIS MODULE WAS AUTO-GENERATED BY TRANSPILING THE API WRAPPER TOOL JSON DEFINITIONS
IN THE ../wrapper_tools DIRECTORY INTO PYTHON CODE. ANY CHANGES TO THIS MODULE WILL
BE OVERWRITTEN BY THE TRANSPILER.
"""

import asyncio
from typing import Annotated, Any

import httpx
from arcade_tdk import ToolContext, tool
from arcade_tdk.auth import OAuth2

# Retry configuration
INITIAL_RETRY_DELAY = 0.5  # seconds

HTTP_CLIENT = httpx.AsyncClient(
    timeout=httpx.Timeout(60.0, connect=10.0),
    limits=httpx.Limits(max_keepalive_connections=20, max_connections=100),
    transport=httpx.AsyncHTTPTransport(retries=3),
    http2=True,
    follow_redirects=True,
)


def remove_none_values(data: dict[str, Any]) -> dict[str, Any]:
    return {k: v for k, v in data.items() if v is not None}


async def make_request(
    url: str,
    method: str,
    params: dict[str, Any] | None = None,
    headers: dict[str, Any] | None = None,
    data: dict[str, Any] | None = None,
    max_retries: int = 3,
) -> httpx.Response:
    """Make an HTTP request with retry logic for 5xx server errors."""
    for attempt in range(max_retries):
        try:
            response = await HTTP_CLIENT.request(
                url=url,
                method=method,
                params=params,
                headers=headers,
                data=data,
            )
            response.raise_for_status()
        except httpx.HTTPStatusError as e:
            # Only retry on 5xx server errors
            if e.response.status_code >= 500 and attempt < max_retries - 1:
                # Exponential backoff: 0.5s, 1s, 2s
                await asyncio.sleep(INITIAL_RETRY_DELAY * (2**attempt))
                continue
            # Re-raise for 4xx errors or if max retries reached
            raise
        except httpx.RequestError:
            # Don't retry request errors (network issues are handled by transport)
            raise
        else:
            return response

    # This should never be reached, but satisfies type checker
    raise httpx.RequestError("Max retries exceeded")  # noqa: TRY003


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_event_invitees(
    context: ToolContext,
    event_unique_identifier: Annotated[
        str,
        "The unique identifier of the event to retrieve invitees for. Use this to specify which event's attendees you want to list.",  # noqa: E501
    ],
    invitee_status: Annotated[
        str | None, "Filter invitees by their status: 'active' or 'canceled'."
    ] = None,
    sort_order_by_creation: Annotated[
        str | None,
        'Specify the sort order of invitees by their created_at date. Use "asc" for ascending or "desc" for descending order.',  # noqa: E501
    ] = None,
    filter_by_email: Annotated[
        str | None,
        "Filter results by the invitee's email address. Only invitees with this email will be returned.",  # noqa: E501
    ] = None,
    pagination_token: Annotated[
        str | None, "Token for fetching the next or previous portion of the event invitee list."
    ] = None,
    number_of_invitees_to_return: Annotated[
        float | None,
        "The number of invitee records to return in the response. Determines how many invitees are included per request.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-event-invitees'."]:
    """Fetch invitees for a specific scheduled event.

    Use this tool to retrieve a list of people invited to a specific event by providing the event's unique identifier. It helps in managing and viewing event attendees."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/scheduled_events/{uuid}/invitees".format(  # noqa: UP032
            uuid=event_unique_identifier
        ),
        method="GET",
        params=remove_none_values({
            "status": invitee_status,
            "sort": sort_order_by_creation,
            "email": filter_by_email,
            "page_token": pagination_token,
            "count": number_of_invitees_to_return,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_scheduled_events(
    context: ToolContext,
    user_uri: Annotated[
        str | None,
        "The URI identifying the user to retrieve scheduled events for. This can be used alone for personal events or with `organization` for specific user events within an organization. Requires appropriate privileges.",  # noqa: E501
    ] = None,
    organization_uri: Annotated[
        str | None,
        "Returns events scheduled with the specified organization's URI. Requires admin or owner privilege.",  # noqa: E501
    ] = None,
    invitee_email: Annotated[
        str | None,
        "Email address to filter events scheduled with the invitee. Use to retrieve events specific to an invitee.",  # noqa: E501
    ] = None,
    event_status: Annotated[
        str | None, "Specifies whether to retrieve events that are 'active' or 'canceled'."
    ] = None,
    order_results_by: Annotated[
        str | None,
        "Specify the field and direction to order results (e.g., 'start_time:asc'). Supported field: start_time; Directions: asc, desc.",  # noqa: E501
    ] = None,
    start_time_after: Annotated[
        str | None,
        'Include events with start times after this specified UTC time (e.g., "2020-01-02T03:04:05.678123Z").',  # noqa: E501
    ] = None,
    max_start_time: Annotated[
        str | None,
        'Include events with start times prior to this UTC time. Format: "2020-01-02T03:04:05.678123Z".',  # noqa: E501
    ] = None,
    pagination_token: Annotated[
        str | None,
        "Token used for paginating results, allowing access to the next or previous portion of the event collection.",  # noqa: E501
    ] = None,
    number_of_events_to_return: Annotated[
        float | None, "Specifies the number of events to be returned in the query result."
    ] = None,
    group_uri: Annotated[
        str | None,
        "URI of the group to retrieve scheduled events for. Requires appropriate admin privileges.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-scheduled-events'."]:
    """Retrieve a list of scheduled events from Calendly.

    This tool retrieves a list of scheduled events for a specified user, group, or organization in Calendly. Use it to view events you have access to, based on your role and privileges."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/scheduled_events",
        method="GET",
        params=remove_none_values({
            "user": user_uri,
            "organization": organization_uri,
            "invitee_email": invitee_email,
            "status": event_status,
            "sort": order_results_by,
            "min_start_time": start_time_after,
            "max_start_time": max_start_time,
            "page_token": pagination_token,
            "count": number_of_events_to_return,
            "group": group_uri,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_user_or_org_event_types(
    context: ToolContext,
    organization_uri: Annotated[
        str | None,
        "The URI of the organization to view its event types. Specify this to retrieve organization event types.",  # noqa: E501
    ] = None,
    user_uri: Annotated[
        str | None,
        "Specify the user's URI to view their personal, team, and organization event types.",
    ] = None,
    user_availability_schedule_filter: Annotated[
        str | None,
        "Filter Event Types for a user based on the primary availability schedule. Requires the 'user' parameter to be used.",  # noqa: E501
    ] = None,
    order_event_types_by: Annotated[
        str | None,
        "Order results by specified fields and directions. Use a comma-separated format: {field}:{direction}. Supported fields are: name, position, created_at, updated_at. Directions can be 'asc' or 'desc'.",  # noqa: E501
    ] = None,
    pagination_token: Annotated[
        str | None,
        "Token used for paginating through results. Pass it to get the next or previous portion of the collection.",  # noqa: E501
    ] = None,
    number_of_rows_to_return: Annotated[
        float | None,
        "Specify the number of event type entries to retrieve. Determines how many rows are returned in the response.",  # noqa: E501
    ] = None,
    filter_active_event_types: Annotated[
        bool | None,
        "Return only active event types if true, only inactive if false, or all event types if omitted.",  # noqa: E501
    ] = None,
    only_admin_managed_event_types: Annotated[
        bool | None,
        "Return only admin managed event types if true, exclude if false, or include all if omitted.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-event-types'."]:
    """Retrieve Event Types for a user or organization.

    Use this tool to get all Event Types for a specific user or organization. Specify either the 'organization' or 'user' as a query parameter when calling this tool."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/event_types",
        method="GET",
        params=remove_none_values({
            "active": filter_active_event_types,
            "organization": organization_uri,
            "user": user_uri,
            "user_availability_schedule": user_availability_schedule_filter,
            "sort": order_event_types_by,
            "admin_managed": only_admin_managed_event_types,
            "page_token": pagination_token,
            "count": number_of_rows_to_return,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_user_info(
    context: ToolContext,
    user_identifier: Annotated[
        str, 'Provide a unique user identifier or use "me" to refer to the current caller.'
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-user'."]:
    """Retrieve information about a specified Calendly user.

    Use this tool to obtain detailed information about a specific Calendly user by providing their unique identifier. Ideal for accessing user settings, profile details, and preferences."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/users/{uuid}".format(uuid=user_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_user_account_info(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-current-user'."]:
    """Retrieve basic information about your Calendly account."""
    response = await make_request(
        url="https://api.calendly.com/users/me",
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_event_invitee_info(
    context: ToolContext,
    event_unique_identifier: Annotated[
        str,
        "A unique string identifier for the event to identify which event's invitee information to retrieve.",  # noqa: E501
    ],
    invitee_unique_identifier: Annotated[
        str,
        "The unique identifier for the invitee of a specific event. Required to retrieve invitee details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-scheduled-event-invitees'."]:
    """Retrieve information about a specific event invitee.

    Use this tool to get detailed information about a specified invitee for an event, including their attendance status and personal details."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/scheduled_events/{event_uuid}/invitees/{invitee_uuid}".format(  # noqa: UP032
            event_uuid=event_unique_identifier, invitee_uuid=invitee_unique_identifier
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_event_details(
    context: ToolContext,
    event_unique_identifier: Annotated[
        str, "A unique identifier for the event to retrieve its details."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-scheduled-event'."]:
    """Retrieve details about a specific scheduled event.

    Use this tool to obtain information about a particular event that has been scheduled, by specifying its unique identifier."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/scheduled_events/{uuid}".format(uuid=event_unique_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_event_type_info(
    context: ToolContext,
    event_type_uuid: Annotated[
        str,
        "A unique identifier for the Event Type. Provide this to get information about the specific Event Type.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-event-type'."]:
    """Retrieve information about a specified Event Type.

    Use this tool to fetch details of a specific Event Type by providing its unique identifier."""
    response = await make_request(
        url="https://api.calendly.com/event_types/{uuid}".format(uuid=event_type_uuid),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_organization_invitations(
    context: ToolContext,
    organization_unique_identifier: Annotated[
        str,
        "The unique identifier for the organization whose member invitations you want to retrieve.",
    ],
    number_of_rows_to_return: Annotated[
        float | None, "Specifies the number of invitation rows to return."
    ] = None,
    pagination_token: Annotated[
        str | None, "Token to retrieve the next or previous set of organization invitation results."
    ] = None,
    sort_order: Annotated[
        str | None,
        "Specify field name and sort direction (asc or desc). Use a comma-separated list for multiple fields.",  # noqa: E501
    ] = None,
    filter_by_email: Annotated[
        str | None,
        "Filter results by a specific email address. Provide the email to narrow down the invitations.",  # noqa: E501
    ] = None,
    filter_by_status: Annotated[
        str | None, 'Filter results by invitation status: "pending", "accepted", or "declined".'
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-organization-invitations'."]:
    """Retrieve invitations sent to organization members.

    Use this tool to obtain a list of invitations that have been sent to the members of an organization. It retrieves all organization member invitations."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organizations/{uuid}/invitations".format(  # noqa: UP032
            uuid=organization_unique_identifier
        ),
        method="GET",
        params=remove_none_values({
            "count": number_of_rows_to_return,
            "page_token": pagination_token,
            "sort": sort_order,
            "email": filter_by_email,
            "status": filter_by_status,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def revoke_org_invitation(
    context: ToolContext,
    organization_unique_identifier: Annotated[
        str, "The unique identifier for the organization whose invitation is to be revoked."
    ],
    invitation_uuid: Annotated[
        str, "The unique identifier for the organization invitation to be revoked."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'revoke-organization-invitation'."]:
    """Revoke an organization's invitation link.

    Use this tool to revoke an existing invitation to an organization. Once revoked, the invitation link becomes invalid and cannot be used."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organizations/{org_uuid}/invitations/{uuid}".format(  # noqa: UP032
            org_uuid=organization_unique_identifier, uuid=invitation_uuid
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def fetch_organization_invitation(
    context: ToolContext,
    organization_unique_identifier: Annotated[
        str,
        "The unique identifier for the organization. Used to fetch the relevant invitation details.",  # noqa: E501
    ],
    invitation_unique_identifier: Annotated[
        str,
        "The unique identifier for the organization invitation. Required to fetch specific invitation details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organization-invitation'."]:
    """Fetches an organization's member invitation details.

    Use this tool to obtain details of an invitation sent to members of a specific organization by providing the organization and invitation identifiers."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organizations/{org_uuid}/invitations/{uuid}".format(  # noqa: UP032
            org_uuid=organization_unique_identifier, uuid=invitation_unique_identifier
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_organization_membership(
    context: ToolContext,
    organization_membership_unique_identifier: Annotated[
        str, "The unique identifier for the organization membership to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organization-membership'."]:
    """Retrieve details about a user's organization membership.

    Use this tool to get detailed information on a user's organization membership by providing their unique identifier."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organization_memberships/{uuid}".format(  # noqa: UP032
            uuid=organization_membership_unique_identifier
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def remove_organization_member(
    context: ToolContext,
    organization_membership_id: Annotated[
        str,
        "The unique identifier for the organization membership to be removed. Required for identifying the specific user.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-organization-membership'."]:
    """Removes a user from an organization as an admin.

    Use this tool to remove a user from an organization if you have admin rights. Note that an organization owner cannot be removed."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organization_memberships/{uuid}".format(  # noqa: UP032
            uuid=organization_membership_id
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_organization_memberships_calendly(
    context: ToolContext,
    pagination_token: Annotated[
        str | None, "Token to fetch the next or previous set of results in the collection."
    ] = None,
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of organization membership records to return."
    ] = None,
    filter_by_email: Annotated[
        str | None, "Filter results to include members with the specified email address."
    ] = None,
    filter_by_organization: Annotated[
        str | None,
        "Filter results to include only members from a specified organization by its identifier.",
    ] = None,
    filter_by_user: Annotated[
        str | None, "Filter results by a specific user's email address or ID."
    ] = None,
    filter_by_role: Annotated[str | None, "Filter results by role: owner, admin, or user."] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-organization-memberships'."]:
    """Retrieve organization memberships and associated details.

    Use this tool to list organization memberships for users within an organization. You can either look up a user's membership or find all users in the organization. This tool also retrieves the organization's URI."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organization_memberships",
        method="GET",
        params=remove_none_values({
            "page_token": pagination_token,
            "count": number_of_rows_to_return,
            "email": filter_by_email,
            "organization": filter_by_organization,
            "user": filter_by_user,
            "role": filter_by_role,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_webhook_subscriptions(
    context: ToolContext,
    organization_identifier: Annotated[
        str, "Specify the organization that owns the subscriptions. This field is mandatory."
    ],
    filter_by_scope: Annotated[
        str,
        "Filter the subscriptions by organization, user, or group. Expected values are 'organization', 'user', or 'group'.",  # noqa: E501
    ],
    user_filter: Annotated[
        str | None,
        "Filter results by user. Required if scope is set to `user`. Provide the user ID.",
    ] = None,
    filter_by_group: Annotated[
        str | None,
        "Filter results by group if the `scope` is set to `group`. Provide the group identifier.",
    ] = None,
    pagination_token: Annotated[
        str | None,
        "The token used to navigate to the next or previous part of the collection results.",
    ] = None,
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of webhook subscription rows to return."
    ] = None,
    sort_order: Annotated[
        str | None,
        "Specify the sort order for the results using a comma-separated list of field:direction pairs (e.g., 'created_at:asc'). Currently, only 'created_at' is supported, with directions 'asc' for ascending and 'desc' for descending.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-webhook-subscriptions'."]:
    """Retrieve webhook subscriptions for an organization or user.

    This tool fetches a list of webhook subscriptions associated with a specified organization or user. Use it to manage or review existing webhook connections."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/webhook_subscriptions",
        method="GET",
        params=remove_none_values({
            "organization": organization_identifier,
            "user": user_filter,
            "group": filter_by_group,
            "page_token": pagination_token,
            "count": number_of_rows_to_return,
            "sort": sort_order,
            "scope": filter_by_scope,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_webhook_subscription(
    context: ToolContext,
    webhook_uuid: Annotated[
        str, "The unique identifier for the webhook subscription to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-webhook-subscription'."]:
    """Retrieve details of a specified webhook subscription.

    Use this tool to get information about a specific webhook subscription by providing the webhook UUID."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/webhook_subscriptions/{webhook_uuid}".format(  # noqa: UP032
            webhook_uuid=webhook_uuid
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def delete_webhook_subscription(
    context: ToolContext,
    webhook_uuid: Annotated[
        str, "The unique identifier for the webhook subscription to be deleted."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-webhook-subscription'."]:
    """Delete a webhook subscription in Calendly.

    Use this tool to delete an existing webhook subscription in Calendly when it's no longer needed."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/webhook_subscriptions/{webhook_uuid}".format(  # noqa: UP032
            webhook_uuid=webhook_uuid
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def retrieve_invitee_no_show_info(
    context: ToolContext,
    invitee_no_show_uuid: Annotated[
        str,
        "The unique identifier for the specific invitee no show entry. This is required to retrieve the details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-invitee-no-show'."]:
    """Retrieve details of an invitee marked as a no show.

    This tool retrieves specific information about an invitee who did not show up for an event as scheduled. Use it to get details when you have the unique identifier for the invitee no show entry."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/invitee_no_shows/{uuid}".format(uuid=invitee_no_show_uuid),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def undo_no_show_mark_calendly(
    context: ToolContext,
    invitee_identifier: Annotated[
        str, "The unique identifier of the invitee whose no-show status needs to be undone."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-invitee-no-show'."]:
    """Undo marking an invitee as a no-show in Calendly.

    Use this tool to reverse the status of an invitee marked as a no-show in Calendly. This is useful when a no-show marking needs to be undone."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/invitee_no_shows/{uuid}".format(uuid=invitee_identifier),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_group_information(
    context: ToolContext,
    group_unique_identifier: Annotated[
        str, "The unique identifier for the group you want to retrieve information about."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-group'."]:
    """Returns information about a specified Group.

    Use this tool to get details about a specific group by providing its UUID."""
    response = await make_request(
        url="https://api.calendly.com/groups/{uuid}".format(uuid=group_unique_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_group_relationships(
    context: ToolContext,
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of rows to return in the response."
    ] = None,
    pagination_token: Annotated[
        str | None,
        "Token for paginating through results, used for accessing the next or previous portion of the collection.",  # noqa: E501
    ] = None,
    filter_by_organization: Annotated[
        str | None,
        "Indicates the results should be filtered by organization. Provide the organization's URI.",
    ] = None,
    filter_by_owner: Annotated[
        str | None,
        "Filter results by owner using a specific URI format: Organization Membership or Organization Invitation.",  # noqa: E501
    ] = None,
    filter_by_group: Annotated[
        str | None,
        "Indicate the group to filter the results by. Provide the group identifier as the value.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-group-relationships'."]:
    """Retrieve group relationships for a Calendly owner.

    This tool returns a list of group relationships for a given owner in Calendly, which includes one membership record and multiple admin records, if available."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/group_relationships",
        method="GET",
        params=remove_none_values({
            "count": number_of_rows_to_return,
            "page_token": pagination_token,
            "organization": filter_by_organization,
            "owner": filter_by_owner,
            "group": filter_by_group,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_group_relationship_by_uuid(
    context: ToolContext,
    group_relationship_uuid: Annotated[
        str,
        "The UUID of the group relationship to retrieve details for. This is a unique identifier for the group within Calendly.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-group-relationship'."]:
    """Retrieve a group relationship using its UUID.

    Use this tool to get details about a specific group relationship by providing its UUID. It is useful for obtaining information about group connections within Calendly."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/group_relationships/{uuid}".format(  # noqa: UP032
            uuid=group_relationship_uuid
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_organization_details(
    context: ToolContext,
    organization_unique_identifier: Annotated[
        str, "The unique identifier for the organization to retrieve details from Calendly."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organization'."]:
    """Retrieve details of a specified organization by UUID.

    Use this tool to get detailed information about a specific organization on Calendly by providing its UUID."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/organizations/{uuid}".format(  # noqa: UP032
            uuid=organization_unique_identifier
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_routing_forms(
    context: ToolContext,
    organization_uri: Annotated[
        str,
        "The URI of the organization to view its routing forms. Use the organization's URI to identify it.",  # noqa: E501
    ],
    rows_to_return: Annotated[
        float | None, "Specify the number of Routing Form entries to retrieve."
    ] = None,
    paging_token: Annotated[
        str | None, "Token for retrieving the next or previous set of Routing Forms in pagination."
    ] = None,
    sort_order: Annotated[
        str | None,
        "Specify sorting order for results using a comma-separated list of {field}:{direction}. Supported fields: created_at. Directions: asc, desc.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-routing-forms'."]:
    """Retrieve a list of Routing Forms for your organization.

    Use this tool to get a comprehensive list of Routing Forms within a specified organization. Ideal for gathering form data for review or analysis."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/routing_forms",
        method="GET",
        params=remove_none_values({
            "organization": organization_uri,
            "count": rows_to_return,
            "page_token": paging_token,
            "sort": sort_order,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_specific_routing_form(
    context: ToolContext,
    routing_form_uuid: Annotated[
        str, "The unique identifier (UUID) for the specific routing form to be retrieved."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-routing-form'."]:
    """Retrieve details of a specified routing form using UUID.

    Use this tool to obtain information about a particular routing form in Calendly by providing the unique identifier (UUID)."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/routing_forms/{uuid}".format(uuid=routing_form_uuid),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_routing_form_submissions(
    context: ToolContext,
    routing_form_uri: Annotated[str, "The URI of the routing form to view its submissions."],
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of form submission rows to return."
    ] = None,
    pagination_token: Annotated[
        str | None,
        "Token used for retrieving the next or previous set of routing form submissions based on pagination.",  # noqa: E501
    ] = None,
    order_results_by_field: Annotated[
        str | None,
        "Comma-separated list to order results by {field}:{direction}, e.g., 'created_at:asc'.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-routing-form-submissions'."]:
    """Retrieve submissions for a specific routing form.

    Get a list of submissions made to a specific routing form in Calendly."""
    response = await make_request(
        url="https://api.calendly.com/routing_form_submissions",
        method="GET",
        params=remove_none_values({
            "form": routing_form_uri,
            "count": number_of_rows_to_return,
            "page_token": pagination_token,
            "sort": order_results_by_field,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_routing_form_submission(
    context: ToolContext,
    submission_uuid: Annotated[
        str, "The unique identifier for the routing form submission to retrieve."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-routing-form-submission'."]:
    """Retrieve details of a specified routing form submission.

    Use this tool to get detailed information about a specific routing form submission by providing its unique identifier (UUID)."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/routing_form_submissions/{uuid}".format(uuid=submission_uuid),  # noqa: UP032
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_event_type_available_times(
    context: ToolContext,
    event_type_uri: Annotated[
        str, "The URI associated with the specific event type to query available times for."
    ],
    availability_start_time: Annotated[
        str, "The start time for the availability request. Ensure the date is not in the past."
    ],
    end_time: Annotated[
        str,
        "End time of the requested availability range. This date must be later than the start_time and within 7 days.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-event-type-available-times'."]:
    """Get available times for an event type within a date range.

    Use this tool to retrieve available times for a specific event type within a 7-day date range. Ideal for scheduling and planning purposes."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/event_type_available_times",
        method="GET",
        params=remove_none_values({
            "event_type": event_type_uri,
            "start_time": availability_start_time,
            "end_time": end_time,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_activity_log_entries(
    context: ToolContext,
    organization_uri: Annotated[
        str, "The URI of the organization for which to return activity log entries."
    ],
    filter_by_search_term: Annotated[
        str | None,
        'Specify terms to filter log entries. Use operators like |, +, " ", -, (), *. Eg: "email@website.com" or (term1 + term2).',  # noqa: E501
    ] = None,
    actor_uris: Annotated[
        list[str] | None,
        "An array of URIs for users whose entries should be returned. Include multiple URIs for multiple users.",  # noqa: E501
    ] = None,
    sort_order: Annotated[
        list[str] | None,
        "Order results by the specified field and direction using {field}:{direction} format. Example: 'date:asc'.",  # noqa: E501
    ] = None,
    include_entries_after_time: Annotated[
        str | None,
        'Include entries that occurred after this specified UTC time (e.g., "2020-01-02T03:04:05.678Z").',  # noqa: E501
    ] = None,
    end_time_utc: Annotated[
        str | None,
        "Specify entries occurring before this UTC time (e.g., '2020-01-02T03:04:05.678Z').",
    ] = None,
    next_page_token: Annotated[
        str | None,
        "Provide the token to retrieve the subsequent portion of the activity log collection.",
    ] = None,
    number_of_rows_to_return: Annotated[
        int | None, "Specifies the number of activity log entries to return."
    ] = None,
    entry_categories: Annotated[
        list[str] | None, "Specify categories of activity log entries to retrieve."
    ] = None,
    filter_by_actions: Annotated[
        list[str] | None,
        "A list of actions to filter activity log entries. Provide actions associated with the entries.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-activity-log-entries'."]:
    """Retrieve a list of activity log entries.

    Use this tool to get a list of activity log entries from Calendly. This endpoint requires an Enterprise subscription."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/activity_log_entries",
        method="GET",
        params=remove_none_values({
            "organization": organization_uri,
            "search_term": filter_by_search_term,
            "actor": actor_uris,
            "sort": sort_order,
            "min_occurred_at": include_entries_after_time,
            "max_occurred_at": end_time_utc,
            "page_token": next_page_token,
            "count": number_of_rows_to_return,
            "namespace": entry_categories,
            "action": filter_by_actions,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def list_user_busy_times(
    context: ToolContext,
    user_uri: Annotated[str, "The URI associated with the user to retrieve busy times for."],
    availability_start_time: Annotated[
        str,
        "Start time of the requested availability range. The date cannot be in the past and must be formatted correctly.",  # noqa: E501
    ],
    availability_end_time: Annotated[
        str, "End time for the requested availability range; must be after the start time."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-user-busy-times'."]:
    """Retrieve user's scheduled events in a date range.

    Get an ascending list of user's internal and external events within a specified date range, up to 7 days. External events are returned for configured calendars only."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/user_busy_times",
        method="GET",
        params=remove_none_values({
            "user": user_uri,
            "start_time": availability_start_time,
            "end_time": availability_end_time,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_user_availability_schedules(
    context: ToolContext,
    user_uri_reference: Annotated[
        str, "A string representing the URI of the user to retrieve availability for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'list-user-availability-schedules'."
]:
    """Retrieve the user's availability schedules.

    This tool returns the availability schedules for a specified user. Call this tool when you need to know a user's available times for scheduling purposes."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/user_availability_schedules",
        method="GET",
        params=remove_none_values({"user": user_uri_reference}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_user_availability_schedule(
    context: ToolContext,
    user_availability_uuid: Annotated[
        str, "The UUID of the user's availability schedule to fetch."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-user-availability-schedule'."]:
    """Fetches the availability schedule for a specific user.

    Use this tool to obtain the availability schedule associated with a specific user's UUID in Calendly. It helps in identifying the available time slots for the user."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/user_availability_schedules/{uuid}".format(  # noqa: UP032
            uuid=user_availability_uuid
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def fetch_event_type_hosts(
    context: ToolContext,
    event_type_uri: Annotated[
        str, "The URI associated with the event type to identify and fetch associated hosts."
    ],
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of event type hosts to return."
    ] = None,
    pagination_token: Annotated[
        str | None, "Token to retrieve the next or previous portion of event type hosts."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-event-type-memberships'."]:
    """Fetch a list of event type hosts from Calendly.

    Use this tool to retrieve a list of hosts for event types from Calendly's API. This is helpful for understanding which hosts are associated with specific event types."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/event_type_memberships",
        method="GET",
        params=remove_none_values({
            "event_type": event_type_uri,
            "count": number_of_rows_to_return,
            "page_token": pagination_token,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_sample_webhook_data(
    context: ToolContext,
    event_type: Annotated[
        str,
        "Specifies the type of event for which you want to retrieve sample webhook data. Options include 'invitee.created', 'invitee.canceled', 'invitee_no_show.created', 'invitee_no_show.deleted', and 'routing_form_submission.created'.",  # noqa: E501
    ],
    organization_identifier: Annotated[
        str,
        "The unique identifier of the organization in Calendly for which you want to retrieve sample webhook data.",  # noqa: E501
    ],
    scope: Annotated[
        str, "Defines the scope of the webhook data to fetch: 'user', 'organization', or 'group'."
    ],
    user_identifier: Annotated[
        str | None,
        "The unique identifier for the Calendly user whose webhook data is being tested. Provide a valid user ID or username.",  # noqa: E501
    ] = None,
    event_group_identifier: Annotated[
        str | None,
        "Specify the group identifier to test webhook data for a specific group. This helps categorize or organize the webhook data samples.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-sample-webhook-data'."]:
    """Retrieve sample webhook data for testing purposes.

    Use this tool to access sample data for testing your Calendly webhook subscription."""
    response = await make_request(
        url="https://api.calendly.com/sample_webhook_data",
        method="GET",
        params=remove_none_values({
            "event": event_type,
            "organization": organization_identifier,
            "user": user_identifier,
            "scope": scope,
            "group": event_group_identifier,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_outgoing_communications(
    context: ToolContext,
    organization_uri: Annotated[
        str, "URI to identify the organization for which to return outgoing communications."
    ],
    number_of_records: Annotated[
        int | None, "Specify the number of outgoing communication records to return."
    ] = None,
    filter_communications_after: Annotated[
        str | None,
        'Include outgoing communications created after this UTC time. Format: "YYYY-MM-DDTHH:MM:SS.sssZ".',  # noqa: E501
    ] = None,
    end_date_time_utc: Annotated[
        str | None,
        'Include outgoing communications created before this UTC time. Format: "2020-01-02T03:04:05.678Z".',  # noqa: E501
    ] = None,
    pagination_token: Annotated[
        str | None, "Token used to retrieve the next set of outgoing communication records."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-outgoing-communications'."]:
    """Retrieve outgoing SMS and email communications.

    Use this tool to access a list of outgoing SMS and email communications. Requires an Enterprise subscription."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/outgoing_communications",
        method="GET",
        params=remove_none_values({
            "organization": organization_uri,
            "count": number_of_records,
            "min_created_at": filter_communications_after,
            "max_created_at": end_date_time_utc,
            "page_token": pagination_token,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_group_list(
    context: ToolContext,
    organization_uri: Annotated[str, "URI of the organization to get associated groups."],
    pagination_token: Annotated[
        str | None, "Token used for pagination to retrieve the next or previous set of groups."
    ] = None,
    number_of_rows_to_return: Annotated[
        float | None, "Specify the number of group entries to return from Calendly."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-groups'."]:
    """Retrieve a list of groups from Calendly.

    This tool calls the Calendly API to return a list of groups. It should be used when you need information about groups within Calendly."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/groups",
        method="GET",
        params=remove_none_values({
            "organization": organization_uri,
            "page_token": pagination_token,
            "count": number_of_rows_to_return,
        }),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_user_location_info(
    context: ToolContext,
    user_uri: Annotated[str, "The URI of the user whose location information is being requested."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-user-locations'."]:
    """Fetches location information for a specific user.

    Use this tool to obtain the configured location details for a specified user. It should be called when you need to know where a user's events or activities are set to take place."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/locations",
        method="GET",
        params=remove_none_values({"user": user_uri}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_auth=OAuth2(id="arcade-calendly"))
async def get_event_type_availability(
    context: ToolContext,
    event_type_uri: Annotated[
        str, "The URI associated with the specific event type whose availability is being queried."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-event-type-availability'."]:
    """Fetches availability for a Calendly event type.

    Use this tool to retrieve the availability schedule for a specific event type on Calendly. It helps in planning and checking open time slots based on the event type's settings."""  # noqa: E501
    response = await make_request(
        url="https://api.calendly.com/event_type_availability_schedules",
        method="GET",
        params=remove_none_values({"event_type": event_type_uri}),
        headers=remove_none_values({
            "Authorization": "Bearer {authorization}".format(  # noqa: UP032
                authorization=context.get_auth_token_or_empty()
            )
        }),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}
