Skip to content

anytype.Tag

Bases: APIWrapper

Source code in anytype/tag.py
class Tag(APIWrapper):
    def __init__(self):
        self.space_id: str = ""
        self._property_id: str = ""
        self.color: str = ""
        self.name: str = ""
        self.id: str = ""
        self.key: str = ""

    @requires_auth
    def update_tag(self, name: str, color: str = "red"):
        """
        Updates the name of an existing tag.
        Parameters:
            tag_id (str): The ID of the tag to update.
            name (str): The new name for the tag.
        Returns:
            A Tag instance representing the updated tag.
        Raises:
            Raises an error if the request to the API fails.
        """
        data = {"name": name, "color": color}
        response = self._apiEndpoints.updateTag(self.space_id, self._property_id, self.id, data)
        tag = Tag._from_api(
            self._apiEndpoints, response.get("tag", []) | {"space_id": self.space_id}
        )
        return tag

    @requires_auth
    def delete_tag(self) -> None:
        """
        Deletes a tag by its ID.

        Returns:
            bool: True if the tag was successfully deleted, False otherwise.

        Raises:
            Raises an error if the request to the API fails.
        """
        _ = self._apiEndpoints.deleteTag(self.space_id, self._property_id, self.id)

    def __repr__(self):
        return f"<Tag(name={self.name})>"

delete_tag()

Deletes a tag by its ID.

Returns:

Name Type Description
bool None

True if the tag was successfully deleted, False otherwise.

Source code in anytype/tag.py
@requires_auth
def delete_tag(self) -> None:
    """
    Deletes a tag by its ID.

    Returns:
        bool: True if the tag was successfully deleted, False otherwise.

    Raises:
        Raises an error if the request to the API fails.
    """
    _ = self._apiEndpoints.deleteTag(self.space_id, self._property_id, self.id)

update_tag(name, color='red')

Updates the name of an existing tag. Parameters: tag_id (str): The ID of the tag to update. name (str): The new name for the tag. Returns: A Tag instance representing the updated tag. Raises: Raises an error if the request to the API fails.

Source code in anytype/tag.py
@requires_auth
def update_tag(self, name: str, color: str = "red"):
    """
    Updates the name of an existing tag.
    Parameters:
        tag_id (str): The ID of the tag to update.
        name (str): The new name for the tag.
    Returns:
        A Tag instance representing the updated tag.
    Raises:
        Raises an error if the request to the API fails.
    """
    data = {"name": name, "color": color}
    response = self._apiEndpoints.updateTag(self.space_id, self._property_id, self.id, data)
    tag = Tag._from_api(
        self._apiEndpoints, response.get("tag", []) | {"space_id": self.space_id}
    )
    return tag