dario_swain/stash-api

与 Stash 交互的 REST 式端点

dev-master 2017-04-22 18:13 UTC

This package is not auto-updated.

Last update: 2024-09-20 18:39:27 UTC


README

不稳定 - 正在积极开发中。

关于

Stash API 的自动生成的 PHP 客户端。它使用 APIMATIC 生成,基于 Stash 官方的 WADL 定义

入门

如何构建

生成的代码依赖于外部库,如 UniRest。这些依赖关系在 SDK 中的 composer.json 文件中定义。要解决这些依赖关系,我们使用 Composer 包管理器,它需要您的系统上安装了大于 5.3.2 的 PHP。访问 https://getcomposer.org.cn/download/ 下载 Composer 安装文件,并在您的系统中运行它。打开命令提示符并输入 composer --version。如果安装成功,它应该会显示已安装的 Composer 的当前版本。

  • 使用命令行导航到包含生成的 SDK 文件(包括 composer.json)的目录。
  • 运行命令 composer install。这将安装所有必需的依赖关系,并在您的项目目录中创建 vendor 目录。

Building SDK - Step 1

[仅限 Windows 用户] 在 php.ini 中配置 CURL 证书路径

CURL 以前包含一个接受 CA 的列表,但现在不再捆绑任何 CA 证书。因此,默认情况下,它将拒绝所有 SSL 证书为不可验证。您必须获取您的 CA 的证书并将 curl 指向它。步骤如下

  1. https://curl.haxx.se/docs/caextract.html 下载证书包(.pem 文件)到您的系统。
  2. 将 curl.cainfo = "PATH_TO/cacert.pem" 添加到您的 PHP 安装目录中的 php.ini 文件。 “PATH_TO” 必须是一个包含 .pem 文件的绝对路径。
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =

如何使用

以下部分解释了如何在新的项目中使用 StashAPILib 库。

1. 在 IDE 中打开项目

打开 PHP IDE,如 PhpStorm。这里展示的基本工作流程也适用于您更喜欢使用不同的编辑器或 IDE 的情况。

Open project in PHPStorm - Step 1

在 PhpStorm 中单击 打开 以浏览到生成的 SDK 目录,然后单击 确定

Open project in PHPStorm - Step 2

2. 添加新的测试项目

如下所示,在解决方案名称上右键单击以创建新目录。

Add a new project in PHPStorm - Step 1

将目录命名为 "test"

Add a new project in PHPStorm - Step 2

向此项目添加 PHP 文件

Add a new project in PHPStorm - Step 3

命名为 "testSDK"

Add a new project in PHPStorm - Step 4

根据您的项目设置,您可能需要在 PHP 代码中包含 composer 的自动加载器以启用类的自动加载。

require_once "../vendor/autoload.php";

确保 require_once 中的路径正确指向依赖安装期间在 vendor 目录中创建的 autoload.php 文件。

Add a new project in PHPStorm - Step 4

之后,您可以添加代码来初始化客户端库并获取控制器类的实例。随后的部分将给出初始化客户端库和使用控制器方法的示例代码。

3. 运行测试项目

要运行您的项目,您必须设置项目的解释器。解释器是安装在您的计算机上的 PHP 引擎。

文件 菜单打开 设置

Run Test Project - Step 1

语言和框架 中选择 PHP

Run Test Project - Step 2

解释器 附近浏览解释器并选择您的解释器。

Run Test Project - Step 3

选择解释器后,单击 确定

Run Test Project - Step 4

要运行您的项目,右键单击测试项目中的 PHP 文件,然后单击 运行

Run Test Project - Step 5

如何测试

此 SDK 中的单元测试可以使用 PHPUnit 运行。

  1. 首先使用composer安装依赖,包括require-dev依赖。
  2. 从命令行运行vendor\bin\phpunit --verbose来执行测试。如果您已全局安装PHPUnit,请使用phpunit --verbose来运行测试。

您可以在phpunit.xml文件中更改PHPUnit测试配置。

初始化

身份验证

为了设置API客户端的身份验证和初始化,您需要以下信息。

API客户端可以按照以下方式初始化。

// Configuration parameters and credentials
$stashDomain = "stashDomain";
$basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication
$basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication

$client = new StashAPILib\StashAPILibClient($stashDomain, $basicAuthUserName, $basicAuthPassword);

类参考

控制器列表

Class: RepositoryController

获取单例实例

可以通过API客户端访问RepositoryController类的单例实例。

$repository = $client->getRepository();

Method: getRepositoryCommitChanges

检索指定提交中进行的更改的一页。

注意: 实现将应用硬上限(page.max.changes),并且当超过该上限时无法请求后续内容。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryCommitChanges(
        $projectKey,
        $repositorySlug,
        $commitId,
        $since = null,
        $withComments = true)

参数

                 If not specified the commit's first parent is assumed (if one exists) |

| withComments | Optional DefaultValue | 设置为true以在更改中应用评论计数(默认值);否则,设置为false以流式传输更改而不包含评论计数 |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$since = 'since';
$withComments = true;

$result = $repository->getRepositoryCommitChanges($projectKey, $repositorySlug, $commitId, $since, $withComments);

Method: getRepositoryCompareDiffByPath

获取在from更改集中存在但在to更改集中不存在的更改的diff。

如果未指定fromto更改集,则它们将由其包含仓库的默认分支替换。

function getRepositoryCompareDiffByPath(
        $projectKey,
        $repositorySlug,
        $path,
        $from = null,
        $to = null,
        $fromRepo = null,
        $srcPath = null,
        $contextLines = -1,
        $whitespace = null)

参数

             if that changeset is not present in the current repository; the repository can be specified
             by either its ID <em>fromRepo=42</em> or by its project key plus its repo slug separated by
             a slash: <em>fromRepo=projectKey/repoSlug</em> |

| srcPath | Optional | TODO:添加参数说明 | | contextLines | Optional DefaultValue | 包围每个添加或删除行周围的上下文行数(可选) | | whitespace | Optional | 可选的空白标志,可以设置为ignore-all |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$from = 'from';
$to = 'to';
$fromRepo = 'fromRepo';
$srcPath = 'srcPath';
$contextLines = -1;
$whitespace = 'whitespace';

$result = $repository->getRepositoryCompareDiffByPath($projectKey, $repositorySlug, $path, $from, $to, $fromRepo, $srcPath, $contextLines, $whitespace);

Method: getRepositoryCompareChanges

获取在from更改集中存在但在to更改集中不存在的文件更改。

如果未指定fromto更改集,则它们将由其包含仓库的默认分支替换。

function getRepositoryCompareChanges(
        $projectKey,
        $repositorySlug,
        $from = null,
        $to = null,
        $fromRepo = null)

参数

             if that changeset is not present in the current repository; the repository can be specified
             by either its ID <em>fromRepo=42</em> or by its project key plus its repo slug separated by
             a slash: <em>fromRepo=projectKey/repoSlug</em> |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$from = 'from';
$to = 'to';
$fromRepo = 'fromRepo';

$result = $repository->getRepositoryCompareChanges($projectKey, $repositorySlug, $from, $to, $fromRepo);

方法: getRepositoryCompareCommits

获取从 {@code from} 变更集可访问但不在 {@code to} 变更集中的提交。

如果未指定fromto更改集,则它们将由其包含仓库的默认分支替换。

function getRepositoryCompareCommits(
        $projectKey,
        $repositorySlug,
        $from = null,
        $to = null,
        $fromRepo = null)

参数

             if that changeset is not present in the current repository; the repository can be specified
             by either its ID <em>fromRepo=42</em> or by its project key plus its repo slug separated by
             a slash: <em>fromRepo=projectKey/repoSlug</em> |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$from = 'from';
$to = 'to';
$fromRepo = 'fromRepo';

$result = $repository->getRepositoryCompareCommits($projectKey, $repositorySlug, $from, $to, $fromRepo);

方法: getRepositoryBranches

