Retrieve role details. --- post: summary: Retrieve role details description: > Fetch detailed information about a role that the user is entitled to access, e.g. their own role, or a group they are part of. parameters: - in: path name: i
(id)
| 165 | |
| 166 | @blueprint.route("/api/2/roles/<int:id>", methods=["GET"]) |
| 167 | def view(id): |
| 168 | """Retrieve role details. |
| 169 | --- |
| 170 | post: |
| 171 | summary: Retrieve role details |
| 172 | description: > |
| 173 | Fetch detailed information about a role that the user is |
| 174 | entitled to access, e.g. their own role, or a group they |
| 175 | are part of. |
| 176 | parameters: |
| 177 | - in: path |
| 178 | name: id |
| 179 | required: true |
| 180 | description: role ID |
| 181 | schema: |
| 182 | type: integer |
| 183 | responses: |
| 184 | '200': |
| 185 | description: OK |
| 186 | content: |
| 187 | application/json: |
| 188 | schema: |
| 189 | $ref: '#/components/schemas/Role' |
| 190 | tags: |
| 191 | - Role |
| 192 | """ |
| 193 | role = obj_or_404(Role.by_id(id)) |
| 194 | require(request.authz.can_read_role(role.id)) |
| 195 | data = role.to_dict() |
| 196 | if request.authz.can_write_role(role.id): |
| 197 | data.update(get_deep_role(role)) |
| 198 | if SETTINGS.MAINTENANCE: |
| 199 | # Prevent continuous fetching of profile information in maintenance mode. |
| 200 | # This is a workaround for the improper permission system (see "write" access). |
| 201 | # This results in the email address not being shown on the profile page in |
| 202 | # maintenance mode, but there is no other way to prevent constant re-fetching. |
| 203 | data.update({"shallow": False}) |
| 204 | return RoleSerializer.jsonify(data) |
| 205 | |
| 206 | |
| 207 | @blueprint.route("/api/2/roles/<int:id>", methods=["POST", "PUT"]) |
nothing calls this directly
no test coverage detected