diff --git a/README.md b/README.md index 7eb249d..1402c0c 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,18 @@ The `Client` is not specific to a project, but a default `project_id` can be set - An init argument: `Client(project_id=1)`. - A property on the client: `client.project_id = 1`. +*Default Identifiers* + +For each endpoint, a default can be set for key identifiers, so these identifiers are optional in most methods. When the identifier is required, validation ensures that either a default value is set, or a value is specified. E.g. + +```python +client.projects.default_project_id = 1 +client.forms.default_form_id = "my_form" +client.submissions.default_form_id = "my_form" +client.entities.default_entity_list_name = "my_list" +client.entities.default_project_id = 1 +``` + ### Session cache file The session cache file uses the TOML format. The default file name is `.pyodk_cache.toml`, and the default location is the user home directory. The file name and location can be customised by setting the environment variable `PYODK_CACHE_FILE` to some other file path, or by passing the path at init with `Client(config_path="my_cache.toml")`. This file should not be pre-created as it is used to store a session token after login. diff --git a/pyodk/_endpoints/entities.py b/pyodk/_endpoints/entities.py index 5db722d..31074ed 100644 --- a/pyodk/_endpoints/entities.py +++ b/pyodk/_endpoints/entities.py @@ -146,20 +146,20 @@ def create( def update( self, - label: str, - data: dict, uuid: str, - force: bool | None = None, - base_version: int | None = None, entity_list_name: str | None = None, project_id: int | None = None, + label: str | None = None, + data: dict | None = None, + force: bool | None = None, + base_version: int | None = None, ) -> Entity: """ Update an Entity. + :param uuid: The unique identifier for the Entity. :param label: Label of the Entity. :param data: Data to store for the Entity. - :param uuid: The unique identifier for the Entity. :param force: If True, update an Entity regardless of its current state. If `base_version` is not specified, then `force` must be True. :param base_version: The expected current version of the Entity on the server. If @@ -181,10 +181,11 @@ def update( params["baseVersion"] = pv.validate_int(base_version, key="base_version") if len([i for i in (force, base_version) if i is not None]) != 1: raise PyODKError("Must specify one of 'force' or 'base_version'.") # noqa: TRY301 - req_data = { - "label": pv.validate_str(label, key="label"), - "data": pv.validate_dict(data, key="data"), - } + req_data = {} + if label is not None: + req_data["label"] = pv.validate_str(label, key="label") + if data is not None: + req_data["data"] = pv.validate_dict(data, key="data") except PyODKError as err: log.error(err, exc_info=True) raise