privileges Endpoint

このページの内容

概要

Use the privileges endpoint to manage Bitbucket Cloud user privileges (permissions). It allows you to grant specific users access to read, write and or administer your repositories. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can can query or modify repository privileges. To manage group access to your repositories, use the group-privileges Endpoint and to manage privilege settings for team accounts, use the privileges Resource.  

The privileges endpoint has the following structure:

    "repo": "tutorials/tutorials.bitbucket.org",
    "privilege": "write",
    "user": {
      "username": "cburwinkle",
      "first_name": "Christine",
      "last_name": "Burwinkle",
      "display_name": "Christine Burwinkle",
      "is_team": false,
      "avatar": "https://secure.gravatar.com/avatar/07155386777a423e803a72cd80dfa3fd?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
    },
    "repository": {
      "owner": {
        "username": "tutorials",
        "first_name": "first name",
        "last_name": "last",
        "display_name": "first name last",
        "is_team": false,
        "avatar": "https://secure.gravatar.com/avatar/0bc5bd490000b8e63c35c0f54e667b9e?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
      },
      "name": "tutorials.bitbucket.org",
      "slug": "tutorials.bitbucket.org"
    }
  }

The fields in the privileges structure are the following:

フィールド 説明
repo

The identifier for the repo in the format:

{owner}/{repo_slug}
privilege

The permission granted to the user. This is one of:

  • 管理
  • read
  • write
user A user profile.
repository A repository profile.

To obtain a list of teams you are a member of, query the  /user/privileges  endpoint.  To list groups with access, see group-privileges Endpoint.

Filtering to limit results

When using the GET methods on this resource, you can use the filter=read|write|admin query parameter to limit your results to a specific privilege level:

$ curl --request GET --user mcatalbas:password https://api.bitbucket.org/1.0/privileges/mcatalbas/?filter=admin

If you filter for the read permission, you also get the higher levels of permission such as write and admin as they also include the ability to read.

You can use the private=true query parameter to filter for private repositories:

$ curl --request GET --user mcatalbas:password https://api.bitbucket.org/1.0/privileges/mcatalbas/?private=true

GET a list of individual user privileges granted on a repository

Gets a list of the privileges granted on a repository.  Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call.  If a repository has no individual users with privileges, the method returns an [] empty array.  To get privileges for groups, use the group-privileges Endpoint.

This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
repo_slug はい Repository identifier.
filter いいえ

Filters for a particular privilege.  The acceptable values are:

  • read
  • write
  • 管理

Lower level privileges encompass the higher levels; admin and write already have read access. To see every individual account with any access, specify the read filter.

GET https://api.bitbucket.org/1.0/privileges/{accountname}/{repo_slug}
ここをクリックして展開...

In the code below, the users jespern and detkin have read access, user davidchambers has write access, and nvenegas has full administrative privileges.

