"""Arcade Starter Tools for Trello

DO NOT EDIT THIS MODULE DIRECTLY.

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

import asyncio
import json
from enum import Enum
from typing import Annotated, Any

import httpx
import jsonschema
from arcade_tdk import ToolContext, tool
from arcade_tdk.errors import RetryableToolError

from .request_body_schemas import REQUEST_BODY_SCHEMAS

# 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,
)


class ToolMode(str, Enum):
    """Mode for tools with complex request bodies."""

    GET_REQUEST_SCHEMA = "get_request_schema"
    EXECUTE = "execute"


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,
    content: str | None = None,
    data: dict[str, Any] | None = None,
    auth: tuple[str, str] | 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,
                auth=auth,
                method=method,
                params=params,
                headers=headers,
                content=content,
            )
            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


async def make_request_with_schema_validation(
    url: str,
    method: str,
    request_data: dict[str, Any],
    schema: dict[str, Any] | str,
    auth: tuple[str, str] | None = None,
    params: dict[str, Any] | None = None,
    headers: dict[str, Any] | None = None,
    max_retries: int = 3,
) -> httpx.Response:
    """Make an HTTP request with schema validation on format errors."""
    # Parse schema if it's a string, skip validation if parsing fails
    parsed_schema = None
    if isinstance(schema, str):
        try:
            parsed_schema = json.loads(schema)
        except Exception:
            # If schema parsing fails, just skip validation
            parsed_schema = None
    else:
        parsed_schema = schema

    try:
        response = await make_request(
            url=url,
            auth=auth,
            method=method,
            params=params,
            headers=headers,
            content=json.dumps(request_data),
            max_retries=max_retries,
        )
    except httpx.HTTPStatusError as e:
        # Only provide schema validation for format-related errors
        if e.response.status_code in (400, 422):
            api_error_details = f"API returned {e.response.status_code}: {e.response.text}"

            # Only run validation if we have a valid parsed schema
            if parsed_schema is not None:
                # Run validation to provide additional context
                is_valid, validation_error = validate_json_against_schema(
                    request_data, parsed_schema
                )

                if not is_valid:
                    # Schema validation found issues - additional context
                    additional_context = (
                        f"{api_error_details}\n\n"
                        f"Schema validation found the following issues:\n"
                        f"{validation_error}"
                    )
                else:
                    # Schema validation passed - just show API error
                    additional_context = api_error_details
            else:
                # No valid schema - just show API error
                additional_context = api_error_details

            raise RetryableToolError(
                message=(f"API request failed with validation error: {e.response.status_code}"),
                developer_message=api_error_details,
                additional_prompt_content=additional_context,
            ) from e
        else:
            # For non-validation errors, re-raise as-is
            raise
    else:
        return response


def validate_json_against_schema(
    json_data: dict[str, Any], schema: dict[str, Any]
) -> tuple[bool, str | None]:
    """Validate JSON data against an OpenAPI/JSON Schema.

    This provides full JSON Schema Draft 7 validation including:
    - Required fields, types, enums
    - Pattern validation (regex)
    - Format validation (email, uuid, date-time, etc.)
    - Min/max length and values
    - oneOf, anyOf, allOf
    - And all other JSON Schema features

    Args:
        json_data: The JSON data to validate
        schema: The JSON Schema to validate against

    Returns:
        Tuple of (is_valid, error_messages). If valid, error_messages is None.
        If invalid, error_messages contains all validation errors.
    """
    try:
        validator = jsonschema.Draft7Validator(
            schema, format_checker=jsonschema.Draft7Validator.FORMAT_CHECKER
        )
        # Collect ALL validation errors
        errors = list(validator.iter_errors(json_data))
        if errors:
            # Format all errors with their paths
            error_messages = []
            for error in errors:
                error_path = ".".join(str(p) for p in error.path) if error.path else "root"
                error_messages.append(f"{error.message} at {error_path}")
            # Join all errors with newlines
            return False, "\n".join(error_messages)
        else:
            return True, None
    except jsonschema.SchemaError as e:
        return False, f"Invalid schema: {e.message}"
    except Exception as e:
        return False, f"Validation error: {e!s}"


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_action(
    context: ToolContext,
    action_id: Annotated[
        str,
        "The unique ID of the Trello action to be fetched. Required for retrieving specific action details.",  # noqa: E501
    ],
    action_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of action fields you want to retrieve. Use 'all' for full details.",  # noqa: E501
    ] = "all",
    include_display_info: Annotated[
        bool | None, "Include display information in the response if true."
    ] = True,
    include_entities: Annotated[
        bool | None,
        "Set to True to include related entities in the response, or False to exclude them.",
    ] = False,
    include_member: Annotated[
        bool | None,
        "Include the member object in the response for the action. Set to true to include.",
    ] = True,
    include_member_creator: Annotated[
        bool | None, "Set to true to include the member object for the creator of the action."
    ] = True,
    member_creator_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of member fields to include for the action creator.",  # noqa: E501
    ] = "avatarHash,fullName,initials,username",
    member_information_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of member fields to include in the response.",
    ] = "avatarHash,fullName,initials,username",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id'."]:
    """Fetches details of a specific Trello action by ID.

    Use this tool to obtain information about a specific action in Trello by providing the action ID. It retrieves detailed information of the action, which can be useful for tracking and managing tasks."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "display": include_display_info,
            "entities": include_entities,
            "fields": action_fields,
            "member": include_member,
            "member_fields": member_information_fields,
            "memberCreator": include_member_creator,
            "memberCreator_fields": member_creator_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_comment(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique identifier for the specific action comment you want to update."
    ],
    new_comment_text: Annotated[str, "The updated text content for the Trello comment action."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-actions-id'."]:
    """Edit a comment action in Trello.

    Use this tool to update the content of a specific comment action on Trello. It is applicable only to comment actions."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}".format(id=action_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "text": new_comment_text,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_action(
    context: ToolContext,
    action_id: Annotated[
        str,
        "The ID of the comment action to be deleted. Only comment actions are valid for deletion.",
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-actions-id'."]:
    """Delete a specific comment action from Trello.

    Use this tool to delete comment actions from Trello boards. Only actions categorized as comments can be removed using this function."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}".format(id=action_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_property(
    context: ToolContext,
    action_field: Annotated[
        str, "The specific field to retrieve from a Trello action, such as 'id', 'type', or 'date'."
    ],
    action_id: Annotated[
        str, "The unique identifier of the action to retrieve its specific property."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-field'."]:
    """Retrieve a specific property of a Trello action.

    Use this tool to get a particular field value from a Trello action using its ID and the desired field name."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/{field}".format(  # noqa: UP032
            id=action_id, field=action_field
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_for_action(
    context: ToolContext,
    action_id: Annotated[str, "The ID of the action to retrieve the associated board details."],
    board_fields: Annotated[
        str | None, "Specify 'all' or a comma-separated list of board fields like 'id, name, desc'."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-board'."]:
    """Retrieve board details for a given action on Trello.

    Use this tool to get information about the board linked to a specific action in Trello. Ideal for when you need to trace back an action's board context."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/board".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_card_for_action(
    context: ToolContext,
    action_id: Annotated[str, "The unique identifier of the action linked to the Trello card."],
    card_fields: Annotated[
        str | None,
        "Specify 'all' to retrieve all fields or provide a comma-separated list of specific card fields like 'id,name,shortUrl'.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-card'."]:
    """Get details of a Trello card associated with an action.

    This tool retrieves the details of a Trello card linked to a specific action. It should be called when you need information about the card associated with a particular Trello action."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/card".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": card_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_list(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique identifier of the Trello action to retrieve its associated list."
    ],
    list_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of fields to retrieve for the list. Acceptable values include specific fields like 'id'.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-list'."]:
    """Retrieve the list associated with a Trello action.

    This tool fetches the list details for a specified action in Trello. It should be called when you need to know the list connected to a specific action ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/list".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": list_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_member(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique ID of the Trello action to retrieve the associated member's details."
    ],
    member_fields: Annotated[
        str | None,
        "Specify `all` to retrieve all member fields or provide a comma-separated list of specific fields.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-member'."]:
    """Retrieve the member associated with a Trello action.

    Use this tool to get information about the member linked to a specific Trello action, excluding the creator. This can be useful when analyzing who is involved in the action."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/member".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_creator_member(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique identifier of the Trello action to retrieve the creator information for."
    ],
    member_fields: Annotated[
        str | None, "Specify 'all' or a comma-separated list of member fields to retrieve."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-membercreator'."]:
    """Retrieve the member who created a specific Trello action.

    Use this tool to get details about the member who created a specific action in Trello. It provides information about the member associated with a particular action ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/memberCreator".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_organization(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique ID of the Trello action to retrieve the associated organization details."
    ],
    organization_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of fields (e.g., 'id', 'name') to determine which organization details to retrieve.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-id-organization'."]:
    """Retrieve the organization related to a Trello action.

    Use this tool to obtain the organization associated with a specific Trello action. It should be called when details about the organization of an action are needed."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/organization".format(id=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": organization_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def modify_trello_comment(
    context: ToolContext,
    action_id_to_update: Annotated[str, "The ID of the Trello comment action to update."],
    new_comment_text: Annotated[
        str, "Provide the new text for the Trello comment you wish to update."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-actions-id-text'."]:
    """Update the text of a Trello comment action.

    Use this tool to modify the text of an existing comment in Trello by specifying the action ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{id}/text".format(id=action_id_to_update),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": new_comment_text,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_reactions_for_action(
    context: ToolContext,
    action_id: Annotated[str, "The unique ID of the action for which you want to list reactions."],
    include_member_as_nested_resource: Annotated[
        bool | None,
        "Specify true to include the member as a nested resource in the response. Useful for detailed member information.",  # noqa: E501
    ] = True,
    load_emoji_as_nested_resource: Annotated[
        bool | None, "Set to true to load the emoji as a nested resource."
    ] = True,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-actions-idaction-reactions'."]:
    """Retrieve reactions for a specific Trello action.

    This tool retrieves a list of reactions associated with a specific action on Trello. It should be called when you need to see how users have reacted to a particular action on a Trello board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{idAction}/reactions".format(idAction=action_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "member": include_member_as_nested_resource,
            "emoji": load_emoji_as_nested_resource,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_reaction_to_trello_action(
    context: ToolContext,
    action_id: Annotated[str, "The ID of the Trello action to which you want to add a reaction."],
    emoji_short_name: Annotated[
        str | None, "The short name of the emoji to add as a reaction, like 'thumbsup' or 'smile'."
    ] = None,
    emoji_skin_variation: Annotated[
        str | None,
        "Specifies the `skinVariation` for the emoji being added as a reaction, like default or medium-light.",  # noqa: E501
    ] = None,
    emoji_unified_value: Annotated[
        str | None,
        "The `unified` value of the emoji to add to the Trello action. This is a code representing the emoji and is used to specify the exact emoji to add.",  # noqa: E501
    ] = None,
    native_emoji_unicode: Annotated[
        str | None,
        "The native unicode emoji to add as a reaction. It should be a valid emoji character.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-actions-idaction-reactions'."]:
    """Add a reaction to a Trello action.

    Use this tool to add a new reaction to a specific action within Trello. It should be called when you want to express feedback or sentiment on an action item on Trello."""  # noqa: E501
    request_data = remove_none_values({
        "shortName": emoji_short_name,
        "skinVariation": emoji_skin_variation,
        "native": native_emoji_unicode,
        "unified": emoji_unified_value,
    })
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{idAction}/reactions".format(idAction=action_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_reaction_info(
    context: ToolContext,
    action_id: Annotated[str, "The ID of the Trello Action to retrieve reaction information for."],
    reaction_id: Annotated[
        str, "The unique identifier for the specific reaction to retrieve details."
    ],
    include_emoji_as_nested_resource: Annotated[
        bool | None, "Set to true to load emoji as a nested resource."
    ] = True,
    include_member_as_nested_resource: Annotated[
        bool | None,
        "Include the member as a nested resource in the reaction details. Refer to the Members Nested Resource guide.",  # noqa: E501
    ] = True,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-actions-idaction-reactions-id'."
]:
    """Get detailed information about a specific Trello reaction.

    This tool retrieves details about a specific reaction associated with a Trello action. Call this tool when you need to access metadata or information related to a particular reaction within an action on Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{idAction}/reactions/{id}".format(  # noqa: UP032
            idAction=action_id, id=reaction_id
        ),
        method="GET",
        params=remove_none_values({
            "member": include_member_as_nested_resource,
            "emoji": include_emoji_as_nested_resource,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_reaction(
    context: ToolContext,
    action_id: Annotated[
        str, "The ID of the Trello action from which the reaction will be deleted."
    ],
    reaction_id: Annotated[
        str, "The unique identifier of the reaction to be deleted from a Trello action."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-actions-idaction-reactions-id'."
]:
    """Deletes a specific reaction on a Trello action.

    Use this tool to delete a reaction from a specified action in Trello by providing the action ID and reaction ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{idAction}/reactions/{id}".format(  # noqa: UP032
            idAction=action_id, id=reaction_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_action_reactions_summary(
    context: ToolContext,
    action_id: Annotated[
        str, "The unique identifier for the specific Trello action to retrieve reactions for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-actions-idaction-reactionsummary'."
]:
    """Get a summary of all reactions for a Trello action.

    Use this tool to obtain a summary of all reactions associated with a specific action on Trello. It helps in understanding how users have interacted with a particular action."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/actions/{idAction}/reactionsSummary".format(  # noqa: UP032
            idAction=action_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_application_compliance_data(
    context: ToolContext,
    application_key: Annotated[
        str,
        "The unique key for the application to retrieve its compliance data. This is required to access the specific compliance details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'applications-key-compliance'."]:
    """Retrieve compliance data for a specified application.

    Fetches compliance information related to a specific application's key. Useful for checking compliance status and details."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/applications/{key}/compliance".format(key=application_key),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def trello_get_batch_requests(
    context: ToolContext,
    urls_list_for_batching: Annotated[
        str,
        "A list of up to 10 API routes, each beginning with a forward slash. Exclude the API version number. Example: '/members/trello', '/cards/[cardId]'.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-batch'."]:
    """Retrieve up to 10 resources with a single batched request.

    Use this tool to efficiently fetch up to 10 resources from Trello in a single API call by batching multiple GET requests."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/batch",
        method="GET",
        params=remove_none_values({
            "urls": urls_list_for_batching,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_memberships(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier for the Trello board to retrieve membership details."
    ],
    include_activity: Annotated[
        bool | None, "Set to true to include activity data for premium organizations only."
    ] = False,
    include_member_object: Annotated[
        bool | None, "Set to true to include a nested member object in the response."
    ] = False,
    member_fields_to_show: Annotated[
        str | None,
        "Specify which fields to display if 'member' is set to true. Valid values are fields from the nested member resource.",  # noqa: E501
    ] = None,
    membership_filter: Annotated[
        str | None,
        "Specifies the type of memberships to retrieve: `admins`, `all`, `none`, or `normal`.",
    ] = "all",
    show_org_member_type: Annotated[
        bool | None,
        "Set to true to show the type of member (e.g., 'admin') a user is to the organization.",
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-memberships'."]:
    """Retrieve user membership details for a Trello board.

    Use this tool to get detailed information about the memberships users have on a specific Trello board. This is helpful for understanding who has access and what roles they have on the board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/memberships".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": membership_filter,
            "activity": include_activity,
            "orgMemberType": show_org_member_type,
            "member": include_member_object,
            "member_fields": member_fields_to_show,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_board(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The unique identifier of the Trello board to retrieve details for. Required to specify which board to access.",  # noqa: E501
    ],
    board_fields_to_include: Annotated[
        str | None,
        "Specify which board fields to include in the response. Use 'all' or a comma-separated list of field names like closed, dateLastActivity, etc.",  # noqa: E501
    ] = "name,desc,descData,closed,idOrganization,pinned,url,shortUrl,prefs,labelNames",
    include_actions: Annotated[
        str | None,
        "Include actions as a nested resource in the response. Refer to Trello's nested resources guide for more information.",  # noqa: E501
    ] = "all",
    include_board_stars: Annotated[
        str | None,
        "Specify whether to include starred boards information. Options are 'mine' or 'none'.",
    ] = "none",
    include_card_plugin_data: Annotated[
        bool | None,
        "Boolean to include card plugin data in the response when used with the `cards` parameter.",
    ] = False,
    include_cards_resource: Annotated[
        str | None,
        "Include card details as part of the response. Cards are nested resources; read more about them in the Trello API documentation.",  # noqa: E501
    ] = "none",
    include_checklists: Annotated[
        str | None, "Set to true to include checklists as a nested resource in the response."
    ] = "none",
    include_custom_fields: Annotated[
        bool | None, "Set to true to include custom fields in the board response."
    ] = False,
    include_labels: Annotated[
        str | None,
        "Specify if the labels nested resource should be included in the board response. Use 'true' or 'false'.",  # noqa: E501
    ] = None,
    include_lists: Annotated[
        str | None,
        "Include the lists associated with the board in the response. This is a nested resource.",
    ] = "open",
    include_members_as_nested_resource: Annotated[
        str | None,
        "Include member details as a nested resource in the response. Set to 'true' to include, 'false' to exclude.",  # noqa: E501
    ] = "none",
    include_memberships: Annotated[
        str | None, "Include memberships data as a nested resource in the response."
    ] = "none",
    include_my_preferences: Annotated[
        bool | None, "Set to true to include the user's preferences for the board in the response."
    ] = False,
    include_organization: Annotated[
        bool | None, "Include organization details for the board. Set to true to include."
    ] = False,
    include_organization_plugin_data: Annotated[
        bool | None,
        "Set to true to include organization pluginData with the response when using the organization parameter. Expects a boolean value.",  # noqa: E501
    ] = False,
    include_plugin_data: Annotated[
        bool | None,
        "Set to true to include pluginData for the board in the response, or false to exclude it.",
    ] = False,
    include_tags: Annotated[
        bool | None,
        "Set to true to include the collection(s) (tags) that a board belongs to in the response.",
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id'."]:
    """Retrieve details of a specific Trello board.

    Call this tool to get information about a single Trello board using its ID. It is useful for accessing board-specific details when managing projects on Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "actions": include_actions,
            "boardStars": include_board_stars,
            "cards": include_cards_resource,
            "card_pluginData": include_card_plugin_data,
            "checklists": include_checklists,
            "customFields": include_custom_fields,
            "fields": board_fields_to_include,
            "labels": include_labels,
            "lists": include_lists,
            "members": include_members_as_nested_resource,
            "memberships": include_memberships,
            "pluginData": include_plugin_data,
            "organization": include_organization,
            "organization_pluginData": include_organization_plugin_data,
            "myPrefs": include_my_preferences,
            "tags": include_tags,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_board(
    context: ToolContext,
    board_id: Annotated[str, "The unique identifier for the Trello board to be updated."],
    allow_workspace_members_to_join: Annotated[
        bool | None,
        "Allows Workspace members to join the board themselves. True to allow, false to disallow.",
    ] = None,
    background_preference: Annotated[
        str | None,
        "Specify the background for the board. Use a custom background ID or choose from: blue, orange, green, red, purple, pink, lime, sky, grey.",  # noqa: E501
    ] = None,
    board_description: Annotated[
        str | None, "A new description for the board, 0 to 16384 characters long."
    ] = None,
    calendar_feed_enabled: Annotated[
        bool | None, "Set to true to enable the calendar feed; false to disable it."
    ] = None,
    card_aging_preference: Annotated[
        str | None, "Set card aging style on the board. Options: pirate, regular."
    ] = None,
    close_board: Annotated[
        bool | None,
        "Sets whether the board should be closed. Use true to close the board and false to keep it open.",  # noqa: E501
    ] = None,
    comment_permission: Annotated[
        str | None,
        "Specify who can comment on cards. Options: disabled, members, observers, org, public.",
    ] = None,
    display_card_covers: Annotated[
        bool | None, "Set to true to display card covers on the board, false to hide them."
    ] = None,
    hide_voter_identities: Annotated[
        bool | None, "If true, the Voting Power-Up hides who voted on cards."
    ] = None,
    new_board_name: Annotated[
        str | None, "The new name for the board. Must be 1 to 16384 characters long."
    ] = None,
    permission_level: Annotated[
        str | None, "Set the board's permission level: org, private, or public."
    ] = None,
    user_subscribed_to_board: Annotated[
        str | None, "Indicate if the acting user is subscribed to the board. Use 'true' or 'false'."
    ] = None,
    voting_permissions: Annotated[
        str | None,
        "Specify who can vote on this board. Options: disabled, members, observers, org, public.",
    ] = None,
    who_can_invite: Annotated[
        str | None, "Specifies who can invite people to the board. Accepts 'admins' or 'members'."
    ] = None,
    workspace_id_for_board: Annotated[
        str | None, "The unique ID of the Workspace to which the board should be moved."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-boards-id'."]:
    """Update details of an existing Trello board.

    This tool updates an existing Trello board using its unique ID. It should be called when board details need to be modified."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "name": new_board_name,
            "desc": board_description,
            "closed": close_board,
            "subscribed": user_subscribed_to_board,
            "idOrganization": workspace_id_for_board,
            "prefs/permissionLevel": permission_level,
            "prefs/selfJoin": allow_workspace_members_to_join,
            "prefs/cardCovers": display_card_covers,
            "prefs/hideVotes": hide_voter_identities,
            "prefs/invitations": who_can_invite,
            "prefs/voting": voting_permissions,
            "prefs/comments": comment_permission,
            "prefs/background": background_preference,
            "prefs/cardAging": card_aging_preference,
            "prefs/calendarFeedEnabled": calendar_feed_enabled,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_board(
    context: ToolContext,
    board_id_to_delete: Annotated[
        str,
        "The ID of the Trello board to delete. Ensure it is the correct board as this action is irreversible.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-boards-id'."]:
    """Delete a specific board from Trello.

    Use this tool to delete a given board from Trello by providing its ID. This action cannot be undone, so ensure it's the right board before calling the tool."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}".format(id=board_id_to_delete),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_board_field(
    context: ToolContext,
    board_field: Annotated[
        str,
        "Specify the field of the Trello board to retrieve. Valid values: closed, dateLastActivity, dateLastView, desc, descData, idMemberCreator, idOrganization, invitations, invited, labelNames, memberships, name, pinned, powerUps, prefs, shortLink, shortUrl, starred, subscribed, url.",  # noqa: E501
    ],
    board_id: Annotated[str, "The unique identifier of the Trello board to fetch the field from."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-field'."]:
    """Retrieve a specific field from a Trello board.

    This tool fetches a specific field from a Trello board using its ID. It should be called when there's a need to access particular details about a Trello board, like name or description."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/{field}".format(id=board_id, field=board_field),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_stars(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board for which to retrieve star count."
    ],
    board_star_filter: Annotated[
        str | None,
        "Specify whose stars to include: 'mine' for personal stars, 'none' for no filtering.",
    ] = "mine",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-boardstars'."]:
    """Retrieve star count for a Trello board.

    This tool retrieves the number of stars (boardStars) associated with a specified Trello board. It should be called when users want to know how popular or favored a board is by examining its star rating."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{boardId}/boardStars".format(boardId=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": board_star_filter,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_checklists(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board from which to retrieve checklists."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'boards-id-checklists'."]:
    """Retrieve all checklists from a specific Trello board.

    Use this tool to get all checklists associated with a specific Trello board by providing the board ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/checklists".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_open_cards_on_board(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board to retrieve open cards from."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-cards'."]:
    """Retrieve all open cards on a Trello board.

    Use this tool to get information about all open cards on a specified Trello board. This is useful for tracking tasks or items on a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/cards".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_filtered_board_cards(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier for the Trello board from which to retrieve cards."
    ],
    card_filter: Annotated[
        str,
        "Specify the filter for retrieving cards: `all`, `closed`, `complete`, `incomplete`, `none`, `open`, `visible`.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-cards-filter'."]:
    """Retrieve cards on a Trello board based on a specified filter.

    Call this tool to get cards from a Trello board using a specific filter. Useful for retrieving only the cards that match certain criteria."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/cards/{filter}".format(  # noqa: UP032
            id=board_id, filter=card_filter
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_custom_fields(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique ID of the Trello board for which custom fields are to be retrieved."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-customfields'."]:
    """Retrieve Custom Field Definitions for a specific Trello board.

    This tool is used to obtain all the Custom Field Definitions that are associated with a specified Trello board. It should be called when there's a need to access or manage the custom fields of a particular board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/customFields".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_label_on_board(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board where the new label will be created."
    ],
    label_color: Annotated[
        str,
        "Sets the color of the new label. Accepted values include specific colors or `null` for no color.",  # noqa: E501
    ],
    label_name: Annotated[
        str, "The name of the label to be created. It must be between 1 and 16,384 characters long."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-boards-id-labels'."]:
    """Create a new label on a Trello board.

    Use this tool to add a new label to a specific Trello board. This can help organize tasks by categorizing them with labels."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/labels".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": label_name,
            "color": label_color,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_board_lists(
    context: ToolContext,
    board_id: Annotated[str, "The unique identifier of the Trello board to retrieve lists from."],
    card_filter: Annotated[
        str | None,
        "Specify how to filter cards within the lists. Options: 'all', 'closed', 'none', 'open'.",
    ] = None,
    card_properties_to_include: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of card fields to include, such as name, id, etc.",
    ] = "all",
    list_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of list fields to include in the response.",
    ] = "all",
    list_filter: Annotated[
        str | None, "Apply a filter to the lists. Options are 'all', 'closed', 'none', or 'open'."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-lists'."]:
    """Retrieve lists from a specified Trello board.

    Use this tool to get all the lists present on a Trello board by providing the board ID. It returns details of each list available on the board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/lists".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "cards": card_filter,
            "card_fields": card_properties_to_include,
            "filter": list_filter,
            "fields": list_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_board_list(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The unique identifier of the Trello board where the list will be created. Required for specifying which board to add the list to.",  # noqa: E501
    ],
    list_name: Annotated[
        str,
        "The name of the list to be created. It should be between 1 to 16384 characters in length.",
    ],
    list_position: Annotated[
        str | None,
        "Specifies where the list should be positioned. Use 'top', 'bottom', or a positive number for custom placement.",  # noqa: E501
    ] = "top",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-boards-id-lists'."]:
    """Create a new list on a Trello board.

    This tool creates a new list on a specified Trello board. Use it when you need to organize tasks by adding a new list to an existing board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/lists".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": list_name,
            "pos": list_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_filtered_board_lists(
    context: ToolContext,
    board_id: Annotated[str, "The unique identifier of the Trello board to retrieve lists for."],
    list_filter: Annotated[
        str,
        "Specifies the filter to apply on board lists. Options are `all`, `closed`, `none`, or `open`.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-lists-filter'."]:
    """Retrieve filtered lists from a Trello board.

    Use this tool to get specific lists from a Trello board based on a filter. Ideal for managing tasks or organizing information within the board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/lists/{filter}".format(  # noqa: UP032
            id=board_id, filter=list_filter
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_members(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board whose members are to be retrieved."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-members'."]:
    """Retrieve members of a Trello board.

    Use this tool to get a list of members associated with a specific Trello board by providing the board ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/members".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def invite_member_to_trello_board(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier for the Trello board to which the member will be invited."
    ],
    member_email_address: Annotated[
        str, "The email address of the user to be added as a member to the Trello board."
    ],
    member_access_type: Annotated[
        str | None,
        "Specifies the role of the new board member. Valid values are: admin, normal, or observer.",
    ] = "normal",
    user_full_name: Annotated[
        str | None,
        "The full name of the user being invited. Must be at least 1 character and not begin or end with a space.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-boards-id-members'."]:
    """Invite a member to a Trello board via email.

    Use this tool to invite a new member to a Trello board using their email address. It is useful for adding collaborators to a project board."""  # noqa: E501
    request_data = remove_none_values({"fullName": user_full_name})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/members".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "email": member_email_address,
            "type": member_access_type,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_member_to_board(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The ID of the board to update. Required to specify which Trello board the member will be added to.",  # noqa: E501
    ],
    member_id_to_add: Annotated[str, "The ID of the member to add to the Trello board."],
    member_role_type: Annotated[
        str,
        "Specifies the role of the member on the board. Choose from 'admin', 'normal', or 'observer'.",  # noqa: E501
    ],
    allow_billable_guest: Annotated[
        bool | None,
        "Set to true to allow organization admins to add multi-board guests to the board.",
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-boards-id-members-idmember'."]:
    """Add a member to a Trello board.

    Use this tool to add a member to a specific Trello board by providing the board ID and the member ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/members/{idMember}".format(  # noqa: UP032
            id=board_id, idMember=member_id_to_add
        ),
        method="PUT",
        params=remove_none_values({
            "type": member_role_type,
            "allowBillableGuest": allow_billable_guest,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_member_from_trello_board(
    context: ToolContext,
    board_id: Annotated[str, "The ID of the Trello board from which to remove a member."],
    member_id_to_remove: Annotated[str, "The ID of the member to remove from the Trello board."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'boardsidmembersidmember'."]:
    """Remove a member from a specified Trello board.

    Use this tool to delete a member from a Trello board by specifying the board and member IDs."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/members/{idMember}".format(  # noqa: UP032
            id=board_id, idMember=member_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_board_membership(
    context: ToolContext,
    board_id: Annotated[str, "The ID of the Trello board you want to update the membership for."],
    membership_id: Annotated[str, "The ID of a membership to be updated on the board."],
    membership_type: Annotated[
        str,
        "Specifies the role of the member on the board. Choose one of: admin, normal, observer.",
    ],
    member_fields_to_update: Annotated[
        str | None,
        "Specify the member fields to update, such as avatarHash, bio, fullName, or all. Valid values include: all, avatarHash, bio, bioData, confirmed, fullName, idPremOrgsAdmin, initials, memberType, products, status, url, username.",  # noqa: E501
    ] = "fullName, username",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-memberships-idmembership'."
]:
    """Update a specific board membership by ID.

    Use this tool to update the membership details of a specific board in Trello by providing the board ID and membership ID. It allows modification of existing membership properties on a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/memberships/{idMembership}".format(  # noqa: UP032
            id=board_id, idMembership=membership_id
        ),
        method="PUT",
        params=remove_none_values({
            "type": membership_type,
            "member_fields": member_fields_to_update,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_board_email_position(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The unique identifier of the Trello board to update the email position preference for.",
    ],
    email_position: Annotated[
        str, "Position of the email address on a board. Valid values: bottom, top."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-myprefs-emailposition'."
]:
    """Update the email position preference on a Trello board.

    This tool updates the email position preference for a specified Trello board. It should be called when you need to change the email notification position settings on a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/emailPosition".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": email_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def set_trello_email_list_default(
    context: ToolContext,
    board_id_to_update: Annotated[
        str,
        "The ID of the Trello board that you want to update the default email-to-board list for. This is required to specify which board's preferences are being changed.",  # noqa: E501
    ],
    email_list_id: Annotated[
        str, "The ID of the email list to set as default for email-to-board cards."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-myprefs-idemaillist'."
]:
    """Change the default email-to-board list in Trello.

    Use this tool to set a new default list for email-to-board cards in a specified Trello board. This can be helpful when organizing how incoming email tasks are managed within Trello boards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/idEmailList".format(  # noqa: UP032
            id=board_id_to_update
        ),
        method="PUT",
        params=remove_none_values({
            "value": email_list_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_sidebar_preference(
    context: ToolContext,
    board_id: Annotated[
        str, "The ID of the Trello board whose sidebar preference is to be updated."
    ],
    show_sidebar: Annotated[
        bool, "Set to true to show the sidebar on the board, false to hide it."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-myPrefs-showsidebar'."
]:
    """Update the sidebar visibility preference for a Trello board.

    This tool updates the 'showSidebar' preference on a specified Trello board, allowing you to set whether the sidebar should be shown or hidden."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/showSidebar".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": show_sidebar,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_sidebar_activity_preference(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board to update the sidebar activity preference."
    ],
    show_sidebar_activity: Annotated[
        bool,
        "Boolean to determine if sidebar activity should be shown. True to show, False to hide.",
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-myPrefs-showsidebaractivity'."
]:
    """Toggle the sidebar activity visibility for a Trello board.

    Use this tool to update the visibility of the sidebar activity on a specific Trello board. It's useful when you want to either display or hide the activity stream in the sidebar for better board management."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/showSidebarActivity".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": show_sidebar_activity,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_sidebar_actions_preference(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board to update the sidebar actions preference."
    ],
    show_sidebar_board_actions: Annotated[
        bool, "Set to true to show sidebar board actions, or false to hide them on a Trello board."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-boards-id-myPrefs-showsidebarboardactions'.",
]:
    """Update sidebar board actions preference on a Trello board.

    This tool updates the showSidebarBoardActions preference on a specified Trello board. Call this tool when you need to modify the display settings of sidebar board actions for better user interface customization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/showSidebarBoardActions".format(  # noqa: UP032
            id=board_id
        ),
        method="PUT",
        params=remove_none_values({
            "value": show_sidebar_board_actions,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_sidebar_members_pref(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board to update the sidebar members preference."
    ],
    show_sidebar_members: Annotated[
        bool, "Set to 'true' to show members of the board in the sidebar, 'false' to hide."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-boards-id-myPrefs-showsidebarmembers'."
]:
    """Update the sidebar members visibility preference on a Trello board.

    Use this tool to change the showSidebarMembers preference for a specific Trello board, allowing you to control whether member information is displayed in the sidebar."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/myPrefs/showSidebarMembers".format(id=board_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": show_sidebar_members,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_board(
    context: ToolContext,
    board_name: Annotated[
        str, "The new name for the Trello board. Must be between 1 to 16384 characters."
    ],
    add_default_lists: Annotated[
        bool | None,
        "Add the default lists (To Do, Doing, Done) to a new board. Ignored if `idBoardSource` is provided.",  # noqa: E501
    ] = True,
    allow_self_join: Annotated[
        bool | None,
        "Set to `true` to allow users to join the board themselves. Set to `false` if they need an invitation.",  # noqa: E501
    ] = True,
    board_background_color: Annotated[
        str | None,
        "Specify the custom background ID or choose from predefined colors: blue, orange, green, red, purple, pink, lime, sky, grey.",  # noqa: E501
    ] = "blue",
    board_description: Annotated[
        str | None, "A description for the new board, ranging from 0 to 16384 characters in length."
    ] = None,
    board_permission_level: Annotated[
        str | None,
        "Set the permission level of the board. Options are: `org`, `private`, `public`.",
    ] = "private",
    card_aging_type: Annotated[
        str | None,
        "Type of card aging on the board: `pirate` or `regular`. Determines visual changes over time when enabled.",  # noqa: E501
    ] = "regular",
    comment_permission: Annotated[
        str | None,
        "Specify who can comment on cards: `disabled`, `members`, `observers`, `org`, `public`.",
    ] = "members",
    enable_card_covers: Annotated[
        bool | None, "Boolean to determine whether card covers are enabled on the board."
    ] = True,
    enabled_power_ups: Annotated[
        str | None,
        "Specify the Power-Ups to enable on the board. Options: all, calendar, cardAging, recap, voting.",  # noqa: E501
    ] = None,
    include_original_cards: Annotated[
        str | None,
        "Specify 'cards' to keep cards from the original board when copying; otherwise, omit for none.",  # noqa: E501
    ] = "none",
    invitation_permissions: Annotated[
        str | None,
        "Specifies who can invite users to join the board. Choose either `admins` or `members`.",
    ] = "members",
    source_board_id: Annotated[
        str | None, "The ID of the board to copy for creating a new board."
    ] = None,
    use_default_labels: Annotated[
        bool | None,
        "Set to true to use the default set of labels on the new board; false to exclude them.",
    ] = True,
    voting_permissions: Annotated[
        str | None,
        "Specifies who can vote on the board: `disabled`, `members`, `observers`, `org`, or `public`.",  # noqa: E501
    ] = "disabled",
    workspace_id_or_name: Annotated[
        str | None, "The ID or name of the Trello Workspace where the board will be created."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-boards'."]:
    """Create a new board on Trello.

    Use this tool to create a new board on Trello when you need to organize tasks or projects. It will return the details of the newly created board, allowing further actions or adjustments."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/",
        method="POST",
        params=remove_none_values({
            "name": board_name,
            "defaultLabels": use_default_labels,
            "defaultLists": add_default_lists,
            "desc": board_description,
            "idOrganization": workspace_id_or_name,
            "idBoardSource": source_board_id,
            "keepFromSource": include_original_cards,
            "powerUps": enabled_power_ups,
            "prefs_permissionLevel": board_permission_level,
            "prefs_voting": voting_permissions,
            "prefs_comments": comment_permission,
            "prefs_invitations": invitation_permissions,
            "prefs_selfJoin": allow_self_join,
            "prefs_cardCovers": enable_card_covers,
            "prefs_background": board_background_color,
            "prefs_cardAging": card_aging_type,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def generate_board_calendar_key(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The unique identifier of the Trello board for which the calendar key is to be generated.",
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'post-boards-id-calendarkey-generate'."
]:
    """Generate a calendar key for a Trello board.

    This tool is used to generate a calendar key for a specified Trello board. Call this tool when you need to create or obtain a calendar key that can be used for syncing or sharing purposes with calendar applications."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/calendarKey/generate".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def generate_board_email_key(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board for which to generate an email key."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'post-boards-id-emailkey-generate'."
]:
    """Generate a unique email key for a Trello board.

    This tool generates a unique email key for a specified Trello board. Use it when you need to associate an email with your board for integration purposes."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/emailKey/generate".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_board_tag(
    context: ToolContext,
    board_id: Annotated[str, "The ID of the Trello board where the tag will be created."],
    organization_tag_id: Annotated[
        str, "The ID of the tag from the organization to associate with the board."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-boards-id-idtags'."]:
    """Create a new tag for a Trello board.

    Call this tool to create a new tag for an existing Trello board. It should be used when you want to organize or categorize elements within a board with new tags."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/idTags".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "value": organization_tag_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def mark_trello_board_as_viewed(
    context: ToolContext,
    board_id: Annotated[str, "The unique identifier of the Trello board to mark as viewed."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-boards-id-markedasviewed'."]:
    """Mark a Trello board as viewed to update status.

    Use this tool to mark a specific Trello board as viewed. This can be useful to update the current status of interaction with the board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/markedAsViewed".format(id=board_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_power_ups(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique ID of the Trello board from which to retrieve enabled Power-Ups."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-boards-id-boardplugins'."]:
    """Retrieve the enabled Power-Ups on a Trello board.

    Use this tool to fetch the list of enabled Power-Ups on a specific Trello board by providing the board ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/boardPlugins".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_board_power_ups(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique identifier of the Trello board for which to list Power-Ups."
    ],
    power_up_filter: Annotated[
        str | None,
        "Specify the filter for Power-Ups: choose 'enabled' to list only those currently active on the board, or 'available' to list those that can be activated.",  # noqa: E501
    ] = "enabled",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-board-id-plugins'."]:
    """Retrieve the Power-Ups enabled on a Trello board.

    Use this tool to get a list of Power-Ups (plugins) that are currently enabled on a specified Trello board. This can be useful for managing and understanding the capabilities of the board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/boards/{id}/plugins".format(id=board_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": power_up_filter,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_card_by_id(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier for the Trello card to retrieve."],
    attachment_fields_list: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of attachment fields to retrieve for the card.",
    ] = "all",
    board_fields_selection: Annotated[
        str | None,
        "Specify 'all' or select specific board fields to include. Defaults to 'name, desc, descData, closed, idOrganization, pinned, url, prefs'.",  # noqa: E501
    ] = None,
    card_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of fields to retrieve for the card. Defaults to all main fields such as badges, desc, due, etc.",  # noqa: E501
    ] = None,
    checklist_fields_detail: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of fields (`idBoard`, `idCard`, `name`, `pos`) to include for checklists.",  # noqa: E501
    ] = "all",
    include_actions_details: Annotated[
        str | None,
        "Specify if actions details should be included. Refer to [Actions Nested Resource](https://cloud/trello/guides/rest-api/nested-resources/#actions-nested-resource) for more information.",  # noqa: E501
    ] = None,
    include_attachments: Annotated[
        str | None,
        "Specify if attachments should be returned. Use 'true' for all attachments, 'false' for none, or 'cover' for cover attachments only.",  # noqa: E501
    ] = "false",
    include_check_item_states: Annotated[
        bool | None,
        "Set to `true` to include check item states of the card; `false` to exclude them.",
    ] = False,
    include_checklists: Annotated[
        str | None, "Specifies whether to return checklists on the card. Use 'all' or 'none'."
    ] = "none",
    include_custom_field_items: Annotated[
        bool | None,
        "Set to `true` to include custom field items in the response; `false` to exclude them.",
    ] = False,
    include_list_resource: Annotated[
        bool | None,
        "A boolean to include list resource information related to the card. Set to true to include this information.",  # noqa: E501
    ] = False,
    include_members: Annotated[
        bool | None,
        "Whether to return member objects for members on the card. Set to true to include them.",
    ] = False,
    include_members_voted: Annotated[
        bool | None, "Set to true to return member objects for members who voted on the card."
    ] = False,
    include_plugin_data: Annotated[
        bool | None, "Specify whether to include plugin data in the card details response."
    ] = False,
    include_stickers: Annotated[
        bool | None, "Set to true to include sticker models in the response; false to exclude."
    ] = False,
    member_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of member fields like avatarHash, fullName, initials, username.",  # noqa: E501
    ] = None,
    member_voted_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of fields for members who voted on the card. Defaults to `avatarHash, fullName, initials, username`.",  # noqa: E501
    ] = None,
    return_board_object: Annotated[
        bool | None,
        "Set to true to return the board object the card is on. Use false to exclude it.",
    ] = False,
    sticker_fields_selection: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of sticker fields to retrieve for a Trello card. This determines which sticker-related data is included in the response.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id'."]:
    """Retrieve details of a Trello card using its ID.

    Use this tool to get comprehensive information about a specific Trello card by providing its unique ID. Ideal for accessing card details directly."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": card_fields,
            "actions": include_actions_details,
            "attachments": include_attachments,
            "attachment_fields": attachment_fields_list,
            "members": include_members,
            "member_fields": member_fields,
            "membersVoted": include_members_voted,
            "memberVoted_fields": member_voted_fields,
            "checkItemStates": include_check_item_states,
            "checklists": include_checklists,
            "checklist_fields": checklist_fields_detail,
            "board": return_board_object,
            "board_fields": board_fields_selection,
            "list": include_list_resource,
            "pluginData": include_plugin_data,
            "stickers": include_stickers,
            "sticker_fields": sticker_fields_selection,
            "customFieldItems": include_custom_field_items,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_card(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier of the Trello card to delete."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-cards-id'."]:
    """Delete a card from Trello by ID.

    This tool deletes a specified card from Trello using its ID. It should be called when you need to permanently remove a card from a Trello board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}".format(id=card_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_card_property(
    context: ToolContext,
    card_id: Annotated[str, "The unique ID of the Trello card to retrieve a property from."],
    desired_card_field: Annotated[
        str,
        "The field or attribute of the Trello card you want to retrieve. Options include 'id', 'desc', 'due', etc.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-field'."]:
    """Retrieve a specific property of a Trello card.

    Use this tool to get a particular property (field) from a Trello card by specifying the card ID and the desired field."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/{field}".format(  # noqa: UP032
            id=card_id, field=desired_card_field
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_actions(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier of the Trello card to retrieve actions for."],
    action_type_filter: Annotated[
        str | None, "Comma-separated list of action types to filter actions on a Trello card."
    ] = "commentCard, updateCard:idList",
    actions_page_number: Annotated[
        float | None,
        "The page number to retrieve for the list of actions on a card, with each page containing 50 actions.",  # noqa: E501
    ] = 0,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-actions'."]:
    """Retrieve the actions performed on a specific Trello card.

    Call this tool to get a list of all actions taken on a specific Trello card, such as comments, moves, or updates."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/actions".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": action_type_filter,
            "page": actions_page_number,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_card_attachments(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to retrieve attachments from."
    ],
    attachment_fields: Annotated[
        str | None,
        "Specify 'all' for all fields or a comma-separated list of attachment fields to retrieve.",
    ] = "all",
    restrict_to_cover_attachment: Annotated[
        str | None, "Set to 'cover' to retrieve only the cover attachment of the card."
    ] = "false",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-attachments'."]:
    """Retrieve all attachments from a specified Trello card.

    Use this tool to get a list of attachments associated with a specific Trello card. It is useful when you need to access or display all files attached to a card in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/attachments".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": attachment_fields,
            "filter": restrict_to_cover_attachment,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_attachment_to_trello_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to which the attachment will be added."
    ],
    attachment_mime_type: Annotated[
        str | None,
        "The MIME type of the attachment file. Should be a valid MIME type string (max 256 characters).",  # noqa: E501
    ] = None,
    attachment_name: Annotated[
        str | None, "The name of the attachment. Maximum length is 256 characters."
    ] = None,
    attachment_url: Annotated[
        str | None, "A URL to attach to the Trello card. Must start with 'http://' or 'https://'."
    ] = None,
    file_attachment: Annotated[
        str | None, "The file data to upload and attach to the Trello card as multipart/form-data."
    ] = None,
    use_as_card_cover: Annotated[
        bool | None, "Set to true to use the new attachment as the card cover."
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-attachments'."]:
    """Attach a file or link to a Trello card.

    Use this tool to add an attachment, such as a file or link, to a specific Trello card by providing the card's ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/attachments".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": attachment_name,
            "file": file_attachment,
            "mimeType": attachment_mime_type,
            "url": attachment_url,
            "setCover": use_as_card_cover,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_card_attachment(
    context: ToolContext,
    attachment_id_to_delete: Annotated[
        str, "The ID of the attachment you want to delete from the card."
    ],
    card_id: Annotated[
        str, "The unique identifier for the Trello card from which the attachment will be deleted."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'deleted-cards-id-attachments-idattachment'."
]:
    """Delete an attachment from a Trello card.

    Use this tool to remove an attachment from a specified Trello card by providing the card ID and attachment ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/attachments/{idAttachment}".format(  # noqa: UP032
            id=card_id, idAttachment=attachment_id_to_delete
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_for_card(
    context: ToolContext,
    card_id: Annotated[str, "The unique ID of the Trello card to retrieve the board for."],
    board_fields: Annotated[
        str | None, "Specify `all` or a comma-separated list of board fields to retrieve."
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-board'."]:
    """Retrieve the board details for a specific card.

    Use this tool to get information about the board a specific Trello card is on. It returns details of the board associated with the given card ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/board".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_checklist_completion_status(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to retrieve completed checklist items."
    ],
    checklist_item_fields: Annotated[
        str | None,
        "Specify `all` for all fields or a comma-separated list of: `idCheckItem`, `state` to filter the checklist item details.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-checkitemstates'."]:
    """Retrieve completed checklist items from a Trello card.

    Use this to get the list of completed checklist items on a specific Trello card. This can be useful to track progress and ensure tasks are marked as done."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checkItemStates".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": checklist_item_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_checklists(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card for which checklists are retrieved."
    ],
    card_fields: Annotated[
        str | None,
        "Specify 'all' or list fields like `idBoard,idCard,name,pos` to include in the response.",
    ] = "all",
    include_all_checklists: Annotated[
        str | None,
        "Specify whether to include all checklists (`all`) or none (`none`) for the card. Accepted values are 'all' or 'none'.",  # noqa: E501
    ] = "all",
    include_check_items: Annotated[
        str | None, "Specify whether to include all check items (`all`) or none (`none`)."
    ] = "all",
    include_checkitem_fields: Annotated[
        str | None,
        "Specify 'all' for all fields or a comma-separated list of desired fields among: name, nameData, pos, state, type, due, dueReminder, idMember.",  # noqa: E501
    ] = "name,nameData,pos,state,due,dueReminder,idMember",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-checklists'."]:
    """Retrieve checklists for a specified Trello card.

    Use this tool to access all checklists attached to a specific Trello card by providing the card ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checklists".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "checkItems": include_check_items,
            "checkItem_fields": include_checkitem_fields,
            "filter": include_all_checklists,
            "fields": card_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_checklist_on_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to which the checklist will be added."
    ],
    checklist_name: Annotated[
        str | None, "The name of the checklist to be created on a Trello card."
    ] = None,
    checklist_position: Annotated[
        str | None,
        "Specify the position of the checklist on the card. Accepts `top`, `bottom`, or a positive number indicating the exact position.",  # noqa: E501
    ] = None,
    source_checklist_id: Annotated[
        str | None,
        "The ID of a source checklist to copy into the new checklist. This is used to duplicate the tasks from another checklist.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-checklists'."]:
    """Create a new checklist on a Trello card.

    Use this tool to add a checklist to a specific Trello card by providing the card ID. It allows for organizing tasks within a card using checklists."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checklists".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": checklist_name,
            "idChecklistSource": source_checklist_id,
            "pos": checklist_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_specific_checkitem_on_card(
    context: ToolContext,
    card_id: Annotated[str, "The ID of the Trello card to retrieve the checkItem from."],
    checkitem_id: Annotated[str, "The unique ID of the checkItem on the card."],
    checkitem_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of fields (`name,nameData,pos,state,type,due,dueReminder,idMember`) to retrieve for the checkItem.",  # noqa: E501
    ] = "name,nameData,pos,state,due,dueReminder,idMember",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-cards-id-checkitem-idcheckitem'."
]:
    """Retrieve details of a specific checkItem on a Trello card.

    Use this tool to obtain information about a particular checkItem located on a Trello card by providing the card ID and checkItem ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checkItem/{idCheckItem}".format(  # noqa: UP032
            id=card_id, idCheckItem=checkitem_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": checkitem_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_checklist_item_trello(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card where the checklist item is located."
    ],
    checkitem_id: Annotated[str, "The unique identifier for the checklist item to be updated."],
    checkitem_due_reminder: Annotated[
        float | None,
        "The number of minutes before the due date when a reminder should be sent for the checkitem.",  # noqa: E501
    ] = None,
    checklist_id: Annotated[
        str | None, "The unique ID of the checklist containing the item to be updated."
    ] = None,
    checklist_item_due_date: Annotated[
        str | None,
        "The due date for the checklist item in ISO 8601 format (e.g., '2023-12-31T23:59:59Z').",
    ] = None,
    checklist_item_new_name: Annotated[str | None, "The new name for the checklist item."] = None,
    checklist_item_position: Annotated[
        str | None,
        "Specify the position of the checklist item as `top`, `bottom`, or a positive float for custom ordering.",  # noqa: E501
    ] = None,
    completion_state: Annotated[
        str | None, "Specify the state of the checklist item as either `complete` or `incomplete`."
    ] = None,
    member_id_to_remove: Annotated[
        str | None, "The Trello member ID to remove from the card's checklist item."
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-cards-id-checkitem-idcheckitem'."
]:
    """Update an item in a Trello checklist on a card.

    This tool updates an item within a checklist on a specified Trello card. Use it to modify checklist entries when changes are needed."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checkItem/{idCheckItem}".format(  # noqa: UP032
            id=card_id, idCheckItem=checkitem_id
        ),
        method="PUT",
        params=remove_none_values({
            "name": checklist_item_new_name,
            "state": completion_state,
            "idChecklist": checklist_id,
            "pos": checklist_item_position,
            "due": checklist_item_due_date,
            "dueReminder": checkitem_due_reminder,
            "idMember": member_id_to_remove,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_checklist_item_on_card(
    context: ToolContext,
    card_id: Annotated[
        str,
        "The unique identifier of the Trello card from which you want to delete a checklist item.",
    ],
    checklist_item_id: Annotated[str, "The ID of the checklist item to delete from the card."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-checkitem-idcheckitem'."
]:
    """Delete a checklist item from a Trello card.

    Use this tool to delete a specific checklist item from a Trello card when you have the card ID and the checklist item ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checkItem/{idCheckItem}".format(  # noqa: UP032
            id=card_id, idCheckItem=checklist_item_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_list(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello Card to find its containing list."
    ],
    list_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of list attributes to retrieve. Defines the fields you want from the list containing the card.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-list'."]:
    """Retrieve the list containing a specific card from Trello.

    Use this tool to find out which list a particular Trello card is located in by providing the card ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/list".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": list_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_members(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier for the Trello card whose members are being retrieved."
    ],
    member_fields: Annotated[
        str | None,
        "Specify `all` for all fields or list specific member fields separated by commas.",
    ] = "avatarHash,fullName,initials,username",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-members'."]:
    """Retrieve members associated with a Trello card.

    Use this tool to get information about members on a specific Trello card identified by its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/members".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_members_who_voted_on_card(
    context: ToolContext,
    card_id: Annotated[
        str,
        "The unique ID of the Trello card for which you want to retrieve the list of voting members.",  # noqa: E501
    ],
    member_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of member fields to retrieve information on those members who voted on the card.",  # noqa: E501
    ] = "avatarHash,fullName,initials,username",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-membersvoted'."]:
    """Retrieve members who voted on a Trello card.

    This tool gets the list of members who have voted on a specific Trello card. Use it when you need to know which members have voted on a particular card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/membersVoted".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def vote_on_trello_card(
    context: ToolContext,
    card_id: Annotated[str, "The unique ID of the Trello card on which to vote."],
    member_id_for_vote: Annotated[
        str, "The ID of the member casting a 'yes' vote on the Trello card."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'cardsidmembersvoted-1'."]:
    """Vote on a Trello card for a specific member.

    This tool allows voting on a specific Trello card for a given member. It should be called when a user needs to add or confirm a vote on a Trello card on behalf of a member."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/membersVoted".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "value": member_id_for_vote,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_card_plugin_data(
    context: ToolContext,
    card_id: Annotated[str, "The unique ID of the Trello card to retrieve plugin data for."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-plugindata'."]:
    """Retrieve shared plugin data from a Trello card.

    Use this tool to get any shared plugin data associated with a specific Trello card. It should be called when you need detailed plugin information for a particular Trello card to assist in managing tasks or integrations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/pluginData".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_stickers(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier for a Trello card to retrieve its stickers."],
    sticker_fields: Annotated[
        str | None, "Specify 'all' or a comma-separated list of sticker fields to retrieve."
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-stickers'."]:
    """Get the stickers on a Trello card using its ID.

    Use this tool to retrieve all stickers associated with a specific Trello card by providing the card ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/stickers".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": sticker_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_sticker_to_trello_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to which the sticker will be added."
    ],
    sticker_identifier: Annotated[
        str,
        "Specify the sticker ID for custom stickers or use default string identifiers like 'taco-cool' for default stickers.",  # noqa: E501
    ],
    sticker_left_position: Annotated[
        float, "The left position of the sticker. Acceptable values range from -60 to 100."
    ],
    sticker_top_position: Annotated[
        float, "Specify the vertical position of the sticker on the card, ranging from -60 to 100."
    ],
    sticker_z_index: Annotated[
        int,
        "Specify the z-index of the sticker to determine overlay order. Use integers to set layer depth.",  # noqa: E501
    ],
    sticker_rotation: Annotated[
        float | None,
        "The rotation angle of the sticker in degrees, allowing for visual adjustment.",
    ] = 0,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-stickers'."]:
    """Add a sticker to a specific Trello card.

    Use this tool to attach a sticker to a Trello card by specifying the card's ID. Ideal for organizing and visually enhancing your Trello boards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/stickers".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "image": sticker_identifier,
            "top": sticker_top_position,
            "left": sticker_left_position,
            "zIndex": sticker_z_index,
            "rotate": sticker_rotation,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_card_sticker(
    context: ToolContext,
    card_id: Annotated[str, "The ID of the Trello card to retrieve the sticker from."],
    sticker_id: Annotated[str, "The unique identifier for the sticker on the Trello card."],
    sticker_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of sticker fields you want to retrieve.",
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-stickers-idsticker'."]:
    """Fetch details of a specific sticker on a Trello card.

    Use this tool to obtain information about a specific sticker on a Trello card by providing the card and sticker identifiers."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/stickers/{idSticker}".format(  # noqa: UP032
            id=card_id, idSticker=sticker_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": sticker_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_card_sticker(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card from which the sticker will be removed."
    ],
    sticker_id: Annotated[
        str, "The ID of the sticker to be removed from the specified Trello card."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-stickers-idsticker'."
]:
    """Removes a specified sticker from a Trello card.

    Use this tool to remove a specific sticker from a Trello card by providing the card and sticker identifiers."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/stickers/{idSticker}".format(  # noqa: UP032
            id=card_id, idSticker=sticker_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_card_sticker(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier of the Trello card to update the sticker on."],
    sticker_id: Annotated[
        str,
        "The unique identifier for the sticker to be updated on the Trello card. It must match an existing sticker on the specified card.",  # noqa: E501
    ],
    sticker_left_position: Annotated[
        float, "The left position of the sticker, ranging from -60 to 100."
    ],
    sticker_top_position: Annotated[
        float,
        "The vertical position of the sticker on the card, ranging from -60 to 100. Determines the position from the top.",  # noqa: E501
    ],
    sticker_z_index: Annotated[
        int,
        "The z-index of the sticker, determining its layer position with respect to other stickers on the card. Provide as an integer.",  # noqa: E501
    ],
    sticker_rotation: Annotated[
        float | None,
        "The rotation angle of the sticker. Provide a number representing the degrees of rotation.",
    ] = 0,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-cards-id-stickers-idsticker'."]:
    """Update a sticker on a specified Trello card.

    Use this tool to update the properties of an existing sticker on a Trello card. Ideal for modifying sticker details based on card ID and sticker ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/stickers/{idSticker}".format(  # noqa: UP032
            id=card_id, idSticker=sticker_id
        ),
        method="PUT",
        params=remove_none_values({
            "top": sticker_top_position,
            "left": sticker_left_position,
            "zIndex": sticker_z_index,
            "rotate": sticker_rotation,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_card_comment(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier for the Trello card where the comment resides."],
    comment_action_id: Annotated[
        str, "The unique ID of the comment action you wish to update on a Trello card."
    ],
    new_comment_text: Annotated[
        str, "The new text content for the comment being updated on the Trello card."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-cards-id-actions-idaction-comments'."
]:
    """Update an existing comment on a Trello card.

    Use this tool to modify an existing comment on a specific Trello card. It should be called when you want to change the content of a previously made comment."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/actions/{idAction}/comments".format(  # noqa: UP032
            id=card_id, idAction=comment_action_id
        ),
        method="PUT",
        params=remove_none_values({
            "text": new_comment_text,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_comment_on_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier for the Trello card from which the comment will be deleted."
    ],
    comment_action_id: Annotated[str, "The ID of the comment action to be deleted from the card."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-actions-id-comments'."
]:
    """Deletes a comment from a Trello card action.

    This tool deletes a specific comment from a Trello card's action. It should be called when a user wants to remove a comment from a card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/actions/{idAction}/comments".format(  # noqa: UP032
            id=card_id, idAction=comment_action_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_card_custom_field(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    card_id: Annotated[
        str | None,
        "The ID of the Trello card where the custom field value will be set or updated.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    custom_field_id: Annotated[
        str | None,
        "The unique identifier for the custom field on the Trello card.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-cards-idcard-customfield-idcustomfield-item'.",
]:
    """Update or remove a custom field value on a Trello card.

    Use this tool to set, update, or remove the value for a custom field on a Trello card. Ideal for managing card data and keeping your board updated with the latest information.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.\n\nThis operation also requires path parameters.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.\n      Note: You must also provide the required path parameters when executing.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELD"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter along with the required path parameters. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters
    # Validate required parameters
    missing_params = []
    if not card_id:
        missing_params.append(("card_id", "path"))
    if not custom_field_id:
        missing_params.append(("custom_field_id", "path"))

    if missing_params:
        param_names = [p[0] for p in missing_params]
        param_details = ", ".join([f"{p[0]} ({p[1]})" for p in missing_params])
        raise RetryableToolError(
            message=f"Missing required parameters: {param_names}",
            developer_message=(f"Required parameters validation failed: {param_details}"),
            additional_prompt_content=(
                f"The following required parameters are missing: "
                f"{param_details}. Please call this tool again with all "
                "required parameters."
            ),
        )

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELD"]
                + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELD"]
                + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/cards/{idCard}/customField/{idCustomField}/item".format(  # noqa: UP032
            idCard=card_id, idCustomField=custom_field_id
        ),
        method="PUT",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELD"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_card_custom_fields(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-cards-idcard-customfields'."]:
    """Update custom fields on a Trello card.

    Use this tool to set, update, or remove values for multiple custom fields on a specific Trello card. Ideal for managing card metadata and ensuring up-to-date information on your board.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELDS"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELDS"]
                + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELDS"]
                + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/cards/{idCard}/customFields",
        method="PUT",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["UPDATETRELLOCARDCUSTOMFIELDS"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_custom_field_items(
    context: ToolContext,
    card_id: Annotated[
        str,
        "The unique identifier for the Trello card whose custom field items you want to retrieve.",
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-cards-id-customfielditems'."]:
    """Retrieve custom field items for a Trello card.

    This tool fetches the custom field items associated with a specific Trello card. Use it to obtain detailed information about custom fields on a card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/customFieldItems".format(id=card_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_comment_to_trello_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card where the comment will be added."
    ],
    comment_text: Annotated[str, "The content of the comment to be added to the Trello card."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-actions-comments'."]:
    """Add a comment to a specific Trello card.

    Use this tool to post a new comment on a Trello card given its ID. It is useful for users needing to add updates or notes directly on a Trello card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/actions/comments".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "text": comment_text,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_label_to_trello_card(
    context: ToolContext,
    card_id: Annotated[str, "The unique identifier for the specific Trello card."],
    label_id: Annotated[str | None, "The ID of the label to add to the Trello card."] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-idlabels'."]:
    """Add a label to a Trello card.

    Use this tool to assign a label to a specific card in Trello by specifying the card ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/idLabels".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "value": label_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_member_to_trello_card(
    context: ToolContext,
    card_id: Annotated[
        str,
        "The unique identifier for the Trello card to which a member will be added. It is required to specify which card the member should be added to.",  # noqa: E501
    ],
    member_id_to_add: Annotated[
        str | None, "The ID of the member to add to the specified Trello card."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-idmembers'."]:
    """Add a member to a specified Trello card.

    Use this tool to assign a specific member to a Trello card by providing the card ID and member information."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/idMembers".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "value": member_id_to_add,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_card_label(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card to which the label will be added."
    ],
    label_color: Annotated[
        str,
        "Specify a valid Trello label color or use 'null'. Check Trello's documentation for available colors.",  # noqa: E501
    ],
    label_name: Annotated[str | None, "The name for the label to add to the Trello card."] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-cards-id-labels'."]:
    """Add a new label to a specific Trello card.

    This tool creates a new label on the specified Trello board and attaches it to the given card. Use this when you need to organize or categorize tasks by adding labels to cards in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/labels".format(id=card_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "color": label_color,
            "name": label_name,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def mark_trello_card_notifications_read(
    context: ToolContext,
    card_id: Annotated[
        str,
        "The unique identifier of the Trello card whose notifications need to be marked as read.",
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'post-cards-id-markassociatednotificationsread'.",
]:
    """Mark Trello card notifications as read.

    Use this tool to mark all notifications associated with a specific Trello card as read. Ideal for managing notification statuses efficiently."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/markAssociatedNotificationsRead".format(  # noqa: UP032
            id=card_id
        ),
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_label_from_trello_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier for the Trello card from which the label will be removed."
    ],
    label_id_to_remove: Annotated[
        str, "The ID of the label you want to remove from the Trello card."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-idlabels-idlabel'."
]:
    """Remove a specific label from a Trello card.

    Use this tool to delete a label from a specific Trello card. It should be called when there's a need to manage labels by removing one from a card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/idLabels/{idLabel}".format(  # noqa: UP032
            id=card_id, idLabel=label_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_member_from_card(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier for the Trello card from which the member will be removed."
    ],
    member_id_to_remove: Annotated[str, "The ID of the member to remove from the Trello card."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-id-idmembers-idmember'."]:
    """Removes a member from a Trello card.

    Use this tool to remove a specific member from a Trello card by providing the card ID and the member ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/idMembers/{idMember}".format(  # noqa: UP032
            id=card_id, idMember=member_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_member_vote(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier of the Trello card from which to remove the vote."
    ],
    member_id_to_remove_vote: Annotated[
        str, "The ID of the member whose vote is to be removed from the Trello card."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-membersvoted-idmember'."
]:
    """Remove a member's vote from a Trello card.

    Use this tool to remove a specific member's vote from a specified card in Trello. It is useful for managing voting permissions on cards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/membersVoted/{idMember}".format(  # noqa: UP032
            id=card_id, idMember=member_id_to_remove_vote
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_checklist_item(
    context: ToolContext,
    card_id: Annotated[
        str, "The unique identifier for the Trello card where the checklist item is located."
    ],
    checklist_id: Annotated[
        str, "The ID of the checklist item you want to update on the Trello card."
    ],
    checklist_item_id: Annotated[
        str, "The unique ID of the checklist item that needs to be updated on the Trello card."
    ],
    position_in_checklist: Annotated[
        str | None,
        "Position the checklist item at the 'top', 'bottom', or a specific order with a positive float.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-cards-idcard-checklist-idchecklist-checkitem-idcheckitem'.",  # noqa: E501
]:
    """Update an item in a Trello card checklist.

    Use this tool to update a specific item in a checklist on a Trello card. It should be called when you need to modify details of an existing checklist item."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{idCard}/checklist/{idChecklist}/checkItem/{idCheckItem}".format(  # noqa: UP032
            idCard=card_id, idCheckItem=checklist_item_id, idChecklist=checklist_id
        ),
        method="PUT",
        params=remove_none_values({
            "pos": position_in_checklist,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_card_checklist(
    context: ToolContext,
    card_id: Annotated[str, "The ID of the Trello card from which the checklist will be deleted."],
    checklist_id: Annotated[str, "The ID of the checklist to delete from the Trello card."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-cards-id-checklists-idchecklist'."
]:
    """Delete a checklist from a Trello card.

    Use this tool to delete a specific checklist from a Trello card by providing the card and checklist IDs."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/cards/{id}/checklists/{idChecklist}".format(  # noqa: UP032
            id=card_id, idChecklist=checklist_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_checklist(
    context: ToolContext,
    card_id: Annotated[str, "The unique ID of the Trello card where the checklist will be added."],
    checklist_name: Annotated[
        str | None,
        "The name of the checklist to be created. It should be a string with 1 to 16384 characters.",  # noqa: E501
    ] = None,
    checklist_position: Annotated[
        str | None,
        "The position of the checklist on the card. Accepts 'top', 'bottom', or a positive number indicating specific placement.",  # noqa: E501
    ] = None,
    source_checklist_id: Annotated[
        str | None, "The ID of the checklist to be copied into the new checklist."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-checklists'."]:
    """Create a new checklist in Trello.

    This tool creates a checklist in Trello. It should be called when a user wants to add a checklist to a Trello board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists",
        method="POST",
        params=remove_none_values({
            "idCard": card_id,
            "name": checklist_name,
            "pos": checklist_position,
            "idChecklistSource": source_checklist_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_checklist_by_id(
    context: ToolContext,
    checklist_id: Annotated[str, "Provide the ID of the Trello checklist you want to retrieve."],
    checkitem_fields_to_return: Annotated[
        str | None,
        "Fields on the checkItem to return if checkItems are included. Use `all` or a comma-separated list of available fields like `name`, `type`, `due`, etc.",  # noqa: E501
    ] = "name, nameData, pos, state, due, dueReminder, idMember",
    checklist_fields: Annotated[
        str | None, "Specify `all` or a comma-separated list of checklist fields to return."
    ] = "all",
    include_cards: Annotated[
        str | None,
        "Specify which cards associated with the checklist should be returned. Valid options are: 'all', 'closed', 'none', 'open', 'visible'.",  # noqa: E501
    ] = "none",
    return_check_items: Annotated[
        str | None, "Specify whether to return check items on the checklist, using 'all' or 'none'."
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-checklists-id'."]:
    """Retrieve a specific Trello checklist by ID.

    Use this tool to access the details of a checklist in Trello by providing the checklist ID. This can be helpful when you need to view or manage checklist items from a Trello card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}".format(id=checklist_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "cards": include_cards,
            "checkItems": return_check_items,
            "checkItem_fields": checkitem_fields_to_return,
            "fields": checklist_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_checklist(
    context: ToolContext,
    checklist_id: Annotated[
        str,
        "ID of the checklist to update on Trello. This is required to specify which checklist needs updating.",  # noqa: E501
    ],
    checklist_name: Annotated[
        str | None, "Name of the checklist to update. Must be 1 to 16,384 characters long."
    ] = None,
    checklist_position: Annotated[
        str | None,
        "Specify the position of the checklist on the card. Options are `top`, `bottom`, or a positive number indicating the precise position.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-checlists-id'."]:
    """Update an existing checklist on Trello.

    Use this tool to update an existing checklist in Trello. Typically called when checklist modifications are needed, such as changing item details or statuses."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}".format(id=checklist_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "name": checklist_name,
            "pos": checklist_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_checklist(
    context: ToolContext,
    checklist_id: Annotated[
        str, "The unique identifier of the checklist to be deleted from Trello."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-checklists-id'."]:
    """Deletes a checklist from Trello using its ID.

    Use this tool to delete a specific checklist from a Trello board by providing the checklist's ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}".format(id=checklist_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_checklist_field(
    context: ToolContext,
    checklist_field_to_retrieve: Annotated[
        str, "Specify the field of the checklist to retrieve: 'name' or 'pos'."
    ],
    checklist_id: Annotated[
        str, "The unique identifier of the checklist to retrieve a specific field from."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-checklists-id-field'."]:
    """Retrieve a specific field from a Trello checklist.

    Use this tool to get a specific field from a checklist in Trello using its ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/{field}".format(  # noqa: UP032
            id=checklist_id, field=checklist_field_to_retrieve
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_checklist_field(
    context: ToolContext,
    checklist_field: Annotated[
        str, "Specify the checklist field to update. Options are 'name' or 'pos'."
    ],
    checklist_id: Annotated[
        str,
        "ID of the checklist to be updated. This is required to specify which checklist field to modify.",  # noqa: E501
    ],
    checklist_name_value: Annotated[
        str, "The new name for the checklist. Must be a string of length 1 to 16384."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-checklists-id-field'."]:
    """Updates a specific field of a checklist on Trello.

    This tool updates a specified field on an existing checklist in Trello by its ID. It should be used when modifications to checklist attributes are needed."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/{field}".format(  # noqa: UP032
            id=checklist_id, field=checklist_field
        ),
        method="PUT",
        params=remove_none_values({
            "value": checklist_name_value,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_from_checklist(
    context: ToolContext,
    checklist_id: Annotated[
        str, "ID of the checklist to identify which board it is associated with on Trello."
    ],
    board_fields_selection: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of board fields to retrieve. Default is 'all'.",
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-checklists-id-board'."]:
    """Retrieve the board associated with a checklist on Trello.

    Call this tool to find out the board on which a specific checklist resides in Trello. Useful for organizing and tracking checklist locations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/board".format(id=checklist_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields_selection,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_card_from_checklist(
    context: ToolContext,
    checklist_id: Annotated[
        str, "The unique identifier of the Trello checklist to retrieve the associated card."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-checklists-id-cards'."]:
    """Retrieve card details for a specified checklist.

    Use this tool to obtain information about the card that contains a specific checklist in Trello. Useful when you need to identify or manage the card linked to a particular checklist."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/cards".format(id=checklist_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_checklist_checkitems(
    context: ToolContext,
    checklist_id: Annotated[
        str, "The unique identifier of the checklist to retrieve its checkitems."
    ],
    fields_to_retrieve: Annotated[
        str | None,
        "Specify which fields to retrieve from the checklist items. Options include: `all`, `name`, `nameData`, `pos`, `state`, `type`, `due`, `dueReminder`, `idMember`.",  # noqa: E501
    ] = "name, nameData, pos, state, due, dueReminder, idMember",
    list_checkitems_filter: Annotated[
        str | None, "Specify whether to retrieve 'all' checkitems or 'none'."
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-checklists-id-checkitems'."]:
    """Retrieve checkitems from a Trello checklist.

    Use this tool to get all checkitems associated with a specific checklist in Trello. It is useful when you need a detailed view of tasks or items within a particular checklist."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/checkItems".format(id=checklist_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": list_checkitems_filter,
            "fields": fields_to_retrieve,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_checkitem_in_checklist(
    context: ToolContext,
    checkitem_name: Annotated[
        str,
        "The name of the new check item on the checklist. Must be between 1 and 16384 characters long.",  # noqa: E501
    ],
    checklist_id: Annotated[
        str, "The unique ID of the checklist where the checkitem will be created."
    ],
    checkitem_due_date: Annotated[
        str | None, "Specify the due date for the checkitem in ISO 8601 format (e.g., YYYY-MM-DD)."
    ] = None,
    checkitem_position: Annotated[
        str | None,
        "Position of the check item in checklist: `top`, `bottom`, or a positive number.",
    ] = None,
    due_reminder_minutes: Annotated[
        float | None, "Minutes before the due date to trigger a reminder for the checkitem."
    ] = None,
    is_checkitem_checked: Annotated[
        bool | None,
        "Set to true if the check item should be checked upon creation. Otherwise, it will be unchecked.",  # noqa: E501
    ] = False,
    member_id: Annotated[str | None, "ID of the member to associate with the checkitem."] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-checklists-id-checkitems'."]:
    """Create a new checkitem in a Trello checklist.

    Use this tool to add a new checkitem to an existing checklist in Trello. This is useful for managing tasks and ensuring that all necessary steps are documented within a checklist."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/checkItems".format(id=checklist_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": checkitem_name,
            "pos": checkitem_position,
            "checked": is_checkitem_checked,
            "due": checkitem_due_date,
            "dueReminder": due_reminder_minutes,
            "idMember": member_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_checklist_item(
    context: ToolContext,
    check_item_id: Annotated[str, "ID of the specific check item to retrieve from the checklist."],
    checklist_id: Annotated[
        str, "The unique identifier of the checklist containing the desired checkitem."
    ],
    checkitem_fields: Annotated[
        str | None,
        "Specify which fields of the checkitem to retrieve. Options include `all`, `name`, `nameData`, `pos`, `state`, `type`, `due`, `dueReminder`, `idMember`.",  # noqa: E501
    ] = "name, nameData, pos, state, due, dueReminder, idMember",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-checklists-id-checkitems-idcheckitem'."
]:
    """Retrieve a specific checkitem from a checklist on Trello.

    This tool is used to get details about a specific checkitem within a checklist on Trello. It should be called when you need information about a particular task or item in a checklist."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/checkItems/{idCheckItem}".format(  # noqa: UP032
            id=checklist_id, idCheckItem=check_item_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": checkitem_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_checklist_item(
    context: ToolContext,
    check_item_id: Annotated[
        str, "The ID of the specific checklist item to be removed from Trello."
    ],
    checklist_id: Annotated[str, "ID of the checklist from which the item will be removed."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-checklists-id-checkitems-idcheckitem'."
]:
    """Remove an item from a Trello checklist.

    Use this tool to delete a specific item from a checklist in Trello, identified by its ID and the checklist ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/checklists/{id}/checkItems/{idCheckItem}".format(  # noqa: UP032
            id=checklist_id, idCheckItem=check_item_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_custom_field(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-customfields'."]:
    """Create a new custom field on a Trello board.

    This tool creates a new custom field on a specified Trello board. Call this tool when you need to add a custom field to organize or manage information on your Trello boards.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["CREATETRELLOCUSTOMFIELD"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n" + REQUEST_BODY_SCHEMAS["CREATETRELLOCUSTOMFIELD"] + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n" + REQUEST_BODY_SCHEMAS["CREATETRELLOCUSTOMFIELD"] + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/customFields",
        method="POST",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["CREATETRELLOCUSTOMFIELD"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_custom_field(
    context: ToolContext,
    custom_field_id: Annotated[
        str, "Provide the ID of the custom field to retrieve its details in Trello."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-customfields-id'."]:
    """Retrieve details of a Trello custom field by ID.

    Use this tool to obtain information about a specific custom field in Trello by providing its ID. Useful for accessing custom field properties or configurations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}".format(id=custom_field_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_custom_field_definition(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    custom_field_id: Annotated[
        str | None,
        "The unique identifier for the Custom Field to update in Trello.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-customfields-id'."]:
    """Update a Custom Field definition in Trello.

    Use this tool to update an existing Custom Field definition on Trello by providing the necessary details.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.\n\nThis operation also requires path parameters.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.\n      Note: You must also provide the required path parameters when executing.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["UPDATECUSTOMFIELDDEFINITION"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter along with the required path parameters. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters
    # Validate required parameters
    missing_params = []
    if not custom_field_id:
        missing_params.append(("custom_field_id", "path"))

    if missing_params:
        param_names = [p[0] for p in missing_params]
        param_details = ", ".join([f"{p[0]} ({p[1]})" for p in missing_params])
        raise RetryableToolError(
            message=f"Missing required parameters: {param_names}",
            developer_message=(f"Required parameters validation failed: {param_details}"),
            additional_prompt_content=(
                f"The following required parameters are missing: "
                f"{param_details}. Please call this tool again with all "
                "required parameters."
            ),
        )

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATECUSTOMFIELDDEFINITION"]
                + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATECUSTOMFIELDDEFINITION"]
                + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/customFields/{id}".format(id=custom_field_id),  # noqa: UP032
        method="PUT",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["UPDATECUSTOMFIELDDEFINITION"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_custom_field(
    context: ToolContext,
    custom_field_id: Annotated[
        str, "The unique identifier of the Custom Field to be deleted from the Trello board."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-customfields-id'."]:
    """Delete a custom field from a Trello board.

    Use this tool to delete a specific custom field from a Trello board by providing the field's ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}".format(id=custom_field_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_dropdown_option_custom_field(
    context: ToolContext,
    custom_field_id: Annotated[
        str, "The unique identifier of the custom field to which a dropdown option will be added."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-customfields-id-options'."]:
    """Add an option to a dropdown Custom Field in Trello.

    Use this tool to add a new option to a dropdown Custom Field on a Trello board. This should be called when needing to expand the choices available in a specific dropdown Custom Field."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}/options".format(id=custom_field_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_custom_field_options(
    context: ToolContext,
    custom_field_id: Annotated[str, "The ID of the Trello custom field to retrieve options for."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-customfields-id-options'."]:
    """Retrieve options of a Trello drop-down custom field.

    Use this tool to get the list of available options for a drop-down custom field in Trello by specifying the field ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}/options".format(id=custom_field_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_custom_field_option_trello(
    context: ToolContext,
    custom_field_item_id: Annotated[
        str, "ID of the custom field item in Trello to retrieve the dropdown option for."
    ],
    custom_field_option_id: Annotated[str, "ID of the Trello custom field option to retrieve."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-customfields-options-idcustomfieldoption'."
]:
    """Retrieve a specific dropdown option from Trello custom fields.

    Use this tool to get information about a specific option within a dropdown-type custom field in Trello. It is useful when you need to access details about a particular custom field option on a Trello card."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}/options/{idCustomFieldOption}".format(  # noqa: UP032
            id=custom_field_item_id, idCustomFieldOption=custom_field_option_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_custom_field_option(
    context: ToolContext,
    custom_field_item_id: Annotated[
        str, "ID of the customfielditem to identify which dropdown option to delete."
    ],
    custom_field_option_id: Annotated[
        str, "ID of the custom field option to delete from the dropdown list."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'delete-customfields-options-idcustomfieldoption'.",
]:
    """Delete an option from a Trello Custom Field dropdown.

    Use this tool to remove a specific option from the dropdown list of a Custom Field in Trello. This is helpful when an option is no longer needed or should be removed from the available choices."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/customFields/{id}/options/{idCustomFieldOption}".format(  # noqa: UP032
            id=custom_field_item_id, idCustomFieldOption=custom_field_option_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_available_emoji(
    context: ToolContext,
    include_spritesheet_urls: Annotated[
        bool | None, "Set to true to include spritesheet URLs in the response."
    ] = False,
    locale_for_emoji: Annotated[
        str | None,
        "Specify the locale for returning emoji descriptions and names. Defaults to the logged-in member's locale.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'emoji'."]:
    """Retrieve a list of available emojis on Trello.

    This tool is used to fetch and list all the available emojis from Trello, useful for incorporating emojis into Trello cards or boards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/emoji",
        method="GET",
        params=remove_none_values({
            "locale": locale_for_emoji,
            "spritesheets": include_spritesheet_urls,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_by_id(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The unique identifier for the enterprise you want to retrieve from Trello."
    ],
    enterprise_fields: Annotated[
        str | None,
        "Comma-separated list of fields to include, such as `id`, `name`, `displayName`, `prefs`, and more.",  # noqa: E501
    ] = "all",
    include_paid_account_information: Annotated[
        bool | None,
        "Include paid account information in the returned workspace objects if set to true. If false, it will be excluded.",  # noqa: E501
    ] = False,
    member_count: Annotated[
        int | None, "Specify the number of members to retrieve, ranging from 0 to 100."
    ] = 10,
    member_fields: Annotated[
        str | None,
        "Specify one of: `avatarHash`, `fullName`, `initials`, `username` to filter member fields.",
    ] = "avatarHash, fullName, initials, username",
    member_filter_query: Annotated[
        str | None,
        "A SCIM-style query to filter members. Overrides member types ('normal', 'admins', etc.) and paginates the member array.",  # noqa: E501
    ] = "none",
    member_inclusion_type: Annotated[
        str | None,
        "Specify which member roles to include: `none`, `normal`, `admins`, `owners`, `all`.",
    ] = "none",
    member_sort: Annotated[
        str | None,
        "Use a SCIM-style sorting value prefixed by '-' for descending or ascending if no prefix. Note: Deprecated `member_sortBy` parameter.",  # noqa: E501
    ] = "none",
    member_sorting_order: Annotated[
        str | None,
        "SCIM-style sorting value for members. Use '-' prefix for descending order, no prefix for ascending.",  # noqa: E501
    ] = None,
    member_start_index: Annotated[
        int | None,
        "Specify the starting index for paginated members. Accepts any integer between 0 and 100.",
    ] = 1,
    organization_fields_value: Annotated[
        str | None, "Specify valid values for nested organization fields as accepted by the API."
    ] = "none",
    organization_inclusion: Annotated[
        str | None,
        "Determine scope of organizations to retrieve with the enterprise: 'none', 'members', 'public', or 'all'.",  # noqa: E501
    ] = "none",
    organization_memberships_list: Annotated[
        str | None,
        "Comma-separated list indicating organization memberships such as `me`, `normal`, `admin`, `active`, `deactivated`.",  # noqa: E501
    ] = "none",
    sort_members_order: Annotated[
        str | None,
        "Order the sorting of members. Acceptable values are `ascending`, `descending`, `asc`, or `desc`. Note: This parameter is deprecated and `member_sort` is preferred.",  # noqa: E501
    ] = "id",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-enterprises-id'."]:
    """Retrieve details of a Trello enterprise by ID.

    Use this tool to obtain detailed information about a specific enterprise in Trello by providing its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": enterprise_fields,
            "members": member_inclusion_type,
            "member_fields": member_fields,
            "member_filter": member_filter_query,
            "member_sort": member_sorting_order,
            "member_sortBy": member_sort,
            "member_sortOrder": sort_members_order,
            "member_startIndex": member_start_index,
            "member_count": member_count,
            "organizations": organization_inclusion,
            "organization_fields": organization_fields_value,
            "organization_paid_accounts": include_paid_account_information,
            "organization_memberships": organization_memberships_list,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_audit_log(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "Specify the ID of the enterprise to retrieve audit log actions for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-enterprises-id-auditlog'."]:
    """Retrieve audit log actions for a specific enterprise.

    This tool returns actions related to the Enterprise object for populating data from an Enterprise's audit log page. Requires an Enterprise admin token."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/auditlog".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_admins(
    context: ToolContext,
    enterprise_id: Annotated[str, "The ID of the enterprise to retrieve admin members for."],
    admin_fields: Annotated[
        str | None,
        "Specify fields to retrieve for each admin member; valid values as per Trello's nested member field resource.",  # noqa: E501
    ] = "fullName, userName",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-enterprises-id-admins'."]:
    """Retrieve admin members of an enterprise by ID.

    Use this tool to obtain a list of admin members associated with a specific enterprise, identified by its ID. The tool helps in managing and viewing enterprise-level administration settings on Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/admins".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": admin_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_signup_url(
    context: ToolContext,
    enterprise_id: Annotated[str, "ID of the enterprise to retrieve the signup URL for."],
    authenticate: Annotated[
        bool | None,
        "Set to 'True' if authentication is required for the API call, otherwise 'False'.",
    ] = False,
    has_confirmation_been_accepted: Annotated[
        bool | None,
        "Indicates whether the user has accepted the required confirmations before being redirected.",  # noqa: E501
    ] = False,
    redirect_url: Annotated[
        str | None, "A valid URL where the user will be redirected after signup."
    ] = None,
    terms_of_service_accepted: Annotated[
        bool | None,
        "Indicate whether the user has consented to the Trello Terms of Service before being redirected to the enterprise signup page.",  # noqa: E501
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-enterprises-id-signupurl'."]:
    """Retrieve the signup URL for a specified enterprise.

    Use this tool to get the signup URL for a specific enterprise by its ID. This is useful when you need to provide users with a direct link to sign up for enterprise-related features."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/signupUrl".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "authenticate": authenticate,
            "confirmationAccepted": has_confirmation_been_accepted,
            "returnUrl": redirect_url,
            "tosAccepted": terms_of_service_accepted,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_users(
    context: ToolContext,
    enterprise_id: Annotated[str, "ID of the Trello enterprise to retrieve users from."],
    active_date_filter: Annotated[
        str | None,
        "Returns only Trello users active since this date (inclusive). Provide the date in YYYY-MM-DD format.",  # noqa: E501
    ] = "none",
    active_since_date: Annotated[
        str | None, "Filter users active since this date (inclusive). Use YYYY-MM-DD format."
    ] = "none",
    fetch_deactivated_members: Annotated[
        bool | None,
        "When true, returns members who have been deactivated; when false, returns members who have not. Both active and deactivated members are returned if unspecified.",  # noqa: E501
    ] = False,
    licensed_members_only: Annotated[
        bool | None,
        "Set to true to retrieve only members with a license for the Trello Enterprise; false for only unlicensed members. Leave unspecified to include both licensed and unlicensed members.",  # noqa: E501
    ] = False,
    only_admin_members: Annotated[
        bool | None,
        "Set to True to return only administrators of the Trello Enterprise. If False, return non-admins. Unspecified returns both.",  # noqa: E501
    ] = False,
    pagination_cursor: Annotated[
        str | None,
        "Cursor value to fetch the next set of user results. Use the cursor received from a previous response to continue fetching more users.",  # noqa: E501
    ] = "none",
    return_board_guests: Annotated[
        bool | None,
        "Set to true to return members who are guests on boards; false to return only non-guests. If not set, both are included.",  # noqa: E501
    ] = False,
    return_managed_members_only: Annotated[
        bool | None,
        "Specify true to return only managed members, false for only unmanaged, or omit for both.",
    ] = None,
    search_query: Annotated[
        str | None, "String to search for members by email or full name starting with this value."
    ] = "none",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-users-id'."]:
    """Fetch users from a Trello enterprise.

    Retrieve the users of a specified Trello enterprise, including licensed members and board guests. The response is paginated, returning 100 users per call."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/members/query".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "licensed": licensed_members_only,
            "deactivated": fetch_deactivated_members,
            "collaborator": return_board_guests,
            "managed": return_managed_members_only,
            "admin": only_admin_members,
            "activeSince": active_since_date,
            "inactiveSince": active_date_filter,
            "search": search_query,
            "cursor": pagination_cursor,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_members(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The unique ID of the enterprise whose members you want to retrieve."
    ],
    board_fields_to_include: Annotated[
        str | None, "Specify valid board field values to include from the nested board resource."
    ] = "name",
    member_count_filter: Annotated[
        str | None,
        "A SCIM-style filter to specify the number of members to retrieve. Use this to filter results according to SCIM standards.",  # noqa: E501
    ] = "none",
    member_field_list: Annotated[
        str | None, "A comma-separated list of member fields to include, e.g., 'fullName,email'."
    ] = "avatarHash, fullName, initials, username",
    organization_fields: Annotated[
        str | None,
        "Valid organization field values allowed by the Trello nested organization field resource. This customizes which organization data is returned.",  # noqa: E501
    ] = "displayName",
    scim_style_filter: Annotated[
        str | None,
        "A SCIM-style query to filter enterprise members, taking precedence over other member settings.",  # noqa: E501
    ] = None,
    sort_by: Annotated[
        str | None,
        "Deprecated: Use 'sort' instead. A SCIM-style value to sort members, affecting pagination.",
    ] = None,
    sorting_order: Annotated[
        str | None,
        "Specify how to sort members using a SCIM-style value. Prefix with `-` for descending order; otherwise, ascending.",  # noqa: E501
    ] = None,
    start_index: Annotated[
        int | None, "The starting point for pagination, using an integer between 0 and 9999."
    ] = None,
    use_deprecated_sort_order: Annotated[
        str | None,
        "Specify the sorting order for members: 'ascending', 'descending', 'asc', 'desc'. Deprecated; use 'sort' instead.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-enterprises-id-members'."]:
    """Retrieve members of a specific enterprise from Trello.

    Use this tool to get a list of all members associated with a specified enterprise on Trello. It should be called when you need to access or display information about the members of an enterprise, such as in management or collaboration scenarios."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/members".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_field_list,
            "filter": scim_style_filter,
            "sort": sorting_order,
            "sortBy": sort_by,
            "sortOrder": use_deprecated_sort_order,
            "startIndex": start_index,
            "count": member_count_filter,
            "organization_fields": organization_fields,
            "board_fields": board_fields_to_include,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_member(
    context: ToolContext,
    enterprise_id: Annotated[
        str,
        "The unique identifier for the enterprise to retrieve. This is required to specify which enterprise's member data you are accessing.",  # noqa: E501
    ],
    member_id: Annotated[
        str, "The ID of the member resource you want to retrieve details for within an enterprise."
    ],
    board_fields: Annotated[
        str | None,
        "Comma-separated list of board fields to retrieve, as defined by the Trello nested board resource.",  # noqa: E501
    ] = "name",
    member_field_values: Annotated[
        str | None,
        "Comma-separated valid values for member fields to retrieve details about a specific enterprise member.",  # noqa: E501
    ] = "avatarHash, fullName, initials, username",
    organization_field_values: Annotated[
        str | None,
        "Comma-separated list of organization fields to include. Refer to Trello's nested organization field resource for valid values.",  # noqa: E501
    ] = "displayName",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-enterprises-id-members-idmember'."
]:
    """Retrieve a specific member of an enterprise by ID.

    Use this tool to obtain details about a particular member within an enterprise by providing the enterprise ID and member ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/members/{idMember}".format(  # noqa: UP032
            id=enterprise_id, idMember=member_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": member_field_values,
            "organization_fields": organization_field_values,
            "board_fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def check_organization_transferability(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "ID of the Enterprise to check for organization transferability."
    ],
    organization_id: Annotated[str, "The ID of the organization to check for transferability."],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'get-enterprises-id-transferrable-organization-idOrganization'.",  # noqa: E501
]:
    """Check if an organization can be transferred to an enterprise.

    This tool checks whether a specified organization can be transferred to an enterprise, providing the transferability status."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/transferrable/organization/{idOrganization}".format(  # noqa: UP032
            id=enterprise_id, idOrganization=organization_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_claimable_workspaces(
    context: ToolContext,
    enterprise_id_to_retrieve_workspaces: Annotated[
        str, "The unique ID of the enterprise to retrieve claimable workspaces for."
    ],
    active_since_date: Annotated[
        str | None,
        "Specify the date in YYYY-MM-DD format to filter workspaces active up to this date.",
    ] = None,
    enterprise_name: Annotated[
        str | None, "The name of the enterprise for which to retrieve claimable workspaces."
    ] = None,
    inactive_since_date: Annotated[
        str | None, "Date in YYYY-MM-DD format to search for workspace inactiveness."
    ] = None,
    maximum_workspaces: Annotated[
        int | None,
        "Sets the maximum number of workspaces to retrieve and sort. Use an integer to specify the limit.",  # noqa: E501
    ] = None,
    sort_order_cursor: Annotated[
        str | None,
        "Specifies the sorting cursor for the order in which matching workspaces are returned. Use this to paginate results.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-enterprises-id-claimableOrganizations'."
]:
    """Retrieve claimable workspaces for an enterprise by ID.

    Use this tool to get a list of workspaces that can be claimed by the specified enterprise. Optionally, filter workspaces by their activity status."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/claimableOrganizations".format(  # noqa: UP032
            id=enterprise_id_to_retrieve_workspaces
        ),
        method="GET",
        params=remove_none_values({
            "limit": maximum_workspaces,
            "cursor": sort_order_cursor,
            "name": enterprise_name,
            "activeSince": active_since_date,
            "inactiveSince": inactive_since_date,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_pending_workspaces_by_enterprise_id(
    context: ToolContext,
    enterprise_id: Annotated[str, "ID of the enterprise to retrieve pending workspaces for."],
    active_since_date: Annotated[
        str | None, "Date in YYYY-MM-DD format to filter active workspaces up to a certain date."
    ] = None,
    search_up_to_inactive_date: Annotated[
        str | None,
        "Date in YYYY-MM-DD format indicating the search cutoff for workspace inactiveness.",
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-enterprises-id-pendingOrganizations'."
]:
    """Retrieve pending workspaces for an enterprise by ID.

    Use this tool to get a list of workspaces that are pending approval within a specific enterprise, identified by its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/pendingOrganizations".format(  # noqa: UP032
            id=enterprise_id
        ),
        method="GET",
        params=remove_none_values({
            "activeSince": active_since_date,
            "inactiveSince": search_up_to_inactive_date,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_enterprise_auth_token(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The unique ID of the enterprise for which the auth token will be generated."
    ],
    token_expiration: Annotated[
        str | None,
        "Specify the token's duration: `1hour`, `1day`, `30days`, or `never`. This determines how long the token will be valid.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-enterprises-id-tokens'."]:
    """Create an auth token for a Trello enterprise.

    This tool generates an authentication token for a specified enterprise in Trello. Use it when managing enterprise-level access or automating processes that require specific enterprise authentication."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/tokens".format(id=enterprise_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "expiration": token_expiration,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_enterprise_organizations(
    context: ToolContext,
    enterprise_id: Annotated[str, "ID of the Enterprise to retrieve its organizations."],
    number_of_organizations_to_retrieve: Annotated[
        int | None,
        "Specify the number of organizations to retrieve. Must be an integer between 0 and 100.",
    ] = None,
    organization_fields: Annotated[
        str | None,
        "Comma-separated list of organization fields to include in the response. Valid options are: 'id', 'name'.",  # noqa: E501
    ] = None,
    organization_filter: Annotated[
        str | None, "Optional filter for specifying which organizations to include in the response."
    ] = "all",
    starting_index: Annotated[
        int | None,
        "The starting index for fetching organizations, must be an integer greater than or equal to 1.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-enterprises-id-organizations'."
]:
    """Retrieve organizations associated with a specific enterprise.

    This tool is used to get the organizations belonging to a given enterprise. It is helpful when you need to access or manage the organizations under a specific enterprise structure."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/organizations".format(id=enterprise_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": organization_fields,
            "filter": organization_filter,
            "startIndex": starting_index,
            "count": number_of_organizations_to_retrieve,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def transfer_organization_to_enterprise(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The ID of the Enterprise to which the organization will be transferred."
    ],
    organization_id: Annotated[
        str, "ID of the organization to be transferred to the enterprise in Trello."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-enterprises-id-organizations'."
]:
    """Transfer an organization to an enterprise.

    This tool is used to initiate the transfer of an organization to a specified enterprise in Trello. For enterprises using AdminHub for user management, the addition is processed asynchronously. A successful response only confirms request receipt, not the completion of the transfer."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/organizations".format(id=enterprise_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "idOrganization": organization_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_enterprise_member_license(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The unique identifier for the enterprise. Required for license updates."
    ],
    grant_enterprise_license: Annotated[
        bool,
        "Boolean indicating if the member should be given an Enterprise license (true) or not (false).",  # noqa: E501
    ],
    member_id: Annotated[str, "The unique ID of the Trello member to update license status."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-enterprises-id-members-idmember-licensed'."
]:
    """Update an enterprise member's license status in Trello.

    Use this tool to update whether a member should use an enterprise's license. Note that revoking a license will deactivate the member, and this operation cannot be performed if the enterprise manages users via AdminHub."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/members/{idMember}/licensed".format(  # noqa: UP032
            id=enterprise_id, idMember=member_id
        ),
        method="PUT",
        params=remove_none_values({
            "value": grant_enterprise_license,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def deactivate_enterprise_member(
    context: ToolContext,
    deactivate_member: Annotated[
        bool, "Set to True to deactivate the member, False to keep active."
    ],
    enterprise_id: Annotated[
        str, "The ID of the enterprise from which the member should be deactivated."
    ],
    member_id_to_deactivate: Annotated[
        str, "The ID of the member to deactivate in a Trello enterprise."
    ],
    board_fields_to_include: Annotated[
        str | None,
        "Specify which board fields should be included. Use values like 'id', 'name', 'desc', etc.",
    ] = None,
    nested_member_fields: Annotated[
        str | None, "Comma-separated list of valid values for the nested member field resource."
    ] = None,
    organization_fields: Annotated[
        str | None,
        "Comma-separated list of fields related to the organization, such as 'id' or 'name'.",
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'enterprises-id-members-idMember-deactivated'."
]:
    """Deactivate a member in a Trello enterprise.

    Deactivate a member of a Trello enterprise unless the enterprise uses AdminHub for user management."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/members/{idMember}/deactivated".format(  # noqa: UP032
            id=enterprise_id, idMember=member_id_to_deactivate
        ),
        method="PUT",
        params=remove_none_values({
            "value": deactivate_member,
            "fields": nested_member_fields,
            "organization_fields": organization_fields,
            "board_fields": board_fields_to_include,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def make_member_admin_enterprise(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The ID of the enterprise for which you want to promote a member to admin."
    ],
    member_id_to_promote: Annotated[
        str, "ID of the member to be promoted to admin of the enterprise."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-enterprises-id-admins-idmember'."
]:
    """Promote a member to admin in a Trello enterprise.

    Call this tool to make a specified member an admin of a Trello enterprise. Note that this endpoint is unavailable for enterprises using AdminHub for user management."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/admins/{idMember}".format(  # noqa: UP032
            id=enterprise_id, idMember=member_id_to_promote
        ),
        method="PUT",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_enterprise_admin(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The Trello Enterprise ID from which to remove the member as admin."
    ],
    member_id_to_remove: Annotated[
        str, "ID of the member to be removed as an admin from the enterprise."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'enterprises-id-organizations-idmember'."
]:
    """Remove a member as admin from an enterprise.

    Use this tool to remove a specific member from the admin role within an enterprise on Trello. Note that this endpoint is unavailable for enterprises using AdminHub for user management."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/admins/{idMember}".format(  # noqa: UP032
            id=enterprise_id, idMember=member_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_organization_from_enterprise(
    context: ToolContext,
    enterprise_id: Annotated[
        str, "The ID of the Trello enterprise from which the organization will be removed."
    ],
    organization_id_to_remove: Annotated[
        str, "The ID of the organization to be removed from the Trello enterprise."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-enterprises-id-organizations-idorg'."
]:
    """Remove an organization from a Trello enterprise.

    This tool removes a specified organization from a Trello enterprise. It should be called when you need to delete an association between an organization and an enterprise in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/enterprises/{id}/organizations/{idOrg}".format(  # noqa: UP032
            id=enterprise_id, idOrg=organization_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_label_info(
    context: ToolContext,
    label_id: Annotated[
        str, "The unique identifier for the Trello label to retrieve information about."
    ],
    label_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of label fields to retrieve details about. Refer to Trello's field documentation for options.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-labels-id'."]:
    """Retrieve information about a specific Trello label.

    Use this tool to get detailed information about a single label in Trello by providing the label ID. This is useful for understanding label attributes and data associated with it."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/labels/{id}".format(id=label_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": label_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_label(
    context: ToolContext,
    label_id: Annotated[str, "The unique identifier for the Trello label to update."],
    label_color: Annotated[
        str | None,
        "Specify the new color for the label. Allowed colors: yellow, purple, blue, red, green, orange, black, sky, pink, lime.",  # noqa: E501
    ] = None,
    new_label_name: Annotated[
        str | None, "The new name for the Trello label to be updated."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-labels-id'."]:
    """Update Trello label details using its ID.

    Use this tool to update the details of a specific Trello label by providing its ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/labels/{id}".format(id=label_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "name": new_label_name,
            "color": label_color,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_label_by_id(
    context: ToolContext,
    label_id: Annotated[str, "The unique identifier for the label to be deleted from Trello."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-labels-id'."]:
    """Delete a label in Trello by its ID.

    Call this tool to delete a specific label from Trello by providing its unique ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/labels/{id}".format(id=label_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_label_field(
    context: ToolContext,
    label_field_to_update: Annotated[
        str, "Specify the label field to update, such as 'color' or 'name'."
    ],
    label_id: Annotated[str, "The unique identifier of the Trello label to update."],
    new_field_value: Annotated[
        str, "The new value to update the specified label field with, such as a new color or name."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-labels-id-field'."]:
    """Update a specific field on a Trello label.

    This tool updates a specified field of a label in Trello, such as color or name. It should be used when changes to label attributes are required."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/labels/{id}/{field}".format(  # noqa: UP032
            id=label_id, field=label_field_to_update
        ),
        method="PUT",
        params=remove_none_values({
            "value": new_field_value,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_new_label_on_board(
    context: ToolContext,
    board_id: Annotated[
        str,
        "The ID of the Trello board on which to create the new label. This is required to specify the target board.",  # noqa: E501
    ],
    label_color: Annotated[
        str,
        "Specify the color for the label. Choose from yellow, purple, blue, red, green, orange, black, sky, pink, or lime.",  # noqa: E501
    ],
    label_name: Annotated[
        str, "The name assigned to the new label being created on the Trello board."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-labels'."]:
    """Create a new label on a Trello board.

    Use this tool to add a new label to a specified Trello board. This is useful for organizing and categorizing tasks within a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/labels",
        method="POST",
        params=remove_none_values({
            "name": label_name,
            "color": label_color,
            "idBoard": board_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_list_info(
    context: ToolContext,
    list_id: Annotated[
        str, "The unique identifier of the Trello list to retrieve information for."
    ],
    list_fields: Annotated[
        str | None,
        "Specify 'all' or provide a comma-separated list of list field names to retrieve specific details.",  # noqa: E501
    ] = "name,closed,idBoard,pos",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-lists-id'."]:
    """Retrieve details for a specific Trello list using its ID.

    Use this tool to obtain detailed information about a Trello list by providing its unique identifier. Call this when specific list details are required to view or manage."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}".format(id=list_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": list_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_list(
    context: ToolContext,
    list_id: Annotated[str, "The unique ID of the Trello list to be updated."],
    archive_list: Annotated[
        bool | None, "Set to true to archive the list, false to keep it open."
    ] = None,
    board_id_destination: Annotated[
        str | None, "ID of the board to which the list will be moved."
    ] = None,
    is_subscribed: Annotated[
        bool | None,
        "Whether the active member is subscribed to this list. Use `true` to subscribe and `false` to unsubscribe.",  # noqa: E501
    ] = None,
    new_list_name: Annotated[str | None, "The new name to assign to the Trello list."] = None,
    new_list_position: Annotated[
        str | None,
        "New position for the list: 'top', 'bottom', or a positive floating point number.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-lists-id'."]:
    """Update the properties of a Trello list.

    This tool updates the properties of a specified list in Trello. It should be called when there is a need to modify attributes of an existing Trello list."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}".format(id=list_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "name": new_list_name,
            "closed": archive_list,
            "idBoard": board_id_destination,
            "pos": new_list_position,
            "subscribed": is_subscribed,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_list(
    context: ToolContext,
    board_id: Annotated[
        str, "The unique string ID of the Trello board where the list will be created."
    ],
    list_name: Annotated[str, "The name of the new list to be created on the Trello board."],
    list_position: Annotated[
        str | None,
        "Position of the list on the board: `top`, `bottom`, or a positive floating number to specify exact placement.",  # noqa: E501
    ] = None,
    source_list_id: Annotated[
        str | None,
        "ID of the list to copy into the new list. Leave blank to create a new list without copying.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-lists'."]:
    """Create a new list on a Trello board.

    This tool is used to create a new list on a specified Trello board. It should be called when you want to organize tasks or items into a new category within a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists",
        method="POST",
        params=remove_none_values({
            "name": list_name,
            "idBoard": board_id,
            "idListSource": source_list_id,
            "pos": list_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def archive_all_cards_in_list(
    context: ToolContext,
    list_id: Annotated[str, "The unique identifier of the Trello list to archive all cards from."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-lists-id-archiveallcards'."]:
    """Archives all cards in a specified Trello list.

    Use this tool to archive all cards within a specific Trello list. This action is useful for organizing and managing tasks by clearing out completed or irrelevant cards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/archiveAllCards".format(id=list_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def trello_move_all_cards_in_list(
    context: ToolContext,
    destination_board_id: Annotated[str, "The board ID where the cards will be moved to."],
    source_list_id: Annotated[str, "The ID of the list from which all cards will be moved."],
    target_list_id: Annotated[str, "The ID of the Trello list to which all cards should be moved."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-lists-id-moveallcards'."]:
    """Move all cards from one list to another in Trello.

    Use this tool when you need to move all cards from one Trello list to another. It facilitates bulk card transfer within a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/moveAllCards".format(id=source_list_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "idBoard": destination_board_id,
            "idList": target_list_id,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def archive_or_unarchive_trello_list(
    context: ToolContext,
    list_id: Annotated[str, "The unique identifier of the Trello list to archive or unarchive."],
    archive_list: Annotated[
        str | None, "Set to true to archive the list or false to unarchive."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-lists-id-closed'."]:
    """Archive or unarchive a Trello list.

    Use this tool to archive or unarchive a specific list in Trello by providing the list ID. It helps manage list visibility and workflow on Trello boards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/closed".format(id=list_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": archive_list,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def move_trello_list_to_board(
    context: ToolContext,
    board_id_for_list_movement: Annotated[
        str, "The ID of the board to which the Trello list should be moved."
    ],
    list_id: Annotated[str, "The unique ID of the Trello list to be moved."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-id-idboard'."]:
    """Reorganize Trello by moving a list to another board.

    Use this tool to transfer a Trello list from one board to another, helping in organizing and restructuring your projects more efficiently."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/idBoard".format(id=list_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": board_id_for_list_movement,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def rename_trello_list(
    context: ToolContext,
    list_field_to_update: Annotated[
        str, "Specifies the list field to update, such as 'name', 'pos', or 'subscribed'."
    ],
    trello_list_id: Annotated[str, "The unique identifier for the Trello list you want to rename."],
    new_list_name: Annotated[
        str | None,
        "The new name for the Trello list. Provide a descriptive and clear title to easily identify the list.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-lists-id-field'."]:
    """Renames a Trello list by its ID.

    Use this tool to update the name of a specific Trello list. Call this when you need to change a list's title by specifying its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/{field}".format(  # noqa: UP032
            id=trello_list_id, field=list_field_to_update
        ),
        method="PUT",
        params=remove_none_values({
            "value": new_list_name,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_list_actions(
    context: ToolContext,
    list_id: Annotated[str, "The unique ID of the Trello list to retrieve actions for."],
    action_types: Annotated[
        str | None, "Comma-separated list of action types to filter actions on the Trello list."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-lists-id-actions'."]:
    """Retrieve actions performed on a specific Trello list.

    Use this tool to get all actions that have been performed on a specific Trello list by providing the list ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/actions".format(id=list_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": action_types,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_of_list(
    context: ToolContext,
    list_id: Annotated[str, "The unique ID of the Trello list to identify its board."],
    board_fields: Annotated[
        str | None,
        "Specify 'all' for all fields, or provide a comma-separated list of desired board fields.",
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-lists-id-board'."]:
    """Retrieve the board associated with a specific list on Trello.

    This tool retrieves the board that a specific list belongs to on Trello. Call this tool when you need to identify which board a list is part of."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/board".format(id=list_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_trello_cards_in_list(
    context: ToolContext,
    list_id: Annotated[str, "The unique ID of the Trello list to fetch cards from."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-lists-id-cards'."]:
    """Fetches all cards from a specified Trello list.

    Use this tool to obtain all cards from a specific Trello list by providing the list ID. It is useful for retrieving tasks or items organized under a particular list in a Trello board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/lists/{id}/cards".format(id=list_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_member_info(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve information for."
    ],
    board_backgrounds_option: Annotated[
        str | None,
        "Specify type of board backgrounds: `all`, `custom`, `default`, `none`, or `premium`.",
    ] = "none",
    include_actions: Annotated[
        str | None,
        "Include actions related to the member. Refer to the Actions Nested Resource for details.",
    ] = None,
    include_boards_details: Annotated[
        str | None,
        "Specify if you want to include detailed information about the member's boards. Refer to the Boards Nested Resource for options.",  # noqa: E501
    ] = None,
    include_boards_invited: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of board states like closed, members, open, etc., to filter invited boards.",  # noqa: E501
    ] = None,
    include_card_details: Annotated[
        str | None,
        "Include detailed information about cards associated with the member. Refer to the Cards Nested Resource for options.",  # noqa: E501
    ] = "none",
    include_custom_board_backgrounds: Annotated[
        str | None,
        "Specify whether to include custom board backgrounds. Use `all` for all backgrounds or `none` to exclude them.",  # noqa: E501
    ] = "none",
    include_custom_emoji: Annotated[
        str | None,
        "Specify whether to include all custom emojis ('all') or none ('none') in the response.",
    ] = "none",
    include_custom_stickers: Annotated[
        str | None,
        "Specify if custom stickers should be included. Use `all` to include or `none` to exclude.",
    ] = "none",
    include_invited_organizations: Annotated[
        str | None,
        "Specify the scope of invited organizations to include: all, members, none, or public.",
    ] = "none",
    include_paid_account_information: Annotated[
        bool | None, "Include paid account information in the returned member object when true."
    ] = False,
    include_paid_account_information_in_workspace: Annotated[
        bool | None, "Include paid account information in the returned workspace object if true."
    ] = False,
    include_saved_searches: Annotated[
        bool | None,
        "Set to true to include saved searches information in the response, false to exclude.",
    ] = False,
    include_tokens: Annotated[
        str | None,
        "Include tokens associated with the member. Options: `all` to include, `none` to exclude.",
    ] = "none",
    invited_boards_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of board fields for invited boards. Options include: id, name, desc, and more.",  # noqa: E501
    ] = None,
    member_fields_selection: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of member fields to retrieve information about. Use 'all' to retrieve all available member fields.",  # noqa: E501
    ] = None,
    notification_details: Annotated[
        str | None,
        "Fetch notification information related to the member. Refer to the Notifications Nested Resource for options.",  # noqa: E501
    ] = None,
    organization_fields_selection: Annotated[
        str | None,
        "Specify 'all' or provide a comma-separated list of organization fields like 'id', 'name'.",
    ] = None,
    organization_fields_to_include: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of organization fields like 'id', 'name' to include in the response.",  # noqa: E501
    ] = None,
    organization_visibility: Annotated[
        str | None, "Specify organization visibility: `all`, `members`, `none`, or `public`."
    ] = "none",
    return_board_stars: Annotated[
        bool | None,
        "Set to true to return boardStars in the response, otherwise false to exclude them.",
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members=id'."]:
    """Fetch information about a Trello member profile.

    Use this tool to get detailed information about a specific Trello member by their ID. This is useful for accessing profile details of users within Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "actions": include_actions,
            "boards": include_boards_details,
            "boardBackgrounds": board_backgrounds_option,
            "boardsInvited": include_boards_invited,
            "boardsInvited_fields": invited_boards_fields,
            "boardStars": return_board_stars,
            "cards": include_card_details,
            "customBoardBackgrounds": include_custom_board_backgrounds,
            "customEmoji": include_custom_emoji,
            "customStickers": include_custom_stickers,
            "fields": member_fields_selection,
            "notifications": notification_details,
            "organizations": organization_visibility,
            "organization_fields": organization_fields_selection,
            "organization_paid_account": include_paid_account_information_in_workspace,
            "organizationsInvited": include_invited_organizations,
            "organizationsInvited_fields": organization_fields_to_include,
            "paid_account": include_paid_account_information,
            "savedSearches": include_saved_searches,
            "tokens": include_tokens,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_member(
    context: ToolContext,
    member_id_or_username: Annotated[str, "The ID or username of the Trello member to be updated."],
    avatar_source: Annotated[
        str | None, "Source of the avatar; must be one of: 'gravatar', 'none', or 'upload'."
    ] = None,
    enable_color_blind_mode: Annotated[
        bool | None,
        "Set to true to enable color blind mode preferences for the member, false to disable.",
    ] = None,
    member_bio: Annotated[
        str | None,
        "Biography of the member. Provide a brief description or update to the member's bio as a string.",  # noqa: E501
    ] = None,
    member_initials: Annotated[
        str | None, "New initials for the member. Must be 1-4 characters long."
    ] = None,
    new_full_name: Annotated[
        str | None, "The new name for the member. Ensure it does not begin or end with a space."
    ] = None,
    new_username: Annotated[
        str | None,
        "The new username for the Trello member. It must be at least 3 characters long and can only contain lowercase letters, underscores, and numbers. The username must be unique within Trello.",  # noqa: E501
    ] = None,
    preferred_locale: Annotated[
        str | None,
        "Specifies the preferred locale for the member's settings. This should be a valid locale string (e.g., 'en_US').",  # noqa: E501
    ] = None,
    summary_notification_interval: Annotated[
        int | None,
        "Time interval in minutes for summary notifications. Use `-1` to disable, `1` for every minute, or `60` for hourly notifications.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-members-id'."]:
    """Update Trello member details.

    This tool updates a member's information in Trello. It should be called when there is a need to modify a member's details, such as changing their username or bio."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}".format(id=member_id_or_username),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "fullName": new_full_name,
            "initials": member_initials,
            "username": new_username,
            "bio": member_bio,
            "avatarSource": avatar_source,
            "prefs/colorBlind": enable_color_blind_mode,
            "prefs/locale": preferred_locale,
            "prefs/minutesBetweenSummaries": summary_notification_interval,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_property(
    context: ToolContext,
    member_field_name: Annotated[
        str, "Specify the name of the member field to retrieve, such as 'username', 'email', etc."
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose property is to be retrieved."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-field'."]:
    """Retrieve a specific property of a Trello member.

    Use this tool to get a particular property of a Trello member by specifying the member ID and the desired field. This is useful for retrieving specific member information such as username, email, or other available fields."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/{field}".format(  # noqa: UP032
            id=member_id_or_username, field=member_field_name
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_member_actions(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member whose actions you want to retrieve."
    ],
    action_types_filter: Annotated[
        str | None,
        "A comma-separated list of action types to filter the actions of a Trello member.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-actions'."]:
    """Retrieve a list of actions for a specified member.

    Use this tool to get all actions associated with a particular Trello member by their ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/actions".format(id=member_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": action_types_filter,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_board_backgrounds(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose board backgrounds are being retrieved."
    ],
    board_background_filter: Annotated[
        str | None,
        "Specify the filter for board backgrounds: `all`, `custom`, `default`, `none`, or `premium`.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-boardbackgrounds'."]:
    """Retrieve custom board backgrounds for a Trello member.

    This tool fetches the custom board backgrounds set by a specific Trello member. It should be called when there's a need to view or manage a member's personalized board designs."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardBackgrounds".format(  # noqa: UP032
            id=member_id_or_username
        ),
        method="GET",
        params=remove_none_values({
            "filter": board_background_filter,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def upload_trello_board_background(
    context: ToolContext,
    background_image_file_path: Annotated[
        str,
        "The file path for the image to be uploaded as a new board background. Provide the full path or a URL to the image file.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to upload the board background for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'post-members-id-boardbackgrounds-1'."
]:
    """Upload a new board background on Trello.

    This tool uploads a new background image to a Trello board for a specific member. It should be called when a user wants to change or set a new background for their Trello board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardBackgrounds".format(  # noqa: UP032
            id=member_id_or_username
        ),
        method="POST",
        params=remove_none_values({
            "file": background_image_file_path,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_board_background(
    context: ToolContext,
    board_background_id: Annotated[
        str,
        "The ID of the board background to retrieve. This is required to specify which background details to fetch for a member.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the member whose board background is being retrieved."
    ],
    fields_to_retrieve: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of fields to retrieve: 'brightness', 'fullSizeUrl', 'scaled', 'tile'.",  # noqa: E501
    ] = "all",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-boardbackgrounds-idbackground'."
]:
    """Retrieve a board background for a specific member.

    Use this tool to get the details of a specific board background associated with a member on Trello. Useful for accessing customized background settings for user boards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=board_background_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": fields_to_retrieve,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_board_background(
    context: ToolContext,
    board_background_id: Annotated[str, "ID of the board background to update."],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member associated with the board to update."
    ],
    background_brightness: Annotated[
        str | None,
        "Set the brightness level for the board background. Options are `dark`, `light`, or `unknown`.",  # noqa: E501
    ] = None,
    tile_background: Annotated[
        bool | None, "Set to true to tile the board background. False to not tile it."
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-members-id-boardbackgrounds-idbackground'."
]:
    """Update the background of a Trello board.

    Use this tool to update the background image or color of a specific Trello board associated with a member."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=board_background_id
        ),
        method="PUT",
        params=remove_none_values({
            "brightness": background_brightness,
            "tile": tile_background,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_board_background(
    context: ToolContext,
    board_background_id: Annotated[
        str, "The unique identifier for the board background to be deleted."
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose board background you want to delete."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'delete-members-id-boardbackgrounds-idbackground'.",
]:
    """Delete a board background from a member's Trello board.

    This tool deletes a specified background from a member's Trello board, which can be useful for managing board appearances."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=board_background_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_member_board_stars(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose board stars are to be listed."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-boardstars'."]:
    """Retrieve a member's board stars on Trello.

    Use this tool to fetch and list all the board stars associated with a Trello member, identified by their member ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardStars".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def star_trello_board_for_member(
    context: ToolContext,
    board_id_to_star: Annotated[str, "The unique identifier of the Trello board to be starred."],
    board_star_position: Annotated[
        str,
        "Specify the position of the starred board: `top`, `bottom`, or a positive float for custom positioning.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member for whom the board is being starred."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-members-id-boardstars'."]:
    """Star a Trello board on behalf of a specified member.

    This tool stars a new board in Trello for a specific member. It should be called when a user wants to mark a board as important or favorite on behalf of another member."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardStars".format(id=member_id_or_username),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "idBoard": board_id_to_star,
            "pos": board_star_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_specific_board_star(
    context: ToolContext,
    board_star_id: Annotated[str, "The ID of the board star to retrieve details for."],
    member_id_or_username: Annotated[
        str, "The ID or username of the member to retrieve the board star for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-boardstars-idstar'."
]:
    """Retrieve details of a specific board star.

    This tool retrieves the details of a specific boardStar using the member and boardStar ID. It's useful when you need to access information about a particular board star in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardStars/{idStar}".format(  # noqa: UP032
            id=member_id_or_username, idStar=board_star_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_starred_board_position(
    context: ToolContext,
    board_star_id: Annotated[str, "The unique identifier for the board star to update."],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to update the board position for."
    ],
    new_board_position: Annotated[
        str | None,
        "The new position for the starred board. Options are `top`, `bottom`, or a positive float for custom positioning.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-members-id-boardstars-idstar'."
]:
    """Update the position of a starred board in Trello.

    Use this tool to change the order of a starred board for a member in Trello by updating its position."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardStars/{idStar}".format(  # noqa: UP032
            id=member_id_or_username, idStar=board_star_id
        ),
        method="PUT",
        params=remove_none_values({
            "pos": new_board_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def unstar_board(
    context: ToolContext,
    board_star_id: Annotated[
        str, "The unique ID of the board star to be removed for a specific member."
    ],
    member_id: Annotated[
        str, "The ID or username of the Trello member who wants to unstar the board."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-members-id-boardstars-idstar'."
]:
    """Unstar a Trello board for a specific member.

    Use this tool to remove a star from a board on Trello for a specified member. Call this when a user wants to unstar a board they previously starred."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardStars/{idStar}".format(  # noqa: UP032
            id=member_id, idStar=board_star_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_user_boards(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member whose boards are to be retrieved."
    ],
    board_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of board fields to include in the response. Available fields include 'id', 'name', 'desc', 'descData', 'closed', 'idMemberCreator', 'idOrganization', 'pinned', 'url', 'shortUrl', 'prefs', 'labelNames', 'starred', 'limits', 'memberships', 'enterpriseOwned'.",  # noqa: E501
    ] = None,
    board_filter: Annotated[
        str | None,
        "Filter boards by specifying 'all' or a comma-separated list of statuses like 'closed', 'members', 'open', etc.",  # noqa: E501
    ] = "all",
    include_lists: Annotated[
        str | None,
        "Specify which lists to include with the boards. Options: `all`, `closed`, `none`, `open`.",
    ] = "none",
    include_organization: Annotated[
        bool | None, "Set to true to include the Organization object with the Boards."
    ] = False,
    organization_fields_to_include: Annotated[
        str | None,
        "Specifies which organization fields to include, either `all` or a comma-separated list of specific fields like `id` and `name`.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-boards'."]:
    """Retrieve boards a user is a member of on Trello.

    Use this tool to get a list of all boards that a specific user is a member of on Trello. Useful for managing or viewing user-related board information."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boards".format(id=member_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": board_filter,
            "fields": board_fields,
            "lists": include_lists,
            "organization": include_organization,
            "organization_fields": organization_fields_to_include,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_invited_boards(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member to retrieve invited boards for."
    ],
    board_fields_option: Annotated[
        str | None,
        "Specify 'all' or provide a comma-separated list of board fields to retrieve (e.g., 'id,name,desc').",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-boardsinvited'."]:
    """Retrieve boards a member is invited to on Trello.

    This tool fetches the list of boards that a specified member has been invited to on Trello. It should be called when you need to check which boards a member is invited to but has not yet joined."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/boardsInvited".format(id=member_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields_option,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_cards(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve cards for."
    ],
    card_status_filter: Annotated[
        str | None,
        "Filter cards by status: `all`, `closed`, `complete`, `incomplete`, `none`, `open`, or `visible`.",  # noqa: E501
    ] = "visible",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-cards'."]:
    """Retrieve cards associated with a specific member on Trello.

    Use this tool to get a detailed list of all the cards a specific Trello member is associated with. It should be called when you need to track or manage the cards a member is involved in."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/cards".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": card_status_filter,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_custom_board_backgrounds(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the member to retrieve custom board backgrounds for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-customboardbackgrounds'."
]:
    """Retrieve a member's custom board backgrounds on Trello.

    Use this tool to get a specific member's custom board backgrounds from Trello. Ideal for when you need to display or manage a user's personalized board aesthetics."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customBoardBackgrounds".format(  # noqa: UP032
            id=member_identifier
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def upload_custom_board_background(
    context: ToolContext,
    background_file_upload: Annotated[
        str,
        "The file path or URL of the custom board background to upload. It should specify the location of the image file you want to use as the board background.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member for whom the background is being uploaded."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'membersidcustomboardbackgrounds-1'."
]:
    """Upload a new custom board background to Trello.

    Use this tool to upload a new custom board background for a specific Trello member. Call this tool when you want to personalize a Trello board's appearance by adding a unique background."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customBoardBackgrounds".format(  # noqa: UP032
            id=member_id_or_username
        ),
        method="POST",
        params=remove_none_values({
            "file": background_file_upload,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_custom_board_background(
    context: ToolContext,
    custom_background_id: Annotated[
        str, "The unique identifier for the custom board background to retrieve."
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve the custom board background for."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'get-members-id-customboardbackgrounds-idbackground'.",
]:
    """Get a specific custom board background from Trello.

    This tool retrieves details of a specific custom board background for a given member on Trello. It is useful for obtaining properties and settings associated with a custom board background."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customBoardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=custom_background_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_custom_board_background(
    context: ToolContext,
    custom_background_id: Annotated[
        str, "The ID of the custom board background to be updated in Trello."
    ],
    member_id_or_username: Annotated[
        str, "The Trello ID or username of the member whose board background will be updated."
    ],
    background_brightness: Annotated[
        str | None,
        "Set the brightness of the custom board background. Options: 'dark', 'light', 'unknown'.",
    ] = None,
    tile_background: Annotated[
        bool | None, "Indicates whether to tile the board background. Accepts a boolean value."
    ] = None,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-members-id-customboardbackgrounds-idbackground'.",
]:
    """Update a specific custom board background in Trello.

    This tool is used to update a custom board background for a Trello member. It should be called when a user wants to change the background of a board to a new custom image."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customBoardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=custom_background_id
        ),
        method="PUT",
        params=remove_none_values({
            "brightness": background_brightness,
            "tile": tile_background,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_custom_board_background(
    context: ToolContext,
    custom_background_id: Annotated[str, "The ID of the custom board background to be deleted."],
    member_id_or_username: Annotated[
        str, "The ID or username of the member whose custom board background will be deleted."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'delete-members-id-customboardbackgrounds-idbackground'.",
]:
    """Delete a specific custom board background.

    Use this tool to remove a specific custom board background for a member on Trello. Call this when you want to delete an unwanted or outdated board background to maintain organization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customBoardBackgrounds/{idBackground}".format(  # noqa: UP032
            id=member_id_or_username, idBackground=custom_background_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_custom_emojis(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose custom emojis are being retrieved."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-customemoji'."]:
    """Retrieve a Trello member's uploaded custom emojis.

    This tool fetches all custom emojis that a specific Trello member has uploaded. It should be called when you need to access the custom emojis of a Trello member by their ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customEmoji".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_custom_emoji_trello(
    context: ToolContext,
    emoji_image_file: Annotated[
        str, "Path or URL to the image file for the emoji. The image must be in a supported format."
    ],
    emoji_name: Annotated[str, "Provide a name for the emoji, between 2 and 64 characters."],
    member_identifier: Annotated[
        str, "The ID or username of the Trello member to whom the emoji will be added."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-members-id-customemoji'."]:
    """Create a new custom emoji in Trello.

    Use this tool to create a custom emoji for a specific Trello member. Call this when you need to add a unique emoji to a member's collection."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customEmoji".format(id=member_identifier),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "file": emoji_image_file,
            "name": emoji_name,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_custom_emoji(
    context: ToolContext,
    custom_emoji_id: Annotated[str, "The unique identifier for a member's custom emoji on Trello."],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose custom emoji you want to retrieve."
    ],
    emoji_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of `name`, `url` to determine which fields to return for the custom emoji.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'membersidcustomemojiidemoji'."]:
    """Retrieve a custom emoji for a Trello member.

    Use this tool to get a specific custom emoji associated with a Trello member. Ideal for displaying or managing user-related emojis."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customEmoji/{idEmoji}".format(  # noqa: UP032
            id=member_id_or_username, idEmoji=custom_emoji_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": emoji_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_uploaded_stickers(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose stickers you want to retrieve."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-customstickers'."]:
    """Retrieve a Trello member's uploaded stickers.

    Call this tool to get the custom stickers uploaded by a Trello member using their member ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customStickers".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def upload_custom_sticker_to_trello(
    context: ToolContext,
    custom_sticker_file_path: Annotated[
        str, "The file path or URL of the custom sticker to be uploaded for the Trello member."
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to whom the custom sticker will be uploaded."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-members-id-customstickers'."]:
    """Upload a new custom sticker to a Trello member's account.

    This tool is used to upload a custom sticker for a specific Trello member. It should be called when a user wants to add a new personal sticker to their Trello account."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customStickers".format(id=member_id_or_username),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "file": custom_sticker_file_path,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_custom_sticker(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose custom sticker is to be retrieved."
    ],
    sticker_id: Annotated[
        str,
        "The unique identifier for the uploaded sticker. Required to fetch the sticker's details.",
    ],
    sticker_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of 'scaled', 'url' to determine which sticker details to retrieve.",  # noqa: E501
    ] = "all",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-customstickers-idsticker'."
]:
    """Retrieve a member's custom sticker from Trello.

    This tool retrieves details about a specific custom sticker associated with a Trello member. It should be called when you need information about a member's custom sticker based on their member ID and the sticker ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customStickers/{idSticker}".format(  # noqa: UP032
            id=member_id_or_username, idSticker=sticker_id
        ),
        method="GET",
        params=remove_none_values({
            "fields": sticker_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_custom_sticker(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose sticker is to be deleted."
    ],
    sticker_id: Annotated[str, "The unique identifier of the uploaded sticker to be deleted."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-members-id-customstickers-idsticker'."
]:
    """Deletes a custom sticker from a Trello member's account."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/customStickers/{idSticker}".format(  # noqa: UP032
            id=member_id_or_username, idSticker=sticker_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_notifications(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member to fetch notifications for."
    ],
    include_display: Annotated[
        bool | None, "Boolean to include display-related data in the response."
    ] = False,
    include_entities: Annotated[
        bool | None, "Include entities in the member's notifications when set to true."
    ] = False,
    include_member_creator_details: Annotated[
        bool | None,
        "A boolean to include details of the member who created the notifications. True to include, False to exclude.",  # noqa: E501
    ] = True,
    member_creator_fields: Annotated[
        str | None,
        "Specify 'all' or provide a comma-separated list of member fields to include in the response.",  # noqa: E501
    ] = "avatarHash,fullName,initials,username",
    notification_fields: Annotated[
        str | None, "Specify `all` or a comma-separated list of notification fields to retrieve."
    ] = "all",
    notification_filter: Annotated[
        str | None,
        "Specify the type of notifications to retrieve: all, createCard, commentCard, etc.",
    ] = "all",
    notification_id_before: Annotated[
        str | None, "Set to retrieve notifications sent before this specific notification ID."
    ] = None,
    notification_limit: Annotated[
        int | None, "The maximum number of notifications to retrieve, capped at 1000."
    ] = 50,
    notification_read_status_filter: Annotated[
        str | None, "Specify read status to filter notifications: `all`, `read`, or `unread`."
    ] = "all",
    page_number: Annotated[int | None, "The page number for pagination. Maximum value is 100."] = 0,
    since_notification_id: Annotated[
        str | None,
        "A notification ID to start retrieving notifications from. Useful for fetching notifications after a specific point.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-notifications'."]:
    """Retrieve a Trello member's notifications.

    Use this tool to fetch notifications for a specific Trello member by their ID. Call this when you need to access recent alerts or updates for a member on Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/notifications".format(id=member_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "entities": include_entities,
            "display": include_display,
            "filter": notification_filter,
            "read_filter": notification_read_status_filter,
            "fields": notification_fields,
            "limit": notification_limit,
            "page": page_number,
            "before": notification_id_before,
            "since": since_notification_id,
            "memberCreator": include_member_creator_details,
            "memberCreator_fields": member_creator_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_workspaces(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve workspaces for."
    ],
    include_paid_account_info: Annotated[
        bool | None,
        "Include paid account information in the returned workspace object if set to true.",
    ] = False,
    organization_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of organization fields like 'id', 'name'.",
    ] = None,
    workspace_filter: Annotated[
        str | None,
        "Specify the type of workspaces to include. Options: `all`, `members` (private), `none`, `public`.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-organizations'."]:
    """Retrieve a member's workspaces from Trello.

    Use this tool to get the list of workspaces (organizations) associated with a specific Trello member by their ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/organizations".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": workspace_filter,
            "fields": organization_fields,
            "paid_account": include_paid_account_info,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_invited_workspaces(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member to retrieve their invited Workspaces."
    ],
    organization_fields: Annotated[
        str | None,
        "Specifies the fields to retrieve for each organization. Use 'all' or a comma-separated list like 'id,name'.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-organizationsinvited'."
]:
    """Retrieve a member's invited Workspaces.

    Use this tool to get a list of Workspaces that a Trello member has been invited to join. It provides insights into pending invitations and collaboration opportunities."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/organizationsInvited".format(  # noqa: UP032
            id=member_identifier
        ),
        method="GET",
        params=remove_none_values({
            "fields": organization_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_member_saved_searches(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose saved searches you want to retrieve."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-savedsearches'."]:
    """Retrieve a Trello member's saved searches.

    Use this tool to obtain a list of saved searches for a specific Trello member. Ideal for accessing or reviewing saved queries associated with a member account."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/savedSearches".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_saved_search(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member for whom the saved search is created."
    ],
    saved_search_name: Annotated[
        str, "The title for the saved search to be created for a Trello member."
    ],
    saved_search_position: Annotated[
        str,
        "Specify the position of the saved search. Can be 'top', 'bottom', or a positive float for custom placement.",  # noqa: E501
    ],
    search_query: Annotated[str, "The search query to be saved for the Trello member."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-members-id-savedsearches'."]:
    """Create a saved search for a Trello member.

    Use this tool to create a saved search for a specific Trello member, helping them quickly access important search results in the future."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/savedSearches".format(id=member_id_or_username),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "name": saved_search_name,
            "query": search_query,
            "pos": saved_search_position,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_saved_search(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose saved search you want to retrieve."
    ],
    saved_search_id: Annotated[str, "The ID of the saved search to retrieve information about."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-savedsearches-idsearch'."
]:
    """Retrieve the details of a saved search from Trello.

    Use this tool to get information about a specific saved search for a Trello member. Useful for retrieving search criteria or managing saved search settings."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/savedSearches/{idSearch}".format(  # noqa: UP032
            id=member_id_or_username, idSearch=saved_search_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_saved_search(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the member whose saved search is being updated."
    ],
    saved_search_id: Annotated[
        str, "The unique identifier of the saved search to be updated in Trello."
    ],
    new_position_for_saved_search: Annotated[
        str | None,
        "Specify the new position for the saved search: 'top', 'bottom', or a positive float for a custom placement.",  # noqa: E501
    ] = None,
    new_saved_search_name: Annotated[str | None, "The new name for the saved search."] = None,
    new_search_query: Annotated[
        str | None, "The new search query to update the saved search in Trello."
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-members-id-savedsearches-idsearch'."
]:
    """Update the details of a saved search in Trello.

    Use this tool to update the information of an existing saved search for a specific member in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/savedSearches/{idSearch}".format(  # noqa: UP032
            id=member_id_or_username, idSearch=saved_search_id
        ),
        method="PUT",
        params=remove_none_values({
            "name": new_saved_search_name,
            "query": new_search_query,
            "pos": new_position_for_saved_search,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_saved_search_on_trello(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username identifying the member whose saved search is to be deleted."
    ],
    saved_search_id: Annotated[
        str, "The unique identifier of the saved search to delete from a Trello member's account."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-members-id-savedsearches-idsearch'."
]:
    """Remove a saved search from a Trello member account.

    This tool is used to delete a saved search from a member's account on Trello. It should be called when a user wants to permanently remove a saved search from their list."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/savedSearches/{idSearch}".format(  # noqa: UP032
            id=member_id_or_username, idSearch=saved_search_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_app_tokens(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve app tokens for."
    ],
    include_webhooks: Annotated[
        bool | None, "Set to true to include webhooks in the response; false to exclude them."
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-members-id-tokens'."]:
    """Retrieve a Trello member's app tokens list.

    Use this tool to get a list of tokens associated with a specific Trello member, identified by their ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/tokens".format(id=member_id_or_username),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "webhooks": include_webhooks,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_member_avatar(
    context: ToolContext,
    avatar_image_file: Annotated[
        str,
        "A string representing the image file data for the member's new avatar. It should be a file path or base64-encoded image.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str,
        "The ID or username of the Trello member for whom you want to create an avatar. This identifies the member uniquely.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'membersidavatar'."]:
    """Create a new avatar for a Trello member.

    This tool creates a new avatar for a specific Trello member using their ID. It should be called when you need to update or set a member's avatar in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/avatar".format(id=member_id_or_username),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "file": avatar_image_file,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def dismiss_trello_message(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose message is being dismissed."
    ],
    message_to_dismiss: Annotated[str, "The specific message to dismiss for a Trello member."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'post-members-id-onetimemessagesdismissed'."
]:
    """Dismiss a specific message in Trello for a member.

    Use this tool to dismiss a one-time message for a Trello member. It should be called when a user wants to acknowledge and dismiss a notification or message within Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/oneTimeMessagesDismissed".format(  # noqa: UP032
            id=member_id_or_username
        ),
        method="POST",
        params=remove_none_values({
            "value": message_to_dismiss,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_member_notification_settings(
    context: ToolContext,
    member_identifier: Annotated[
        str, "The ID or username of the Trello member to retrieve notification settings for."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-members-id-notificationChannelSettings'."
]:
    """Retrieve a Trello member's notification settings.

    Use this tool to obtain the notification channel settings for a specific Trello member identified by their ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/notificationsChannelSettings".format(  # noqa: UP032
            id=member_identifier
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_member_notification_blocked_keys(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    member_identifier: Annotated[
        str | None,
        "The unique ID or username of the Trello member to update notification settings for.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-members-id-notificationChannelSettings-channel-blockedKeys'.",  # noqa: E501
]:
    """Update a member's blocked notification keys on Trello.

    This tool updates the blocked notification keys for a specific member on a designated channel in Trello. Use this to manage which notifications a member will not receive.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.\n\nThis operation also requires path parameters.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.\n      Note: You must also provide the required path parameters when executing.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["UPDATEMEMBERNOTIFICATIONBLOCKEDKEYS"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter along with the required path parameters. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters
    # Validate required parameters
    missing_params = []
    if not member_identifier:
        missing_params.append(("member_identifier", "path"))

    if missing_params:
        param_names = [p[0] for p in missing_params]
        param_details = ", ".join([f"{p[0]} ({p[1]})" for p in missing_params])
        raise RetryableToolError(
            message=f"Missing required parameters: {param_names}",
            developer_message=(f"Required parameters validation failed: {param_details}"),
            additional_prompt_content=(
                f"The following required parameters are missing: "
                f"{param_details}. Please call this tool again with all "
                "required parameters."
            ),
        )

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATEMEMBERNOTIFICATIONBLOCKEDKEYS"]
                + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATEMEMBERNOTIFICATIONBLOCKEDKEYS"]
                + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/members/{id}/notificationsChannelSettings".format(  # noqa: UP032
            id=member_identifier
        ),
        method="PUT",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["UPDATEMEMBERNOTIFICATIONBLOCKEDKEYS"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_member_notification_settings(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member to retrieve notification settings for."
    ],
    notification_channel: Annotated[
        str,
        "Specify the channel to block notifications on for the Trello member. Accepted value: 'email'.",  # noqa: E501
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'get-members-id-notificationChannelSettings-channel'.",
]:
    """Retrieve blocked notification keys for a Trello member's channel.

    Fetches the blocked notification keys of a member on a specific Trello channel. Useful for managing notification preferences or debugging notification issues."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/notificationsChannelSettings/{channel}".format(  # noqa: UP032
            id=member_id_or_username, channel=notification_channel
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_member_notification_settings(
    context: ToolContext,
    mode: Annotated[
        ToolMode,
        "Operation mode: 'get_request_schema' returns the OpenAPI spec "
        "for the request body, 'execute' performs the actual operation",
    ],
    member_id_or_username: Annotated[
        str | None,
        "The ID or username of the Trello member whose notification settings will be updated.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    notification_channel: Annotated[
        str | None,
        "Specify the channel where notifications should be blocked, e.g., 'email'.  Required when mode is 'execute', ignored when mode is 'get_request_schema'.",  # noqa: E501
    ] = None,
    request_body: Annotated[
        str | None,
        "Stringified JSON representing the request body. Required when "
        "mode is 'execute', ignored when mode is 'get_request_schema'",
    ] = None,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-members-id-notificationChannelSettings-channel-blockedKeys'.",  # noqa: E501
]:
    """Update blocked notification keys for a Trello member's channel.

    Use this tool to update blocked notification keys for a specific channel of a Trello member. This is useful when a user wants to change which notifications are blocked for a particular communication channel.

    Note: Understanding the request schema is necessary to properly create
    the stringified JSON input object for execution.\n\nThis operation also requires path parameters.

    Modes:
    - GET_REQUEST_SCHEMA: Returns the schema. Only call if you don't
      already have it. Do NOT call repeatedly if you already received
      the schema.
    - EXECUTE: Performs the operation with the provided request body
      JSON.\n      Note: You must also provide the required path parameters when executing.

    If you need the schema, call with mode='get_request_schema' ONCE, then execute.
    """  # noqa: E501
    if mode == ToolMode.GET_REQUEST_SCHEMA:
        return {
            "request_body_schema": REQUEST_BODY_SCHEMAS["UPDATETRELLOMEMBERNOTIFICATIONSETTINGS"],
            "instructions": (
                "Use the request_body_schema to construct a valid JSON object. "
                "Once you have populated the object following the schema "
                "structure and requirements, call this tool again with "
                "mode='execute' and the stringified JSON as the "
                "request_body parameter along with the required path parameters. "
                "Do NOT call the schema mode again - you already have "
                "the schema now."
            ),
        }

    # Mode is EXECUTE - validate parameters
    # Validate required parameters
    missing_params = []
    if not member_id_or_username:
        missing_params.append(("member_id_or_username", "path"))
    if not notification_channel:
        missing_params.append(("notification_channel", "path"))

    if missing_params:
        param_names = [p[0] for p in missing_params]
        param_details = ", ".join([f"{p[0]} ({p[1]})" for p in missing_params])
        raise RetryableToolError(
            message=f"Missing required parameters: {param_names}",
            developer_message=(f"Required parameters validation failed: {param_details}"),
            additional_prompt_content=(
                f"The following required parameters are missing: "
                f"{param_details}. Please call this tool again with all "
                "required parameters."
            ),
        )

    # Validate request body is provided (not None or empty string)
    # Note: Empty objects like {} are allowed - schema validation will check if valid
    if request_body is None or request_body.strip() == "":
        raise RetryableToolError(
            message="Request body is required when mode is 'execute'",
            developer_message="The request_body parameter was null or empty string",
            additional_prompt_content=(
                "The request body is required to perform this operation. "
                "Use the schema below to construct a valid JSON object, "
                "then call this tool again in execute mode with the "
                "stringified JSON as the request_body parameter.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOMEMBERNOTIFICATIONSETTINGS"]
                + "\n```"
            ),
        )

    # Parse JSON
    try:
        request_data = json.loads(request_body)
    except json.JSONDecodeError as e:
        raise RetryableToolError(
            message=f"Invalid JSON in request body: {e!s}",
            developer_message=f"JSON parsing failed: {e!s}",
            additional_prompt_content=(
                f"The request body contains invalid JSON. Error: {e!s}\n\n"
                "Please provide a valid JSON string that matches the schema "
                "below, then call this tool again in execute mode.\n\n"
                "Schema:\n\n```json\n"
                + REQUEST_BODY_SCHEMAS["UPDATETRELLOMEMBERNOTIFICATIONSETTINGS"]
                + "\n```"
            ),
        ) from e

    response = await make_request_with_schema_validation(
        url="https://api.trello.com/1/members/{id}/notificationsChannelSettings/{channel}".format(  # noqa: UP032
            id=member_id_or_username, channel=notification_channel
        ),
        method="PUT",
        request_data=request_data,
        schema=REQUEST_BODY_SCHEMAS["UPDATETRELLOMEMBERNOTIFICATIONSETTINGS"],
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def modify_member_notifications_trello(
    context: ToolContext,
    blocked_notification_keys: Annotated[
        str,
        "List the notification keys to block, either as a singular key or comma-separated list. Valid keys include: notification_comment_card, notification_added_a_due_date, notification_changed_due_date, and others.",  # noqa: E501
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the Trello member whose notification settings will be updated."
    ],
    notification_channel: Annotated[
        str, "Specify the channel to block notifications on, such as 'email'."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-members-id-notificationChannelSettings-channel-blockedKeys'.",  # noqa: E501
]:
    """Update a member's blocked notification keys on Trello.

    Use this tool to update the blocked notification keys for a specific member's notification channel in Trello. It should be called when changes to notification preferences are required for a member."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/members/{id}/notificationsChannelSettings/{channel}/{blockedKeys}".format(  # noqa: UP032
            id=member_id_or_username,
            channel=notification_channel,
            blockedKeys=blocked_notification_keys,
        ),
        method="PUT",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_notification(
    context: ToolContext,
    notification_id: Annotated[
        str, "The unique identifier for the Trello notification you want to retrieve."
    ],
    board_fields_list: Annotated[
        str | None, "Specify 'all' or a comma-separated list of board fields to include."
    ] = None,
    card_fields_to_include: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of card fields to include, such as `id`, `name`, or `due`.",  # noqa: E501
    ] = None,
    include_board_object: Annotated[
        bool | None, "Include the board object in the response if true."
    ] = False,
    include_card: Annotated[bool | None, "Specify True to include the card object."] = False,
    include_creator_member: Annotated[
        bool | None, "Set to true to include the member object of the creator in the response."
    ] = True,
    include_display_object: Annotated[
        bool | None, "Set to true to include the display object with the results."
    ] = False,
    include_entities_object: Annotated[
        bool | None,
        "Include the entities object in the notification results. Set to true to include, false to exclude.",  # noqa: E501
    ] = False,
    include_list_object: Annotated[
        bool | None, "Include the list object in the notification data if set to true."
    ] = False,
    include_member_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of member fields to include in the response.",
    ] = None,
    include_member_object: Annotated[
        bool | None, "Include the member object in the notification details if set to true."
    ] = True,
    include_notification_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of notification fields to include, such as 'id', 'unread', or 'type'.",  # noqa: E501
    ] = None,
    include_organization: Annotated[
        bool | None, "Set to true to include the organization object in the response."
    ] = False,
    member_creator_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of member fields to include the member object of the creator.",  # noqa: E501
    ] = None,
    organization_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of organization fields (e.g., `id`, `name`) to include in the response.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-notifications-id'."]:
    """Retrieve detailed Trello notification information by ID.

    Use this tool to obtain information about a specific Trello notification. Call this tool when you need to retrieve detailed data for a notification using its unique identifier."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "board": include_board_object,
            "board_fields": board_fields_list,
            "card": include_card,
            "card_fields": card_fields_to_include,
            "display": include_display_object,
            "entities": include_entities_object,
            "fields": include_notification_fields,
            "list": include_list_object,
            "member": include_member_object,
            "member_fields": include_member_fields,
            "memberCreator": include_creator_member,
            "memberCreator_fields": member_creator_fields,
            "organization": include_organization,
            "organization_fields": organization_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_notification_read_status(
    context: ToolContext,
    notification_id: Annotated[str, "The unique identifier for the Trello notification to update."],
    mark_as_unread: Annotated[
        bool | None, "Set to false to mark the notification as read, or true to mark as unread."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-notifications-id'."]:
    """Update the read status of a Trello notification.

    Use this tool to change the read status of a specific Trello notification by providing its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}".format(id=notification_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "unread": mark_as_unread,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_notification_property(
    context: ToolContext,
    notification_id: Annotated[str, "The unique identifier of the Trello notification to query."],
    notification_property_field: Annotated[
        str,
        "Specify the property field of the Trello notification to retrieve. Options include: id, unread, type, date, dateRead, data, card, board, idMemberCreator, idAction, reactions.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-notifications-id-field'."]:
    """Retrieve a specific property of a Trello notification.

    This tool is called to get a particular property of a Trello notification, using its ID and the field name as parameters."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/{field}".format(  # noqa: UP032
            id=notification_id, field=notification_property_field
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def mark_all_notifications_read(
    context: ToolContext,
    mark_as_read: Annotated[
        bool | None,
        "Specify true to mark notifications as read or false to mark as unread. Defaults to true.",
    ] = True,
    notification_ids: Annotated[
        list[str] | None,
        "A list of notification IDs to mark as read or unread. Useful for grouping related notifications.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-notifications-all-read'."]:
    """Marks all Trello notifications as read.

    Use this tool to mark all notifications in Trello as read. This is useful for clearing unread notification indicators."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/all/read",
        method="POST",
        params=remove_none_values({
            "read": mark_as_read,
            "ids": notification_ids,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def mark_notification_as_unread(
    context: ToolContext,
    notification_id: Annotated[
        str, "The unique ID of the Trello notification you want to mark as unread."
    ],
    notification_read_status: Annotated[
        str | None,
        "Set this to an empty string to mark the notification as unread. This is a required field to change the read status.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-notifications-id-unread'."]:
    """Mark a Trello notification as unread.

    Use this tool to update the read status of a specific Trello notification to unread. Call this when you need to change a notification back to an unread state."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/unread".format(id=notification_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "value": notification_read_status,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_board_from_notification(
    context: ToolContext,
    notification_id: Annotated[
        str,
        "The unique identifier of the Trello notification to retrieve associated board details.",
    ],
    board_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of board fields (e.g., 'name,desc,url').",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-notifications-id-board'."]:
    """Retrieve the board linked to a specific notification.

    Call this tool to get information about the board associated with a particular Trello notification. Useful for tracking which board a specific notification pertains to."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/board".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_notification_card(
    context: ToolContext,
    notification_id: Annotated[
        str,
        "The unique ID of the notification for which the associated card details are being fetched.",  # noqa: E501
    ],
    card_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of card fields like 'id', 'name', etc., to retrieve.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-notifications-id-card'."]:
    """Retrieve the card linked to a specific notification.

    Use this tool to obtain details about the card associated with a specific Trello notification ID. It helps in understanding the context of the notification."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/card".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": card_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_notification_list(
    context: ToolContext,
    notification_id: Annotated[
        str, "The ID of the Trello notification to retrieve the associated list for."
    ],
    notification_fields: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of fields for the list associated with the notification.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-notifications-id-list'."]:
    """Retrieve the list a Trello notification is associated with.

    Use this tool to find out which list a specific Trello notification belongs to. It is useful when you need to track or organize tasks based on notification details."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/list".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": notification_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_notification_member_details(
    context: ToolContext,
    notification_id: Annotated[
        str, "The ID of the Trello notification to get details about the member involved."
    ],
    member_fields: Annotated[
        str | None, "Specify 'all' or a comma-separated list of member fields to retrieve."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'notificationsidmember'."]:
    """Retrieve information about the member involved in a notification.

    Use this tool to obtain details about the member a specific Trello notification is concerning, excluding the notification creator."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/member".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_notification_creator(
    context: ToolContext,
    notification_id: Annotated[
        str, "The ID of the Trello notification to retrieve the creator's details."
    ],
    member_fields: Annotated[
        str | None, "Specify `all` or a comma-separated list of member fields to retrieve."
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-notifications-id-membercreator'."
]:
    """Retrieve the creator of a Trello notification.

    Call this tool to get details about the Trello member who created a specific notification using its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/memberCreator".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": member_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_associated_organization_notifications(
    context: ToolContext,
    notification_id: Annotated[
        str, "Provide the ID of the Trello notification to retrieve its associated organization."
    ],
    organization_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of organization fields ('id', 'name') to retrieve.",  # noqa: E501
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-notifications-id-organization'."
]:
    """Retrieve the organization associated with a notification.

    Use this tool to get details about the organization linked to a specific Trello notification. It retrieves information based on the notification ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/notifications/{id}/organization".format(id=notification_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": organization_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_workspace_trello(
    context: ToolContext,
    display_name: Annotated[
        str,
        "The name to display for the Trello Workspace. This is how the Workspace will be labeled in Trello.",  # noqa: E501
    ],
    website_url: Annotated[
        str | None, "A URL for the workspace starting with `http://` or `https://`."
    ] = None,
    workspace_description: Annotated[
        str | None, "A detailed description for the Trello Workspace."
    ] = None,
    workspace_name: Annotated[
        str | None,
        "A lowercase alphanumeric string, min 3 characters, underscores allowed. Invalid characters are removed. Unique name is substituted if conflict occurs.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-organizations'."]:
    """Create a new Trello Workspace.

    Use this tool to create a new Workspace in Trello. This can be utilized when users need to organize projects or teams within Trello by creating a new Workspace."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations",
        method="POST",
        params=remove_none_values({
            "displayName": display_name,
            "desc": workspace_description,
            "name": workspace_name,
            "website": website_url,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_organization_details(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The unique ID or name of the Trello organization to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id'."]:
    """Retrieve details about a Trello organization.

    Use this tool to obtain information about a specific Trello organization by its ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}".format(id=organization_id_or_name),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_organization_trello(
    context: ToolContext,
    organization_id_or_name: Annotated[str, "The ID or name of the Trello organization to update."],
    google_apps_associated_domain: Annotated[
        str | None, "The Google Apps domain to link this organization to."
    ] = None,
    google_apps_version: Annotated[
        int | None, "Set the Google Apps version to `1` or `2` for the organization."
    ] = None,
    new_display_name: Annotated[
        str | None,
        "A new display name for the organization. It must be at least 1 character long without leading or trailing spaces.",  # noqa: E501
    ] = None,
    organization_description: Annotated[
        str | None, "A new description for the organization. Provide relevant and concise details."
    ] = None,
    organization_invite_restriction: Annotated[
        str | None,
        "An email address with optional wildcard characters to restrict organization invites. Example: `subdomain.*.trello.com`",  # noqa: E501
    ] = None,
    organization_new_name: Annotated[
        str | None,
        "A unique name for the organization with at least 3 lowercase letters, underscores, and numbers.",  # noqa: E501
    ] = None,
    organization_website: Annotated[
        str | None, "A URL for the organization starting with `http://`, `https://`, or `null`."
    ] = None,
    prevent_external_members: Annotated[
        bool | None,
        "Set to true to prevent non-workspace members from being added to boards inside the Workspace.",  # noqa: E501
    ] = None,
    private_board_visibility: Annotated[
        str | None,
        "Specifies who can create private boards in the organization. Options: `admin`, `none`, `org`.",  # noqa: E501
    ] = None,
    public_board_visibility_permission: Annotated[
        str | None,
        "Who on the Workspace can create public boards. Options are: `admin`, `none`, `org`.",
    ] = None,
    workspace_board_visibility_restriction: Annotated[
        str | None,
        "Determines who in the Workspace can create Workspace-visible boards. Accepts one of: `admin`, `none`, `org`.",  # noqa: E501
    ] = None,
    workspace_visibility_permission: Annotated[
        str | None, "Set the visibility level of the Workspace page. Accepts 'private' or 'public'."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-organizations-id'."]:
    """Updates an organization's details in Trello.

    Use this tool to update the details of a specific organization in Trello. It should be called when you need to modify information such as the organization's name, description, or website."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}".format(id=organization_id_or_name),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "name": organization_new_name,
            "displayName": new_display_name,
            "desc": organization_description,
            "website": organization_website,
            "prefs/associatedDomain": google_apps_associated_domain,
            "prefs/externalMembersDisabled": prevent_external_members,
            "prefs/googleAppsVersion": google_apps_version,
            "prefs/boardVisibilityRestrict/org": workspace_board_visibility_restriction,
            "prefs/boardVisibilityRestrict/private": private_board_visibility,
            "prefs/boardVisibilityRestrict/public": public_board_visibility_permission,
            "prefs/orgInviteRestrict": organization_invite_restriction,
            "prefs/permissionLevel": workspace_visibility_permission,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_organization(
    context: ToolContext,
    organization_identifier: Annotated[
        str, "The ID or name of the organization to delete in Trello."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-organizations-id'."]:
    """Delete an organization in Trello using its ID.

    This tool is used to delete an organization from Trello by providing the organization's ID. It should be called when there is a need to permanently remove an organization from Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}".format(id=organization_identifier),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_organization_field(
    context: ToolContext,
    organization_field: Annotated[
        str, "Specify the field of the organization to retrieve, such as 'id' or 'name'."
    ],
    organization_identifier: Annotated[
        str, "The unique ID or name of the Trello organization to retrieve information from."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-field'."]:
    """Retrieve a specific field from a Trello organization.

    Call this tool to get a specific field's value from a Trello organization. Useful for accessing detailed information about an organization's attribute on Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/{field}".format(  # noqa: UP032
            id=organization_identifier, field=organization_field
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_workspace_actions(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello Workspace to list actions for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-actions'."]:
    """Retrieve actions related to a specific Trello Workspace.

    Use this tool to obtain a list of all actions that have taken place within a specific Trello Workspace. This can include changes, updates, and any other activities relevant to the workspace."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/actions".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_workspace_boards(
    context: ToolContext,
    workspace_identifier: Annotated[
        str, "The ID or name of the Trello Workspace to retrieve boards from."
    ],
    board_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of board fields such as 'id', 'name', 'desc', etc. This determines which fields to include in the response.",  # noqa: E501
    ] = None,
    board_filter: Annotated[
        str | None,
        "Specify `all` or a comma-separated list of `open`, `closed`, `members`, `organization`, `public` to filter board types.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-boards'."]:
    """Retrieve boards in a specified Trello Workspace.

    Use this tool to get a list of all boards within a specific Trello Workspace by providing the workspace ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/boards".format(id=workspace_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "filter": board_filter,
            "fields": board_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def start_organization_csv_export(
    context: ToolContext,
    workspace_id_or_name: Annotated[
        str, "The ID or name of the Trello Workspace to export data from."
    ],
    include_attachments: Annotated[
        bool | None, "Set to true to include attachments in the CSV export, otherwise set to false."
    ] = True,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-organizations-id-exports'."]:
    """Initiate CSV export for a Trello organization.

    Use this tool to start exporting organization data into a CSV file in Trello. Call this when an organization needs its data exported for analysis or backup. Returns a confirmation of the export initiation."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/exports".format(id=workspace_id_or_name),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "attachments": include_attachments,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def retrieve_organization_exports(
    context: ToolContext,
    workspace_identifier: Annotated[
        str, "The identifier for the Trello Workspace, which can be either its ID or name."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-exports'."]:
    """Retrieve exports for a Trello organization.

    This tool should be called to get a list of exports that exist for a specific Trello organization. It returns the exports associated with the specified organization ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/exports".format(id=workspace_identifier),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_workspace_members(
    context: ToolContext,
    workspace_id_or_name: Annotated[
        str, "The ID or name of the Trello Workspace to retrieve members from."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-members'."]:
    """Retrieve members of a Trello Workspace by ID.

    Use this tool to obtain a list of all members within a specific Trello Workspace by providing the workspace ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members".format(id=workspace_id_or_name),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_organization_members(
    context: ToolContext,
    member_email: Annotated[
        str, "The email address of the member to be updated in the organization."
    ],
    member_full_name: Annotated[
        str,
        "The full name of the member, at least 1 character not beginning or ending with a space.",
    ],
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello organization to update members for."
    ],
    member_role: Annotated[
        str | None, "Specify the role of the member, either `admin` or `normal`."
    ] = "normal",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-organizations-id-members'."]:
    """Update members of a Trello organization.

    Use this tool to update the members associated with a specific Trello organization. It is useful for managing team membership changes within an organization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="PUT",
        params=remove_none_values({
            "email": member_email,
            "fullName": member_full_name,
            "type": member_role,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_workspace_memberships(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello Workspace you want to retrieve memberships for."
    ],
    include_member_objects: Annotated[
        bool | None,
        "Whether to include Member objects with the Workspace memberships. `True` to include, `False` to exclude.",  # noqa: E501
    ] = False,
    membership_filter: Annotated[
        str | None,
        "Filter memberships: use `all` or a comma-separated list of `active`, `admin`, `deactivated`, `me`, `normal`.",  # noqa: E501
    ] = "all",
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-organizations-id-memberships'."
]:
    """Retrieve memberships of a Trello Workspace.

    Use this tool to obtain a list of all memberships in a specified Trello Workspace. Useful for understanding who belongs to a Workspace and their roles."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/memberships".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="GET",
        params=remove_none_values({
            "filter": membership_filter,
            "member": include_member_objects,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_organization_membership(
    context: ToolContext,
    membership_id: Annotated[
        str, "The ID of the membership to retrieve details for a specific organization."
    ],
    organization_id_or_name: Annotated[
        str, "The unique ID or name of the organization to fetch membership details for."
    ],
    include_member_object: Annotated[
        bool | None, "Include the Member object in the response when set to true."
    ] = False,
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'get-organizations-id-memberships-idmembership'.",
]:
    """Retrieve a specific membership for an organization.

    This tool retrieves information about a specific membership within an organization on Trello. It should be called when you need detailed information about a particular membership's status or details."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/memberships/{idMembership}".format(  # noqa: UP032
            id=organization_id_or_name, idMembership=membership_id
        ),
        method="GET",
        params=remove_none_values({
            "member": include_member_object,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_workspace_plugin_data(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the organization in Trello to retrieve plugin data for a workspace."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-plugindata'."]:
    """Retrieve organization scoped plugin data for a Trello workspace.

    Use this tool to obtain plugin data specific to a Trello workspace by its organization ID. This is useful for accessing settings or configurations from plugins associated with the workspace."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/pluginData".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def list_organization_collections(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello organization to list collections for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-organizations-id-tags'."]:
    """List collections or tags for a specified organization on Trello.

    Use this tool to retrieve a list of collections or tags associated with a specific organization on Trello by providing the organization ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/tags".format(id=organization_id_or_name),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_organization_tag(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello organization where the tag will be created."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-organizations-id-tags'."]:
    """Create a new tag within a specific Trello organization.

    Use this tool to add a tag to a Trello organization by providing the organization ID. It facilitates organizing and categorizing items within the organization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/tags".format(id=organization_id_or_name),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_or_update_workspace_member(
    context: ToolContext,
    member_id_or_username: Annotated[
        str, "The ID or username of the member to add or update in the Trello Workspace."
    ],
    member_role_type: Annotated[
        str,
        "Specify the role of the member in the workspace. Acceptable values are 'admin' or 'normal'.",  # noqa: E501
    ],
    organization_id_or_name: Annotated[
        str,
        "The ID or name of the Trello organization to which the member will be added or updated.",
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-organizations-id-members-idmember'."
]:
    """Add or update a member in a Trello Workspace.

    This tool is used to add a new member to a Trello Workspace or update the type of an existing member. It should be called when you need to manage workspace memberships and roles."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members/{idMember}".format(  # noqa: UP032
            id=organization_id_or_name, idMember=member_id_or_username
        ),
        method="PUT",
        params=remove_none_values({
            "type": member_role_type,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_member_from_workspace(
    context: ToolContext,
    member_id: Annotated[str, "The ID of the member to remove from the Trello Workspace."],
    workspace_identifier: Annotated[
        str,
        "The ID or name of the Trello Workspace to identify the organization for removal of a member.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-organizations-id-members'."]:
    """Remove a member from a Trello Workspace.

    Use this tool to remove a specific member from a Trello Workspace by providing the workspace and member IDs."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members/{idMember}".format(  # noqa: UP032
            id=workspace_identifier, idMember=member_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_workspace_member_status(
    context: ToolContext,
    deactivate_member: Annotated[
        bool,
        "Set to true to deactivate the member or false to reactivate the member in the workspace.",
    ],
    member_id_or_username: Annotated[
        str, "The ID or username of the member whose status needs to be updated in the workspace."
    ],
    organization_id_or_name: Annotated[
        str, "The ID or name of the organization within Trello to update the member status."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'put-organizations-id-members-idmember-deactivated'.",
]:
    """Deactivate or reactivate a member of a workspace.

    This tool allows you to deactivate or reactivate a member within a given workspace on Trello. It should be called when there's a need to change a member's active status within an organization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members/{idMember}/deactivated".format(  # noqa: UP032
            id=organization_id_or_name, idMember=member_id_or_username
        ),
        method="PUT",
        params=remove_none_values({
            "value": deactivate_member,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def set_workplace_logo(
    context: ToolContext,
    workspace_identifier: Annotated[
        str, "The ID or name of the Trello Workspace for which to set the logo."
    ],
    logo_image_file: Annotated[
        str | None,
        "The image file to set as the Workspace logo. Provide the file path or URL of the image.",
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-organizations-id-logo'."]:
    """Set the logo image for a Workspace.

    This tool allows setting or updating the logo image for a specified Trello Workspace. Use it when you need to change the visual branding of a Workspace by uploading a new logo."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/logo".format(id=workspace_identifier),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "file": logo_image_file,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_workspace_logo(
    context: ToolContext,
    workspace_id_or_name: Annotated[
        str, "The ID or name of the Trello Workspace to delete the logo from."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-organizations-id-logo'."]:
    """Remove the logo from a Trello Workspace.

    Call this tool to delete the existing logo from a specified Trello Workspace. It should be used when a user wants to remove the logo from an organization in Trello."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/logo".format(id=workspace_id_or_name),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_member_from_workspace(
    context: ToolContext,
    member_id_to_remove: Annotated[str, "The ID of the member to be removed from the Workspace."],
    organization_id_or_name: Annotated[
        str,
        "The ID or name of the Trello organization (Workspace) from which the member is to be removed.",  # noqa: E501
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'organizations-id-members-idmember-all'."
]:
    """Remove a member from a Workspace and all Workspace boards.

    Use this tool to remove a specified member from a Trello Workspace and all associated boards. Useful for managing Workspace membership and access control."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/members/{idMember}/all".format(  # noqa: UP032
            id=organization_id_or_name, idMember=member_id_to_remove
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_workspace_domain(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the Trello organization to dissociate the Google Apps domain from."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'delete-organizations-id-prefs-associateddomain'.",
]:
    """Remove the associated Google Apps domain from a Workspace.

    This tool removes the associated Google Apps domain from a specified Trello Workspace. Use this when you need to dissociate a Google Apps domain from an organization."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/prefs/associatedDomain".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_email_domain_restriction(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str,
        "The ID or name of the Trello organization to remove the email domain restriction from.",
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'delete-organizations-id-prefs-orginviterestrict'.",
]:
    """Remove email domain restriction for Workspace invites.

    This tool removes the restriction on which email domains can be invited to a Trello Workspace, allowing more flexible invitation policies."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/prefs/orgInviteRestrict".format(  # noqa: UP032
            id=organization_id_or_name
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_organization_tag(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the organization from which to delete the tag."
    ],
    tag_id_to_delete: Annotated[str, "The ID of the tag to be removed from the organization."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-organizations-id-tags-idtag'."
]:
    """Delete a specified tag from an organization.

    Use this tool to remove a tag from a specified organization in Trello by providing the organization ID and tag ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/tags/{idTag}".format(  # noqa: UP032
            id=organization_id_or_name, idTag=tag_id_to_delete
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def check_board_billable_guests(
    context: ToolContext,
    board_id: Annotated[str, "The ID of the Trello board to check for new billable guests."],
    organization_id_or_name: Annotated[
        str,
        "The ID or name of the Trello organization to check for new billable guests on the board.",
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'get-organizations-id-newbillableguests-idboard'.",
]:
    """Check if a board has new billable guests.

    This tool is used to determine if a specific Trello board has new billable guests. Use it when you need to audit or manage guest access on a board."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/organizations/{id}/newBillableGuests/{idBoard}".format(  # noqa: UP032
            id=organization_id_or_name, idBoard=board_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_plugin_info(
    context: ToolContext,
    organization_id_or_name: Annotated[
        str, "The ID or name of the organization for which the plugin information is requested."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-plugins-id'."]:
    """Retrieve information about a specific Trello plugin.

    Use this tool to get detailed information about a Trello plugin by its ID. It can be useful when you need to understand plugin capabilities or configurations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/plugins/{id}/".format(id=organization_id_or_name),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_plugin(
    context: ToolContext,
    organization_identifier: Annotated[
        str, "The ID or name of the organization associated with the plugin to update."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-plugins-id'."]:
    """Update a specific plugin on Trello.

    Use this tool to update the details of a specific plugin on Trello by providing the plugin's ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/plugins/{id}/".format(id=organization_identifier),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_plugin_listing(
    context: ToolContext,
    power_up_id: Annotated[str, "The ID of the Power-Up for which you are creating a new listing."],
    listing_locale: Annotated[
        str | None,
        "The specific locale code (e.g., 'en-US') for which the listing should be displayed.",
    ] = None,
    locale_description: Annotated[
        str | None, "The description for the Power-Up listing in the specified locale."
    ] = None,
    overview_for_locale: Annotated[
        str | None,
        "The overview text to display for the specified locale. Provide a concise summary relevant to the plugin.",  # noqa: E501
    ] = None,
    plugin_locale_name: Annotated[
        str | None, "The name for the Power-Up listing in the specified locale."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-plugins-idplugin-listing'."]:
    """Create a new listing for a Trello Power-Up.

    This tool creates a new listing for a Trello Power-Up in a specified locale. Use this tool when you need to add a new entry for a Power-Up on Trello's platform."""  # noqa: E501
    request_data = remove_none_values({
        "description": locale_description,
        "locale": listing_locale,
        "overview": overview_for_locale,
        "name": plugin_locale_name,
    })
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/plugins/{idPlugin}/listing".format(idPlugin=power_up_id),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_plugin_member_privacy_compliance(
    context: ToolContext,
    power_up_id: Annotated[
        str, "The unique identifier of the Power-Up to check member privacy compliance."
    ],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-plugins-id-compliance-memberprivacy'."
]:
    """Retrieve a plugin's member privacy compliance status.

    Use this tool to get information about the privacy compliance of a specific plugin's members in Trello. It is used when there is a need to verify the compliance status related to member privacy of a plugin by its ID."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/plugins/{id}/compliance/memberPrivacy".format(id=power_up_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_power_up_listing(
    context: ToolContext,
    listing_id: Annotated[
        str, "The ID of the existing listing for the Power-Up that is being updated."
    ],
    power_up_id: Annotated[str, "The ID of the Power-Up whose listing is being updated."],
    listing_description: Annotated[
        str | None, "The description to show for the specified locale of the Power-Up listing."
    ] = None,
    listing_locale: Annotated[
        str | None, "The locale code for displaying the listing, e.g., 'en' for English."
    ] = None,
    localized_name: Annotated[
        str | None, "The name of the listing to display for the specified locale."
    ] = None,
    overview_for_locale: Annotated[
        str | None, "Provide the overview text for the specified locale to update the listing."
    ] = None,
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'put-plugins-idplugin-listings-idlisting'."
]:
    """Update an existing listing for a Trello Power-Up.

    Call this tool to update information on an existing listing for a Trello Power-Up, identified by specific plugin and listing IDs."""  # noqa: E501
    request_data = remove_none_values({
        "description": listing_description,
        "locale": listing_locale,
        "overview": overview_for_locale,
        "name": localized_name,
    })
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/plugins/{idPlugin}/listings/{idListing}".format(  # noqa: UP032
            idPlugin=power_up_id, idListing=listing_id
        ),
        method="PUT",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({"Content-Type": "application/json"}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def trello_search(
    context: ToolContext,
    search_query: Annotated[
        str, "The search query string, with a length between 1 and 16384 characters."
    ],
    board_fields_selection: Annotated[
        str | None,
        "Comma-separated list of board fields to return or 'all' for every field. Options include: closed, dateLastActivity, etc.",  # noqa: E501
    ] = "name,idOrganization",
    board_identifiers: Annotated[
        str | None,
        "Specify 'mine' to search all your boards or provide a comma-separated list of Board IDs.",
    ] = None,
    card_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of card fields like 'badges', 'desc', 'labels'. Defaults to 'all' if omitted.",  # noqa: E501
    ] = "all",
    card_ids: Annotated[
        str | None, "Comma-separated list of Trello Card IDs to search within."
    ] = None,
    cards_page_number: Annotated[
        float | None, "Specify the page number for card search results. Maximum value is 100."
    ] = 0,
    enable_partial_search: Annotated[
        bool | None,
        "Enable partial search to match content starting with words in your query, allowing for more flexible search results.",  # noqa: E501
    ] = False,
    include_card_attachments: Annotated[
        str | None,
        "Specify 'true' to include all attachment objects, 'cover' for only card cover attachments, or 'false' for no attachments.",  # noqa: E501
    ] = "false",
    include_card_list: Annotated[
        bool | None, "Include the parent list with card results. A boolean value (true or false)."
    ] = False,
    include_card_members: Annotated[
        bool | None,
        "Include member objects with card results if set to true; exclude them if false.",
    ] = False,
    include_card_stickers: Annotated[
        bool | None,
        "Set to true to include sticker objects with card results. Set to false to exclude them.",
    ] = False,
    include_parent_board_with_card_results: Annotated[
        bool | None, "Set to true to include parent board details in card results."
    ] = False,
    include_parent_organization_with_board_results: Annotated[
        bool | None,
        "Include the parent organization in the board results. Set to true to include, false to exclude.",  # noqa: E501
    ] = False,
    max_members_returned: Annotated[
        int | None,
        "The maximum number of members to return in the search results. Maximum value is 1000.",
    ] = 10,
    max_workspaces_to_return: Annotated[
        int | None, "The maximum number of Workspaces to return. Accepts an integer up to 1000."
    ] = 10,
    maximum_boards_returned: Annotated[
        int | None, "The maximum number of boards to return. Must be an integer up to 1000."
    ] = 10,
    maximum_cards_to_return: Annotated[
        int | None, "The maximum number of cards to return. Maximum value is 1000."
    ] = 10,
    member_fields_selection: Annotated[
        str | None,
        "Specify which member fields to return. Options: `all` or a comma-separated list of: avatarHash, bio, bioData, confirmed, fullName, idPremOrgsAdmin, initials, memberType, products, status, url, username.",  # noqa: E501
    ] = "avatarHash,fullName,initials,username,confirmed",
    organization_fields_to_return: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of organization attributes like 'billableMemberCount', 'desc', 'displayName', etc., to include in the results.",  # noqa: E501
    ] = "name,displayName",
    organization_ids: Annotated[
        str | None,
        "A comma-separated list of Trello Organization IDs to filter the search results.",
    ] = None,
    trello_object_types: Annotated[
        str | None,
        "Specify types of Trello objects to search, such as 'all', 'actions', 'boards', 'cards', 'members', or 'organizations'. Use a comma-separated list.",  # noqa: E501
    ] = "all",
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-search'."]:
    """Search for information within Trello.

    Use this tool to find cards, boards, members, and other elements in Trello by searching with specific keywords."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/search",
        method="GET",
        params=remove_none_values({
            "query": search_query,
            "idBoards": board_identifiers,
            "idOrganizations": organization_ids,
            "idCards": card_ids,
            "modelTypes": trello_object_types,
            "board_fields": board_fields_selection,
            "boards_limit": maximum_boards_returned,
            "board_organization": include_parent_organization_with_board_results,
            "card_fields": card_fields,
            "cards_limit": maximum_cards_to_return,
            "cards_page": cards_page_number,
            "card_board": include_parent_board_with_card_results,
            "card_list": include_card_list,
            "card_members": include_card_members,
            "card_stickers": include_card_stickers,
            "card_attachments": include_card_attachments,
            "organization_fields": organization_fields_to_return,
            "organizations_limit": max_workspaces_to_return,
            "member_fields": member_fields_selection,
            "members_limit": max_members_returned,
            "partial": enable_partial_search,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def search_trello_members(
    context: ToolContext,
    search_query: Annotated[
        str, "The search term for finding Trello members, between 1 and 16384 characters long."
    ],
    board_id: Annotated[
        str | None,
        "The ID of the Trello board to filter members by. Leave empty to include all boards.",
    ] = None,
    organization_id: Annotated[
        str | None,
        "Unique identifier for the organization to filter the search results. Use this to limit the search to members within a specific organization.",  # noqa: E501
    ] = None,
    restrict_to_organization_members: Annotated[
        bool | None,
        "If true, limit the search results to include only members of the organization.",
    ] = False,
    result_limit: Annotated[
        int | None,
        "Specify the maximum number of Trello member search results to return, with a maximum of 20.",  # noqa: E501
    ] = 8,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-search-members'."]:
    """Search and retrieve Trello member information.

    Use this tool to search for and retrieve information about Trello members based on specified criteria. It helps in finding users within Trello efficiently."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/search/members/",
        method="GET",
        params=remove_none_values({
            "query": search_query,
            "limit": result_limit,
            "idBoard": board_id,
            "idOrganization": organization_id,
            "onlyOrgMembers": restrict_to_organization_members,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def retrieve_trello_token_info(
    context: ToolContext,
    trello_token: Annotated[
        str, "The unique identifier for the Trello token to retrieve information about."
    ],
    include_webhooks: Annotated[
        bool | None, "Set to true to include webhooks in the response; false to exclude them."
    ] = False,
    retrieve_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of fields: dateCreated, dateExpires, idMember, identifier, permissions.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-tokens-token'."]:
    """Retrieve information about a Trello token.

    Use this tool to obtain details about a specific Trello token. Ideal for checking token-related data when handling Trello API integrations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}".format(token=trello_token),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": retrieve_fields,
            "webhooks": include_webhooks,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_token_owner(
    context: ToolContext,
    trello_token: Annotated[
        str,
        "The unique Trello token to identify and retrieve the owner information. Must be a valid string.",  # noqa: E501
    ],
    retrieve_fields: Annotated[
        str | None,
        "Specify 'all' or a comma-separated list of Trello member fields to retrieve, such as 'id'.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-tokens-token-member'."]:
    """Retrieve information about a Trello token's owner.

    Use this tool to get details about the owner of a specified Trello token. Useful when you need to verify token ownership or access token-related user information."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/member".format(token=trello_token),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "fields": retrieve_fields,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def retrieve_token_webhooks(
    context: ToolContext,
    trello_token: Annotated[
        str,
        "The Trello token used to retrieve associated webhooks. It identifies the user's session and permissions.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-tokens-token-webhooks'."]:
    """Retrieve all webhooks created with a specific token.

    Use this tool to get a list of all webhooks associated with a given Trello token. This is useful for managing and reviewing webhook integrations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/webhooks".format(token=trello_token),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def create_trello_webhook(
    context: ToolContext,
    object_id_for_webhook: Annotated[
        str, "ID of the Trello object (board or card) to create a webhook on."
    ],
    trello_token: Annotated[
        str,
        "The authentication token for Trello. It allows access to create the webhook. Required for authorization.",  # noqa: E501
    ],
    webhook_callback_url: Annotated[
        str, "The URL where the webhook will POST updates. Ensure it's a valid and accessible URL."
    ],
    webhook_description: Annotated[
        str | None,
        "A string description displayed when retrieving information about the webhook. It helps identify the purpose or function of the webhook.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-tokens-token-webhooks'."]:
    """Create a new webhook for a Trello token.

    This tool allows you to create a new webhook for a specific Trello token. Use it to set up webhooks for tracking changes or events related to Trello boards or cards."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/webhooks".format(token=trello_token),  # noqa: UP032
        method="POST",
        params=remove_none_values({
            "description": webhook_description,
            "callbackURL": webhook_callback_url,
            "idModel": object_id_for_webhook,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def retrieve_trello_webhook(
    context: ToolContext,
    trello_token: Annotated[
        str,
        "The Trello API token used to authenticate the request and retrieve the webhook details.",
    ],
    webhook_id: Annotated[str, "The ID of the Trello webhook you want to retrieve details for."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'get-tokens-token-webhooks-idwebhook'."
]:
    """Retrieve details of a specific Trello webhook.

    Use this tool to obtain information about a webhook created with a Trello token. It should be called when you need to access detailed information about a particular Trello webhook associated with a token."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/webhooks/{idWebhook}".format(  # noqa: UP032
            token=trello_token, idWebhook=webhook_id
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_webhook(
    context: ToolContext,
    access_token: Annotated[
        str,
        "The access token used for authentication. It identifies the user and grants permission to delete the webhook.",  # noqa: E501
    ],
    webhook_id: Annotated[str, "The unique ID of the Trello webhook you wish to delete."],
) -> Annotated[
    dict[str, Any], "Response from the API endpoint 'delete-tokens-token-webhooks-idwebhook'."
]:
    """Delete a specific Trello webhook.

    Use this tool to remove a webhook associated with a specific Trello token and webhook ID. This is helpful when managing or updating webhook configurations."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/webhooks/{idWebhook}".format(  # noqa: UP032
            token=access_token, idWebhook=webhook_id
        ),
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def update_trello_webhook(
    context: ToolContext,
    authentication_token: Annotated[
        str,
        "The token used for authenticating the request to update the webhook in Trello. Required for authorization.",  # noqa: E501
    ],
    webhook_id: Annotated[
        str, "The ID of the Trello webhook to be updated. Used to identify which webhook to modify."
    ],
    callback_url: Annotated[
        str | None,
        "The URL where the webhook will POST data. Ensure the URL is accessible and correct.",
    ] = None,
    object_id_for_webhook: Annotated[
        str | None, "ID of the Trello object (e.g., board, card) associated with the webhook."
    ] = None,
    webhook_description: Annotated[
        str | None, "A description to be displayed when retrieving information about the webhook."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'tokenstokenwebhooks-1'."]:
    """Update a Trello webhook using a specific token.

    This tool updates a webhook in Trello identified by a specific token and webhook ID. Useful for modifying webhook settings or endpoints."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/webhooks/{idWebhook}".format(  # noqa: UP032
            token=authentication_token, idWebhook=webhook_id
        ),
        method="PUT",
        params=remove_none_values({
            "description": webhook_description,
            "callbackURL": callback_url,
            "idModel": object_id_for_webhook,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def delete_trello_token(
    context: ToolContext,
    trello_token_to_delete: Annotated[
        str, "The Trello token string that needs to be deleted to revoke access."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-token'."]:
    """Deletes a Trello token to revoke access.

    Use this tool to delete a specified Trello token and revoke its access. Call this tool when you need to ensure that a token is no longer valid."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/tokens/{token}/".format(token=trello_token_to_delete),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def add_trello_webhook(
    context: ToolContext,
    callback_url: Annotated[
        str, "A valid URL that supports `HEAD` and `POST` requests for webhook notifications."
    ],
    model_id_to_monitor: Annotated[
        str, "ID of the Trello model (board, card, etc.) to monitor for changes."
    ],
    is_webhook_active: Annotated[
        bool | None, "A boolean to specify whether the webhook is active and sending POST requests."
    ] = None,
    webhook_description: Annotated[
        str | None, "A description of the webhook, up to 16384 characters long."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'post-webhooks'."]:
    """Create a new webhook on Trello.

    Use this tool to create a new webhook on Trello, enabling you to receive updates about changes to boards, cards, lists, or other Trello elements."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/webhooks/",
        method="POST",
        params=remove_none_values({
            "description": webhook_description,
            "callbackURL": callback_url,
            "idModel": model_id_to_monitor,
            "active": is_webhook_active,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_trello_webhook_by_id(
    context: ToolContext,
    webhook_id: Annotated[str, "The unique identifier for the Trello webhook to retrieve."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-webhooks-id'."]:
    """Retrieve details of a Trello webhook by its ID.

    Use this tool to get detailed information about a specific Trello webhook by providing its ID. Ensure the correct token is used to avoid errors."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/webhooks/{id}".format(id=webhook_id),  # noqa: UP032
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def modify_trello_webhook(
    context: ToolContext,
    webhook_id: Annotated[
        str,
        "The ID of the Trello webhook to update. This identifies which webhook's settings you want to modify.",  # noqa: E501
    ],
    activate_webhook: Annotated[
        bool | None,
        "Set to true to activate the webhook and enable sending POST requests, or false to deactivate.",  # noqa: E501
    ] = None,
    callback_url: Annotated[
        str | None,
        "A valid URL that is reachable with a `HEAD` and `POST` request, used to receive webhook data.",  # noqa: E501
    ] = None,
    model_id: Annotated[str | None, "ID of the model to be monitored for webhook updates."] = None,
    webhook_description: Annotated[
        str | None, "A string describing the webhook, with a length from 0 to 16384 characters."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'put-webhooks-id'."]:
    """Updates a Trello webhook by its ID.

    Use this tool to update a specific Trello webhook when you need to modify its configuration or target URL. Useful for maintaining synchronization with external services."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/webhooks/{id}".format(id=webhook_id),  # noqa: UP032
        method="PUT",
        params=remove_none_values({
            "description": webhook_description,
            "callbackURL": callback_url,
            "idModel": model_id,
            "active": activate_webhook,
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def remove_trello_webhook(
    context: ToolContext,
    webhook_id: Annotated[str, "The ID of the Trello webhook you want to delete."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-webhooks-id'."]:
    """Delete a Trello webhook by ID.

    Use this tool to delete a specific webhook in Trello by providing its ID."""
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/webhooks/{id}".format(id=webhook_id),  # noqa: UP032
        method="DELETE",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["TRELLO_API_KEY", "TRELLO_TOKEN"])
async def get_webhook_field(
    context: ToolContext,
    webhook_field_to_retrieve: Annotated[
        str,
        "Specify which field to retrieve from the webhook. Options are: `active`, `callbackURL`, `description`, `idModel`.",  # noqa: E501
    ],
    webhook_id: Annotated[str, "ID of the Trello webhook to retrieve information from."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'webhooksidfield'."]:
    """Retrieve a specific field from a Trello webhook.

    Use this tool to get a specific field from a Trello webhook by providing the webhook ID and the field name you want to access."""  # noqa: E501
    request_data = remove_none_values({})
    content = json.dumps(request_data) if request_data else None
    response = await make_request(
        url="https://api.trello.com/1/webhooks/{id}/{field}".format(  # noqa: UP032
            id=webhook_id, field=webhook_field_to_retrieve
        ),
        method="GET",
        params=remove_none_values({
            "key": context.get_secret("TRELLO_API_KEY"),
            "token": context.get_secret("TRELLO_TOKEN"),
        }),
        headers=remove_none_values({}),
        content=content,
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}
