文档首页> 代码托管 CodeHub> API参考> 应用示例> 示例2:通过仓库的UUID查询指定仓库详情
更新时间:2021-12-29 GMT+08:00
分享

示例2:通过仓库的UUID查询指定仓库详情

场景描述

本章以Devcloud用户为例,指导您通过API查询指定仓库详情。

API的调用方法请参见如何调用API

前提

用户已经在Devcloud控制台中开启了代码托管服务。

总体思路

先通过api查看所有的仓库列表,并获得想要查看的仓库的UUID,使用该UUID在本api中查询该仓库的详细信息,步骤如下:

  1. 查询用户的所有仓库
  2. 查询某个仓库的详细信息

步骤1:查询用户的所有仓库

  • 请求示例
    GET  https://codehub-ext.cn-north-7.myhuaweicloud.com/v2/projects/repositories
  • 响应示例
    {
     "result": {
      "total": 40,
      "repositories": [
       {
        "star": false,
        "status": 5,
        "userRole": null,
        "repository_uuid": "25c88b23d4dc400fa7b3e2a152e4d53c",
        "repository_id": 522140,
        "repository_name": "1111111111111",
        "ssh_url": "git@codehub.devcloud.cn-north-208.ulanqab.huawei.com:testzxq00001/1111111111111.git",
        "https_url": "https://codehub.devcloud.cn-north-208.ulanqab.huawei.com/testzxq00001/1111111111111.git",
        "group_name": "testzxq00001",
        "web_url": "https://devcloud.cn-north-208.ulanqab.huawei.com/codehub/522140/home",
        "visibility_level": 0,
        "created_at": "2020-07-22 10:45:56",
        "updated_at": "2020-07-22 10:45:56",
        "repository_size": "0.16M",
        "lfs_size": "0.00M",
        "creator_name": "devcloud_codehub_l00314597_01",
        "domain_name": "devcloud_codehub_l00314597_01",
        "is_owner": 1,
        "iam_user_uuid": "a618e34bd5704be3ae3395dfede06041",
        "project_uuid": "a689e057c2304abfa35d4ff65630a90a",
        "project_is_deleted": "false"
       }
      ]
     },
     "status": "success"}

步骤2:查询仓库详情

  • 请求示例
    GET  https://codehub-ext.cn-north-7.myhuaweicloud.com/v2/repositories/73de3f67b30a46a4a7305f3be980c3b1
  • 响应示例
    {                         
     "result": {
      "star": null,
      "status": null,
      "userRole": null,
      "repository_uuid": "25c88b23d4dc400fa7b3e2a152e4d53c",
      "repository_id": 522140,
      "repository_name": "1111111111111",
      "ssh_url": "git@codehub.devcloud.cn-north-208.ulanqab.huawei.com:testzxq00001/1111111111111.git",
      "https_url": "https://codehub.devcloud.cn-north-208.ulanqab.huawei.com/testzxq00001/1111111111111.git",
      "group_name": "testzxq00001",
      "web_url": "https://devcloud.cn-north-208.ulanqab.huawei.com/codehub/522140/home",
      "visibility_level": 0,
      "created_at": "2020-07-22 10:45:56",
      "updated_at": null,
      "repository_size": null,
      "lfs_size": null,
      "creator_name": null,
      "domain_name": null,
      "is_owner": null,
      "iam_user_uuid": null,
      "project_uuid": "a689e057c2304abfa35d4ff65630a90a",
      "project_is_deleted": "false"
     },
     "status": "success"
    }
分享:

    相关文档

    相关产品

关闭导读