[
  {
    "repo": "tutorials/tutorials.bitbucket.org",
    "privilege": "write",
    "user": {
      "username": "cburwinkle",
      "first_name": "Christine",
      "last_name": "Burwinkle",
      "display_name": "Christine Burwinkle",
      "is_team": false,
      "avatar": "https://secure.gravatar.com/avatar/07155386777a423e803a72cd80dfa3fd?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
    },
    "repository": {
      "owner": {
        "username": "tutorials",
        "first_name": "first name",
        "last_name": "last",
        "display_name": "first name last",
        "is_team": false,
        "avatar": "https://secure.gravatar.com/avatar/0bc5bd490000b8e63c35c0f54e667b9e?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
      },
      "name": "tutorials.bitbucket.org",
      "slug": "tutorials.bitbucket.org"
    }
  },
  {
    "repo": "tutorials/tutorials.bitbucket.org",
    "privilege": "read",
    "user": {
      "username": "sgriffin",
      "first_name": "Susan",
      "last_name": "Griffin",
      "display_name": "Susan Griffin",
      "is_team": false,
      "avatar": "https://secure.gravatar.com/avatar/b48e3c3f4f60961f2689de516736a224?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
    },
    "repository": {
      "owner": {
        "username": "tutorials",
        "first_name": "first name",
        "last_name": "last",
        "display_name": "first name last",
        "is_team": false,
        "avatar": "https://secure.gravatar.com/avatar/0bc5bd490000b8e63c35c0f54e667b9e?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F13b5a9275dc9%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
      },
      "name": "tutorials.bitbucket.org",
      "slug": "tutorials.bitbucket.org"
    }
]

GET privileges for an individual

Get a list of privileges for an individual account. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
repo_slug はい Repository identifier.
privilege_account はい The account to list privileges for.
GET https://api.bitbucket.org/1.0/privileges/{accountname}/{repo_slug}/{privilege_account}
ここをクリックして展開...
[
    {
        "repo": "evzijst/test",
        "privilege": "admin",
        "user": {
            "username": "nvenegas",
            "first_name": "Nicolas",
            "last_name": "Venegas"
        }
    }
]

GET a list of all privileges across all an account's repositories

Gets a list of all the privilege across all an account's repositories. If a repository has no individual users with privileges, it does not appear in this list. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
filter いいえ

Filters for a particular privilege.  The acceptable values are:

  • read
  • write
  • 管理
GET https://api.bitbucket.org/1.0/privileges/{accountname}
ここをクリックして展開...
[
    {
        "repo": "buserbb/mybuserrepo",
        "privilege": "write",
        "user": {
            "username": "tutorials",
            "first_name": "",
            "last_name": "",
            "avatar": "https://secure.gravatar.com/avatar/0bc5bd490000b8e63c35c0f54e667b9e?d=identicon&s=32",
            "is_team": false
        },
        "repository": {
            "owner": {
                "username": "buserbb",
                "first_name": "B",
                "last_name": "userbb",
                "avatar": "https://secure.gravatar.com/avatar/b677e1e3bf1c781f852b288fd4b68480?d=identicon&s=32",
                "is_team": false
            },
            "name": "mybuserrepo",
            "slug": "mybuserrepo"
        }
    }
]

PUT a new privilege

Grants an account a privilege on a repository. You can upgrade or downgrade a user's permissions with this method. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
repo_slug はい Repository identifier.
group_slug はい The group's slug.
privilege_account はい The account to list privileges for.
privilege はい

The privilege to assign.  Valid values are:

  • read
  • write
  • 管理

To grant user brodie write access to the test repo,  PUT on /1.0/privileges/evzijst/test/brodie with the string write as request body:

$ curl --request PUT --user evzijst:password https://api.bitbucket.org/1.0/privileges/evzijst/test/brodie --data write

This will return a 200 status code on success, with an empty response body.

$ curl --request PUT --user evzijst:password https://api.bitbucket.org/1.0/privileges/evzijst/test/brodie --data read

 

PUT  https://api.bitbucket.org/1.0/privileges/{accountname}/{repo_slug}/{privilege_account} --data {read}
ここをクリックして展開...
[
    {
        "repo": "tutorials/mydvcsproject",
        "privilege": "write",
        "user": {
            "username": "atlassian_tutorial",
            "first_name": "Atlassian Tutorials",
            "last_name": "",
            "avatar": "https://secure.gravatar.com/avatar/eb4e0ad6934518b3e335345a4ceeef21?d=https%3A%2F%2Fdwz7u9t8u8usb.clou
dfront.net%2Fm%2F8319cb1efac9%2Fimg%2Fteam_no_avatar_32.png&s=32",
            "is_team": true
        },
        "repository": {
            "owner": {
                "username": "tutorials",
                "first_name": "",
                "last_name": "",
                "avatar": "https://secure.gravatar.com/avatar/0bc5bd490000b8e63c35c0f54e667b9e?d=identicon&s=32",
                "is_team": false
            },
            "name": "mydvcsproject",
            "slug": "mydvcsproject"
        }
    }
]

 

DELETE account privileges from a repository

Delete an account's privileges from a repository. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
repo_slug はい Repository identifier.
privilege_account はい The account to list privileges for.
DELETE  https://api.bitbucket.org/1.0/privileges/{accountname}/{repo_slug}/{privilege_account}

On success, this call returns HTTP/1.1 204 NO CONTENT.

DELETE all privileges from a repository  

Delete all privileges from a repository. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:  

 

パラメーター
必須かどうか
説明
accountname はい Owner of the repository.
repo_slug はい Repository identifier.
 
DELETE  https://api.bitbucket.org/1.0/privileges/{accountname}/{repo_slug}
  On success, this call returns HTTP/1.1 204 NO CONTENT.

DELETE all privileges from all repositories  

DELETE an privileges from all repositories. Only the repository owner, a team account administrator, or an account with administrative rights on the repository can make this call. This method has the following parameters:

パラメーター
必須かどうか
説明
accountname はい Owner of the repositories.
DELETE  https://api.bitbucket.org/1.0/privileges/{accountname}

On success, this call returns HTTP/1.1 204 NO CONTENT.

 

最終更新日: 2015 年 12 月 24 日

この翻訳に満足しましたか?

はい
いいえ
この記事についてのフィードバックを送信する

お探しの情報が見つかりませんか?

コミュニティへの質問

Powered by Confluence and Scroll Viewport.