|
19 | 19 | import invite.repository.UserRepository; |
20 | 20 | import invite.security.SuperAdmin; |
21 | 21 | import invite.security.UserPermissions; |
| 22 | +import io.swagger.v3.oas.annotations.Operation; |
22 | 23 | import io.swagger.v3.oas.annotations.Parameter; |
| 24 | +import io.swagger.v3.oas.annotations.media.Content; |
| 25 | +import io.swagger.v3.oas.annotations.media.ExampleObject; |
| 26 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 27 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; |
23 | 28 | import io.swagger.v3.oas.annotations.security.SecurityRequirement; |
24 | 29 | import jakarta.servlet.http.HttpServletRequest; |
25 | 30 | import jakarta.servlet.http.HttpServletResponse; |
@@ -103,6 +108,81 @@ public InvitationController(MailBox mailBox, |
103 | 108 | } |
104 | 109 |
|
105 | 110 | @PostMapping("") |
| 111 | + @Operation(summary = "Invite member for existing Role", |
| 112 | + description = "Invite a member for an existing role. An invitation email will be sent. Do not forget to set guestRoleIncluded to true." + |
| 113 | + "At least one email must be either present in invites or invitations. When using the invitations you can also specify the " + |
| 114 | + "internalPlaceholderIdentifier, which will be used as the id in the SCIM POST to /User.", |
| 115 | + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( |
| 116 | + required = true, |
| 117 | + content = {@Content( |
| 118 | + mediaType = "application/json", |
| 119 | + examples = { |
| 120 | + @ExampleObject( |
| 121 | + name = "Invitation example", |
| 122 | + summary = "Example invitation request", |
| 123 | + value = """ |
| 124 | + { |
| 125 | + "intendedAuthority": "INVITER", |
| 126 | + "message": "Personal message included in the email", |
| 127 | + "language": "en", |
| 128 | + "guestRoleIncluded": true, |
| 129 | + "invites": [ |
| 130 | + "admin@service.org" |
| 131 | + ], |
| 132 | + "invitations": [{ |
| 133 | + "email": "admin2@service.org" |
| 134 | + "internalPlaceholderIdentifier": "4EFF937F-EE78-4A54-9FD8-A214FD64D7E1", |
| 135 | + }], |
| 136 | + "roleIdentifiers": [ |
| 137 | + 99 |
| 138 | + ], |
| 139 | + "roleExpiryDate": 1760788376, |
| 140 | + "expiryDate": 1730461976 |
| 141 | + } |
| 142 | + """ |
| 143 | + )})} |
| 144 | + ), |
| 145 | + responses = { |
| 146 | + @ApiResponse(responseCode = "201", description = "Created", |
| 147 | + content = {@Content(schema = @Schema(implementation = InvitationResponse.class), |
| 148 | + examples = {@ExampleObject(value = """ |
| 149 | + { |
| 150 | + "status": 201, |
| 151 | + "recipientInvitationURLs": [ |
| 152 | + { |
| 153 | + "recipient": "admin@service.nl", |
| 154 | + "invitationURL": "https://invite.test.surfconext.nl/invitation/accept?{hash}" |
| 155 | + } |
| 156 | + ] |
| 157 | + } |
| 158 | + """ |
| 159 | + )})}), |
| 160 | + @ApiResponse(responseCode = "400", description = "BadRequest", |
| 161 | + content = {@Content(schema = @Schema(implementation = StatusResponse.class), |
| 162 | + examples = {@ExampleObject(value = """ |
| 163 | + { |
| 164 | + "timestamp": 1717672263253, |
| 165 | + "status": 400, |
| 166 | + "error": "BadRequest", |
| 167 | + "exception": "access.exception.UserRestrictionException", |
| 168 | + "message": "No access to application", |
| 169 | + "path": "/api/internal/invite/invitations" |
| 170 | + } |
| 171 | + """ |
| 172 | + )})}), |
| 173 | + @ApiResponse(responseCode = "404", description = "Role not found", |
| 174 | + content = {@Content(schema = @Schema(implementation = StatusResponse.class), |
| 175 | + examples = {@ExampleObject(value = """ |
| 176 | + { |
| 177 | + "timestamp": 1717672263253, |
| 178 | + "status": 404, |
| 179 | + "error": "Not found", |
| 180 | + "exception": "access.exception.NotFoundException", |
| 181 | + "message": "Role not found", |
| 182 | + "path": "/api/internal/invite/invitations" |
| 183 | + } |
| 184 | + """ |
| 185 | + )})})}) |
106 | 186 | public ResponseEntity<InvitationResponse> newInvitation(@Validated @RequestBody InvitationRequest invitationRequest, |
107 | 187 | @Parameter(hidden = true) User user) { |
108 | 188 | LOG.debug(String.format("New invitation request by user %s", user.getEduPersonPrincipalName())); |
|
0 commit comments