api_docs: Document "/invites/{invite_id}/resend" endpoint.

This commit is contained in:
Vector73 2024-06-07 20:41:42 +05:30 committed by Tim Abbott
parent ef88057d2c
commit faa06497ed
6 changed files with 57 additions and 5 deletions

View File

@ -95,6 +95,7 @@
* [Get all invitations](/api/get-invites)
* [Send invitations](/api/send-invites)
* [Create a reusable invitation link](/api/create-invite-link)
* [Resend an email invitation](/api/resend-email-invite)
* [Revoke an email invitation](/api/revoke-email-invite)
* [Revoke a reusable invitation link](/api/revoke-invite-link)

View File

@ -431,6 +431,20 @@ def revoke_reusable_invitation_link(client: Client) -> None:
validate_against_openapi_schema(result, "/invites/multiuse/{invite_id}", "delete", "200")
@openapi_test_function("/invites/{invite_id}/resend:post")
def resend_email_invitation(client: Client) -> None:
invites = client.call_endpoint(url="/invites", method="GET")["invites"]
email_invites = [s for s in invites if not s["is_multiuse"]]
assert len(email_invites) > 0
invite_id = email_invites[0]["id"]
# {code_example|start}
# Resend email invitation.
result = client.call_endpoint(url=f"/invites/{invite_id}/resend", method="POST")
# {code_example|end}
validate_response_result(result)
validate_against_openapi_schema(result, "/invites/{invite_id}/resend", "post", "200")
@openapi_test_function("/users/{user_id}:get")
def get_single_user(client: Client) -> None:
user_id = 8
@ -1801,6 +1815,7 @@ def test_invitations(client: Client) -> None:
create_reusable_invitation_link(client)
revoke_reusable_invitation_link(client)
get_invitations(client)
resend_email_invitation(client)
def test_the_api(client: Client, nonadmin_client: Client, owner_client: Client) -> None:

View File

@ -12794,6 +12794,44 @@ paths:
description: |
A typical failed JSON response for when the invitation link has already
been revoked:
/invites/{invite_id}/resend:
post:
operationId: resend-email-invite
summary: Resend an email invitation
tags: ["invites"]
description: |
Resend an [email invitation](/help/invite-new-users#send-email-invitations).
A user can only resend [invitations that they can
manage](/help/invite-new-users#manage-pending-invitations).
parameters:
- name: invite_id
in: path
description: |
The ID of the email invitation to be resent.
schema:
type: integer
example: 1
required: true
responses:
"200":
$ref: "#/components/responses/SimpleSuccess"
"400":
description: Bad request.
content:
application/json:
schema:
oneOf:
- allOf:
- $ref: "#/components/schemas/CodedError"
- example:
{
"result": "error",
"msg": "No such invitation",
"code": "BAD_REQUEST",
}
description: |
A typical failed JSON response for an invalid email invitation ID:
/register:
post:
operationId: register-queue

View File

@ -237,8 +237,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):
"/default_stream_groups/create",
"/default_stream_groups/{group_id}",
"/default_stream_groups/{group_id}/streams",
# Administer invitations
"/invites/{prereg_id}/resend",
# Single-stream settings alternative to the bulk endpoint
# users/me/subscriptions/properties; probably should just be a
# section of the same page.

View File

@ -181,10 +181,10 @@ def revoke_multiuse_invite(
@require_member_or_admin
@has_request_variables
def resend_user_invite_email(
request: HttpRequest, user_profile: UserProfile, prereg_id: int
request: HttpRequest, user_profile: UserProfile, invite_id: int
) -> HttpResponse:
try:
prereg_user = PreregistrationUser.objects.get(id=prereg_id)
prereg_user = PreregistrationUser.objects.get(id=invite_id)
except PreregistrationUser.DoesNotExist:
raise JsonableError(_("No such invitation"))

View File

@ -318,7 +318,7 @@ v1_api_and_json_patterns = [
# invites -> zerver.views.invite
rest_path("invites", GET=get_user_invites, POST=invite_users_backend),
rest_path("invites/<int:invite_id>", DELETE=revoke_user_invite),
rest_path("invites/<int:prereg_id>/resend", POST=resend_user_invite_email),
rest_path("invites/<int:invite_id>/resend", POST=resend_user_invite_email),
# invites/multiuse -> zerver.views.invite
rest_path("invites/multiuse", POST=generate_multiuse_invite_backend),
# invites/multiuse -> zerver.views.invite