[FEATURE]
Problem Statement In order to provide entitlements when creating a new user using the SDK, one must pass a List of ComplexValues, which looks like --
[
ComplexValue(value = "workspace-access"),
ComplexValue(value = "databricks-sql-access"),
ComplexValue(value = "allow-cluster-create")
]
There are two things to note in the current state of the docs -- For the underlying API call's documentation--https://docs.databricks.com/api/account/accountusers/create--, there is no mention of an entitlements parameter, so there is no guidance there on how to structure an entitlements request.
For the SDK itself, we have in the docstring for the UsersAPI.create function only the expected type, with no guidance on how to structure it correctly. Without looking at the source code, one wouldn't be aware that you could use the as_dict class method to construct the List more easily, e.g.
entitlements = [
ComplexValue.from_dict({
'value': value
}) for value in ["workspace-access", "databricks-sql-access", "allow-cluster-create"]
]
Proposed solution I would suggest that requiring users to structure a creation request in this way is strange--it would I think make more sense to handle conversion from SDK to API request structure in a way more friendly to the SDK user--taking in a list of strings and doing this conversion for them.
To generalize this more fully, as it is a repeated pattern across the SDK, I would suggest an auxiliary method or internal module to do conversion of simplified user input to the required format for the Databricks REST API.
I would further suggest extracting the hard-coded REST API endpoints as well as part of such a change, so that as the REST API evolves, evolving the Python SDK becomes simpler, e.g, res = self._api.do("POST", "/api/2.0/preview/scim/v2/Users", body=body, headers=headers).
This calls perhaps for a specification or map of class operations to API endpoints, and specification of required request structure and type conversion from ComplexValue to JSON-request syntax.