"""Arcade Starter Tools for Freshservice

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
from typing import Annotated, Any

import httpx
from arcade_tdk import ToolContext, tool

# Retry configuration
INITIAL_RETRY_DELAY = 0.5  # seconds

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


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


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

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


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_freshservice_departments(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "The number of entries to retrieve per page in a paginated list."
    ] = 10,
    page_number: Annotated[
        int | None, "The specific page number of departments to retrieve from Freshservice."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-departments'."]:
    """Retrieve all departments from Freshservice.

    This tool retrieves a list of all departments or companies (in MSP Mode) from Freshservice. It should be used when you need to access the department or company information maintained in the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/departments".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_department_details(
    context: ToolContext,
    department_id: Annotated[
        int, "The ID of the department to retrieve from Freshservice. Use only integer values."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-department'."]:
    """Retrieve department details using department ID.

    Use this tool to obtain detailed information about a specific department (or company in MSP mode) from Freshservice by providing the department ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/departments/{department_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            department_id=department_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_department(
    context: ToolContext,
    department_id: Annotated[int, "The unique ID of the department to delete from Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-department'."]:
    """Delete a department from Freshservice by ID.

    Use this tool to delete a specific department from Freshservice using its ID. This is useful for managing and updating department records within the service."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/departments/{department_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            department_id=department_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_department_fields(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-department-fields'."]:
    """Retrieve department or company fields from Freshservice.

    Use this tool to obtain the department or company fields as displayed in Freshservice. Especially useful for understanding the available fields and their order in the user interface."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/department_fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_freshservice_agent_groups(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Specify the number of entries to retrieve in each page of the list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The specific page number to retrieve from a paginated list of agent groups."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-agent-groups'."]:
    """Retrieve a list of all Agent Groups in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agent_groups".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_agent_group_info(
    context: ToolContext,
    agent_group_identifier: Annotated[
        int, "The unique integer ID of the Freshservice agent group to retrieve."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-agent-group'."]:
    """Retrieve details of a Freshservice agent group by ID.

    Use this tool to get information about a specific agent group in Freshservice by providing the agent group ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agent_groups/{agent_group_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            agent_group_id=agent_group_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_agent_group(
    context: ToolContext,
    agent_group_id_to_delete: Annotated[
        int, "The unique integer ID of the agent group to be deleted in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-agent-group'."]:
    """Delete an agent group in Freshservice by ID.

    Use this tool to delete an agent group from Freshservice by specifying the group's ID. This should be called when you need to remove an agent group permanently."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agent_groups/{agent_group_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            agent_group_id=agent_group_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_all_products(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Specify the number of entries to retrieve in each page of the product list."
    ] = 10,
    page_number: Annotated[
        int | None, "Specify the page number to retrieve from the paginated list of products."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-products'."]:
    """Retrieve a comprehensive list of products from Freshservice.

    Use this tool to obtain a complete list of products managed within Freshservice. This can be useful for inventory management, product categorization, and maintaining an updated product database."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/products".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_product_details(
    context: ToolContext,
    product_id: Annotated[
        int,
        "The unique identifier for the product in the Freshservice Product Catalog to retrieve details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-product'."]:
    """Retrieve a specific Product from the Product Catalog.

    Call this tool to get details about a specific product by providing the product ID. It accesses the Freshservice Product Catalog to retrieve the necessary information."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/products/{product_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            product_id=product_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_product(
    context: ToolContext,
    product_identifier: Annotated[
        int, "The unique ID of the product to be deleted from the Freshservice catalog."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-product'."]:
    """Delete a product from the Freshservice catalog.

    Use this tool to delete an existing product from the Freshservice Product Catalog. Provide the product ID to specify which product to remove."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/products/{product_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            product_id=product_identifier,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_business_hours_configs(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "The number of Business Hours configurations to retrieve per page in the paginated list.",
    ] = 10,
    requested_page_number: Annotated[
        int | None, "Specify the page number of results you want to retrieve."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-business-hours-configs'."]:
    """Retrieve a list of all Business Hours configurations from Freshservice.

    Call this tool to obtain the current Business Hours configurations from Freshservice. Useful for understanding operation times and support availability."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/business_hours".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": requested_page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_business_hours_config(
    context: ToolContext,
    business_hours_configuration_id: Annotated[
        int, "The ID of the Business Hours configuration to retrieve from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-business-hours-config'."]:
    """Retrieve Freshservice Business Hours configuration by ID.

    Use this tool to get the Business Hours configuration from Freshservice using the specified ID. It helps in accessing detailed information about business operating hours as configured in the Freshservice system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/business_hours/{business_hours_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            business_hours_id=business_hours_configuration_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_all_locations(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "The number of entries to retrieve per page when listing locations. Typically an integer value.",  # noqa: E501
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number of locations to retrieve from Freshservice."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-locations'."]:
    """Retrieve a list of all locations in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/locations".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_location_details(
    context: ToolContext,
    location_identifier: Annotated[
        int,
        "The ID of the location to be retrieved. It should be an integer representing a specific location in the Freshservice system.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-location'."]:
    """Retrieve details of a specific location by ID.

    This tool is used to get information about a specific location using its ID in the Freshservice system. It should be called when detailed information about a location is needed."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/locations/{location_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            location_id=location_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_existing_location(
    context: ToolContext,
    location_id: Annotated[
        int,
        "The unique identifier of the location to be deleted. Provide the numeric ID corresponding to the location you wish to remove from Freshservice.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-location'."]:
    """Deletes an existing location from Freshservice.

    Use this tool to remove an existing location in Freshservice by providing the location ID. It should be called when you need to delete a location from the system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/locations/{location_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            location_id=location_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_all_vendors(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "Specify the number of vendor entries to retrieve for each page when listing vendors.",
    ] = 10,
    page_number: Annotated[
        int | None, "Specify the page number to retrieve from the paginated list of vendors."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-vendors'."]:
    """Retrieve and list all vendors from Freshservice.

    Call this tool to obtain a comprehensive list of all vendors stored in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/vendors".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_vendor_details(
    context: ToolContext,
    vendor_identifier: Annotated[
        int,
        "The unique ID of the vendor to retrieve. This ID is an integer and identifies the vendor in the Freshservice system.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-vendor'."]:
    """Retrieve details of a specific vendor by ID.

    Use this tool to get detailed information about a vendor by providing the vendor ID. It is helpful for accessing vendor-related data from your Freshservice account."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/vendors/{vendor_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            vendor_id=vendor_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_existing_vendor(
    context: ToolContext,
    vendor_id: Annotated[
        int, "The unique identifier of the vendor to be deleted. It should be an integer value."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-vendor'."]:
    """Delete an existing vendor in Freshservice.

    Use this tool to delete a vendor from the Freshservice platform when a user requests vendor removal."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/vendors/{vendor_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), vendor_id=vendor_id
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_asset_types(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "The number of asset type entries to retrieve per page in the paginated list."
    ] = 10,
    page_number: Annotated[
        int | None, "The page number to retrieve from the list of asset types."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-types'."]:
    """Retrieve all asset types from Freshservice.

    Use this tool to get a comprehensive list of asset types available in Freshservice, useful for asset management and categorization."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/asset_types".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_asset_type(
    context: ToolContext,
    asset_type_id: Annotated[
        int,
        "The unique integer identifier for the asset type to retrieve from Freshservice. Required for querying specific asset type details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-asset-type'."]:
    """Retrieve details of a specific asset type by ID.

    Use this tool to retrieve information about a specific asset type using its ID. Ideal for obtaining detailed descriptions or attributes of an asset type in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/asset_types/{asset_type_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            asset_type_id=asset_type_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_asset_type(
    context: ToolContext,
    asset_type_id: Annotated[
        int,
        "The unique integer ID of the asset type to be deleted. This ID identifies which asset type should be removed from the Freshservice database.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-asset-type'."]:
    """Delete an existing asset type in Freshservice.

    Use this tool to delete a specific asset type by providing its ID. This is useful for managing and updating the asset database by removing obsolete or incorrect asset types."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/asset_types/{asset_type_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            asset_type_id=asset_type_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_asset_fields(
    context: ToolContext,
    asset_type_identifier: Annotated[
        int, "The unique identifier for the asset type to retrieve its fields in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-type-fields'."]:
    """Retrieve asset fields for a specific asset type.

    Use this tool to get the list of asset fields for a particular asset type in Freshservice. This includes both default fields and asset-type-specific fields, returned in the order they appear in the UI."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/asset_types/{asset_type_id}/fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            asset_type_id=asset_type_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_component_types(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "The number of component type entries to retrieve per page in a paginated list. Specify an integer value.",  # noqa: E501
    ] = 10,
    page_number: Annotated[
        int | None, "The specific page number of component types to retrieve from Freshservice."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-component-types'."]:
    """Retrieve all component types in Freshservice.

    This tool calls the Freshservice API to get a list of all component types along with the specific fields for each type. Use it when you need detailed information about the component types within Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/component_types".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_asset_list(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "Specify the number of entries to retrieve per page for pagination. Not applicable with search or filter queries.",  # noqa: E501
    ] = 30,
    page_number: Annotated[
        int | None, "The page number to retrieve for paginated asset lists."
    ] = 1,
    include_asset_type_fields: Annotated[
        str | None,
        "Specify asset type fields to include in the response. Use this to get additional data about each asset type.",  # noqa: E501
    ] = None,
    apply_asset_filter: Annotated[
        str | None,
        "A URL-encoded string to filter the asset list. Supports parameters like asset_type_id, department_id, and more.",  # noqa: E501
    ] = None,
    asset_search_query: Annotated[
        str | None,
        "A simple query to search assets by name, asset_tag, or serial_number. Formulate queries like \"name:'dell monitor'\".",  # noqa: E501
    ] = None,
    include_trashed_assets: Annotated[bool | None, "Set to true to list assets in trash."] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-assets'."]:
    """Retrieve a list of all assets from Freshservice.

    Use this tool to get details about all assets managed in Freshservice, such as hardware and software resources."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number,
            "trashed": include_trashed_assets,
            "include": include_asset_type_fields,
            "filter": apply_asset_filter,
            "search": asset_search_query,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_asset_details(
    context: ToolContext,
    asset_display_id: Annotated[
        int, "The unique display ID of the asset to retrieve details from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-asset'."]:
    """Retrieve details of a specific asset by ID.

    This tool is used to obtain detailed information about a specific asset using its display ID in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_asset(
    context: ToolContext,
    asset_display_id: Annotated[
        int,
        "The unique integer identifier of the asset to be deleted. Required to specify which asset to remove from Freshservice.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-asset'."]:
    """Delete an existing asset in Freshservice.

    Use this tool to remove an asset from the Freshservice platform when it is no longer needed or is being decommissioned."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_installed_software(
    context: ToolContext,
    device_display_id: Annotated[
        int,
        "The unique integer identifier for the device whose installed software applications are to be retrieved.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-applications'."]:
    """Retrieve all software installed on a specific device.

    Use this tool to get a comprehensive list of all software applications installed on a device identified by its display ID. Useful for inventory management or system audits."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/applications".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=device_display_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_asset_requests(
    context: ToolContext,
    asset_display_id: Annotated[
        int, "The display ID of the asset for which to retrieve associated requests."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-requests'."]:
    """Retrieve all requests linked to a specific asset.

    Use this tool to get a comprehensive list of requests associated with a particular asset by providing its display ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/requests".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_asset_contracts(
    context: ToolContext,
    asset_display_id: Annotated[
        int, "The unique display ID of the asset to retrieve contracts for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-contracts'."]:
    """Retrieve all contracts linked to a specific asset.

    This tool calls the Freshservice API to retrieve a list of contracts that are linked to a specified asset. It should be used whenever detailed information about asset contracts is needed."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/contracts".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_device_components(
    context: ToolContext,
    device_display_id: Annotated[
        int, "The integer ID of the device whose components you want to list."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-asset-components'."]:
    """Retrieve all components of a specified device.

    Use this tool to get a comprehensive list of components for a specific device by its display ID. This is useful for inventory tracking, device management, or component verification."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/components".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=device_display_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def add_asset_component(
    context: ToolContext,
    asset_display_id: Annotated[
        int,
        "The unique identifier of the asset to which the new component will be added. This should be an integer value.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'create-asset-component'."]:
    """Add a new component to an existing asset.

    Use this tool to add a new component to a specific asset in the Freshservice system. This is useful for updating asset details by appending components."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/components".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
        ),
        method="POST",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def update_asset_component(
    context: ToolContext,
    asset_display_id: Annotated[
        int, "The numeric identifier of the asset to be updated in Freshservice."
    ],
    component_identifier: Annotated[
        int, "The unique identifier of the component to be updated, as an integer."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'update-asset-component'."]:
    """Update a component in an asset.

    This tool updates a specific component within an asset in Freshservice. Call this tool when you need to modify details of a component associated with an asset."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/components/{component_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
            component_id=component_identifier,
        ),
        method="PUT",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_asset_component(
    context: ToolContext,
    asset_display_id: Annotated[
        int,
        "The display ID of the asset from which the component will be deleted. This ID uniquely identifies the asset in the Freshservice system.",  # noqa: E501
    ],
    component_id: Annotated[
        int,
        "The unique identifier of the component to be deleted. This is required to specify which component will be removed from the asset.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-asset-component'."]:
    """Delete a specific component from an asset.

    This tool deletes an existing component from an asset using the asset's display ID and the component's ID. It should be called when there's a need to remove a component from an asset in the Freshservice system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/assets/{display_id}/components/{component_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            display_id=asset_display_id,
            component_id=component_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_software_list(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Number of software entries to retrieve per page for pagination."
    ] = 10,
    page_number: Annotated[
        int | None, "The page number of the software list to retrieve. Used for pagination."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-applications'."]:
    """Retrieve all software applications in Freshservice.

    Use this tool to get a complete list of software applications managed in Freshservice. It accesses the Freshservice API to provide detailed information about all registered software."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/applications".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_software_application(
    context: ToolContext,
    application_id: Annotated[
        int,
        "The unique identifier for the specific software application in Freshservice to be retrieved. It must be an integer.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-application'."]:
    """Retrieve a specific software application from Freshservice.

    Use this tool to get detailed information about a specific software application by providing the application ID. Ideal for accessing software details and managing applications within Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/applications/{application_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            application_id=application_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_software_installation_list(
    context: ToolContext,
    software_application_id: Annotated[
        int, "The unique identifier of the software application to fetch the installation list."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-application-installations'."]:
    """Retrieve a list of devices where specified software is installed.

    Use this tool to get a list of all devices with a particular software application installed by providing the application ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/applications/{application_id}/installations".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            application_id=software_application_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_application_licenses(
    context: ToolContext,
    application_id: Annotated[
        int,
        "The unique identifier for the software application to retrieve licenses for. Provide as an integer.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-application-licenses'."]:
    """Retrieve licenses linked to a specific software application.

    Use this tool to get a list of all licenses associated with a specific application by providing the application ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/applications/{application_id}/licenses".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            application_id=application_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_all_csat_surveys(
    context: ToolContext,
    filter_active_surveys: Annotated[
        int | None, "Filter surveys by activity status. Use 1 for active and 0 for inactive."
    ] = None,
    entries_per_page: Annotated[
        int | None,
        "The number of entries to retrieve per page in a paginated list. Specify an integer value.",
    ] = 10,
    survey_page_number: Annotated[
        int | None, "The page number of CSAT surveys to retrieve for pagination."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-surveys'."]:
    """Retrieve a list of all CSAT surveys in Freshservice.

    Use this tool to obtain a list of all Customer Satisfaction (CSAT) surveys available in Freshservice. This can be useful for analyzing survey data or managing customer feedback efforts."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/surveys".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "active": filter_active_surveys,
            "per_page": entries_per_page,
            "page": survey_page_number,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_csat_survey(
    context: ToolContext,
    csat_survey_id: Annotated[
        int,
        "The ID of the CSAT survey to retrieve from Freshservice. It should be an integer value.",
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-survey'."]:
    """Retrieve a CSAT survey by its ID from Freshservice.

    Use this tool to get detailed information about a specific CSAT survey in Freshservice by providing the survey ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/surveys/{survey_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            survey_id=csat_survey_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_survey(
    context: ToolContext,
    survey_id_to_delete: Annotated[
        int, "The ID of the survey you wish to delete from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-survey'."]:
    """Delete a survey and its responses from Freshservice.

    Use this tool to delete a specific survey and all its associated responses from Freshservice by providing the survey ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/surveys/{survey_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            survey_id=survey_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def activate_csat_survey(
    context: ToolContext,
    csat_survey_id: Annotated[int, "The ID of the CSAT survey to activate in Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'activate-survey'."]:
    """Activate a CSAT survey in Freshservice using its ID.

    Use this tool to activate the Customer Satisfaction (CSAT) Survey in Freshservice by providing the survey ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/surveys/{survey_id}/activate".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            survey_id=csat_survey_id,
        ),
        method="PUT",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def deactivate_csat_survey(
    context: ToolContext,
    survey_id: Annotated[int, "The ID of the CSAT survey you wish to deactivate in Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'deactivate-survey'."]:
    """Deactivate a specified CSAT Survey in Freshservice.

    Use this tool to deactivate a CSAT Survey by its ID in Freshservice. It should be called when you need to disable a survey to stop collecting responses."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/surveys/{survey_id}/deactivate".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), survey_id=survey_id
        ),
        method="PUT",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def view_service_item(
    context: ToolContext,
    service_item_id: Annotated[int, "The ID of the service item you want to retrieve."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-service-item'."]:
    """Retrieve details of a specific service item.

    This tool is used to fetch and view details of a specific service item from Freshservice by providing its ID. It should be called when users need information about a particular service-related entry."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/service_items/{service_item_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            service_item_id=service_item_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_service_items_list(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "The number of service items to retrieve per page in a paginated list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve for paginated service items."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-service-items'."]:
    """Retrieve a list of all Service Items in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/service_items".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_catalog_item_fields(
    context: ToolContext,
    service_item_id: Annotated[
        int,
        "The ID of the service item to retrieve. Use an integer value representing the specific catalog item.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-catalog-item-fields'."]:
    """Retrieve all fields for a specific service catalog item.

    Use this tool to get detailed information about all fields associated with a particular service catalog item in Freshservice. It should be called when you need to understand the structure and content of a service item."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/catalog/item/{service_item_id}/fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            service_item_id=service_item_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_solution_articles(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "Specify the number of solution articles to retrieve per page in the paginated results.",
    ] = 30,
    page_number: Annotated[
        int | None, "The page number of the solution articles to retrieve from Freshservice."
    ] = 1,
    folder_identifier: Annotated[
        int | None, "The numeric ID of the folder to list solution articles from."
    ] = None,
    solution_category_id: Annotated[
        int | None, "Specify the ID of the category whose solution articles are to be retrieved."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-solution-article'."]:
    """Retrieve a list of Solution articles from Freshservice.

    Use this tool to get a comprehensive list of all Solution articles available in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/articles".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number,
            "folder_id": folder_identifier,
            "category_id": solution_category_id,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def view_solution_article(
    context: ToolContext,
    solution_article_id: Annotated[
        int, "The unique integer ID of the solution article to retrieve."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-solution-article'."]:
    """Retrieve details of a Freshservice solution article.

    Use this tool to get information about a specific solution article from Freshservice, identified by its article ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/articles/{article_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            article_id=solution_article_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_solution_article(
    context: ToolContext,
    solution_article_id: Annotated[
        int, "ID of the solution article to be deleted from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-solution-article'."]:
    """Delete a solution article from Freshservice by ID.

    Use this tool to delete a specified solution article in Freshservice by providing its ID. It's useful for managing and maintaining the solution knowledge base."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/articles/{article_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            article_id=solution_article_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_solution_folders(
    context: ToolContext,
    solution_category_id: Annotated[
        int | None, "ID of the solution category where the folders reside."
    ] = None,
    per_page_count: Annotated[
        int | None, "Specifies the number of solution folders to retrieve per page for pagination."
    ] = 30,
    page_number_to_retrieve: Annotated[
        int | None, "Specify the page number to retrieve from the paginated solution folders list."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-solution-folders'."]:
    """Retrieve all Solution Folders from Freshservice.

    Use this tool to fetch a comprehensive list of all the Solution Folders within Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/folders".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "category_id": solution_category_id,
            "per_page": per_page_count,
            "page": page_number_to_retrieve,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def view_solution_folder(
    context: ToolContext,
    solution_folder_id: Annotated[int, "The unique ID of the solution folder to retrieve details."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-solution-folder'."]:
    """Retrieve details of a specific solution folder.

    Use this tool to obtain information about a particular solution folder by specifying its folder ID within the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/folders/{folder_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            folder_id=solution_folder_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_solution_folder(
    context: ToolContext,
    solution_folder_id: Annotated[
        int, "ID of the solution folder to be deleted from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-solution-folder'."]:
    """Delete a solution folder in Freshservice.

    Use this tool to delete a solution folder from Freshservice by specifying its ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/folders/{folder_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            folder_id=solution_folder_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_solution_categories(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "The number of entries to retrieve per page in the paginated list."
    ] = 30,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve in the paginated list of solution categories."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-solution-category'."]:
    """Retrieve a list of all solution categories in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/categories".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def view_solution_category(
    context: ToolContext,
    solution_category_id: Annotated[int, "ID of the solution category to retrieve details for."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-solution-category'."]:
    """Retrieve details of a specific solution category.

    Use this tool to fetch and view information about a specific solution category by its ID in the Freshservice system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/categories/{category_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            category_id=solution_category_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_solution_category(
    context: ToolContext,
    solution_category_id: Annotated[
        int, "The unique ID of the solution category to be deleted from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-solution-category'."]:
    """Delete a solution category by its ID from Freshservice.

    Use this tool to delete a solution category in Freshservice using its unique category ID. This tool ensures that the specified category is permanently removed from the system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/solutions/categories/{category_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            category_id=solution_category_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_all_freshservice_requesters(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Number of entries to retrieve in each page of the paginated list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve from the list of Freshservice requesters."
    ] = 1,
    requester_email: Annotated[
        str | None, "The email address to find the corresponding requester."
    ] = None,
    filter_by_mobile_phone_number: Annotated[
        str | None, "Filter requesters by their mobile phone number to return matching entries."
    ] = None,
    work_phone_number_for_requesters: Annotated[
        str | None,
        "The work phone number to filter requesters with that specific number in Freshservice.",
    ] = None,
    query_filter: Annotated[
        str | None,
        "URL-encoded query filter to apply to the list of requesters. Supports first_name, last_name, job_title, primary_email, and more.",  # noqa: E501
    ] = None,
    filter_active_accounts: Annotated[
        bool | None,
        "Include only active user accounts if true. If false, include only deactivated accounts. Leaving unspecified returns both.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-requesters'."]:
    """Retrieve a list of all requesters in Freshservice.

    Use this tool to get a comprehensive list of all requesters from the Freshservice platform, suitable for managing or reviewing requester information."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number_to_retrieve,
            "email": requester_email,
            "mobile_phone_number": filter_by_mobile_phone_number,
            "work_phone_number": work_phone_number_for_requesters,
            "active": filter_active_accounts,
            "query": query_filter,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_freshservice_requester(
    context: ToolContext,
    requester_id: Annotated[
        int, "The unique integer ID of the requester to retrieve from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-requester'."]:
    """Retrieve a requester by ID from Freshservice.

    This tool is used to obtain information about a specific requester in Freshservice using their unique ID. Call this tool when you need details about a requester such as their profile or contact information."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters/{requester_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            requester_id=requester_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_requester_from_freshservice(
    context: ToolContext,
    requester_id_to_delete: Annotated[
        int, "The ID of the requester to be deleted from Freshservice. This should be an integer."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-requester'."]:
    """Delete a requester by ID from Freshservice.

    Use this tool to delete a specific requester from Freshservice by providing their ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters/{requester_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            requester_id=requester_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_requester_and_tickets(
    context: ToolContext,
    requester_id_to_delete: Annotated[
        int, "The ID of the requester to permanently delete along with their tickets."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'forget-requester'."]:
    """Permanently delete a requester and their tickets.

    Use this tool to permanently delete a requester and all the tickets they have requested in Freshservice when such removal is necessary."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters/{requester_id}/forget".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            requester_id=requester_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def convert_requester_to_agent(
    context: ToolContext,
    requester_identifier: Annotated[
        int, "The integer ID of the requester to convert into an occasional agent."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'convert-requester-to-agent'."]:
    """Convert a requester into an occasional agent.

    This tool is used to convert a Freshservice requester into an occasional agent, assigning them the SD Agent role with no group memberships. Use this when you need to change a requester's role to facilitate agent tasks."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters/{requester_id}/convert_to_agent".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            requester_id=requester_identifier,
        ),
        method="PUT",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def merge_requesters(
    context: ToolContext,
    secondary_requester_ids: Annotated[
        list[int], "List of IDs for the secondary requesters to merge into the primary."
    ],
    primary_requester_id: Annotated[
        int, "Specify the ID of the primary requester to merge secondary requesters into."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'merge-requester'."]:
    """Merge secondary requesters into a primary requester.

    This tool merges one or more secondary requesters into a specified primary requester. It is useful when consolidating duplicate or related entries under a single master requester. Use this to streamline requester management in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requesters/{primary_requester_id}/merge".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            primary_requester_id=primary_requester_id,
        ),
        method="PUT",
        params=remove_none_values({"secondary_requesters": secondary_requester_ids}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_requester_fields(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "The number of entries to retrieve per page in a paginated list for requester fields.",
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "Specify the page number of requester fields to retrieve from Freshservice."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-requester-fields'."]:
    """Retrieve all requester fields from Freshservice.

    Call this tool to obtain a comprehensive list of requester fields available in Freshservice. Useful for understanding the structure and available fields for requesters within the system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/requester_fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_freshservice_agents(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None,
        "The number of agent entries to retrieve in each page of a paginated list. Useful for controlling the size of paginated results.",  # noqa: E501
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The specific page number of the agent list to retrieve."
    ] = 1,
    requester_email: Annotated[
        str | None,
        "The email address of the requester for which the corresponding agent needs to be listed.",
    ] = None,
    filter_by_mobile_phone_number: Annotated[
        str | None,
        "Filter agents by a specific mobile phone number to list the corresponding requesters.",
    ] = None,
    filter_by_work_phone_number: Annotated[
        str | None,
        "Work phone number to filter the list of agents by their corresponding requesters.",
    ] = None,
    agent_type: Annotated[
        str | None, "Filter agents by employment type: 'fulltime' or 'occasional'."
    ] = None,
    agent_query_filter: Annotated[
        str | None,
        "URL-encoded string for filtering agents. Supports parameters like first_name, last_name, job_title, email, etc.",  # noqa: E501
    ] = None,
    filter_active_users: Annotated[
        bool | None,
        "Set to true to list active accounts, false to list deactivated ones, or omit to include both.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-agents'."]:
    """Retrieve a list of all Agents in Freshservice.

    Use this tool to get a comprehensive list of all agents currently active in Freshservice, useful for administrative and reporting purposes."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agents".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number_to_retrieve,
            "email": requester_email,
            "mobile_phone_number": filter_by_mobile_phone_number,
            "work_phone_number": filter_by_work_phone_number,
            "state": agent_type,
            "active": filter_active_users,
            "query": agent_query_filter,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_freshservice_agent(
    context: ToolContext,
    agent_id: Annotated[
        int, "The unique integer ID of the Freshservice agent to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-agent'."]:
    """Retrieve details of a Freshservice agent by ID.

    This tool retrieves the details of a specific agent from Freshservice using their agent ID. It should be called when detailed information about an agent is needed."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agents/{agent_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), agent_id=agent_id
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def convert_agent_to_requester(
    context: ToolContext,
    agent_id_for_conversion: Annotated[
        int,
        "The ID of the agent to be converted into a requester. This must be a valid integer representing the agent's ID in Freshservice.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-agent'."]:
    """Convert an agent into a requester in Freshservice.

    Use this tool to change the status of an agent by converting them into a requester. This is useful when the agent no longer needs to handle support tickets or requires access to agent-level features."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agents/{agent_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            agent_id=agent_id_for_conversion,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_agent_and_tickets(
    context: ToolContext,
    agent_id_to_delete: Annotated[
        int,
        "The ID of the agent to permanently delete along with their tickets. This is irreversible.",
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'forget-agent'."]:
    """Permanently deletes an agent and their tickets.

    Use this tool to permanently remove an agent from the system, along with any tickets they have requested. This action is irreversible."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agents/{agent_id}/forget".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            agent_id=agent_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_agent_fields(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "The number of entries to retrieve per page in a paginated list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve for paginated results."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-agent-fields'."]:
    """Retrieve a list of all Agent Fields in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/agent_fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_ticket_list(
    context: ToolContext,
    ticket_filter_type: Annotated[
        str | None,
        "Apply pre-defined filters to fetch specific ticket sets. Options: 'new_and_my_open', 'watching', 'spam', 'deleted'.",  # noqa: E501
    ] = None,
    requester_email_filter: Annotated[
        str | None, "Filter tickets by the requester's email ID to retrieve specific ticket data."
    ] = None,
    filter_by_requester_id: Annotated[
        int | None, "Filter tickets created by a specific requester using their ID."
    ] = None,
    filter_by_updated_since: Annotated[
        str | None,
        "Specify the ISO 8601 date-time to filter tickets updated since that time. Example: '2015-01-19T02:00:00Z'.",  # noqa: E501
    ] = None,
    fields_to_include_in_response: Annotated[
        str | None,
        "Specify which additional fields to include in the ticket response. Options are 'stats' and 'requester'.",  # noqa: E501
    ] = None,
    sort_order: Annotated[
        str | None,
        "Order to sort the ticket list. Supported values: 'asc' for ascending and 'desc' for descending. Default is 'desc'.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-tickets'."]:
    """Fetches the list of all support tickets in Freshservice.

    Use this tool to obtain a comprehensive list of all tickets available in the Freshservice system. Ideal for reviewing, updating, or analyzing support requests."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "filter": ticket_filter_type,
            "email": requester_email_filter,
            "requester_id": filter_by_requester_id,
            "updated_since": filter_by_updated_since,
            "include": fields_to_include_in_response,
            "order_type": sort_order,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_ticket_details(
    context: ToolContext,
    ticket_id: Annotated[int, "ID of the Freshservice ticket to be retrieved."],
    include_fields_in_ticket_response: Annotated[
        str | None,
        "Specify fields to include in the ticket response, such as 'stats', 'requester', 'conversations', etc.",  # noqa: E501
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-ticket'."]:
    """Retrieve details of a FreshService ticket using its ID.

    Use this tool to obtain detailed information about a specific ticket in FreshService by providing the ticket ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), ticket_id=ticket_id
        ),
        method="GET",
        params=remove_none_values({"include": include_fields_in_ticket_response}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def remove_freshservice_ticket(
    context: ToolContext,
    ticket_id_to_delete: Annotated[int, "ID of the Freshservice support ticket to delete."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-ticket'."]:
    """Remove a Freshservice support ticket by ID.

    Use this tool to delete a specific support ticket in Freshservice using its ticket ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def restore_deleted_ticket(
    context: ToolContext,
    ticket_id_to_restore: Annotated[
        int, "The ID of the Freshservice ticket to be restored. This must be an integer."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'restore-ticket'."]:
    """Restore a deleted Freshservice ticket.

    Use this tool to restore a deleted ticket in Freshservice by providing the ticket ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/restore".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_id_to_restore,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_ticket_conversations(
    context: ToolContext,
    ticket_id: Annotated[
        int,
        "The ID of the Freshservice ticket for which conversations need to be fetched. This should be an integer.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-ticket-conversations'."]:
    """Fetches all conversations for a specific Freshservice ticket.

    Use this tool to get a list of all conversations associated with a specific ticket in Freshservice. It's useful for retrieving detailed communication history related to a ticket."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/conversations".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), ticket_id=ticket_id
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def remove_ticket_conversation(
    context: ToolContext,
    conversation_ticket_id: Annotated[
        int, "The ID of the ticket from which the conversation should be removed."
    ],
    conversation_id_to_remove: Annotated[
        int, "The ID of the specific reply or note to delete from a Freshservice ticket."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-ticket-conversation'."]:
    """Remove a conversation from a Freshservice ticket.

    This tool is used to delete a specific conversation from a ticket in Freshservice. It should be called when there is a need to remove unnecessary or incorrect conversation threads from a support ticket."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/conversations/{conversation_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=conversation_ticket_id,
            conversation_id=conversation_id_to_remove,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_ticket_tasks(
    context: ToolContext,
    ticket_request_id: Annotated[
        int, "ID of the Freshservice ticket for which tasks are to be retrieved."
    ],
    tasks_per_page: Annotated[
        int | None, "Specify the number of tasks to retrieve per page in the paginated list."
    ] = 30,
    page_number: Annotated[
        int | None, "The specific page number to retrieve from the paginated list of tasks."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-ticket-tasks'."]:
    """Retrieve tasks for a specific Freshservice ticket.

    Use this tool to obtain all tasks linked to a given ticket in Freshservice by providing the ticket ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/tasks".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_request_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": tasks_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_ticket_task(
    context: ToolContext,
    ticket_request_id: Annotated[
        int, "The ID of the ticket request to retrieve the specific task from Freshservice."
    ],
    task_identifier: Annotated[
        int,
        "The unique identifier for the task to be retrieved. Provide this to get task details from a ticket.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-ticket-task'."]:
    """Retrieve details of a task from a ticket in Freshservice.

    Use this tool to get specific information about a task associated with a ticket by providing the ticket and task IDs. It is useful for accessing task details in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_request_id,
            task_id=task_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_ticket_task(
    context: ToolContext,
    ticket_id: Annotated[int, "The unique ID of the ticket from which you want to delete a task."],
    task_id: Annotated[int, "The unique identifier for the task to be deleted from the ticket."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-ticket-task'."]:
    """Deletes a task from a specified ticket in Freshservice.

    This tool should be called when you need to delete a specific task from a ticket in Freshservice using the ticket and task IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_id,
            task_id=task_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_ticket_time_entries(
    context: ToolContext,
    ticket_request_id: Annotated[
        int, "The unique ID of the ticket request to retrieve time entries for."
    ],
    number_of_entries_per_page: Annotated[
        int | None, "The number of time entries to retrieve in each page of a paginated list."
    ] = 30,
    page_number: Annotated[
        int | None, "The page number to retrieve from the paginated list of time entries."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-ticket-time-entries'."]:
    """Retrieve time entries for a given ticket ID.

    Use this tool to fetch all time entries associated with a specific ticket ID on Freshservice. It helps track time spent on each ticket."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/time_entries".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_request_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": number_of_entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_ticket_time_entry(
    context: ToolContext,
    ticket_request_id: Annotated[
        int,
        "The ID of the specific ticket request for which you want to retrieve the time entry. It must be an integer.",  # noqa: E501
    ],
    time_entry_id: Annotated[
        int,
        "Provide the ID of the time entry to retrieve specific details from a ticket in Freshservice.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-ticket-time-entry'."]:
    """Retrieve a time entry for a specific ticket in Freshservice.

    Use this tool to access details of a time entry associated with a specific ticket request in Freshservice. It is useful for monitoring or auditing time spent on ticket resolutions."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_request_id,
            time_entry_id=time_entry_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_ticket_time_entry(
    context: ToolContext,
    ticket_id: Annotated[
        int,
        "The unique identifier for the Freshservice ticket from which the time entry will be deleted. This must be an integer.",  # noqa: E501
    ],
    time_entry_id: Annotated[
        int, "The unique integer ID of the time entry to be deleted from the Freshservice ticket."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-ticket-time-entry'."]:
    """Deletes a time entry from a Freshservice ticket.

    Use this tool to delete a specific time entry associated with a ticket in Freshservice. This is helpful when you need to update or correct time tracking records."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/tickets/{ticket_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            ticket_id=ticket_id,
            time_entry_id=time_entry_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_freshservice_changes(
    context: ToolContext,
    change_filter_name: Annotated[
        str | None,
        "Specify the filter name to retrieve changes. Possible values: 'my_open', 'unassigned', 'closed', 'release_requested', 'deleted', 'all'.",  # noqa: E501
    ] = None,
    requester_id: Annotated[
        str | None, "ID of the person who requested the changes to filter results."
    ] = None,
    requester_email: Annotated[
        str | None, "Retrieve changes by the requester's email address in Freshservice."
    ] = None,
    updated_since: Annotated[
        str | None,
        "Retrieve changes updated after a specified date. Date format should be YYYY-MM-DD.",
    ] = None,
    page_size: Annotated[
        int | None, "Specify the number of changes to retrieve per page in a paginated list."
    ] = 30,
    page_number: Annotated[
        int | None, "The specific page number to retrieve in a paginated list of changes."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-changes'."]:
    """Retrieve all changes from Freshservice.

    Use this tool to get a comprehensive list of all changes in the Freshservice system. Ideal for tracking updates and modifications within the service."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "filter_name": change_filter_name,
            "requester_id": requester_id,
            "email": requester_email,
            "updated_since": updated_since,
            "per_page": page_size,
            "page": page_number,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_request(
    context: ToolContext,
    change_request_id: Annotated[int, "ID of the Change request to retrieve from Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-change'."]:
    """Fetch a Change request by ID from Freshservice.

    Use this tool to retrieve detailed information about a specific Change request using its ID from the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_freshservice_change(
    context: ToolContext,
    change_request_id: Annotated[int, "The ID of the change request to delete from Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-change'."]:
    """Deletes a specified change request from Freshservice.

    Use this tool to delete a change request by its ID in Freshservice. It should be called when a user wants to permanently remove a change request from the system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_notes(
    context: ToolContext,
    change_request_id: Annotated[
        int,
        "ID of the change request for which notes are to be retrieved. This is an integer value.",
    ],
    notes_per_page: Annotated[
        int | None, "The number of notes to retrieve per page in a paginated list."
    ] = 30,
    page_number_to_retrieve: Annotated[
        int | None, "The specific page number of notes to retrieve for pagination."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-change-notes'."]:
    """Retrieve notes from a specific change request.

    Use this tool to retrieve the notes related to a specific change request in Freshservice by providing the change ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/notes".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": notes_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_note(
    context: ToolContext,
    change_request_id: Annotated[int, "ID of the change request to retrieve its specific note."],
    note_identifier: Annotated[
        int,
        "The unique identifier for the note to be retrieved from a change request in Freshservice.",
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-change-note'."]:
    """Retrieve a specific note from a change request in Freshservice.

    Use this tool to obtain a specific note from a change request by providing the change ID and note ID in Freshservice. It's helpful for tracking updates or comments on change requests."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            note_id=note_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_change_note(
    context: ToolContext,
    change_request_id: Annotated[
        int, "The unique ID of the Change request from which the note will be deleted."
    ],
    note_id: Annotated[
        int, "The unique identifier of the note to delete from a Change request in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-change-note'."]:
    """Delete a note from a Change request in Freshservice.

    Use this tool to delete a specific note from a Change request in Freshservice by providing the relevant Change and Note IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            note_id=note_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_tasks(
    context: ToolContext,
    change_request_id: Annotated[
        int, "ID of the Change request for retrieving associated tasks from Freshservice."
    ],
    tasks_per_page: Annotated[
        int | None, "Specify the number of tasks to retrieve per page in the paginated list."
    ] = 10,
    page_number: Annotated[
        int | None, "Specify the page number of tasks to retrieve for the Change request."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-change-tasks'."]:
    """Retrieve tasks for a specific Change request in Freshservice.

    Use this tool to obtain a list of tasks associated with a specific Change request by providing the Change ID. It helps in tracking and managing tasks related to changes efficiently."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/tasks".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": tasks_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_task_info(
    context: ToolContext,
    change_request_id: Annotated[
        int, "ID of the change request to retrieve the corresponding task details."
    ],
    task_identifier: Annotated[int, "Provide the integer ID of the task to retrieve its details."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-change-task'."]:
    """Retrieve details of a task in a change request.

    Use this tool to get detailed information about a specific task within a change request using its ID in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            task_id=task_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def remove_change_task(
    context: ToolContext,
    change_request_id: Annotated[
        int,
        "The unique identifier for the change request from which a task will be deleted. This should be an integer.",  # noqa: E501
    ],
    task_identifier: Annotated[
        int, "The unique integer ID of the task to delete from a change request in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-change-task'."]:
    """Delete a task from a change request in Freshservice.

    Use this tool to remove a specific task from a change request in Freshservice by specifying the change and task IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            task_id=task_identifier,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_change_time_entries(
    context: ToolContext,
    change_request_id: Annotated[
        int,
        "ID of the change request for which time entries should be retrieved. This is necessary to specify which change request's time entries are needed.",  # noqa: E501
    ],
    time_entries_per_page: Annotated[
        int | None,
        "Specify the number of time entries to retrieve per page. Helps in paginated responses.",
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve from the paginated list of time entries."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-change-time-entries'."]:
    """Retrieve time entries for a specific Change request.

    Use this tool to get the time entries associated with a particular Change request in Freshservice by providing the Change ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/time_entries".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
        ),
        method="GET",
        params=remove_none_values({
            "per_page": time_entries_per_page,
            "page": page_number_to_retrieve,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_change_request_time_entry(
    context: ToolContext,
    change_request_id: Annotated[
        int,
        "The ID of the Change request to retrieve the time entry from. This must be an integer.",
    ],
    time_entry_id: Annotated[
        int, "The numeric ID of the time entry to retrieve details for from a Change request."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-change-time-entry'."]:
    """Retrieve a time entry from a Change request by ID.

    Use this tool to obtain information about a specific time entry associated with a Change request in Freshservice by providing the change ID and time entry ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            time_entry_id=time_entry_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_change_time_entry_freshservice(
    context: ToolContext,
    change_request_id: Annotated[
        int,
        "The unique identifier of the Change request from which the time entry will be deleted. This integer ID specifies the specific change.",  # noqa: E501
    ],
    time_entry_id: Annotated[
        int,
        "ID of the time entry to be deleted from the Change request in Freshservice. Integer value expected.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-change-time-entry'."]:
    """Delete a time entry from a Change request in Freshservice.

    Use this tool to delete a specific time entry associated with a Change request in Freshservice. Provide the Change ID and the Time Entry ID to perform the deletion."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/changes/{change_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            change_id=change_request_id,
            time_entry_id=time_entry_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_all_projects(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Specify the number of project entries to retrieve per page for pagination."
    ] = 30,
    page_number: Annotated[
        int | None, "Specify the page number to retrieve in a paginated list of projects."
    ] = 1,
    project_status_filter: Annotated[
        str | None, "Filter projects by status: 'all', 'open', 'in_progress', or 'completed'."
    ] = "all",
    filter_archived_projects: Annotated[
        bool | None, "If true, filter for archived projects; if false, filter for active projects."
    ] = False,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-projects'."]:
    """Retrieve a list of all projects in Freshservice.

    Call this tool to get a comprehensive list of all projects managed within the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number,
            "status": project_status_filter,
            "archived": filter_archived_projects,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_freshservice_project(
    context: ToolContext,
    project_id: Annotated[
        int, "The unique integer ID of the project to retrieve from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-project'."]:
    """Retrieve project details from Freshservice by ID.

    Use this tool to access project information from Freshservice by providing the project ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{project_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            project_id=project_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_freshservice_project(
    context: ToolContext,
    project_id: Annotated[
        int,
        "The ID of the project in Freshservice to delete. This should be an integer representing the specific project you wish to remove.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-project'."]:
    """Deletes a project in Freshservice by ID.

    Use this tool to delete an existing project in Freshservice by providing the project ID. It is called when a user wants to remove a project from their Freshservice account."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{project_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            project_id=project_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def archive_project(
    context: ToolContext,
    project_id: Annotated[
        int, "The unique ID of the project to be archived in Freshservice. Provide a valid integer."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'archive-project'."]:
    """Archive an existing project in Freshservice.

    Use this tool to archive a specified project in Freshservice. This is useful when a project is completed or no longer active and you want to store it without deletion."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{id}/archive".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), id=project_id
        ),
        method="POST",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def restore_archived_project(
    context: ToolContext,
    project_id: Annotated[
        int,
        "The identifier of the archived project to be restored in Freshservice. It should be an integer value.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'restore-project'."]:
    """Restores an archived project in Freshservice.

    Use this tool to unarchive and restore a project that has been previously archived in Freshservice. Ideal for retrieving projects that need to be active again."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{id}/restore".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), id=project_id
        ),
        method="POST",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_project_tasks(
    context: ToolContext,
    project_id: Annotated[int, "The ID of the project for which you want to retrieve tasks."],
    entries_per_page: Annotated[
        int | None, "The number of entries to retrieve in each page for pagination."
    ] = 30,
    page_number: Annotated[
        int | None, "The specific page number of the task list to retrieve."
    ] = 1,
    task_filter: Annotated[
        str | None,
        "Filter tasks by status. Options: all, open, in_progress, completed, overdue, unassigned.",
    ] = "all",
    task_parent_id: Annotated[
        int | None, "Filter tasks by parent ID for specific task hierarchy or relationships."
    ] = None,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-project-tasks'."]:
    """Retrieve a list of all project tasks in Freshservice.

    Use this tool to get all tasks associated with a specific project in Freshservice. Ideal for accessing detailed task information or project management purposes."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{id}/tasks".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"), id=project_id
        ),
        method="GET",
        params=remove_none_values({
            "per_page": entries_per_page,
            "page": page_number,
            "filter": task_filter,
            "parent_id": task_parent_id,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_project_task_details(
    context: ToolContext,
    task_id: Annotated[int, "The unique identifier for the task to retrieve details."],
    project_id: Annotated[int, "The unique identifier for the project to which the task belongs."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-project-task'."]:
    """Retrieve detailed information about a project task in Freshservice.

    Use this tool to get comprehensive details about a specific task within a project on Freshservice, including its status, assigned personnel, and other relevant information."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{project_id}/tasks/{id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            id=task_id,
            project_id=project_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_project_task(
    context: ToolContext,
    project_identifier: Annotated[
        int,
        "The unique identifier for the project containing the task to be deleted. This is required to specify which project's task needs to be removed.",  # noqa: E501
    ],
    task_id_to_delete: Annotated[
        int, "ID of the task to be deleted from a project in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-project-task'."]:
    """Deletes a specified project task in Freshservice.

    Use this tool to remove an existing project task from a Freshservice project when you need to manage or clean up tasks."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/projects/{project_id}/tasks/{id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            project_id=project_identifier,
            id=task_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_change_form_fields(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-change-form-fields'."]:
    """Retrieve all fields in the Change Object of Freshservice.

    Call this tool to obtain a list of all fields that make up the Change Object in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/change_form_fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_release_form_fields(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-release-form-fields'."]:
    """Retrieve all fields of the release object form.

    Use this tool to obtain all the fields that constitute a release object in the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/release_form_fields".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_freshservice_announcements(
    context: ToolContext,
    announcement_state: Annotated[
        str | None,
        "Specify the state of the announcements to retrieve: archived, active, scheduled, or unread.",  # noqa: E501
    ] = None,
    announcements_per_page: Annotated[
        int | None, "Specify the number of announcements to retrieve per page for pagination."
    ] = 30,
    retrieve_page_number: Annotated[
        int | None,
        "Specify the page number of announcements to retrieve. Useful for navigating through paginated results.",  # noqa: E501
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-announcement'."]:
    """Retrieve all announcements from Freshservice.

    Use this tool to get a list of all announcements available in Freshservice. It should be called when you need to display or review information about current announcements."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/announcements".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "state": announcement_state,
            "per_page": announcements_per_page,
            "page": retrieve_page_number,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_announcement_details(
    context: ToolContext,
    announcement_id: Annotated[
        int, "The unique integer ID of the announcement to retrieve from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-announcement'."]:
    """Retrieve specific announcement details from Freshservice.

    Use this tool to fetch details of a specific announcement using its ID in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/announcements/{announcement_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            announcement_id=announcement_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_freshservice_announcement(
    context: ToolContext,
    announcement_id_to_delete: Annotated[
        int, "The ID of the announcement to delete from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-announcement'."]:
    """Delete a specific announcement from Freshservice.

    Use this tool to delete an announcement in Freshservice by providing its ID. Useful for managing and removing outdated or incorrect announcements."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/announcements/{announcement_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            announcement_id=announcement_id_to_delete,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_freshservice_problems(
    context: ToolContext,
    updated_since: Annotated[
        str | None, "Retrieve problems updated since the specified date. Format: YYYY-MM-DD."
    ] = None,
    problems_per_page: Annotated[
        int | None,
        "The number of problems to retrieve per page in a paginated list from Freshservice.",
    ] = 30,
    page_number_to_retrieve: Annotated[
        int | None, "The page number of the problems list to retrieve from Freshservice."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-problems'."]:
    """Retrieve all problems from Freshservice.

    Call this tool to get a list of all problems currently recorded in Freshservice, useful for tracking and management purposes."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "updated_since": updated_since,
            "per_page": problems_per_page,
            "page": page_number_to_retrieve,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_freshservice_problem(
    context: ToolContext,
    problem_identifier: Annotated[
        int, "The unique ID of the problem in Freshservice to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-problem'."]:
    """Retrieve a specific problem in Freshservice by ID.

    This tool fetches the details of a problem from Freshservice using the problem ID. It should be called when there's a need to access information about a particular problem within Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problem/{problem_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_problem(
    context: ToolContext,
    problem_id: Annotated[int, "The unique ID of the problem to delete from Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-problem'."]:
    """Delete a problem using its ID from Freshservice.

    Use this tool to delete a problem from Freshservice by providing its unique ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problem/{problem_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_problem_notes(
    context: ToolContext,
    problem_id: Annotated[
        int,
        "The unique integer ID of the problem for which you want to retrieve notes from Freshservice.",  # noqa: E501
    ],
    notes_per_page: Annotated[
        int | None, "The number of notes to retrieve per page in the paginated results."
    ] = 30,
    page_number: Annotated[
        int | None, "The page number of the notes to retrieve for pagination purposes."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-problem-notes'."]:
    """Retrieve notes for a specific problem ID in Freshservice.

    This tool retrieves the notes for a problem specified by its ID from Freshservice. It should be called when you need to access detailed notes or updates associated with a particular problem in the Freshservice system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/notes".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": notes_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_problem_note(
    context: ToolContext,
    problem_identifier: Annotated[
        int, "The unique ID of the problem to retrieve the note from. Must be an integer."
    ],
    note_id: Annotated[int, "The unique identifier for the note to be retrieved."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-problem-note'."]:
    """Retrieve a specific note from a problem in Freshservice.

    This tool retrieves a specific note from a problem in Freshservice using the problem and note IDs. It should be called when you need to access detailed information about a note associated with a specific problem."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_identifier,
            note_id=note_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_problem_note(
    context: ToolContext,
    problem_id: Annotated[
        int,
        "The unique identifier for the problem from which the note will be deleted. This should be an integer corresponding to the specific problem in Freshservice.",  # noqa: E501
    ],
    note_id: Annotated[
        int, "The unique identifier for the note to be deleted from a problem in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-problem-note'."]:
    """Delete a note from a specific problem in Freshservice.

    Use this tool to delete a note associated with a specific problem in Freshservice by providing the problem and note IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
            note_id=note_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_problem_tasks(
    context: ToolContext,
    problem_id: Annotated[
        int, "The ID of the problem for which tasks need to be retrieved from Freshservice."
    ],
    tasks_per_page: Annotated[
        int | None, "Specify the number of tasks to retrieve per page for pagination."
    ] = 10,
    page_number: Annotated[int | None, "The specific page number of tasks to retrieve."] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-problem-tasks'."]:
    """Retrieve tasks for a specific problem from Freshservice.

    Use this tool to get a list of tasks associated with a specific problem by providing the problem ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/tasks".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": tasks_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_problem_task(
    context: ToolContext,
    problem_id: Annotated[
        int, "The unique integer ID of the problem to retrieve the task from in Freshservice."
    ],
    task_id: Annotated[
        int, "The unique identifier for the task to retrieve from the specified problem."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-problem-task'."]:
    """Retrieve details of a specific task from a problem in Freshservice.

    Use this tool to get information about a specific task linked to a problem in Freshservice using the task and problem IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
            task_id=task_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_problem_task(
    context: ToolContext,
    problem_id: Annotated[int, "The unique ID of the problem from which the task will be deleted."],
    task_id: Annotated[int, "The unique identifier of the task to be deleted in Freshservice."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-problem-task'."]:
    """Delete a task from a problem in Freshservice.

    Use this tool to delete a specific task associated with a problem in Freshservice by providing the problem ID and task ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
            task_id=task_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_problem_time_entries(
    context: ToolContext,
    problem_id: Annotated[
        int,
        "ID of the problem for which time entries need to be retrieved. This is an integer value.",
    ],
    entries_per_page: Annotated[
        int | None, "The number of time entries to retrieve per page in a paginated list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve in the paginated list of time entries."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-problem-time-entries'."]:
    """Retrieve time entries for a specific problem by ID.

    Use this tool to get the time entries associated with a problem by providing its ID. Useful for tracking and managing the time spent on problem resolution."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/time_entries".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_problem_time_entry(
    context: ToolContext,
    problem_id: Annotated[
        int, "The unique identifier for the problem to retrieve a time entry from in Freshservice."
    ],
    time_entry_id: Annotated[int, "The unique integer ID of the time entry to be retrieved."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-problem-time-entry'."]:
    """Retrieve time entry details for a specific problem.

    Use this tool to obtain information about a particular time entry associated with a problem in Freshservice. This can be useful for tracking time spent on solving issues."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_id,
            time_entry_id=time_entry_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_problem_time_entry(
    context: ToolContext,
    problem_identifier: Annotated[
        int, "The unique ID representing the problem from which you want to delete a time entry."
    ],
    time_entry_id: Annotated[
        int, "The unique identifier for the time entry to be deleted from the specified problem."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-problem-time-entry'."]:
    """Delete a time entry from a specified problem in Freshservice.

    Use this tool to delete a time entry associated with a specific problem in Freshservice. Call it when you need to remove a recorded time entry from a problem."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/problems/{problem_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            problem_id=problem_identifier,
            time_entry_id=time_entry_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_user_onboarding_requests(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-onboarding-requests'."]:
    """Retrieve onboarding requests for a user.

    This tool fetches all onboarding requests related to a specific user from Freshservice. It should be called when you need to view or manage a user's onboarding process and details."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/onboarding_requests".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_onboarding_request(
    context: ToolContext,
    onboarding_request_id: Annotated[
        int, "The unique display ID of the onboarding request to retrieve details for."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-onboarding-request'."]:
    """Retrieve details of a specific onboarding request.

    Call this tool to get information about a specific onboarding request using its ID. Useful for accessing details related to employee onboarding processes."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/onboarding_requests/{request_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            request_id=onboarding_request_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_onboarding_request_tickets(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-onboarding-request-tickets'."]:
    """Retrieve FreshService Tickets for a specific Onboarding Request.

    Use this tool to get detailed information about the FreshService Tickets linked to a specific Onboarding Request. It's useful for tracking the progress and details of onboarding activities."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/onboarding_requests/id/tickets".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_canned_responses(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-canned-responses'."]:
    """Retrieve all canned responses from Freshservice.

    Call this tool to retrieve a list of all available canned responses stored in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_responses".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_canned_response(
    context: ToolContext,
    canned_response_id: Annotated[
        int, "The unique ID of the Canned Response you want to retrieve from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-canned-response'."]:
    """Retrieve a specific Canned Response by ID from Freshservice.

    Call this tool to get details of a specific Canned Response using its ID. Useful for accessing predefined responses in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response/{canned_response_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            canned_response_id=canned_response_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_canned_response(
    context: ToolContext,
    canned_response_id: Annotated[
        int, "The unique integer ID of the canned response to delete from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-canned-response'."]:
    """Delete a specific canned response from Freshservice.

    Use this tool to delete a canned response from Freshservice by providing its unique ID."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response/{canned_response_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            canned_response_id=canned_response_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_freshservice_canned_response_folders(
    context: ToolContext,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-canned-response-folders'."]:
    """Retrieve all canned response folders from Freshservice.

    Use this tool to retrieve a list of all canned response folders available in Freshservice. This can be useful for managing quick reply templates or automated responses within the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response_folders".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_canned_response_folder(
    context: ToolContext,
    canned_response_folder_id: Annotated[
        int,
        "The ID of the canned response folder to retrieve from Freshservice. It should be an integer.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-canned-response-folder'."]:
    """Retrieve a specific canned response folder from Freshservice.

    Use this tool to fetch details of a specific canned response folder in Freshservice by providing the folder ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response_folder/{canned_response_folder_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            canned_response_folder_id=canned_response_folder_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_canned_response_folder(
    context: ToolContext,
    canned_response_folder_id: Annotated[
        int,
        "ID of the canned response folder to delete. This is required to identify which folder should be removed from Freshservice.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-caned-response-folder'."]:
    """Delete a Canned Response Folder in Freshservice.

    Use this tool to delete a specified Canned Response Folder by its ID in Freshservice. This is useful for managing your canned responses by removing folders that are no longer needed."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response_folder/{canned_response_folder_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            canned_response_folder_id=canned_response_folder_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_canned_responses(
    context: ToolContext,
    canned_response_folder_id: Annotated[
        int, "ID of the canned response folder to retrieve responses from."
    ],
) -> Annotated[
    dict[str, Any],
    "Response from the API endpoint 'list-canned-response-folders-canned-responses'.",
]:
    """Retrieve all canned responses from a specified folder.

    This tool fetches all available canned responses within a specified canned response folder in Freshservice. It is useful for accessing pre-defined replies for ticket responses."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/canned_response_folders/{canned_response_folder_id}/canned_responses".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            canned_response_folder_id=canned_response_folder_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_releases_list(
    context: ToolContext,
    fetch_releases_updated_since: Annotated[
        str | None, "Retrieve releases updated since a specific date in YYYY-MM-DD format."
    ] = None,
    releases_per_page: Annotated[
        int | None, "The number of releases to retrieve per page in the paginated list."
    ] = 30,
    page_number_to_retrieve: Annotated[
        int | None, "Specify the page number of release data to retrieve for pagination."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-releases'."]:
    """Retrieve a list of all Releases in Freshservice.

    Use this tool to get information on all current and past releases managed within Freshservice. It should be called when there's a need to gather release details for projects or updates."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({
            "updated_since": fetch_releases_updated_since,
            "per_page": releases_per_page,
            "page": page_number_to_retrieve,
        }),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_release_details(
    context: ToolContext,
    release_identifier: Annotated[
        int,
        "The ID of the release you want to retrieve from Freshservice. Provide the specific release ID as an integer to get its details.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-release'."]:
    """Retrieve details of a specific release by ID in Freshservice.

    Use this tool to get information about a release from Freshservice by providing the release ID. It fetches the release details from the Freshservice platform."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/release/{release_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_identifier,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_freshservice_release(
    context: ToolContext,
    release_id_for_deletion: Annotated[
        int, "The unique integer ID of the release to delete from Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-release'."]:
    """Delete a specific release in Freshservice.

    Use this tool to delete a release from Freshservice by providing the release ID. It is useful for managing releases and ensuring outdated or incorrect entries are removed from the system."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/release/{release_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id_for_deletion,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_release_notes(
    context: ToolContext,
    release_id: Annotated[int, "The ID of the release for which notes are to be retrieved."],
    notes_per_page: Annotated[
        int | None, "The number of release notes to retrieve in each page."
    ] = 30,
    retrieve_page_number: Annotated[
        int | None,
        "The specific page number of release notes to retrieve. Useful for paginated results.",
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-release-note'."]:
    """Retrieve release notes from Freshservice using a release ID.

    Use this tool to get the notes associated with a specific release in Freshservice by providing the release ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/notes".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": notes_per_page, "page": retrieve_page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_release_note(
    context: ToolContext,
    release_id: Annotated[
        int,
        "The unique integer ID representing the release in Freshservice to retrieve the note from.",
    ],
    note_id: Annotated[
        int, "The unique identifier for the note to be retrieved. It must be an integer."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-release-note'."]:
    """Retrieve a note on a release by ID from Freshservice.

    Call this tool to get details of a specific note from a release by providing the release ID and note ID in Freshservice."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            note_id=note_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_release_note_freshservice(
    context: ToolContext,
    release_id: Annotated[
        int,
        "The numeric ID of the release from which the note will be deleted. This ID is required to identify the specific release in Freshservice.",  # noqa: E501
    ],
    note_id: Annotated[
        int, "The integer ID of the note to be deleted from the release in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-release-note'."]:
    """Deletes a note from a specified release in Freshservice.

    Use this tool to delete a note from a specific release in Freshservice by specifying the release and note IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/notes/{note_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            note_id=note_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_release_tasks(
    context: ToolContext,
    release_id: Annotated[
        int, "ID of the release for which tasks are to be retrieved in Freshservice."
    ],
    tasks_per_page: Annotated[
        int | None, "Number of tasks to retrieve per page in a paginated list."
    ] = 10,
    page_number: Annotated[
        int | None, "The page number to retrieve tasks from. Use for paginated results."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-release-tasks'."]:
    """Retrieve tasks for a specified release in Freshservice.

    Use this tool to get a list of tasks associated with a particular release ID in Freshservice."""
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/tasks".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": tasks_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def retrieve_release_task(
    context: ToolContext,
    release_id: Annotated[
        int,
        "The unique identifier for the release to retrieve a specific task from. This is an integer value.",  # noqa: E501
    ],
    task_id: Annotated[int, "The unique ID of the task you want to retrieve within a release."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-release-task'."]:
    """Retrieve a specific task from a release in Freshservice.

    Use this tool to get information about a particular task within a release by specifying the release and task IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            task_id=task_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_release_task(
    context: ToolContext,
    release_id: Annotated[
        int, "ID of the release from which the task will be deleted. This must be a valid integer."
    ],
    task_id_integer: Annotated[int, "The integer ID of the task to be deleted from the release."],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-release-task'."]:
    """Delete a task from a specified release in Freshservice.

    Use this tool to remove a specific task from a release in Freshservice when you have both the release and task IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/tasks/{task_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            task_id=task_id_integer,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_release_time_entries(
    context: ToolContext,
    release_id: Annotated[
        int,
        "The unique ID of the release for which time entries are to be retrieved in Freshservice.",
    ],
    entries_per_page: Annotated[
        int | None, "The number of time entries to retrieve per page in the paginated list."
    ] = 10,
    page_number_to_retrieve: Annotated[
        int | None, "The page number to retrieve in the paginated list of time entries."
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-release-time-entries'."]:
    """Retrieve time entries for a specific release in Freshservice.

    Use this tool to get detailed time entry information associated with a specific release ID from Freshservice. It should be called when you need to analyze or report on time logged for release activities."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/time_entries".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number_to_retrieve}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def fetch_release_time_entry(
    context: ToolContext,
    release_id: Annotated[
        int,
        "The unique integer ID of the release for which you want to fetch the time entry details. This identifies the specific release in Freshservice.",  # noqa: E501
    ],
    time_entry_id: Annotated[
        int, "The integer ID of the specific time entry you want to retrieve from a release."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-release-time-entry'."]:
    """Retrieve details of a release time entry by ID.

    Use this tool to obtain information about a specific time entry associated with a release by providing the release and time entry IDs."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            time_entry_id=time_entry_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_release_time_entry(
    context: ToolContext,
    release_id: Annotated[
        int, "The unique integer ID of the release from which to delete the time entry."
    ],
    time_entry_id: Annotated[
        int, "ID of the time entry to be deleted from the release in Freshservice."
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-release-time-entry'."]:
    """Delete a time entry from a release in Freshservice.

    Use this tool to delete a specific time entry from a release in Freshservice by providing the release and time entry IDs. Typically called when you need to manage or cleanup time entries associated with release records."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/releases/{release_id}/time_entries/{time_entry_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            release_id=release_id,
            time_entry_id=time_entry_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def list_purchase_orders(
    context: ToolContext,
    entries_per_page: Annotated[
        int | None, "Specify the number of entries to retrieve per page."
    ] = 10,
    page_number: Annotated[
        int | None,
        "Specify the page number to retrieve from the list of purchase orders. Useful for navigating paginated results.",  # noqa: E501
    ] = 1,
) -> Annotated[dict[str, Any], "Response from the API endpoint 'list-purchase-orders'."]:
    """Retrieve a list of all Purchase Orders from Freshservice.

    Use this tool to get a comprehensive list of all purchase orders stored in Freshservice. This can be useful for inventory management, procurement tracking, or financial analysis."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/purchase_orders".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN")
        ),
        method="GET",
        params=remove_none_values({"per_page": entries_per_page, "page": page_number}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def get_purchase_order(
    context: ToolContext,
    purchase_order_id: Annotated[
        int,
        "The unique identifier for the purchase order you wish to retrieve. This must be an integer.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'get-purchase-order'."]:
    """Retrieve details of an existing purchase order by ID.

    Use this tool to fetch the details of a specific purchase order using its ID. This is useful when you need to view or verify purchase order information."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/purchase_orders/{purchase_order_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            purchase_order_id=purchase_order_id,
        ),
        method="GET",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}


@tool(requires_secrets=["FRESHSERVICE_API_KEY", "FRESHSERVICE_SUBDOMAIN"])
async def delete_purchase_order(
    context: ToolContext,
    purchase_order_id: Annotated[
        int,
        "The unique ID of the purchase order to delete from Freshservice. This ID identifies the specific order to be removed.",  # noqa: E501
    ],
) -> Annotated[dict[str, Any], "Response from the API endpoint 'delete-purchase-order'."]:
    """Delete a specified purchase order in Freshservice.

    Use this tool to delete a purchase order from Freshservice by providing the purchase order ID."""  # noqa: E501
    response = await make_request(
        auth=(context.get_secret("FRESHSERVICE_API_KEY"), ""),
        url="https://{freshservice_subdomain}.freshservice.com/api/v2/purchase_orders/{purchase_order_id}".format(
            freshservice_subdomain=context.get_secret("FRESHSERVICE_SUBDOMAIN"),
            purchase_order_id=purchase_order_id,
        ),
        method="DELETE",
        params=remove_none_values({}),
        headers=remove_none_values({}),
        data=remove_none_values({}),
    )
    try:
        return {"response_json": response.json()}
    except Exception:
        return {"response_text": response.text}
