Help Center/ CodeArts Repo/ API Reference/ APIs/ V2Project/ Creating a Project and Forking a Repository
Updated on 2023-09-12 GMT+08:00

Creating a Project and Forking a Repository

Function

After a warehouse is created, the following parameters are transferred to the fork warehouse: warehouse name, whether to import project members, and home project.

URI

POST /v2/projects/repositories/fork

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

import_members

No

Integer

Indicates whether to import project members. The options are as follows: 0->Do not import project members; 1->Import project members

project_name

Yes

String

Project name. The options are as follows: The value can contain uppercase letters, lowercase letters, digits, hyphens (-), and underscores (_), and must start with a letter.

repo_name

Yes

String

Repository name. The options are as follows: The value can contain uppercase letters, lowercase letters, digits, hyphens (-), and underscores (_), and must start with a letter.

Minimum: 2

Maximum: 128

template_id

Yes

String

ID of the replication template.

type

No

String

Project type. The options are normal and scrum.

visibility_level

No

Integer

Whether the warehouse is a public warehouse

external_project_info

No

ExternalKeyMessage object

Third-party service information

Table 3 ExternalKeyMessage

Parameter

Mandatory

Type

Description

external_key_message

No

String

Key information stored by third parties in code hosting

external_service

No

String

External Service Name

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error.

result

ProjectRepository object

Result

status

String

Status code in a response

Table 5 Error

Parameter

Type

Description

code

String

Error Codes

message

String

Error message

Table 6 ProjectRepository

Parameter

Type

Description

projectUuid

String

Specifies the UUID of the created project.

Minimum: 32

Maximum: 32

repositoryUuid

String

UUID of the repository to be created.

Minimum: 32

Maximum: 32

Example Requests

POST https://{endpoint}/v2/projects/{project_uuid}/repositories/fork

{
  "project_name" : "testworld",
  "repo_name" : "demotest1",
  "template_id" : 453489,
  "import_members" : 0,
  "visibility_level" : 20,
  "type" : "normal"
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "repositoryUuid" : "9a780fd55cd64333b668ba26132629d2",
    "projectUuid" : "278a03286efe45c6b788122bfc166976"
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.