user_access_restrictions
Creates, updates, deletes, gets or lists a user_access_restrictions resource.
Overview
| Name | user_access_restrictions |
| Type | Resource |
| Id | github.repos.user_access_restrictions |
Fields
The following fields are returned by SELECT queries:
- get_users_with_access_to_protected_branch
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
name | string | |
gravatar_id | string | (example: 41d064eb2195891e12d0413f63227ea7) |
node_id | string | (example: MDQ6VXNlcjE=) |
avatar_url | string (uri) | (example: https://github.com/images/error/octocat_happy.gif) |
email | string | |
events_url | string | (example: https://api.github.com/users/octocat/events{/privacy}) |
followers_url | string (uri) | (example: https://api.github.com/users/octocat/followers) |
following_url | string | (example: https://api.github.com/users/octocat/following{/other_user}) |
gists_url | string | (example: https://api.github.com/users/octocat/gists{/gist_id}) |
html_url | string (uri) | (example: https://github.com/octocat) |
login | string | (example: octocat) |
organizations_url | string (uri) | (example: https://api.github.com/users/octocat/orgs) |
received_events_url | string (uri) | (example: https://api.github.com/users/octocat/received_events) |
repos_url | string (uri) | (example: https://api.github.com/users/octocat/repos) |
site_admin | boolean | |
starred_at | string | (example: "2020-07-09T00:17:55Z") |
starred_url | string | (example: https://api.github.com/users/octocat/starred{/owner}{/repo}) |
subscriptions_url | string (uri) | (example: https://api.github.com/users/octocat/subscriptions) |
type | string | (example: User) |
url | string (uri) | (example: https://api.github.com/users/octocat) |
user_view_type | string | (example: public) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_users_with_access_to_protected_branch | select | owner, repo, branch | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Lists the people who have push access to this branch. | |
add_user_access_restrictions | insert | owner, repo, branch, users | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Grants the specified people push access for this branch. | Type | Description | | ------- | ----------------------------------------------------------------------------------------------------------------------------- | | array | Usernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items. | | |
set_user_access_restrictions | replace | owner, repo, branch, users | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people. | Type | Description | | ------- | ----------------------------------------------------------------------------------------------------------------------------- | | array | Usernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items. | | |
remove_user_access_restrictions | delete | owner, repo, branch | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Removes the ability of a user to push to this branch. | Type | Description | | ------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | array | Usernames of the people who should no longer have push access. Note: The list of users, apps, and teams in total is limited to 100 items. | |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
branch | string | The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API. |
owner | string | The account owner of the repository. The name is not case sensitive. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
SELECT examples
- get_users_with_access_to_protected_branch
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Lists the people who have push access to this branch.
SELECT
id,
name,
gravatar_id,
node_id,
avatar_url,
email,
events_url,
followers_url,
following_url,
gists_url,
html_url,
login,
organizations_url,
received_events_url,
repos_url,
site_admin,
starred_at,
starred_url,
subscriptions_url,
type,
url,
user_view_type
FROM github.repos.user_access_restrictions
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND branch = '{{ branch }}' -- required
;
INSERT examples
- add_user_access_restrictions
- Manifest
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Grants the specified people push access for this branch.
| Type | Description |
| ------- | ----------------------------------------------------------------------------------------------------------------------------- |
| array | Usernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items. |
INSERT INTO github.repos.user_access_restrictions (
users,
owner,
repo,
branch
)
SELECT
'{{ users }}' /* required */,
'{{ owner }}',
'{{ repo }}',
'{{ branch }}'
RETURNING
id,
name,
gravatar_id,
node_id,
avatar_url,
email,
events_url,
followers_url,
following_url,
gists_url,
html_url,
login,
organizations_url,
received_events_url,
repos_url,
site_admin,
starred_at,
starred_url,
subscriptions_url,
type,
url,
user_view_type
;
# Description fields are for documentation purposes
- name: user_access_restrictions
props:
- name: owner
value: "{{ owner }}"
description: Required parameter for the user_access_restrictions resource.
- name: repo
value: "{{ repo }}"
description: Required parameter for the user_access_restrictions resource.
- name: branch
value: "{{ branch }}"
description: Required parameter for the user_access_restrictions resource.
- name: users
value:
- "{{ users }}"
description: |
The username for users
REPLACE examples
- set_user_access_restrictions
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.
| Type | Description |
| ------- | ----------------------------------------------------------------------------------------------------------------------------- |
| array | Usernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items. |
REPLACE github.repos.user_access_restrictions
SET
users = '{{ users }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND branch = '{{ branch }}' --required
AND users = '{{ users }}' --required
RETURNING
id,
name,
gravatar_id,
node_id,
avatar_url,
email,
events_url,
followers_url,
following_url,
gists_url,
html_url,
login,
organizations_url,
received_events_url,
repos_url,
site_admin,
starred_at,
starred_url,
subscriptions_url,
type,
url,
user_view_type;
DELETE examples
- remove_user_access_restrictions
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Removes the ability of a user to push to this branch.
| Type | Description |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| array | Usernames of the people who should no longer have push access. Note: The list of users, apps, and teams in total is limited to 100 items. |
DELETE FROM github.repos.user_access_restrictions
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND branch = '{{ branch }}' --required
;