项目管理模块

查看指定代码库的指定分析项目列表

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/

参数列表

参数类型描述
scm_url_or_namestr选填,代码库地址或者名称,支持模糊匹配
scm_urlstr选填,代码库仓库匹配
scopestr选填,过滤范围(my/subscribed/related_me),my表示我创建的,subscribed表示我关注的,related_me表示我有权限的

返回结果

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "name": "test_repo.git",
            "scm_url": "http://git.com/xxx/test_repo",
            "scm_type": "git",
            "branch_count": 1,
            "scheme_count": 1,
            "job_count": 1,
            "created_time": "2021-03-15 02:26:31.423674+00:00",
            "recent_active": {
                "id": 1,
                "branch_name": "master",
                "active_time": "2021-03-15T03:14:56.760427Z",
                "total_line_num": null,
                "code_line_num": null
            },
            "created_from": "codedog_web",
            "creator": {
                "username": "username",
                "nickname": "nickname",
                "status": 1,
                "avatar": null,
                "org": 1
            },
            "symbol": null
        }
    ]
}

查看已创建的授权信息

GET /server/main/api/authen/scmallaccounts/

返回结果

{
    "data": {
        "ssh": [
            {
                "id": 1,
                "user": {
                    "username": "CodeDog",
                    "nickname": "CodeDog",
                    "status": 1,
                    "avatar": null,
                    "latest_login_time": "2022-10-22T15:30:30+08:00",
                    "org": null
                },
                "auth_origin": "CodeDog",
                "indentity": "xxx",
                "display_scm_platform": "tgit",
                "name": "gerrit",
                "scm_platform": 1,
                "scm_platform_desc": null
            }
        ],
        "account": [
            {
                "id": 1,
                "user": {
                    "username": "CodeDog",
                    "nickname": "CodeDog",
                    "status": 1,
                    "avatar": null,
                    "latest_login_time": "2022-10-22T15:30:30+08:00",
                    "org": null
                },
                "auth_origin": "CodeDog",
                "display_scm_platform": "tgit",
                "scm_username": "CodeDog",
                "scm_platform": 1,
                "scm_platform_desc": null
            }
        ],
        "oauth": [
            {
                "id": 1,
                "user": {
                    "username": "CodeDog",
                    "nickname": "CodeDog",
                    "status": 1,
                    "avatar": null,
                    "latest_login_time": "2022-10-22T15:30:30+08:00",
                    "org": null
                },
                "auth_origin": "CodeDog",
                "scm_platform_name": "tgit"
            }
        ],
    }
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

登记代码库

POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/

参数列表

参数类型描述
scm_urlstr必填,代码库地址
scm_typestr必填,git或svn
ssh_urlstr选填,代码库SSH地址
namestr选填, 代码库名称
scm_authdict选填,代码库授权

例子:

{
    "scm_url": "https://github.com/Tencent/CodeAnalysis",
    "scm_type": "git",
    "name": "CodeAnalysis",
    "scm_auth": {
        # 通过 查看已创建的授权信息 接口获取到对应的凭证id,scm_account、scm_oauth、scm_ssh 只需填一个
        "scm_account": account_id,
        "scm_ssh": ssh_id,
        "scm_oauth": oauth_id
    }
}

返回结果

{
    "data":{
        "id": 1,
        "name": "CodeAnalysis",
        "scm_url": "http://github.com/Tencent/CodeAnalysis",
        "scm_type": "git",
        "branch_count": 0,
        "scheme_count": 0,
        "job_count": 0,
        "created_time": "2022-10-22T16:30:30+08:00",
        "recent_active": {
        },
        "created_from": "codedog_web",
        "creator": {
            "username": "username",
            "nickname": "nickname",
            "status": 1,
            "avatar": null,
            "org": 1
        },
        "symbol": null
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库详情

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/

返回结果

{
    "data":{
        "id": 1,
        "name": "test_repo.git",
        "scm_url": "http://git.com/xxx/test_repo",
        "scm_type": "git",
        "branch_count": 1,
        "scheme_count": 1,
        "job_count": 1,
        "created_time": "2021-03-15 02:26:31.423674+00:00",
        "recent_active": {
            "id": 1,
            "branch_name": "master",
            "active_time": "2021-03-15T03:14:56.760427Z",
            "total_line_num": null,
            "code_line_num": null
        },
        "created_from": "codedog_web",
        "creator": {
            "username": "username",
            "nickname": "nickname",
            "status": 1,
            "avatar": null,
            "org": 1
        },
        "symbol": null
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库的不同分支的列表接口

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/branches/

返回结果

{
    "data": {
        "count": 1,
        "next": null,
        "previous": null,
        "results": [
            {
                "branch": "master",
                "schemes": [
                    {
                        "project_id": 1,
                        "scan_scheme_id": 1,
                        "scan_scheme_name": "默认"
                    }
                ]
            }
        ]
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库的分析项目列表

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/

参数列表

参数类型描述
branchstr选填,分支名称
scan_schemeint选填,扫描方案名称
scan_scheme__statusint选填,扫描方案状态,1为活跃,2为废弃
branch_or_schemestr选填,分支名称/扫描方案名称
statusint选填,项目状态筛选,1表示活跃,2表示失活,3表示关闭

返回结果

{
    "data": {
        "count": 1,
        "next": null,
        "previous": null,
        "results": [
            {
                "id": 1,
                "creator": {
                    "username": "username",
                    "nickname": "nickname",
                    "status": 1,
                    "avatar": null,
                    "org": 1
                },
                "created_time": "2021-01-28 02:27:26.256015+00:00",
                "modifier": null,
                "modified_time": "2021-01-28 02:27:26.256284+00:00",
                "deleter": null,
                "deleted_time": null,
                "scan_scheme": {
                    "id": 1,
                    "creator": {
                        "username": "username",
                        "nickname": "nickname",
                        "status": 1,
                        "avatar": null,
                        "org": 1
                    },
                    "created_time": "2021-01-28 02:27:26.209661+00:00",
                    "modifier": null,
                    "modified_time": "2021-01-28 02:27:26.255023+00:00",
                    "deleter": null,
                    "deleted_time": null,
                    "languages": [
                        "python"
                    ],
                    "tag": "TCA_Linux",
                    "refer_scheme_info": null,
                    "name": "默认",
                    "description": null,
                    "default_flag": true,
                    "created_from": "web",
                    "job_runtime_limit": 600,
                    "ignore_merged_issue": false,
                    "ignore_branch_issue": null,
                    "ignore_submodule_clone": false,
                    "ignore_submodule_issue": true,
                    "issue_global_ignore": false,
                    "daily_save": false,
                    "lfs_flag": null,
                    "webhook_flag": false,
                    "issue_revision_merge_flag": false,
                    "status": 1,
                    "scheme_key": null,
                    "repo": 1
                },
                "branch": "master",
                "status": 1,
                "created_from": "codedog_web",
                "repo": 1
            }
        ]
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

创建指定代码库的指定分析项目

POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/

参数列表

参数类型描述
scan_scheme_idint和global_scheme_id二选一进行填写,当前代码库的扫描方案编号
global_scheme_idint和scan_scheme_id二选一进行填写,扫描方案模板编号
custom_scheme_namestr选填,自定义方案名称
branchstr必填,分支
created_fromstr选填,创建渠道,用于区分不同运行场景

返回结果

{
    "data": {
        "id":1,
        "creator": {
            "username": "username",
            "nickname": "nickname",
            "status": 1,
            "avatar": null,
            "org": 1
        },
        "created_time": "2021-01-28 02:27:26.256015+00:00",
        "modifier": null,
        "modified_time": "2021-01-28 02:27:26.256284+00:00",
        "deleter": null,
        "deleted_time": null,
        "repo": {
            "id": 1,
            "name": "test_demo.git",
            "scm_url": "http://github.com/xxxx/test_demo.git",
            "scm_type": "git",
            "scm_auth": {
                "id": 1,
                "scm_account": null,
                "scm_oauth": null,
                "scm_ssh": {
                    "id": 1,
                    "name": "1",
                    "scm_platform": 1,
                    "scm_platform_desc": null,
                    "user": {
                        "username": "username",
                        "nickname": "nickname",
                        "status": 1,
                        "avatar": null,
                        "org": 1
                    }
                },
                "auth_type": "ssh_token",
                "created_time": "2021-01-28T10:26:31.453389+08:00",
                "modified_time": "2021-01-28T10:26:31.453417+08:00"
            },
            "symbol": null
        },
        "scan_scheme": {
            "id": 1,
            "creator": {
                "username": "username",
                "nickname": "nickname",
                "status": 1,
                "avatar": null,
                "org": 1
            },
            "created_time": "2021-01-28 02:27:26.209661+00:00",
            "modifier": null,
            "modified_time": "2021-01-28 02:27:26.255023+00:00",
            "deleter": null,
            "deleted_time": null,
            "languages": [
                "python"
            ],
            "tag": "TCA_Linux",
            "refer_scheme_info": null,
            "name": "默认",
            "description": null,
            "default_flag": true,
            "created_from": "web",
            "job_runtime_limit": 600,
            "ignore_merged_issue": false,
            "ignore_branch_issue": null,
            "ignore_submodule_clone": false,
            "ignore_submodule_issue": true,
            "issue_global_ignore": false,
            "daily_save": false,
            "lfs_flag": null,
            "webhook_flag": false,
            "issue_revision_merge_flag": false,
            "status": 1,
            "scheme_key": null,
            "repo": 1
        },
        "branch": "master",
        "status": 1,
        "created_from": "tca_web"
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库的指定分析项目

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/

返回结果

{
    "data": {
        "id":1,
        "creator": {
            "username": "username",
            "nickname": "nickname",
            "status": 1,
            "avatar": null,
            "org": 1
        },
        "created_time": "2021-01-28 02:27:26.256015+00:00",
        "modifier": null,
        "modified_time": "2021-01-28 02:27:26.256284+00:00",
        "deleter": null,
        "deleted_time": null,
        "repo": {
            "id": 1,
            "name": "test_demo.git",
            "scm_url": "http://github.com/xxxx/test_demo.git",
            "scm_type": "git",
            "scm_auth": {
                "id": 1,
                "scm_account": null,
                "scm_oauth": null,
                "scm_ssh": {
                    "id": 1,
                    "name": "1",
                    "scm_platform": 1,
                    "scm_platform_desc": null,
                    "user": {
                        "username": "username",
                        "nickname": "nickname",
                        "status": 1,
                        "avatar": null,
                        "org": 1
                    }
                },
                "auth_type": "ssh_token",
                "created_time": "2021-01-28T10:26:31.453389+08:00",
                "modified_time": "2021-01-28T10:26:31.453417+08:00"
            },
            "symbol": null
        },
        "scan_scheme": {
            "id": 1,
            "creator": {
                "username": "username",
                "nickname": "nickname",
                "status": 1,
                "avatar": null,
                "org": 1
            },
            "created_time": "2021-01-28 02:27:26.209661+00:00",
            "modifier": null,
            "modified_time": "2021-01-28 02:27:26.255023+00:00",
            "deleter": null,
            "deleted_time": null,
            "languages": [
                "python"
            ],
            "tag": "TCA_Linux",
            "refer_scheme_info": null,
            "name": "默认",
            "description": null,
            "default_flag": true,
            "created_from": "web",
            "job_runtime_limit": 600,
            "ignore_merged_issue": false,
            "ignore_branch_issue": null,
            "ignore_submodule_clone": false,
            "ignore_submodule_issue": true,
            "issue_global_ignore": false,
            "daily_save": false,
            "lfs_flag": null,
            "webhook_flag": false,
            "issue_revision_merge_flag": false,
            "status": 1,
            "scheme_key": null,
            "repo": 1
        },
        "branch": "master",
        "status": 1,
        "created_from": "tca_web"
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库的扫描方案列表

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/

参数列表

参数类型描述
namestr选填,扫描方案名称
statusint选填,扫描方案状态,1为活跃,2为废弃

返回结果

{
    "data": {
        "count": 1,
        "next": null,
        "previous": null,
        "results": [
            {
                "id": 1,
                "creator": {
                    "username": "username",
                    "nickname": "nickname",
                    "status": 1,
                    "avatar": null,
                    "org": 1
                },
                "created_time": "2021-01-28 02:27:26.209661+00:00",
                "modifier": null,
                "modified_time": "2021-01-28 02:27:26.255023+00:00",
                "deleter": null,
                "deleted_time": null,
                "languages": [
                    "python"
                ],
                "tag": "TCA_Linux",
                "refer_scheme": null,
                "name": "默认",
                "description": null,
                "default_flag": true,
                "created_from": "web",
                "job_runtime_limit": 600,
                "ignore_merged_issue": false,
                "ignore_branch_issue": null,
                "ignore_submodule_clone": false,
                "ignore_submodule_issue": true,
                "issue_global_ignore": false,
                "daily_save": false,
                "lfs_flag": null,
                "issue_revision_merge_flag": false,
                "status": 1,
                "repo": 1
            }
        ]
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

查看指定代码库的指定扫描方案

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/basicconf/

返回结果

{
    "data": {
        "id": 1,
        "creator": {
            "username": "username",
            "nickname": "nickname",
            "status": 1,
            "avatar": null,
            "org": 1
        },
        "created_time": "2021-01-28 02:27:26.209661+00:00",
        "modifier": null,
        "modified_time": "2021-01-28 02:27:26.255023+00:00",
        "deleter": null,
        "deleted_time": null,
        "languages": [
            "python"
        ],
        "tag": "TCA_Linux",
        "refer_scheme": null,
        "name": "默认",
        "description": null,
        "default_flag": true,
        "created_from": "web",
        "job_runtime_limit": 600,
        "ignore_merged_issue": false,
        "ignore_branch_issue": null,
        "ignore_submodule_clone": false,
        "ignore_submodule_issue": true,
        "issue_global_ignore": false,
        "daily_save": false,
        "lfs_flag": null,
        "issue_revision_merge_flag": false,
        "status": 1,
        "repo": 1
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

更新指定代码库的指定方案

PUT /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/basicconf/

参数列表

参数类型描述
languageslist选填,代码语言
tagstr选填,执行标签,目前只支持 CodeDog_Linux
namestr必填,方案名称
descriptionstr选填,方案描述
default_flagbool选填,默认方案标志,一个代码库只能有一个默认方案
job_runtime_limitint选填,任务执行超时时间,默认为600分钟
ignore_merged_issuebool选填,忽略合入的问题
ignore_branch_issuestr选填,过滤参考分支引入的问题
ignore_submodule_clonebool选填,不拉取子模块扫描,True表示不拉取,False表示拉取
ignore_submodule_issuebool选填,忽略子模块引入的问题,True表示忽略,False表示不忽略
issue_global_ignorebool选填,问题全局忽略
daily_savebool选填,每次扫描原始数据存储,默认存储7天
lfs_flagbool选填,拉取lfs模块开关
issue_revision_merge_flagbool选填,"是否开启Issue按引入版本号聚合开关
statusint选填,方案状态,1表示活跃,2表示废弃

返回结果

查看指定代码库的指定扫描方案的返回结果一致

查看指定代码库的扫描方案的代码扫描配置

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/lintconf/

返回结果

{
    "data": {
        "id": 1,
        "enabled": true,
        "checkprofile": {
            "id": 1,
            "profile_type": 1,
            "custom_checkpackage": 1,
            "checkpackages": [
                1
            ]
        },
        "scan_scheme": 1
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

更新指定代码库的指定方案的代码扫描配置

PUT /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/lintconf/

参数列表

参数类型描述
enabledbool必填,是否开启代码扫描

返回结果

指定代码库的指定方案的代码扫描配置的返回结果一致

查看指定代码库的扫描方案的代码度量配置

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/metricconf/

返回结果

{
    "data": {
        "id": 1,
        "cc_scan_enabled": false,
        "min_ccn": 20,
        "dup_scan_enabled": false,
        "dup_block_length_min": 120,
        "dup_block_length_max": null,
        "dup_min_dup_times": 2,
        "dup_max_dup_times": null,
        "dup_min_midd_rate": 5,
        "dup_min_high_rate": 11,
        "dup_min_exhi_rate": 20,
        "dup_issue_limit": 1000,
        "cloc_scan_enabled": false,
        "scan_scheme": 1
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

更新指定代码库的指定方案的代码度量配置

PUT /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/metricconf/

参数列表

参数类型描述
cc_scan_enabledbool选填,圈复杂度扫描开关
min_ccnint选填,最小圈复杂度
dup_scan_enabledbool选填,重复代码扫描开关
dup_block_length_minint选填,重复块最小长度
dup_block_length_maxint选填,重复块最大长度
dup_max_dup_timesint选填,最大重复次数
dup_min_midd_rateint选填,中风险最小重复率
dup_min_high_rateint选填,高风险最小重复率
dup_min_exhi_rateint选填,极高风险风险最小重复率
dup_issue_limitint选填,上报重复代码块数上限
cloc_scan_enabledboolean选填,代码统计扫描开关

返回结果

指定代码库的指定方案的代码度量配置的返回结果一致

查看指定代码库的扫描方案的过滤路径列表

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/scandirs/

返回结果

{
    "data": {
        "count": 1,
        "next": null,
        "previous": null,
        "results": [
            {
                "id": 1,
                "dir_path": "test/*",
                "path_type": 1,
                "scan_type": 1,
                "scan_scheme": 1
            }
        ]
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

创建指定代码库的指定方案的过滤路径列表

POST /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/scandirs/

参数列表

参数类型描述
dir_pathstr必填,指定过滤路径
path_typeint选填,路径格式,1表示通配符,2表示正则表达式,默认为通配符
scan_typeint选填,扫描类型,1表示包含,2表示排除

返回结果

{
    "data": {
        "id": 13,
        "dir_path": "test/*.py",
        "path_type": 1,
        "scan_type": 1,
        "scan_scheme": 36
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 201
}

查看指定代码库的扫描方案的指定过滤路径

GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/scandirs/<dir_id>/

返回结果

{
    "data": {
        "id": 1,
        "dir_path": "test/*.py",
        "path_type": 1,
        "scan_type": 1,
        "scan_scheme": 1
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 200
}

更新指定代码库的指定方案的指定过滤路径

PUT /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/scandirs/<dir_id>/

参数列表

参数类型描述
dir_pathstr必填,指定过滤路径
path_typeint选填,路径格式,1表示通配符,2表示正则表达式,默认为通配符
scan_typeint选填,扫描类型,1表示包含,2表示排除

返回结果

{
    "data": {
        "id": 13,
        "dir_path": "test/*.py",
        "path_type": 1,
        "scan_type": 1,
        "scan_scheme": 36
    },
    "code": 0,
    "msg": "请求成功",
    "status_code": 201
}

删除指定代码库的指定方案的指定过滤路径

DELETE /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/scandirs/<dir_id>/

返回结果