Skip to content

Project Group#

pyticktick.models.v2.parameters.project_group #

Parameters for creating and updating project groups via the V2 API.

Unofficial API

These models are part of the unofficial TickTick API. They were created by reverse engineering the API. They may be incomplete or inaccurate.

Classes:

Name Description
CreateProjectGroupV2

Model for creating a project group via the V2 API.

PostBatchProjectGroupV2

Model for batch project group operations via the V2 API.

UpdateProjectGroupV2

Model for updating a project group via the V2 API.

CreateProjectGroupV2 pydantic-model #

Bases: BaseModelV2

Model for creating a project group via the V2 API.

This model is used to create a project group via the V2 API. This is not currently documented or supported in the official API docs. This is used in the PostBatchProjectGroupV2 model.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Model for creating a project group via the V2 API.\n\nThis model is used to create a project group via the V2 API. This is not currently\ndocumented or supported in the official API docs. This is used in the\n`PostBatchProjectGroupV2` model.",
  "properties": {
    "name": {
      "description": "Name of the project group to create",
      "title": "Name",
      "type": "string"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "ID of the project group to create",
      "title": "Id"
    },
    "list_type": {
      "const": "group",
      "default": "group",
      "description": "Fixed value 'group'",
      "title": "List Type",
      "type": "string"
    }
  },
  "required": [
    "name"
  ],
  "title": "CreateProjectGroupV2",
  "type": "object"
}

Fields:

Validators:

id pydantic-field #

id: ObjectId | None = None

ID of the project group to create

list_type pydantic-field #

list_type: Literal['group'] = 'group'

Fixed value 'group'

name pydantic-field #

name: str

Name of the project group to create

empty_str_to_none pydantic-validator #

empty_str_to_none(v: Any) -> Any

Convert empty strings to None.

TickTick API responses sometimes conflates None and empty strings for optional fields. This validator ensures that empty strings are converted to None, which then allows for more consistent handling of the data within the library.

Parameters:

Name Type Description Default
v Any

The value to validate.

required

Returns:

Name Type Description
Any Any

The input value if it is not an empty string, otherwise None.

Source code in src/pyticktick/models/v2/models.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@field_validator("*", mode="before")
@classmethod
def empty_str_to_none(cls, v: Any) -> Any:
    """Convert empty strings to None.

    TickTick API responses sometimes conflates `None` and empty strings for
    optional fields. This validator ensures that empty strings are converted to
    `None`, which then allows for more consistent handling of the data within the
    library.

    Args:
        v (Any): The value to validate.

    Returns:
        Any: The input value if it is not an empty string, otherwise `None`.
    """
    if isinstance(v, str) and len(v) == 0:
        return None
    return v

override_forbid_extra_message_injector pydantic-validator #

