api: Document DELETE ../users/{user_id} endpoint.

This adds deactivate_user to python_examples.py in zerver/openapi.
This also adds delete-user.md to templates/zerver/api and adds
delete-user to rest-endpoints.md (templates/zerver/help/include).
This commit is contained in:
akashaviator
2020-02-15 02:32:24 +05:30
committed by Tim Abbott
parent 08efb00321
commit dc6a5e3ca2
3 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# Deactivate a user
{!api-admin-only.md!}
[Deactivates a
user](https://zulipchat.com/help/deactivate-or-reactivate-a-user)
given their user ID.
`DELETE {{ api_url }}/v1/users/{user_id}`
## Usage examples
{start_tabs}
{tab|python}
{generate_code_example(python)|/users/{user_id}:delete|example}
{tab|curl}
{generate_code_example(curl)|/users/{user_id}:delete|example}
{end_tabs}
## Arguments
{generate_api_arguments_table|zulip.yaml|/users/{user_id}:delete}
## Response
#### Example response
A typical successful JSON response may look like:
{generate_code_example|/users/{user_id}:delete|fixture(200)}
An example JSON error response when attempting to deactivate the only
organization administrator:
{generate_code_example|/users/{user_id}:delete|fixture(400)}

View File

@@ -30,6 +30,7 @@
* [Get all users](/api/get-all-users) * [Get all users](/api/get-all-users)
* [Get a user](/api/get-user) * [Get a user](/api/get-user)
* [Deactivate a user](/api/deactivate-user)
* [Get profile](/api/get-profile) * [Get profile](/api/get-profile)
* [Create a user](/api/create-user) * [Create a user](/api/create-user)
* [Set "typing" status](/api/typing) * [Set "typing" status](/api/typing)

View File

@@ -242,6 +242,21 @@ def get_single_user(client):
validate_against_openapi_schema(result, '/users/{user_id}', 'get', '200') validate_against_openapi_schema(result, '/users/{user_id}', 'get', '200')
@openapi_test_function("/users/{user_id}:delete")
def deactivate_user(client):
# type: (Client) -> None
# {code_example|start}
# Deactivate a user
user_id = 8
url = 'users/' + str(user_id)
result = client.call_endpoint(
url=url,
method='DELETE',
)
# {code_example|end}
validate_against_openapi_schema(result, '/users/{user_id}', 'delete', '200')
@openapi_test_function("/realm/filters:get") @openapi_test_function("/realm/filters:get")
def get_realm_filters(client): def get_realm_filters(client):
# type: (Client) -> None # type: (Client) -> None
@@ -1150,6 +1165,7 @@ def test_users(client):
create_user(client) create_user(client)
get_members(client) get_members(client)
get_single_user(client) get_single_user(client)
deactivate_user(client)
get_profile(client) get_profile(client)
update_notification_settings(client) update_notification_settings(client)
upload_file(client) upload_file(client)