检索与提供的 filterText 参数匹配的分支。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryBranches(
        $projectKey,
        $repositorySlug,
        $base = null,
        $details = null,
        $filterText = null,
        $orderBy = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$base = 'base';
$details = false;
$filterText = 'filterText';
$orderBy = 'orderBy';

$result = $repository->getRepositoryBranches($projectKey, $repositorySlug, $base, $details, $filterText, $orderBy);

方法: getRepositoryDefaultBranch

获取存储库的默认分支。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryDefaultBranch(
        $projectKey,
        $repositorySlug)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $repository->getRepositoryDefaultBranch($projectKey, $repositorySlug);

方法: updateSetRepositoryDefaultBranch

更新存储库的默认分支。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function updateSetRepositoryDefaultBranch(
        $dynamic,
        $projectKey,
        $repositorySlug)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $repository->updateSetRepositoryDefaultBranch($dynamic, $projectKey, $repositorySlug);

方法: updateSetRepositoryPermissionForGroup

提升或降低指定存储库中组的权限级别。可用的存储库权限包括

  • REPO_READ
  • REPO_WRITE
  • REPO_ADMIN
请参阅 Stash 文档 了解每个权限的详细说明。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。此外,如果这样做会降低他们的权限级别,则用户不能降低组的权限级别。

function updateSetRepositoryPermissionForGroup(
        $projectKey,
        $repositorySlug,
        $permission = null,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$permission = 'permission';
$name = 'name';

$result = $repository->updateSetRepositoryPermissionForGroup($projectKey, $repositorySlug, $permission, $name);

方法: getRepositoryGroupsWithAnyPermission

检索至少对指定存储库授予了一个权限的组的一页。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

function getRepositoryGroupsWithAnyPermission(
        $projectKey,
        $repositorySlug,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$filter = 'filter';

$result = $repository->getRepositoryGroupsWithAnyPermission($projectKey, $repositorySlug, $filter);

方法: deleteRevokeRepositoryPermissionsForGroup

撤销对指定存储库的组的所有权限。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

此外,如果撤销组权限会降低其权限级别,则用户不能撤销组的权限。

function deleteRevokeRepositoryPermissionsForGroup(
        $projectKey,
        $repositorySlug,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$name = 'name';

$result = $repository->deleteRevokeRepositoryPermissionsForGroup($projectKey, $repositorySlug, $name);

方法: updateSetRepositoryPermissionForUser

提升或降低特定仓库中用户的权限级别。可用的仓库权限有

  • REPO_READ
  • REPO_WRITE
  • REPO_ADMIN
请参阅 Stash 文档 了解每个权限的详细说明。

认证用户必须对特定仓库拥有 REPO_ADMIN 权限,或者拥有更高权限的项目或全局权限来调用此资源。此外,如果没有项目或全局权限隐含该权限,用户不能降低自己的权限级别。

function updateSetRepositoryPermissionForUser(
        $projectKey,
        $repositorySlug,
        $name = null,
        $permission = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$name = 'name';
$permission = 'permission';

$result = $repository->updateSetRepositoryPermissionForUser($projectKey, $repositorySlug, $name, $permission);

方法: getRepositoryUsersWithAnyPermission

检索至少被授予指定仓库一项权限的用户页面。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

function getRepositoryUsersWithAnyPermission(
        $projectKey,
        $repositorySlug,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$filter = 'filter';

$result = $repository->getRepositoryUsersWithAnyPermission($projectKey, $repositorySlug, $filter);

方法: deleteRevokeRepositoryPermissionsForUser

撤销特定仓库中用户的所有权限。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

此外,如果没有更高权限的项目或全局权限,用户不能撤销自己的仓库权限。

function deleteRevokeRepositoryPermissionsForUser(
        $projectKey,
        $repositorySlug,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$name = 'name';

$result = $repository->deleteRevokeRepositoryPermissionsForUser($projectKey, $repositorySlug, $name);

方法: getRepositoryGroupsWithoutAnyPermission

检索没有为指定仓库授予任何权限的组页面。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

function getRepositoryGroupsWithoutAnyPermission(
        $projectKey,
        $repositorySlug,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$filter = 'filter';

$result = $repository->getRepositoryGroupsWithoutAnyPermission($projectKey, $repositorySlug, $filter);

方法: getRepositoryUsersWithoutPermission

检索没有为指定仓库授予任何权限的 授权 用户页面。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限或更高的项目或全局权限。

function getRepositoryUsersWithoutPermission(
        $projectKey,
        $repositorySlug,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$filter = 'filter';

$result = $repository->getRepositoryUsersWithoutPermission($projectKey, $repositorySlug, $filter);

方法: getRepositoryCommits

从给定的起始提交或“之间”的两个提交检索提交页面。如果没有指定明确的提交,则假定是仓库默认分支的尖端。提交可以通过分支或标签名称或ID进行识别。可以提供路径以限制返回的提交仅影响该路径。

认证用户必须对指定仓库拥有 REPO_READ 权限才能调用此资源。

function getRepositoryCommits(
        $projectKey,
        $repositorySlug,
        $path = null,
        $since = null,
        $until = null,
        $withCounts = false)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$since = 'since';
$until = 'until';
$withCounts = false;

$result = $repository->getRepositoryCommits($projectKey, $repositorySlug, $path, $since, $until, $withCounts);

方法: getRepositoryCommit

检索单个提交 通过其ID识别。通常,该ID是SHA1。从2.11版本开始,此资源不再接受如“refs/heads/master”的引用名称。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryCommit(
        $projectKey,
        $repositorySlug,
        $commitId,
        $path = null)

参数

         be for the specified commit. Instead, starting from the specified commit, they will be the
         details for the first commit affecting the specified path. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$path = 'path';

$result = $repository->getRepositoryCommit($projectKey, $repositorySlug, $commitId, $path);

方法: getRepositoryTags

检索与提供的 filterText 参数匹配的标签。

认证用户必须拥有对上下文存储库的 REPO_READ 权限才能调用此资源。

function getRepositoryTags(
        $projectKey,
        $repositorySlug,
        $filterText = null,
        $orderBy = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$filterText = 'filterText';
$orderBy = 'orderBy';

$result = $repository->getRepositoryTags($projectKey, $repositorySlug, $filterText, $orderBy);

方法: getRepositories

根据控制搜索的查询参数检索一页存储库。请参阅参数的文档以获取更多详细信息。

此资源可匿名访问。

关于权限的说明。如果没有提供 {@code permission} 查询参数,则假定隐式的 'read' 权限。请注意,此权限低于 REPO_READ 权限,而不是等于它。给定存储库的隐式 'read' 权限分配给具有任何更高权限的用户,例如,以及如果存储库被标记为公共,则分配给匿名用户。上述内容的含义是,带有权限级别的匿名请求保证会收到一个空的存储库列表。因此,对于匿名请求,建议不要指定该参数。

function getRepositories(
        $name = null,
        $projectname = null,
        $permission = null,
        $visibility = null)

参数

                matches this parameter's value. The match will be done case-insensitive and any leading
                and/or trailing whitespace characters on the <code>name</code> parameter will be stripped. |

| projectname | 可选 | (可选)如果指定,这将限制结果存储库列表,使其与参数值的项目的名称匹配。匹配将不区分大小写,并将删除 projectname 参数上任何前导和/或尾随空白字符。 | | permission | 可选 | (可选)如果指定,它必须是有效的存储库权限级别名称,并将限制结果存储库列表,使其仅包含请求用户具有指定权限级别的存储库。如果未指定,则假定默认的隐式 'read' 权限级别。当前支持的显式权限值是 , 和 。 | | visibility | 可选 | (可选)如果指定,这将根据存储库的可见性限制结果存储库列表。有效值是 publicprivate。 |

示例用法

$name = 'name';
$projectname = 'projectname';
$permission = 'permission';
$visibility = 'visibility';

$result = $repository->getRepositories($name, $projectname, $permission, $visibility);

方法: listRepositoryFiles

检索特定目录的存储库中的一页文件。搜索是递归的,因此将返回指定目录的任何子目录中的所有文件。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function listRepositoryFiles(
        $projectKey,
        $repositorySlug,
        $at = null)

参数

         If not specified the default branch will be used instead. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$at = 'at';

$result = $repository->listRepositoryFiles($projectKey, $repositorySlug, $at);

方法: listRepositoryFilesByPath

检索特定目录的存储库中的一页文件。搜索是递归的,因此将返回指定目录的任何子目录中的所有文件。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function listRepositoryFilesByPath(
        $projectKey,
        $repositorySlug,
        $path,
        $at = null)

参数

         If not specified the default branch will be used instead. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$at = 'at';

$result = $repository->listRepositoryFilesByPath($projectKey, $repositorySlug, $path, $at);

方法: createRepository

创建一个新的存储库。需要现有的项目,其中将创建此存储库。唯一将使用的参数是名称和 scmId。

认证用户必须对上下文项目拥有 PROJECT_ADMIN 权限才能调用此资源。

function createRepository(
        $dynamic,
        $projectKey)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';

$result = $repository->createRepository($dynamic, $projectKey);

方法: deleteRepository

调度与提供的 projectKeyrepositorySlug 匹配的仓库进行删除。如果请求的仓库不存在

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function deleteRepository(
        $repositorySlug,
        $projectKey)

参数

示例用法

$repositorySlug = 'repositorySlug';
$projectKey = 'projectKey';

$result = $repository->deleteRepository($repositorySlug, $projectKey);

方法: createForkRepository

从现有仓库创建一个新的仓库分叉。

此 {@code POST} 的 JSON 主体不必包含 任何 属性。名称也可能被省略。如果提供,将使用以下属性

  • {@code "name":"Fork 名称"} - 指定分叉仓库的名称
    • 如果未指定,默认为原始仓库的名称
  • {@code "project":{"key":"TARGET_KEY"}} - 通过密钥指定分叉仓库的目标项目
    • 如果未指定,默认为当前用户的个人项目

认证用户必须对指定的仓库拥有 REPO_READ 权限,并且对目标项目拥有 PROJECT_ADMIN 权限才能调用此资源。请注意,用户 始终 在他们的个人项目中拥有 PROJECT_ADMIN 权限。

function createForkRepository(
        $dynamic,
        $repositorySlug,
        $projectKey)

参数

示例用法

$dynamic = array('key' => 'value');
$repositorySlug = 'repositorySlug';
$projectKey = 'projectKey';

$result = $repository->createForkRepository($dynamic, $repositorySlug, $projectKey);

方法: getRepository

检索与提供的 projectKeyrepositorySlug 匹配的仓库。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepository(
        $repositorySlug,
        $projectKey)

参数

示例用法

$repositorySlug = 'repositorySlug';
$projectKey = 'projectKey';

$result = $repository->getRepository($repositorySlug, $projectKey);

方法: updateRepository

更新与资源路径中提供的 repositorySlug 匹配的仓库。

仓库的 slug 是从其名称派生的。如果名称更改,slug 也可能更改。

此 API 可以通过在请求中设置新项目来将仓库移动到不同的项目。例如:{@code {"project":{"key":"NEW_KEY"}}} .

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function updateRepository(
        $dynamic,
        $repositorySlug,
        $projectKey)

参数

示例用法

$dynamic = array('key' => 'value');
$repositorySlug = 'repositorySlug';
$projectKey = 'projectKey';

$result = $repository->updateRepository($dynamic, $repositorySlug, $projectKey);

方法: getForkedRepositories

检索已从该仓库分叉的仓库。与 {@link #getRelatedRepositories(Repository, PageRequest) 相关仓库} 不同,这仅查看给定仓库的直接分叉。如果那些分叉本身又是更多分叉的原始,这种“孙”仓库将不会被检索。

仅包括认证用户拥有 REPO_READ 权限的仓库,即使其他仓库已从该仓库分叉。

function getForkedRepositories(
        $projectKey,
        $repositorySlug)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $repository->getForkedRepositories($projectKey, $repositorySlug);

方法: getRelatedRepositories

检索与该存储库相关的存储库。相关的存储库与该存储库属于相同的Repository#getHierarchyId()层次。

只有认证用户有REPO_READ权限的存储库将被包括在内,即使更多的存储库是此存储库层次结构的一部分。

function getRelatedRepositories(
        $projectKey,
        $repositorySlug)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $repository->getRelatedRepositories($projectKey, $repositorySlug);

方法: createRetryCreateRepository

如果在创建或分叉操作失败时,调用此方法将清理损坏的存储库并重试。存储库必须处于INITIALISATION_FAILED状态。

认证用户必须对指定的项目有PROJECT_ADMIN权限才能调用此资源。

function createRetryCreateRepository(
        $projectKey,
        $repositorySlug)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $repository->createRetryCreateRepository($projectKey, $repositorySlug);

方法: getRepositoryShowDiff

检索两个提供的修订版之间指定文件路径的diff。

注意:此资源当前未进行分页。服务器将内部应用硬上限到流行行,如果超过此上限,则无法请求后续页面。在达到上限的情况下,diff将被截断,并且在返回的JSON响应的segments、hunks和diff子结构中将设置一个或多个truncated标志为true

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryShowDiff(
        $projectKey,
        $repositorySlug,
        $contextLines = -1,
        $since = null,
        $srcPath = null,
        $until = null,
        $whitespace = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$contextLines = -1;
$since = 'since';
$srcPath = 'srcPath';
$until = 'until';
$whitespace = 'whitespace';

$result = $repository->getRepositoryShowDiff($projectKey, $repositorySlug, $contextLines, $since, $srcPath, $until, $whitespace);

方法: getRepositoryShowDiffByPath

检索两个提供的修订版之间指定文件路径的diff。

注意:此资源当前未进行分页。服务器将内部应用硬上限到流行行,如果超过此上限,则无法请求后续页面。在达到上限的情况下,diff将被截断,并且在返回的JSON响应的segments、hunks和diff子结构中将设置一个或多个truncated标志为true

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryShowDiffByPath(
        $projectKey,
        $repositorySlug,
        $path,
        $contextLines = -1,
        $since = null,
        $srcPath = null,
        $until = null,
        $whitespace = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$contextLines = -1;
$since = 'since';
$srcPath = 'srcPath';
$until = 'until';
$whitespace = 'whitespace';

$result = $repository->getRepositoryShowDiffByPath($projectKey, $repositorySlug, $path, $contextLines, $since, $srcPath, $until, $whitespace);

方法: getRepositoryContent

检索指定修订版中文件路径的一页内容。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryContent(
        $projectKey,
        $repositorySlug,
        $at = null,
        $type = false,
        $blame = null,
        $noContent = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$at = 'at';
$type = false;
$blame = 'blame';
$noContent = 'noContent';

$result = $repository->getRepositoryContent($projectKey, $repositorySlug, $at, $type, $blame, $noContent);

方法: getRepositoryContentByPath

检索指定修订版中文件路径的一页内容。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryContentByPath(
        $projectKey,
        $repositorySlug,
        $path,
        $at = null,
        $type = false,
        $blame = null,
        $noContent = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$at = 'at';
$type = false;
$blame = 'blame';
$noContent = 'noContent';

$result = $repository->getRepositoryContentByPath($projectKey, $repositorySlug, $path, $at, $type, $blame, $noContent);

方法: createRepositoryCommitComment

添加新的评论。

可以通过设置不同的属性在几个地方添加评论

通用提交评论

     {
         "text": "An insightful general comment on a commit."
     }
     

回复评论

     {
         "text": "A measured reply.",
         "parent": {
             "id": 1
         }
     }
     

通用文件评论

     {
         "text": "An insightful general comment on a file.",
         "anchor": {
             "path": "path/to/file",
             "srcPath": "path/to/file"
         }
     }
     

文件行评论

     {
         "text": "A pithy comment on a particular line within a file.",
         "anchor": {
             "line": 1,
             "lineType": "CONTEXT",
             "fileType": "FROM"
             "path": "path/to/file",
             "srcPath": "path/to/file"
     }
     }
     

注意:通用文件评论是一个实验性功能,可能在不久的将来发生变化!

对于文件和行评论,'path'指要应用的文件的路径,'srcPath'指该文件曾经拥有的路径(仅适用于复制和移动)。

对于行评论,'line'指diff中应该应用评论的行。'lineType'指diff hunk的类型,可以是

  • 'ADDED' - 对于添加的行;
  • 'REMOVED' - 对于删除的行;或者
  • 上下文 - 指未修改但位于diff附近的行。
'fileType' 指的是diff中应附加锚点的文件 - 当以并排方式显示diff时相关。目前支持的值包括
  • 'FROM' - diff的源文件
  • 'TO' - diff的目标文件
如果当前用户不是参与者,则将其添加为参与者并更新以监视提交。

认证用户必须对提交所在的存储库具有 REPO_READ 权限才能调用此资源。

function createRepositoryCommitComment(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $commitId,
        $since = null)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$since = 'since';

$result = $repository->createRepositoryCommitComment($dynamic, $projectKey, $repositorySlug, $commitId, $since);

方法: getRepositoryCommitComments

待办事项:添加方法描述

function getRepositoryCommitComments(
        $projectKey,
        $repositorySlug,
        $commitId,
        $path = null,
        $since = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$path = 'path';
$since = 'since';

$result = $repository->getRepositoryCommitComments($projectKey, $repositorySlug, $commitId, $path, $since);

方法: updateRepositoryCommitComment

更新评论的文本。只有创建评论的用户才能更新它。

注意:提供的JSON对象必须包含一个与服务器上评论版本匹配的 version,否则更新将失败。在更新之前,应从服务器获取评论以确定评论的当前版本。在返回的JSON结构中查找 'version' 属性。

认证用户必须对提交所在的存储库具有 REPO_READ 权限才能调用此资源。

function updateRepositoryCommitComment(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $commitId,
        $commentId)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$commentId = 51;

$result = $repository->updateRepositoryCommitComment($dynamic, $projectKey, $repositorySlug, $commitId, $commentId);

方法: deleteRepositoryCommitComment

删除提交评论。任何人都可以删除自己的评论。只有具有 REPO_ADMIN 及以上权限的用户才能删除其他用户创建的评论。即使有权限,包含回复的评论 也可能无法删除

认证用户必须对提交所在的存储库具有 REPO_READ 权限才能调用此资源。

function deleteRepositoryCommitComment(
        $projectKey,
        $repositorySlug,
        $commitId,
        $commentId,
        $version = -1)

参数

              the delete will fail. To determine the current version of the comment, the comment should be
              fetched from the server prior to the delete. Look for the 'version' attribute in the returned
              JSON structure. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$commentId = 51;
$version = -1;

$result = $repository->deleteRepositoryCommitComment($projectKey, $repositorySlug, $commitId, $commentId, $version);

方法: getRepositoryCommitComment

检索提交讨论评论。

认证用户必须对提交所在的存储库具有 REPO_READ 权限才能调用此资源。

function getRepositoryCommitComment(
        $projectKey,
        $repositorySlug,
        $commitId,
        $commentId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$commentId = 51;

$result = $repository->getRepositoryCommitComment($projectKey, $repositorySlug, $commitId, $commentId);

方法: getRepositoryHooks

检索此存储库的页面级存储库钩子。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function getRepositoryHooks(
        $projectKey,
        $repositorySlug,
        $type = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$type = 'type';

$result = $repository->getRepositoryHooks($projectKey, $repositorySlug, $type);

方法: updateSetRepositoryHookSettings

修改此存储库钩子的设置。

服务将拒绝任何过大设置,当前限制为序列化后32KB。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function updateSetRepositoryHookSettings(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $hookKey)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$hookKey = 'hookKey';

$result = $repository->updateSetRepositoryHookSettings($dynamic, $projectKey, $repositorySlug, $hookKey);

方法: getRepositoryHookSettings

获取此存储库的存储库钩子设置。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function getRepositoryHookSettings(
        $projectKey,
        $repositorySlug,
        $hookKey)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$hookKey = 'hookKey';

$result = $repository->getRepositoryHookSettings($projectKey, $repositorySlug, $hookKey);

方法: getRepositoryHook

获取此存储库的存储库钩子。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function getRepositoryHook(
        $projectKey,
        $repositorySlug,
        $hookKey)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$hookKey = 'hookKey';

$result = $repository->getRepositoryHook($projectKey, $repositorySlug, $hookKey);

方法: updateEnableRepositoryHook

启用此存储库的存储库钩子,并可选择应用新配置。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function updateEnableRepositoryHook(
        $projectKey,
        $repositorySlug,
        $hookKey,
        $contentLength = 0)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$hookKey = 'hookKey';
$contentLength = 0;

$result = $repository->updateEnableRepositoryHook($projectKey, $repositorySlug, $hookKey, $contentLength);

方法: deleteDisableRepositoryHook

禁用此存储库的存储库钩子。

调用此资源,认证用户必须对指定的存储库有 REPO_ADMIN 权限。

function deleteDisableRepositoryHook(
        $projectKey,
        $repositorySlug,
        $hookKey)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$hookKey = 'hookKey';

$result = $repository->deleteDisableRepositoryHook($projectKey, $repositorySlug, $hookKey);

方法: getRepositoryChanges

检索指定提交中进行的更改的一页。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryChanges(
        $projectKey,
        $repositorySlug,
        $since = null,
        $until = null)

参数

                 If not specified the commit's first parent is assumed (if one exists) |

| until | 可选 | 获取更改的提交 |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$since = 'since';
$until = 'until';

$result = $repository->getRepositoryChanges($projectKey, $repositorySlug, $since, $until);

方法: deleteUnwatchRepositoryCommit

将认证用户从指定提交的观察者列表中删除。

认证用户必须对包含提交的存储库具有 REPO_READ 权限才能调用此资源。

function deleteUnwatchRepositoryCommit(
        $projectKey,
        $repositorySlug,
        $commitId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';

$result = $repository->deleteUnwatchRepositoryCommit($projectKey, $repositorySlug, $commitId);

方法: createWatchRepositoryCommit

将认证用户添加为指定提交的观察者。

认证用户必须对包含提交的存储库具有 REPO_READ 权限才能调用此资源。

function createWatchRepositoryCommit(
        $projectKey,
        $repositorySlug,
        $commitId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';

$result = $repository->createWatchRepositoryCommit($projectKey, $repositorySlug, $commitId);

方法: getRepositoryCommitDiff

检索提供的两个修订版本之间的差异。

注意:此资源当前未进行分页。服务器将内部应用硬上限到流行行,如果超过此上限,则无法请求后续页面。在达到上限的情况下,diff将被截断,并且在返回的JSON响应的segments、hunks和diff子结构中将设置一个或多个truncated标志为true

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryCommitDiff(
        $projectKey,
        $repositorySlug,
        $commitId,
        $contextLines = -1,
        $since = null,
        $srcPath = null,
        $whitespace = null,
        $withComments = true)

参数

                 to stream the diff without comments |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$commitId = 'commitId';
$contextLines = -1;
$since = 'since';
$srcPath = 'srcPath';
$whitespace = 'whitespace';
$withComments = true;

$result = $repository->getRepositoryCommitDiff($projectKey, $repositorySlug, $commitId, $contextLines, $since, $srcPath, $whitespace, $withComments);

方法: getRepositoryCommitDiffByPath

检索提供的两个修订版本之间的差异。

注意:此资源当前未进行分页。服务器将内部应用硬上限到流行行,如果超过此上限,则无法请求后续页面。在达到上限的情况下,diff将被截断,并且在返回的JSON响应的segments、hunks和diff子结构中将设置一个或多个truncated标志为true

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

function getRepositoryCommitDiffByPath(
        $projectKey,
        $repositorySlug,
        $path,
        $commitId,
        $contextLines = -1,
        $since = null,
        $srcPath = null,
        $whitespace = null,
        $withComments = true)

参数

                 to stream the diff without comments |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$path = 'path';
$commitId = 'commitId';
$contextLines = -1;
$since = 'since';
$srcPath = 'srcPath';
$whitespace = 'whitespace';
$withComments = true;

$result = $repository->getRepositoryCommitDiffByPath($projectKey, $repositorySlug, $path, $commitId, $contextLines, $since, $srcPath, $whitespace, $withComments);

方法: getRepositories1

根据提供的 projectKey 获取对应项目的仓库。

调用此资源之前,认证用户必须对指定的项目具有 REPO_READ 权限。

function getRepositories1($projectKey)

参数

示例用法

$projectKey = 'projectKey';

$result = $repository->getRepositories1($projectKey);

返回控制器列表

类: AdminController

获取单例实例

可以从 API 客户端访问 AdminController 类的单例实例。

$admin = $client->getAdmin();

方法: getClusterInformation

获取构成当前 stash 集群的节点信息。

调用此资源之前,认证用户必须具有 SYS_ADMIN 权限。

function getClusterInformation()

示例用法

$result = $admin->getClusterInformation();

方法: updateLicense

解码提供的编码许可证并设置其为活动许可证。如果没有提供许可证,则返回 400。如果许可证无法解码或无法应用,则返回 409。可能无法应用许可证的一些可能原因包括

  • 它是为不同产品
  • 它已经过期
否则,如果许可证更新成功,将返回 200 响应,并返回新许可证的详细信息。

警告:更新许可证时可能会降级许可证,应用具有较少允许用户的许可证。如果当前授权用户数量超过新许可证的限制,则将禁用推送,直到授权用户数量符合新许可证。

认证用户必须具有 SYS_ADMIN 权限。 ADMIN 用户可以 查看 当前许可证详情,但不能 更新 许可证。

function updateLicense($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->updateLicense($dynamic);

方法: deleteMailConfig

删除当前邮件配置。

调用此资源之前,认证用户必须具有 SYS_ADMIN 权限。

function deleteMailConfig()

示例用法

$result = $admin->deleteMailConfig();

方法: getMailConfig

检索当前邮件配置。

调用此资源之前,认证用户必须具有 SYS_ADMIN 权限。

function getMailConfig()

示例用法

$result = $admin->getMailConfig();

方法: updateSetMailConfig

更新邮件配置

调用此资源之前,认证用户必须具有 SYS_ADMIN 权限。

function updateSetMailConfig($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->updateSetMailConfig($dynamic);

方法: deleteClearSenderAddress

清除服务器电子邮件地址。

调用此资源之前,认证用户必须具有 管理员 权限。

function deleteClearSenderAddress()

示例用法

$result = $admin->deleteClearSenderAddress();

方法: getSenderAddress

检索服务器电子邮件地址

function getSenderAddress()

示例用法

$result = $admin->getSenderAddress();

方法: updateSetSenderAddress

更新服务器电子邮件地址

调用此资源之前,认证用户必须具有 管理员 权限。

function updateSetSenderAddress($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->updateSetSenderAddress($dynamic);

方法: getUsersWithoutAnyPermission

检索没有授予任何全局权限的用户页面。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getUsersWithoutAnyPermission($filter = null)

参数

示例用法

$filter = 'filter';

$result = $admin->getUsersWithoutAnyPermission($filter);

方法: getGroupsWithAnyPermission

检索至少被授予一个全局权限的组页面。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getGroupsWithAnyPermission($filter = null)

参数

示例用法

$filter = 'filter';

$result = $admin->getGroupsWithAnyPermission($filter);

方法: updateSetPermissionForGroups

提升或降低用户的全局权限级别。可用的全局权限包括

  • 授权用户
  • 创建项目
  • 管理员
  • 系统管理员
请参阅 Stash 文档 以了解每个权限的详细说明。

认证用户必须具有

  • 管理员 或更高权限;并且
  • 尝试授予的权限或更高;以及
  • 高于或等于组当前权限级别的权限(用户不能降低比他们权限高的组的权限级别)
才能调用此资源。此外,如果用户的权限级别因此降低,用户不能降低组的权限级别。
function updateSetPermissionForGroups(
        $permission = null,
        $name = null)

参数

示例用法

$permission = 'permission';
$name = 'name';

$result = $admin->updateSetPermissionForGroups($permission, $name);

方法: deleteRevokePermissionsForGroup

撤销组的所有全局权限。

认证用户必须具有

  • 管理员 或更高权限;并且
  • 高于或等于组当前权限级别的权限(用户不能降低比他们权限高的组的权限级别)
才能调用此资源。此外,如果因此降低自己的权限级别,用户不能撤销组的权限。
function deleteRevokePermissionsForGroup($name = null)

参数

示例用法

$name = 'name';

$result = $admin->deleteRevokePermissionsForGroup($name);

方法: getGroupsWithoutAnyPermission

检索没有分配任何全局权限的一页组。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getGroupsWithoutAnyPermission($filter = null)

参数

示例用法

$filter = 'filter';

$result = $admin->getGroupsWithoutAnyPermission($filter);

方法: getUsersWithAnyPermission

检索至少被分配一个全局权限的一页用户。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getUsersWithAnyPermission($filter = null)

参数

示例用法

$filter = 'filter';

$result = $admin->getUsersWithAnyPermission($filter);

方法: updateSetPermissionForUsers

提升或降低用户的全局权限级别。可用的全局权限包括

  • 授权用户
  • 创建项目
  • 管理员
  • 系统管理员
请参阅 Stash 文档 以了解每个权限的详细说明。

认证用户必须具有

  • 管理员 或更高权限;并且
  • 他们试图授予的权限;
  • 大于或等于用户当前权限级别的权限(用户不能降低高于他们权限级别的用户的权限级别)
来调用此资源。此外,用户不能降低自己的权限级别。
function updateSetPermissionForUsers(
        $name = null,
        $permission = null)

参数

示例用法

$name = 'name';
$permission = 'permission';

$result = $admin->updateSetPermissionForUsers($name, $permission);

方法: deleteRevokePermissionsForUser

撤销用户的所有全局权限。

认证用户必须具有

  • 管理员 或更高权限;并且
  • 大于或等于用户当前权限级别的权限(用户不能降低高于他们权限级别的用户的权限级别)
来调用此资源。此外,用户不能降低自己的权限级别。
function deleteRevokePermissionsForUser($name = null)

参数

示例用法

$name = 'name';

$result = $admin->deleteRevokePermissionsForUser($name);

方法: getUsers

检索一页用户。

认证用户必须具有 LICENSED_USER 权限才能调用此资源。

function getUsers($filter = null)

参数

           string will be returned |

示例用法

$filter = 'filter';

$result = $admin->getUsers($filter);

方法: createUser

从组装的查询参数创建新用户。

默认组可以用来控制新用户的初始权限,例如授予用户登录能力或提供对某些项目或存储库的读取访问权限。如果用户未添加到默认组,则在配置显式权限之前,他们可能无法在创建账户后登录。

调用此资源之前,认证用户必须具有 管理员 权限。

function createUser(
        $name = null,
        $password = null,
        $displayName = null,
        $emailAddress = null,
        $addToDefaultGroup = true,
        $notify = null)

参数

                      a set of initial permissions; otherwise, <code>false</code> to not add them to a group |

| 通知 | 可选 | 如果存在且不为 false,则使用通知而不是密码,创建用户将通过电子邮件通知其账户已创建,需要重置密码。此选项只能在配置了邮件服务器的情况下使用 |

示例用法

$name = 'name';
$password = 'password';
$displayName = 'displayName';
$emailAddress = 'emailAddress';
$addToDefaultGroup = true;
$notify = 'notify';

$result = $admin->createUser($name, $password, $displayName, $emailAddress, $addToDefaultGroup, $notify);

方法: deleteUser

删除指定的用户,将其从系统中删除。这也会删除可能授予用户的任何权限。

用户不能删除自己,拥有ADMIN权限的用户也不能删除拥有SYS_ADMIN权限的用户。

调用此资源之前,认证用户必须具有 管理员 权限。

function deleteUser($name = null)

参数

示例用法

$name = 'name';

$result = $admin->deleteUser($name);

方法: updateUserDetails

更新用户的详细信息。

调用此资源之前,认证用户必须具有 管理员 权限。

function updateUserDetails($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->updateUserDetails($dynamic);

方法: createRenameUser

重命名用户。

调用此资源之前,认证用户必须具有 管理员 权限。

function createRenameUser($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->createRenameUser($dynamic);

方法: deleteClearUserCaptchaChallenge

清除可能约束提供用户名的用户在认证时的任何CAPTCHA挑战。此外,任何导致用户被发放CAPTCHA挑战的计数器或指标(例如连续登录失败次数过多)也将重置。

认证用户必须具有ADMIN权限才能调用此资源,并且不能清除比自己权限更高的用户的CAPTCHA。

function deleteClearUserCaptchaChallenge($name = null)

参数

示例用法

$name = 'name';

$result = $admin->deleteClearUserCaptchaChallenge($name);

方法: deleteGroup

删除指定的组,从系统中移除该组。这也会移除可能授予该组的任何权限。

用户不能删除授予他们管理权限的最后一个组,或者比自己权限更高的组。

调用此资源之前,认证用户必须具有 管理员 权限。

function deleteGroup($name = null)

参数

示例用法

$name = 'name';

$result = $admin->deleteGroup($name);

方法: createGroup

创建一个新的组。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function createGroup($name = null)

参数

示例用法

$name = 'name';

$result = $admin->createGroup($name);

方法: getGroups

检索一页的组。

认证用户必须具有LICENSED_USER权限或更高才能调用此资源。

function getGroups($filter = null)

参数

示例用法

$filter = 'filter';

$result = $admin->getGroups($filter);

方法: addUserToGroup

自2.10版本开始弃用,将在4.0版本中删除。请使用{@code /rest/users/add-groups}代替。

将用户添加到组中。

在请求实体中,context属性是组,而itemName是用户。

调用此资源之前,认证用户必须具有 管理员 权限。

function addUserToGroup($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->addUserToGroup($dynamic);

方法: addGroupToUser

自2.10版本开始弃用,将在4.0版本中删除。请使用{@code /rest/users/add-groups}代替。

将用户添加到组中。这与 groups/add-user 非常相似,但请求实体的 contextitemName 属性相反。表面上这似乎是多余的,但它便于在 Stash 中的特定 UI 组件中使用。

在请求实体中,context 属性是用户,而 itemName 是组。

调用此资源之前,认证用户必须具有 管理员 权限。

function addGroupToUser($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->addGroupToUser($dynamic);

方法: addUsersToGroup

将多个用户添加到组中。

调用此资源之前,认证用户必须具有 管理员 权限。

function addUsersToGroup($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->addUsersToGroup($dynamic);

方法: addUserToGroups

将用户添加到一个或多个组中。

调用此资源之前,认证用户必须具有 管理员 权限。

function addUserToGroups($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->addUserToGroups($dynamic);

方法: createRemoveUserFromGroup

自 2.10 版本以来已弃用,并在 3.0 版本中删除。请使用 {@code /rest/users/remove-groups} 代替。

从组中删除用户。

调用此资源之前,认证用户必须具有 管理员 权限。

在请求实体中,context属性是组,而itemName是用户。

function createRemoveUserFromGroup($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->createRemoveUserFromGroup($dynamic);

方法: createRemoveGroupFromUser

从组中删除用户。这与 groups/remove-user 非常相似,但请求实体的 contextitemName 属性相反。表面上这似乎是多余的,但它便于在 Stash 中的特定 UI 组件中使用。

在请求实体中,context 属性是用户,而 itemName 是组。

调用此资源之前,认证用户必须具有 管理员 权限。

function createRemoveGroupFromUser($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->createRemoveGroupFromUser($dynamic);

方法: findUsersInGroup

检索属于指定组的用户列表。

认证用户必须具有 LICENSED_USER 权限才能调用此资源。

function findUsersInGroup(
        $context = null,
        $filter = null)

参数

              supplied string will be returned |

示例用法

$context = 'context';
$filter = 'filter';

$result = $admin->findUsersInGroup($context, $filter);

方法: findUsersNotInGroup

检索不属于指定组的用户列表。

认证用户必须具有 LICENSED_USER 权限才能调用此资源。

function findUsersNotInGroup(
        $context = null,
        $filter = null)

参数

              supplied string will be returned |

示例用法

$context = 'context';
$filter = 'filter';

$result = $admin->findUsersNotInGroup($context, $filter);

方法: findGroupsForUser

检索指定用户是成员的组列表。

认证用户必须具有 LICENSED_USER 权限才能调用此资源。

function findGroupsForUser(
        $context = null,
        $filter = null)

参数

示例用法

$context = 'context';
$filter = 'filter';

$result = $admin->findGroupsForUser($context, $filter);

方法: findOtherGroupsForUser

获取指定用户不是成员的群组列表。

认证用户必须具有 LICENSED_USER 权限才能调用此资源。

function findOtherGroupsForUser(
        $context = null,
        $filter = null)

参数

示例用法

$context = 'context';
$filter = 'filter';

$result = $admin->findOtherGroupsForUser($context, $filter);

方法: updateUserPassword

更新用户的密码。

调用此资源时,认证用户必须具有管理员权限,且不能更新权限高于自己的用户的密码。

function updateUserPassword($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $admin->updateUserPassword($dynamic);

方法: getLicense

获取当前许可证的详细信息以及当前系统相对于已安装许可证的状态。状态包括当前用户数,以及任何有关许可证的状态消息(关于许可证过期或用户数超出许可证限制的警告)。

认证用户必须具有管理员权限。未经认证的用户和非管理员不允许访问许可证详情。

function getLicense()

示例用法

$result = $admin->getLicense();

返回控制器列表

类: PullRequestController

获取单例实例

可以通过API客户端访问PullRequestController类的单例实例。

$pullRequest = $client->getPullRequest();

方法: deleteUnwatchPullRequest

使认证用户停止关注指定的拉取请求。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function deleteUnwatchPullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->deleteUnwatchPullRequest($projectKey, $repositorySlug, $pullRequestId);

方法: createWatchPullRequest

使认证用户关注指定的拉取请求。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function createWatchPullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->createWatchPullRequest($projectKey, $repositorySlug, $pullRequestId);

方法: getPullRequestDiff

在拉取请求中流式传输差异。

如果指定的文件已被复制、移动或重命名,则必须同时指定srcPath以生成正确的差异。

注意:此RESTful端点目前未分页。如果超过内部流线硬限制,服务器将应用限制,无法请求后续页面。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestDiff(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $contextLines = -1,
        $srcPath = null,
        $whitespace = null,
        $withComments = true)

参数

                 to stream the diff without comments |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';
$contextLines = -1;
$srcPath = 'srcPath';
$whitespace = 'whitespace';
$withComments = true;

$result = $pullRequest->getPullRequestDiff($projectKey, $repositorySlug, $pullRequestId, $contextLines, $srcPath, $whitespace, $withComments);

方法: getPullRequestDiffByPath

在拉取请求中流式传输差异。

如果指定的文件已被复制、移动或重命名,则必须同时指定srcPath以生成正确的差异。

注意:此RESTful端点目前未分页。如果超过内部流线硬限制,服务器将应用限制,无法请求后续页面。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestDiffByPath(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $path,
        $contextLines = -1,
        $srcPath = null,
        $whitespace = null,
        $withComments = true)

参数

                 to stream the diff without comments |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';
$path = 'path';
$contextLines = -1;
$srcPath = 'srcPath';
$whitespace = 'whitespace';
$withComments = true;

$result = $pullRequest->getPullRequestDiffByPath($projectKey, $repositorySlug, $pullRequestId, $path, $contextLines, $srcPath, $whitespace, $withComments);

方法: getPullRequestCommits

检索指定拉取请求的更改集。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestCommits(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $withCounts = null)

参数

                 "authorCount" is the number of different authors and "totalCount" is the total number of changesets. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$withCounts = true;

$result = $pullRequest->getPullRequestCommits($projectKey, $repositorySlug, $pullRequestId, $withCounts);

方法: getPullRequestTasks

检索与拉取请求关联的任务。

function getPullRequestTasks(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';

$result = $pullRequest->getPullRequestTasks($projectKey, $repositorySlug, $pullRequestId);

方法: getCountPullRequestTasks

检索与拉取请求关联的 {@link com.atlassian.stash.task.TaskState#OPEN 开放} 和 {@link com.atlassian.stash.task.TaskState#RESOLVED 已解决} 任务的总量。

function getCountPullRequestTasks(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';

$result = $pullRequest->getCountPullRequestTasks($projectKey, $repositorySlug, $pullRequestId);

方法: createPullRequestComment

添加新的评论。

可以通过设置不同的属性在几个地方添加评论

通用拉取请求评论

     {
         "text": "An insightful general comment on a pull request."
     }
     

回复评论

     {
         "text": "A measured reply.",
         "parent": {
             "id": 1
         }
     }
     

通用文件评论

     {
         "text": "An insightful general comment on a file.",
         "anchor": {
             "path": "path/to/file",
             "srcPath": "path/to/file"
         }
     }
     

文件行评论

     {
         "text": "A pithy comment on a particular line within a file.",
         "anchor": {
             "line": 1,
             "lineType": "CONTEXT",
             "fileType": "FROM"
             "path": "path/to/file",
             "srcPath": "path/to/file"
         }
     }
     

注意:通用文件评论是一个实验性功能,可能在不久的将来发生变化!

对于文件和行评论,'path'指要应用的文件的路径,'srcPath'指该文件曾经拥有的路径(仅适用于复制和移动)。

对于行评论,'line'指diff中应该应用评论的行。'lineType'指diff hunk的类型,可以是

  • 'ADDED' - 对于添加的行;
  • 'REMOVED' - 对于删除的行;或者
  • 上下文 - 指未修改但位于diff附近的行。
'fileType' 指的是diff中应附加锚点的文件 - 当以并排方式显示diff时相关。目前支持的值包括
  • 'FROM' - diff的源文件
  • 'TO' - diff的目标文件
如果当前用户不是参与者,则将该用户添加为拉取请求的观察者。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function createPullRequestComment(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->createPullRequestComment($dynamic, $projectKey, $repositorySlug, $pullRequestId);

方法: getPullRequestComments

待办事项:添加方法描述

function getPullRequestComments(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $path = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$path = 'path';

$result = $pullRequest->getPullRequestComments($projectKey, $repositorySlug, $pullRequestId, $path);

方法: updatePullRequestComment

更新评论的文本。只有创建评论的用户才能更新它。

注意:提供的JSON对象必须包含一个与服务器上评论版本匹配的 version,否则更新将失败。在更新之前,应从服务器获取评论以确定评论的当前版本。在返回的JSON结构中查找 'version' 属性。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function updatePullRequestComment(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $commentId)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$commentId = 234;

$result = $pullRequest->updatePullRequestComment($dynamic, $projectKey, $repositorySlug, $pullRequestId, $commentId);

方法: deletePullRequestComment

删除拉取请求评论。任何人都可以删除自己的评论。只有具有 REPO_ADMIN 以上权限的用户才能删除其他用户创建的评论。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function deletePullRequestComment(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $commentId,
        $version = -1)

参数

                  the delete will fail. To determine the current version of the comment, the comment should be
                  fetched from the server prior to the delete. Look for the 'version' attribute in the
                  returned JSON structure. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$commentId = 234;
$version = -1;

$result = $pullRequest->deletePullRequestComment($projectKey, $repositorySlug, $pullRequestId, $commentId, $version);

方法: getPullRequestComment

检索拉取请求评论。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestComment(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $commentId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$commentId = 234;

$result = $pullRequest->getPullRequestComment($projectKey, $repositorySlug, $pullRequestId, $commentId);

方法: getPullRequestChanges

获取指定PullRequest的更改。

注意:此资源当前未分页。服务器将返回最多一页。服务器将截断更改数量,以请求的页限制或内部最大值中的较小者为准。页面请求的起始参数也将被忽略。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestChanges(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $withComments = true)

参数

                 to stream changes without comment counts |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';
$withComments = true;

$result = $pullRequest->getPullRequestChanges($projectKey, $repositorySlug, $pullRequestId, $withComments);

方法: getPullRequests

检索指定仓库的拉取请求页面。

认证用户必须对指定的仓库有REPO_READ权限才能调用此资源。

客户端可以指定PR参与者过滤器。每个过滤器都有一个必填的{@code username.N}参数,以及可选的{@code role.N}和{@code approved.N}参数。

  • {@code username.N} - 单个参与者过滤器的“根”,其中“N”是从1开始的自然数。这允许客户端指定多个参与者过滤器,通过提供连续的过滤器作为{@code username.1}、{@code username.2}等。请注意,过滤器编号必须从1开始,并且对于所有过滤器都必须是连续的,才能处理所有过滤器。允许的参与者过滤器总数为10,超过该限制的过滤器将被丢弃。
  • {@code role.N}(可选) 与{@code username.N}关联的角色。这必须是以下之一:{@code AUTHOR}、{@code REVIEWER}或{@code PARTICIPANT}
  • {@code approved.N}(可选) 与{@code username.N}关联的批准状态。即{@code username.N}是否批准了PR。可以是{@code true}或{@code false}
function getPullRequests(
        $projectKey,
        $repositorySlug,
        $direction = 'incoming',
        $at = null,
        $state = null,
        $order = null,
        $withAttributes = true,
        $withProperties = true)

参数

              repository. Either <strong>INCOMING</strong> or <strong>OUTGOING</strong>. |

| at | 可选 | (可选) 要查找拉取请求的完全限定分支ID,例如{@code refs/heads/master} | | state | 可选 | (可选,默认为OPEN)。提供ALL以返回任何状态的拉取请求。如果提供状态,则只返回指定状态的拉取请求。可以是OPENDECLINEDMERGED。 | | order | 可选 | (可选) 返回拉取请求的顺序,可以是OLDEST(即“最旧的首先”)或NEWEST。 | | withAttributes | 可选 默认值 | (可选) 默认为true,是否返回额外的拉取请求属性 | | withProperties | 可选 默认值 | (可选) 默认为true,是否返回额外的拉取请求属性 |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$direction = 'incoming';
$at = 'at';
$state = 'state';
$order = 'order';
$withAttributes = true;
$withProperties = true;

$result = $pullRequest->getPullRequests($projectKey, $repositorySlug, $direction, $at, $state, $order, $withAttributes, $withProperties);

错误

方法: createDeclinePullRequest

拒绝一个拉取请求。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function createDeclinePullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $version = -1)

参数

            version the operation will fail. To determine the current version of the pull request it should be
            fetched from the server prior to this operation. Look for the 'version' attribute in the returned
            JSON structure. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$version = -1;

$result = $pullRequest->createDeclinePullRequest($projectKey, $repositorySlug, $pullRequestId, $version);

方法: getPullRequestActivities

检索与拉取请求关联的活动页面。

活动项包括评论、批准、重设范围(即添加和删除提交)、合并等。

在 Stash 的新版本或用户安装的插件中可能会引入不同类型的活动项目,因此客户端应足够灵活以处理返回页面中的意外实体形状。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequestActivities(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $fromId = null,
        $fromType = null)

参数

             <strong>fromId</strong> (either <strong>COMMENT</strong> or <strong>ACTIVITY</strong>) |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$fromId = 234;
$fromType = 'fromType';

$result = $pullRequest->getPullRequestActivities($projectKey, $repositorySlug, $pullRequestId, $fromId, $fromType);

方法: createReopenPullRequest

重新打开已拒绝的拉取请求。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function createReopenPullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $version = -1)

参数

            version the operation will fail. To determine the current version of the pull request it should be
            fetched from the server prior to this operation. Look for the 'version' attribute in the returned
            JSON structure. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$version = -1;

$result = $pullRequest->createReopenPullRequest($projectKey, $repositorySlug, $pullRequestId, $version);

方法: getCanMergePullRequest

测试拉取请求是否可以合并。

如果以下情况之一发生,则可能无法合并拉取请求:

  • 在合并之前需要手动解决的冲突;以及/或
  • 一个或多个合并检查已否决合并。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getCanMergePullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->getCanMergePullRequest($projectKey, $repositorySlug, $pullRequestId);

方法: createMergePullRequest

合并指定的拉取请求。

调用此资源时,认证用户必须对该拉取请求的目标存储库有 REPO_WRITE 权限。

function createMergePullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $version = -1)

参数

            version the operation will fail. To determine the current version of the pull request it should be
            fetched from the server prior to this operation. Look for the 'version' attribute in the returned
            JSON structure. |

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$version = -1;

$result = $pullRequest->createMergePullRequest($projectKey, $repositorySlug, $pullRequestId, $version);

方法: getPullRequest

检索一个拉取请求。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function getPullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';

$result = $pullRequest->getPullRequest($projectKey, $repositorySlug, $pullRequestId);

方法: updatePullRequest

更新现有拉取请求的标题、描述、审阅者或目标分支。

注意:可以使用此资源更新 审阅者 列表。但是,作者参与者 列表可能无法更新。

认证用户必须是拉取请求的作者并具有对该拉取请求目标存储库的 REPO_READ 权限,或者

  • 具有对该拉取请求目标存储库的 REPO_WRITE 权限,才能调用此资源。
  • 才能调用此资源。
function updatePullRequest(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 'pullRequestId';

$result = $pullRequest->updatePullRequest($dynamic, $projectKey, $repositorySlug, $pullRequestId);

方法: createAssignPullRequestParticipantRole

将参与者分配到拉取请求中的显式角色。目前只能分配 REVIEWER 角色。

如果用户还不是拉取请求的参与者,他们将被添加为参与者并分配所提供的角色。

如果用户已经是拉取请求的参与者,他们的先前角色将被替换为所提供的角色,除非他们已分配作者角色,该角色不能更改,并将导致 Bad Request (400) 响应代码。

调用此资源时,认证用户必须对该拉取请求的目标存储库有 REPO_WRITE 权限。

function createAssignPullRequestParticipantRole(
        $dynamic,
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->createAssignPullRequestParticipantRole($dynamic, $projectKey, $repositorySlug, $pullRequestId);

方法: deleteUnassignPullRequestParticipantRole

从拉取请求中取消分配参与者可能获得的REVIEWER角色。

如果参与者没有明确的角色,则此方法没有任何效果。

之后,用户仍将是拉取请求的参与者,但他们的角色将降级为PARTICIPANT。这是因为一旦成为拉取请求的参与者,用户将永远保持参与者状态。只有他们的角色可以更改。

调用此资源时,认证用户必须对该拉取请求的目标存储库有 REPO_WRITE 权限。

function deleteUnassignPullRequestParticipantRole(
        $projectKey,
        $repositorySlug,
        $pullRequestId,
        $username = null)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;
$username = 'username';

$result = $pullRequest->deleteUnassignPullRequestParticipantRole($projectKey, $repositorySlug, $pullRequestId, $username);

方法: listPullRequestParticipants

检索给定拉取请求的参与者页面。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function listPullRequestParticipants(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->listPullRequestParticipants($projectKey, $repositorySlug, $pullRequestId);

方法: createApprovePullRequest

作为当前用户批准拉取请求。如果用户尚未作为参与者添加,则隐式添加。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function createApprovePullRequest(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 234;

$result = $pullRequest->createApprovePullRequest($projectKey, $repositorySlug, $pullRequestId);

方法: deleteWithdrawPullRequestApproval

作为当前用户从拉取请求中移除批准。这不会移除用户作为参与者的状态。

认证用户必须对该拉取请求目标仓库具有REPO_READ权限才能调用此资源。

function deleteWithdrawPullRequestApproval(
        $projectKey,
        $repositorySlug,
        $pullRequestId)

参数

示例用法

$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';
$pullRequestId = 192;

$result = $pullRequest->deleteWithdrawPullRequestApproval($projectKey, $repositorySlug, $pullRequestId);

方法: createPullRequest

在两个分支之间创建新的拉取请求。这些分支可以是同一存储库的,也可以是不同的。当使用不同的存储库时,它们必须仍然属于同一{@link Repository#getHierarchyId()层次结构}。

调用此资源时,认证用户必须对“from”和“to”存储库拥有REPO_READ权限。

function createPullRequest(
        $pullRequest,
        $projectKey,
        $repositorySlug)

参数

示例用法

$pullRequest = new PullRequest();
$projectKey = 'projectKey';
$repositorySlug = 'repositorySlug';

$result = $pullRequest->createPullRequest($pullRequest, $projectKey, $repositorySlug);

错误

返回控制器列表

类: HookController

获取单例实例

可以从API客户端访问HookController类的单例实例。

$hook = $client->getHook();

方法: getAvatar

检索与提供的moduleKey匹配的项目头像。

function getAvatar(
        $hookKey,
        $version = null)

参数

            Note that this does not affect the Last-Modified header. |

示例用法

$hookKey = 'hookKey';
$version = 'version';

$result = $hook->getAvatar($hookKey, $version);

返回控制器列表

类: ProjectController

获取单例实例

可以通过API客户端访问 ProjectController 类的单例实例。

$project = $client->getProject();

方法: getProjectGroupsWithAnyPermission

检索至少被授予指定项目一个权限的组的页面。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function getProjectGroupsWithAnyPermission(
        $projectKey,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$filter = 'filter';

$result = $project->getProjectGroupsWithAnyPermission($projectKey, $filter);

方法: updateSetProjectPermissionForGroups

提升或降低指定项目的组权限级别。可用的项目权限有

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN
请参阅 Stash 文档 了解每个权限的详细说明。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。此外,如果用户的权限级别会因此降低,则用户不能降低组的权限级别。

function updateSetProjectPermissionForGroups(
        $projectKey,
        $permission = null,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$permission = 'permission';
$name = 'name';

$result = $project->updateSetProjectPermissionForGroups($projectKey, $permission, $name);

方法: deleteRevokeProjectPermissionsForGroup

撤销组在指定项目中的所有权限。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

此外,如果撤销组权限会降低其权限级别,则用户不能撤销组的权限。

function deleteRevokeProjectPermissionsForGroup(
        $projectKey,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$name = 'name';

$result = $project->deleteRevokeProjectPermissionsForGroup($projectKey, $name);

方法: getProjectGroupsWithoutAnyPermission

检索没有授予指定项目权限的组的页面。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function getProjectGroupsWithoutAnyPermission(
        $projectKey,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$filter = 'filter';

$result = $project->getProjectGroupsWithoutAnyPermission($projectKey, $filter);

方法: getProjectUsersWithAnyPermission

检索至少被授予指定项目一个权限的用户的页面。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function getProjectUsersWithAnyPermission(
        $projectKey,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$filter = 'filter';

$result = $project->getProjectUsersWithAnyPermission($projectKey, $filter);

方法: updateSetProjectPermissionForUsers

提升或降低特定项目的用户权限级别。可用的项目权限有

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN
请参阅 Stash 文档 了解每个权限的详细说明。

认证用户必须拥有特定项目的 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。此外,如果没有全局权限已经隐含该权限,用户不能降低自己的权限级别。

function updateSetProjectPermissionForUsers(
        $projectKey,
        $name = null,
        $permission = null)

参数

示例用法

$projectKey = 'projectKey';
$name = 'name';
$permission = 'permission';

$result = $project->updateSetProjectPermissionForUsers($projectKey, $name, $permission);

方法: deleteRevokeProjectPermissionsForUser

撤销指定项目为用户的所有权限。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

此外,如果没有更高的全局权限,用户不能撤销自己的项目权限。

function deleteRevokeProjectPermissionsForUser(
        $projectKey,
        $name = null)

参数

示例用法

$projectKey = 'projectKey';
$name = 'name';

$result = $project->deleteRevokeProjectPermissionsForUser($projectKey, $name);

方法: getProjectUsersWithoutPermission

检索一页没有为指定项目授予权限的 授权 用户。

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function getProjectUsersWithoutPermission(
        $projectKey,
        $filter = null)

参数

示例用法

$projectKey = 'projectKey';
$filter = 'filter';

$result = $project->getProjectUsersWithoutPermission($projectKey, $filter);

方法: getHasProjectAllUserPermission

检查指定权限是否为项目的默认权限(授予所有用户)。可用的项目权限有

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function getHasProjectAllUserPermission(
        $projectKey,
        $permission)

参数

示例用法

$projectKey = 'projectKey';
$permission = 'permission';

$result = $project->getHasProjectAllUserPermission($projectKey, $permission);

方法: modifyProjectAllUserPermission

授予或撤销所有用户的项目的权限,即设置默认权限。可用的项目权限有

  • PROJECT_READ
  • PROJECT_WRITE
  • PROJECT_ADMIN

认证用户必须对指定项目具有 PROJECT_ADMIN 权限或更高的全局权限才能调用此资源。

function modifyProjectAllUserPermission(
        $projectKey,
        $permission,
        $allow = null)

参数

示例用法

$projectKey = 'projectKey';
$permission = 'permission';
$allow = true;

$result = $project->modifyProjectAllUserPermission($projectKey, $permission, $allow);

方法: createProject

创建一个新的项目。

要包含项目的自定义头像,项目定义应包含一个额外的属性,键为 avatar,值为包含Base64编码的图像数据的data URI。URI应采用以下格式

     data:(content type, e.g. image/png);base64,(data)
 
如果数据未Base64编码,或者在URI中定义了字符集,或者URI无效,则 项目创建将失败

认证用户必须拥有 PROJECT_CREATE 权限才能调用此资源。

function createProject($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $project->createProject($dynamic);

方法: getProjects

检索一页项目。

只有认证用户具有 PROJECT_VIEW 权限的项目将被返回。

function getProjects(
        $name = null,
        $permission = null)

参数

示例用法

$name = 'name';
$permission = 'permission';

$result = $project->getProjects($name, $permission);

方法: deleteProject

删除与提供的 projectKey 匹配的项目。

认证用户必须对指定的项目有PROJECT_ADMIN权限才能调用此资源。

function deleteProject($projectKey)

参数

示例用法

$projectKey = 'projectKey';

$result = $project->deleteProject($projectKey);

方法: updateProject

更新与资源路径中提供的 projectKey 匹配的项目。

为了包含更新项目的自定义头像,项目定义应包含一个额外的属性,键为 avatar,值为包含 Base64 编码图像数据的 data URI。URI 应采用以下格式:data:(content type, 例如 image/png);base64,(数据) 如果数据不是 Base64 编码,或者 URI 中定义了字符集,或者 URI 无效,则 项目创建将失败

认证用户必须对指定的项目有PROJECT_ADMIN权限才能调用此资源。

function updateProject(
        $dynamic,
        $projectKey)

参数

示例用法

$dynamic = array('key' => 'value');
$projectKey = 'projectKey';

$result = $project->updateProject($dynamic, $projectKey);

方法: getProject

检索与提供的 projectKey 匹配的项目。

认证用户必须具有指定项目的 PROJECT_VIEW 权限才能调用此资源。

function getProject($projectKey)

参数

示例用法

$projectKey = 'projectKey';

$result = $project->getProject($projectKey);

方法: getProjectAvatar

检索与提供的 projectKey 匹配的项目的头像。

认证用户必须具有指定项目的 PROJECT_VIEW 权限才能调用此资源。

function getProjectAvatar(
        $projectKey,
        $s = 0)

参数

         size. |

示例用法

$projectKey = 'projectKey';
$s = 0;

$result = $project->getProjectAvatar($projectKey, $s);

方法: uploadProjectAvatar

更新与提供的 projectKey 匹配的项目的头像。

此资源接受 POST 多部分表单数据,包含一个名为 'avatar' 的表单字段中的单个图像。

服务器对尺寸(默认为 1024x1024 像素)和上传文件大小(默认为 1MB)都有可配置的限制。支持多种不同的图像格式,但 PNGJPEG 更受青睐,因为文件大小限制。

以下是一个上传图像名 'avatar.png' 的示例 curl 请求

 curl -X POST -u username:password http://example.com/rest/api/1.0/projects/STASH/avatar.png -F avatar=@avatar.png
 

认证用户必须对指定的项目有PROJECT_ADMIN权限才能调用此资源。

function uploadProjectAvatar($projectKey)

参数

示例用法

$projectKey = 'projectKey';

$result = $project->uploadProjectAvatar($projectKey);

返回控制器列表

类: TaskController

获取单例实例

可以从 API 客户端访问 TaskController 类的单一实例。

$task = $client->getTask();

方法: createTask

创建一个新任务。

function createTask($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $task->createTask($dynamic);

方法: deleteTask

删除任务。

请注意,只有任务的创建者、上下文的作者或上下文仓库的管理员才能删除任务。(对于拉取请求任务,这些是任务的创建者、拉取请求的作者或包含拉取请求的仓库的管理员)。此外,如果任务已被解决,则无法删除。

function deleteTask($taskId)

参数

示例用法

$taskId = 192;

$result = $task->deleteTask($taskId);

方法: updateTask

更新现有任务。

从Stash 3.3版本开始,只能更新任务的状态和文本。

任何拥有对仓库的读取访问权限的用户都可以更新任务的状态。但是,只有任务的创建者、上下文的作者或上下文仓库的管理员可以更新任务的文本。(对于拉取请求任务,这些是任务的创建者、拉取请求的作者或包含拉取请求的仓库的管理员)。此外,如果任务已被解决,则无法更新文本。

function updateTask(
        $dynamic,
        $taskId)

参数

示例用法

$dynamic = array('key' => 'value');
$taskId = 192;

$result = $task->updateTask($dynamic, $taskId);

方法: getTask

检索现有任务。

function getTask($taskId)

参数

示例用法

$taskId = 192;

$result = $task->getTask($taskId);

返回控制器列表

类: GroupController

获取单例实例

可以从API客户端访问GroupController类的单例实例。

$group = $client->getGroup();

方法: getGroups

检索一组群组名称的一页。

调用此资源时,认证用户必须具有项目管理员权限或更高权限。

function getGroups($filter = null)

参数

示例用法

$filter = 'filter';

$result = $group->getGroups($filter);

返回控制器列表

类: ProfileController

获取单例实例

可以从API客户端访问ProfileController类的单例实例。

$profile = $client->getProfile();

方法: getProfileRepositoriesRecentlyAccessed

检索当前认证用户最近访问的仓库的一页。

仓库按最近访问到最早访问的顺序排列。

只有认证用户可以调用此资源。

function getProfileRepositoriesRecentlyAccessed($permission = null)

参数

               the resulting repository list to ones that the requesting user has the specified permission
               level to. If not specified, the default <code>REPO_READ</code> permission level will be assumed. |

示例用法

$permission = 'permission';

$result = $profile->getProfileRepositoriesRecentlyAccessed($permission);

返回控制器列表

类: ApplicationController

获取单例实例

可以通过API客户端访问ApplicationController类的单例实例。

$application = $client->getApplication();

方法: getApplicationProperties

检索版本信息和其他应用程序属性。

调用此资源不需要身份验证。

function getApplicationProperties()

示例用法

$result = $application->getApplicationProperties();

返回控制器列表

类: LogController

获取单例实例

可以通过API客户端访问LogController类的单例实例。

$log = $client->getLog();

方法: getRootLevel

检索根记录器的当前日志级别。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getRootLevel()

示例用法

$result = $log->getRootLevel();

方法: updateSetRootLevel

设置根记录器的当前日志级别。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function updateSetRootLevel($levelName)

参数

示例用法

$levelName = 'levelName';

$result = $log->updateSetRootLevel($levelName);

方法: getLevel

检索给定记录器的当前日志级别。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function getLevel($loggerName)

参数

示例用法

$loggerName = 'loggerName';

$result = $log->getLevel($loggerName);

类: UserController

可以通过API客户端访问UserController类的单例实例。

调用此资源之前,认证用户必须具有 管理员 或更高权限。

function updateSetLevel(
        $levelName,
        $loggerName)

参数

示例用法

$levelName = 'levelName';
$loggerName = 'loggerName';

$result = $log->updateSetLevel($levelName, $loggerName);

返回控制器列表

方法: getUsers

获取单例实例

检索用户的一页,可选地通过提供的过滤器运行。

$user = $client->getUser();

支持的过滤器

过滤器以标准name=value形式包含在查询参数中。目前支持以下过滤器

只有认证用户可以调用此资源。

过滤器

过滤器以标准name=value形式包含在查询参数中。目前支持以下过滤器

  • {@code filter} - 仅返回用户名、姓名或电子邮件地址中包含{@code filter}值的用户
  • {@code permission} - 权限过滤器的"root",其值必须是有效的全局、项目或存储库权限。必须以permission.前缀指定引用此过滤器的附加过滤器参数,这些参数指定要应用过滤器的资源(项目或存储库)。有关更多详细信息,请参阅下面的"权限过滤器"部分。
  • {@code permission.N} - 单个权限过滤器的基础,类似于 {@code permission} 参数,其中 "N" 是从 1 开始的自然数。这允许客户端通过提供连续的过滤器(例如,{@code permission.1}、{@code permission.2} 等)来指定多个权限过滤器。请注意,过滤器编号必须从 1 开始,并且对于所有过滤器都需要连续处理。允许的最大权限过滤器数量为 50,所有超过此限制的过滤器都将被丢弃。有关权限过滤器处理详情,请参阅下面的“权限过滤器”部分。

权限过滤器

以下三个子部分列出了根据权限资源支持的权限过滤器参数(其中 [root] 是基础权限过滤器名称,例如 {@code permission}、{@code permission.1} 等)。系统根据 [root] 权限值确定应用哪个过滤器(全局、项目或仓库权限)。例如,ADMIN 是全局权限,PROJECT_ADMIN 是项目权限,REPO_ADMIN 是仓库权限。请注意,给定资源的参数将按以下顺序查找,例如,对于项目资源,如果同时提供了 projectIdprojectKey,则系统将使用 projectId 进行查找。

全局权限

[root] 下的权限值是唯一必需和识别的参数,因为全局权限不应用于特定资源。

示例有效过滤器:permission=ADMIN

项目权限

  • [root] - 指定项目权限
  • [root].projectId - 指定用于查找项目的项目 ID
  • [root].projectKey - 指定用于查找项目的项目密钥

示例有效过滤器:permission.1=PROJECT_ADMIN&permission.1.projectKey=TEST_PROJECT

仓库权限

  • [root] - 指定仓库权限
  • [root].projectId - 指定用于查找仓库的仓库 ID
  • [root].projectKey[root].repositorySlug - 指定用于查找仓库的项目密钥和仓库别名;这两个值都必须提供才能触发此查找
示例有效过滤器:permission.2=REPO_ADMIN&permission.2.projectKey=TEST_PROJECT&permission.2.repositorySlug=test_repo
function getUsers()

示例用法

$result = $user->getUsers();

方法: updateUserDetails

更新当前认证用户的详细信息。请注意,名称属性被忽略,更新将始终应用于当前认证用户。

function updateUserDetails($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $user->updateUserDetails($dynamic);

方法: deleteUserAvatar

删除与用户关联的头像。

用户始终允许删除自己的头像。要删除其他人的头像,认证用户必须具有全局 ADMIN 权限,或者具有更新 SYS_ADMIN 用户头像的全局 SYS_ADMIN 权限。

function deleteUserAvatar($userSlug)

参数

示例用法

$userSlug = 'userSlug';

$result = $user->deleteUserAvatar($userSlug);

方法: uploadUserAvatar

使用提供的 slug 更新用户的头像。

此资源接受 POST 多部分表单数据,包含一个名为 'avatar' 的表单字段中的单个图像。

服务器对尺寸(默认为 1024x1024 像素)和上传文件大小(默认为 1MB)都有可配置的限制。支持多种不同的图像格式,但 PNGJPEG 更受青睐,因为文件大小限制。

此资源具有跨站请求伪造(XSRF)保护。为了使请求通过 XSRF 检查,调用者需要发送带有值 no-checkX-Atlassian-Token HTTP 标头。

以下是一个上传图像名 'avatar.png' 的示例 curl 请求

 curl -X POST -u username:password -H "X-Atlassian-Token: no-check" http://example.com/rest/api/latest/users/jdoe/avatar.png -F avatar=@avatar.png
 

用户始终可以更新自己的头像。要更新他人的头像,认证用户必须具有全局管理员权限,或者具有全局系统管理员权限以更新系统管理员用户的头像。

function uploadUserAvatar($userSlug)

参数

示例用法

$userSlug = 'userSlug';

$result = $user->uploadUserAvatar($userSlug);

方法: getUser

检索与提供的用户别名匹配的用户。

function getUser($userSlug)

参数

示例用法

$userSlug = 'userSlug';

$result = $user->getUser($userSlug);

方法: updateUserPassword

更新当前认证用户的密码。

function updateUserPassword($dynamic)

参数

示例用法

$dynamic = array('key' => 'value');

$result = $user->updateUserPassword($dynamic);

方法: getUserSettings

检索特定用户的用户设置键值映射,用户通过用户别名识别。

function getUserSettings($userSlug)

参数

示例用法

$userSlug = 'userSlug';

$result = $user->getUserSettings($userSlug);

方法: updateUserSettings

更新特定用户通过用户别名识别的用户设置键/值映射条目。

function updateUserSettings(
        $dynamic,
        $userSlug)

参数

示例用法

$dynamic = array('key' => 'value');
$userSlug = 'userSlug';

$result = $user->updateUserSettings($dynamic, $userSlug);

返回控制器列表

类: MarkupController

获取单例实例

可以从API客户端访问MarkupController类的单例实例。

$markup = $client->getMarkup();

方法: createPreviewMarkup

预览给定Markdown内容的生成HTML。

只有认证用户可以调用此资源。

function createPreviewMarkup(
        $dynamic,
        $urlMode = null,
        $hardwrap = null,
        $htmlEscape = null)

参数

示例用法

$dynamic = array('key' => 'value');
$urlMode = 'urlMode';
$hardwrap = true;
$htmlEscape = true;

$result = $markup->createPreviewMarkup($dynamic, $urlMode, $hardwrap, $htmlEscape);

返回控制器列表