# Access requests

Users can request access to groups and projects.

When access is granted the user should be given a numerical access level. The following constants are provided to represent the access levels:

- `gitlab.GUEST_ACCESS`: `10`
- `gitlab.REPORTER_ACCESS`: `20`
- `gitlab.DEVELOPER_ACCESS`: `30`
- `gitlab.MASTER_ACCESS`: `40`
- `gitlab.OWNER_ACCESS`: `50`

## References

- v4 API:
  - `gitlab.v4.objects.ProjectAccessRequest`
  - `gitlab.v4.objects.ProjectAccessRequestManager`
  - `gitlab.v4.objects.Project.accessrequests`
  - `gitlab.v4.objects.GroupAccessRequest`
  - `gitlab.v4.objects.GroupAccessRequestManager`
  - `gitlab.v4.objects.Group.accessrequests`
- v3 API:
  - `gitlab.v3.objects.ProjectAccessRequest`
  - `gitlab.v3.objects.ProjectAccessRequestManager`
  - `gitlab.v3.objects.Project.accessrequests`
  - `gitlab.Gitlab.project_accessrequests`
  - `gitlab.v3.objects.GroupAccessRequest`
  - `gitlab.v3.objects.GroupAccessRequestManager`
  - `gitlab.v3.objects.Group.accessrequests`
  - `gitlab.Gitlab.group_accessrequests`
- GitLab API: https://docs.gitlab.com/ce/api/access_requests.html

## Examples

List access requests from projects and groups:

    p_ars = project.accessrequests.list()
    g_ars = group.accessrequests.list()

Get a single request:

    p_ar = project.accessrequests.get(user_id)
    g_ar = group.accessrequests.get(user_id)

Create an access request:

    p_ar = project.accessrequests.create({})
    g_ar = group.accessrequests.create({})

Approve an access request:

    ar.approve()  # defaults to DEVELOPER level
    ar.approve(access_level=gitlab.MASTER_ACCESS)  # explicitly set access level

Deny (delete) an access request:

    project.accessrequests.delete(user_id)
    group.accessrequests.delete(user_id)
    # or
    ar.delete()