override_forbid_extra_message_injector(
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2

Provide a better error message for extra fields.

The TickTick V2 API is unofficial and may change without notice. As such, the models may not always be up to date with the API. This validator catches the extra_forbidden errors and provides a more informative error message, including a link to the documentation on how to override the extra_forbidden behavior if needed.

Parameters:

Name Type Description Default
data Any

The input data to validate.

required
handler ModelWrapValidatorHandler[BaseModelV2]

The handler to call the next validator in the chain.

required

Raises:

Type Description
ValidationError

If the pydantic model fails validation for any reason.

Returns:

Name Type Description
BaseModelV2 BaseModelV2

The validated model instance.

Source code in src/pyticktick/models/v2/models.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@model_validator(mode="wrap")
@classmethod
def override_forbid_extra_message_injector(
    cls,
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2:
    """Provide a better error message for extra fields.

    The TickTick V2 API is unofficial and may change without notice. As such, the
    models may not always be up to date with the API. This validator catches the
    `extra_forbidden` errors and provides a more informative error message,
    including a link to the documentation on how to override the `extra_forbidden`
    behavior if needed.

    Args:
        data (Any): The input data to validate.
        handler (ModelWrapValidatorHandler[BaseModelV2]): The handler to call the
            next validator in the chain.

    Raises:
        ValidationError: If the pydantic model fails validation for any reason.

    Returns:
        BaseModelV2: The validated model instance.
    """  # noqa: DOC501, DOC502 # ruff thinks `from_exception_data` should be raised instead of `ValidationError`
    try:
        return handler(data)
    except ValidationError as e:
        errors = []
        for error_dict in e.errors():
            if error_dict.get("type") in (
                "extra_forbidden",
                "custom_pyticktick_extra_forbidden",
            ):
                _type: str | PydanticCustomError = PydanticCustomError(
                    "custom_pyticktick_extra_forbidden",
                    f"Extra inputs are not permitted by default for `{cls.__name__}`. Please set `override_forbid_extra` to `True` if you believe the TickTick API has diverged from the model. See https://pyticktick.pretzer.io/guides/settings/overriding_models_that_forbid_extra_fields/ for more information.",  # pyright: ignore[reportArgumentType] # ty: ignore[invalid-argument-type]
                )
            else:
                _type = error_dict["type"]

            init_error_details: InitErrorDetails = {
                "type": _type,
                "input": error_dict["input"],
            }
            if "loc" in error_dict:
                init_error_details["loc"] = error_dict["loc"]
            if "ctx" in error_dict:
                init_error_details["ctx"] = error_dict["ctx"]

            errors.append(init_error_details)

        raise ValidationError.from_exception_data(e.title, errors) from e

PostBatchProjectGroupV2 pydantic-model #

Bases: BaseModelV2

Model for batch project group operations via the V2 API.

This model is used to batch create, update, and delete project groups in bulk against the V2 API endpoint POST /batch/projectGroup.

Show JSON schema:
{
  "$defs": {
    "CreateProjectGroupV2": {
      "additionalProperties": false,
      "description": "Model for creating a project group via the V2 API.\n\nThis model is used to create a project group via the V2 API. This is not currently\ndocumented or supported in the official API docs. This is used in the\n`PostBatchProjectGroupV2` model.",
      "properties": {
        "name": {
          "description": "Name of the project group to create",
          "title": "Name",
          "type": "string"
        },
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "ID of the project group to create",
          "title": "Id"
        },
        "list_type": {
          "const": "group",
          "default": "group",
          "description": "Fixed value 'group'",
          "title": "List Type",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "title": "CreateProjectGroupV2",
      "type": "object"
    },
    "UpdateProjectGroupV2": {
      "additionalProperties": false,
      "description": "Model for updating a project group via the V2 API.\n\nThis model is used to update a project group via the V2 API. This is not currently\ndocumented or supported in the official API docs. This is used in the\n`PostBatchProjectGroupV2` model.",
      "properties": {
        "name": {
          "description": "Name of the project group to update",
          "title": "Name",
          "type": "string"
        },
        "id": {
          "description": "ID of the project group to update",
          "title": "Id",
          "type": "string"
        },
        "list_type": {
          "const": "group",
          "default": "group",
          "description": "Fixed value 'group'",
          "title": "List Type",
          "type": "string"
        }
      },
      "required": [
        "name",
        "id"
      ],
      "title": "UpdateProjectGroupV2",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "Model for batch project group operations via the V2 API.\n\nThis model is used to batch create, update, and delete project groups in bulk\nagainst the V2 API endpoint `POST /batch/projectGroup`.",
  "properties": {
    "add": {
      "default": [],
      "description": "List of project groups to add",
      "items": {
        "$ref": "#/$defs/CreateProjectGroupV2"
      },
      "title": "Add",
      "type": "array"
    },
    "delete": {
      "default": [],
      "description": "List of project group IDs to delete",
      "items": {
        "type": "string"
      },
      "title": "Delete",
      "type": "array"
    },
    "update": {
      "default": [],
      "description": "List of project groups to update",
      "items": {
        "$ref": "#/$defs/UpdateProjectGroupV2"
      },
      "title": "Update",
      "type": "array"
    }
  },
  "title": "PostBatchProjectGroupV2",
  "type": "object"
}

Fields:

Validators:

add pydantic-field #

add: list[CreateProjectGroupV2] = []

List of project groups to add

delete pydantic-field #

delete: list[ObjectId] = []

List of project group IDs to delete

update pydantic-field #

update: list[UpdateProjectGroupV2] = []

List of project groups to update

empty_str_to_none pydantic-validator #

empty_str_to_none(v: Any) -> Any

Convert empty strings to None.

TickTick API responses sometimes conflates None and empty strings for optional fields. This validator ensures that empty strings are converted to None, which then allows for more consistent handling of the data within the library.

Parameters:

Name Type Description Default
v Any

The value to validate.

required

Returns:

Name Type Description
Any Any

The input value if it is not an empty string, otherwise None.

Source code in src/pyticktick/models/v2/models.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@field_validator("*", mode="before")
@classmethod
def empty_str_to_none(cls, v: Any) -> Any:
    """Convert empty strings to None.

    TickTick API responses sometimes conflates `None` and empty strings for
    optional fields. This validator ensures that empty strings are converted to
    `None`, which then allows for more consistent handling of the data within the
    library.

    Args:
        v (Any): The value to validate.

    Returns:
        Any: The input value if it is not an empty string, otherwise `None`.
    """
    if isinstance(v, str) and len(v) == 0:
        return None
    return v

override_forbid_extra_message_injector pydantic-validator #

override_forbid_extra_message_injector(
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2

Provide a better error message for extra fields.

The TickTick V2 API is unofficial and may change without notice. As such, the models may not always be up to date with the API. This validator catches the extra_forbidden errors and provides a more informative error message, including a link to the documentation on how to override the extra_forbidden behavior if needed.

Parameters:

Name Type Description Default
data Any

The input data to validate.

required
handler ModelWrapValidatorHandler[BaseModelV2]

The handler to call the next validator in the chain.

required

Raises:

Type Description
ValidationError

If the pydantic model fails validation for any reason.

Returns:

Name Type Description
BaseModelV2 BaseModelV2

The validated model instance.

Source code in src/pyticktick/models/v2/models.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@model_validator(mode="wrap")
@classmethod
def override_forbid_extra_message_injector(
    cls,
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2:
    """Provide a better error message for extra fields.

    The TickTick V2 API is unofficial and may change without notice. As such, the
    models may not always be up to date with the API. This validator catches the
    `extra_forbidden` errors and provides a more informative error message,
    including a link to the documentation on how to override the `extra_forbidden`
    behavior if needed.

    Args:
        data (Any): The input data to validate.
        handler (ModelWrapValidatorHandler[BaseModelV2]): The handler to call the
            next validator in the chain.

    Raises:
        ValidationError: If the pydantic model fails validation for any reason.

    Returns:
        BaseModelV2: The validated model instance.
    """  # noqa: DOC501, DOC502 # ruff thinks `from_exception_data` should be raised instead of `ValidationError`
    try:
        return handler(data)
    except ValidationError as e:
        errors = []
        for error_dict in e.errors():
            if error_dict.get("type") in (
                "extra_forbidden",
                "custom_pyticktick_extra_forbidden",
            ):
                _type: str | PydanticCustomError = PydanticCustomError(
                    "custom_pyticktick_extra_forbidden",
                    f"Extra inputs are not permitted by default for `{cls.__name__}`. Please set `override_forbid_extra` to `True` if you believe the TickTick API has diverged from the model. See https://pyticktick.pretzer.io/guides/settings/overriding_models_that_forbid_extra_fields/ for more information.",  # pyright: ignore[reportArgumentType] # ty: ignore[invalid-argument-type]
                )
            else:
                _type = error_dict["type"]

            init_error_details: InitErrorDetails = {
                "type": _type,
                "input": error_dict["input"],
            }
            if "loc" in error_dict:
                init_error_details["loc"] = error_dict["loc"]
            if "ctx" in error_dict:
                init_error_details["ctx"] = error_dict["ctx"]

            errors.append(init_error_details)

        raise ValidationError.from_exception_data(e.title, errors) from e

UpdateProjectGroupV2 pydantic-model #

Bases: BaseModelV2

Model for updating a project group via the V2 API.

This model is used to update a project group via the V2 API. This is not currently documented or supported in the official API docs. This is used in the PostBatchProjectGroupV2 model.

Show JSON schema:
{
  "additionalProperties": false,
  "description": "Model for updating a project group via the V2 API.\n\nThis model is used to update a project group via the V2 API. This is not currently\ndocumented or supported in the official API docs. This is used in the\n`PostBatchProjectGroupV2` model.",
  "properties": {
    "name": {
      "description": "Name of the project group to update",
      "title": "Name",
      "type": "string"
    },
    "id": {
      "description": "ID of the project group to update",
      "title": "Id",
      "type": "string"
    },
    "list_type": {
      "const": "group",
      "default": "group",
      "description": "Fixed value 'group'",
      "title": "List Type",
      "type": "string"
    }
  },
  "required": [
    "name",
    "id"
  ],
  "title": "UpdateProjectGroupV2",
  "type": "object"
}

Fields:

Validators:

id pydantic-field #

id: ObjectId

ID of the project group to update

list_type pydantic-field #

list_type: Literal['group'] = 'group'

Fixed value 'group'

name pydantic-field #

name: str

Name of the project group to update

empty_str_to_none pydantic-validator #

empty_str_to_none(v: Any) -> Any

Convert empty strings to None.

TickTick API responses sometimes conflates None and empty strings for optional fields. This validator ensures that empty strings are converted to None, which then allows for more consistent handling of the data within the library.

Parameters:

Name Type Description Default
v Any

The value to validate.

required

Returns:

Name Type Description
Any Any

The input value if it is not an empty string, otherwise None.

Source code in src/pyticktick/models/v2/models.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@field_validator("*", mode="before")
@classmethod
def empty_str_to_none(cls, v: Any) -> Any:
    """Convert empty strings to None.

    TickTick API responses sometimes conflates `None` and empty strings for
    optional fields. This validator ensures that empty strings are converted to
    `None`, which then allows for more consistent handling of the data within the
    library.

    Args:
        v (Any): The value to validate.

    Returns:
        Any: The input value if it is not an empty string, otherwise `None`.
    """
    if isinstance(v, str) and len(v) == 0:
        return None
    return v

override_forbid_extra_message_injector pydantic-validator #

override_forbid_extra_message_injector(
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2

Provide a better error message for extra fields.

The TickTick V2 API is unofficial and may change without notice. As such, the models may not always be up to date with the API. This validator catches the extra_forbidden errors and provides a more informative error message, including a link to the documentation on how to override the extra_forbidden behavior if needed.

Parameters:

Name Type Description Default
data Any

The input data to validate.

required
handler ModelWrapValidatorHandler[BaseModelV2]

The handler to call the next validator in the chain.

required

Raises:

Type Description
ValidationError

If the pydantic model fails validation for any reason.

Returns:

Name Type Description
BaseModelV2 BaseModelV2

The validated model instance.

Source code in src/pyticktick/models/v2/models.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@model_validator(mode="wrap")
@classmethod
def override_forbid_extra_message_injector(
    cls,
    data: Any,
    handler: ModelWrapValidatorHandler[BaseModelV2],
) -> BaseModelV2:
    """Provide a better error message for extra fields.

    The TickTick V2 API is unofficial and may change without notice. As such, the
    models may not always be up to date with the API. This validator catches the
    `extra_forbidden` errors and provides a more informative error message,
    including a link to the documentation on how to override the `extra_forbidden`
    behavior if needed.

    Args:
        data (Any): The input data to validate.
        handler (ModelWrapValidatorHandler[BaseModelV2]): The handler to call the
            next validator in the chain.

    Raises:
        ValidationError: If the pydantic model fails validation for any reason.

    Returns:
        BaseModelV2: The validated model instance.
    """  # noqa: DOC501, DOC502 # ruff thinks `from_exception_data` should be raised instead of `ValidationError`
    try:
        return handler(data)
    except ValidationError as e:
        errors = []
        for error_dict in e.errors():
            if error_dict.get("type") in (
                "extra_forbidden",
                "custom_pyticktick_extra_forbidden",
            ):
                _type: str | PydanticCustomError = PydanticCustomError(
                    "custom_pyticktick_extra_forbidden",
                    f"Extra inputs are not permitted by default for `{cls.__name__}`. Please set `override_forbid_extra` to `True` if you believe the TickTick API has diverged from the model. See https://pyticktick.pretzer.io/guides/settings/overriding_models_that_forbid_extra_fields/ for more information.",  # pyright: ignore[reportArgumentType] # ty: ignore[invalid-argument-type]
                )
            else:
                _type = error_dict["type"]

            init_error_details: InitErrorDetails = {
                "type": _type,
                "input": error_dict["input"],
            }
            if "loc" in error_dict:
                init_error_details["loc"] = error_dict["loc"]
            if "ctx" in error_dict:
                init_error_details["ctx"] = error_dict["ctx"]

            errors.append(init_error_details)

        raise ValidationError.from_exception_data(e.title, errors) from e