Updated on 2025-09-08 GMT+08:00

Creating a Microservice

Function

This API is used to create a microservice.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{cloudProjectId}/component/create

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

cloudProjectId

Yes

String

Project ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Name.

type

Yes

String

Type.

parent_id

Yes

String

Parent ID.

desc

Yes

String

Description.

repos

Yes

Array of ComponentRepoVO objects

Repository.

Table 3 ComponentRepoVO

Parameter

Mandatory

Type

Description

type

Yes

String

Definition:

Repository type.

Value range:

N/A

repo_id

Yes

String

Definition:

Repo ID.

Value range:

N/A

http_url

Yes

String

Definition:

HTTP address of the repository.

Value range:

N/A

git_url

Yes

String

Definition:

GIT address of the repository.

Value range:

N/A

branch

Yes

String

Definition:

Branch.

Value range:

N/A

language

Yes

String

Definition:

Language.

Value range:

N/A

endpoint_id

No

String

Definition:

Endpoint ID.

Value range:

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

id

String

Definition:

Microservice ID.

Value range:

The value consists of 32 characters, including digits and letters.

name

String

Definition:

Microservice name.

Value range:

N/A

type

String

Definition:

Microservice type.

Value range:

N/A

description

String

Definition:

Microservice description.

Value range:

N/A

status

String

Definition:

Microservice status.

Value range:

N/A

parent_id

String

Definition:

Parent ID.

Value range:

N/A

cloud_project_id

String

Definition:

Project ID.

Value range:

The value consists of 32 characters, including digits and letters.

repos

Array of ComponentRepoVO objects

Definition:

Microservice code repository.

Value range:

N/A

is_followed

Boolean

Definition:

Whether the component is added to favorites.

Value range:

  • true: The component has been added to favorites.

  • false: The component is not added to favorites.

creator_id

String

Definition:

Creator ID.

Value range:

The value consists of 32 characters, including digits and letters.

creator_name

String

Definition:

Creator name.

Value range:

N/A

create_time

String

Definition:

Creation time.

Value range:

N/A

updater_id

String

Definition:

Updater ID.

Value range:

The value consists of 32 characters, including digits and letters.

updater_name

String

Definition:

Updater name.

Value range:

N/A

update_time

String

Definition:

Update time.

Value range:

N/A

Table 5 ComponentRepoVO

Parameter

Type

Description

type

String

Definition:

Repository type.

Value range:

N/A

repo_id

String

Definition:

Repo ID.

Value range:

N/A

http_url

String

Definition:

HTTP address of the repository.

Value range:

N/A

git_url

String

Definition:

GIT address of the repository.

Value range:

N/A

branch

String

Definition:

Branch.

Value range:

N/A

language

String

Definition:

Language.

Value range:

N/A

endpoint_id

String

Definition:

Endpoint ID.

Value range:

N/A

Example Requests

POSt http://{endpoint}/v2/2d09f712e9504b61b034cc8f40e475a8/component/create

{
  "name" : "aaa",
  "type" : "microservice",
  "parent_id" : null,
  "desc" : "",
  "repos" : [ {
    "type" : "codehub",
    "repo_id" : "985241",
    "http_url" : "http://example.com/test00001/maven.git",
    "git_url" : "git@example.com:test00001/maven.git",
    "branch" : "master",
    "language" : "java",
    "endpoint_id" : ""
  } ]
}

Example Responses

Status code: 200

Response body for creating a microservice.

{
  "id" : "fcefc80dd6a844d89fd12031fd83bac0",
  "name" : "aaa",
  "type" : "microservice",
  "description" : "",
  "status" : "active",
  "parent_id" : null,
  "cloud_project_id" : "2d09f712e9504b61b034cc8f40e475a8",
  "repos" : [ {
    "type" : "codehub",
    "repo_id" : "985241",
    "http_url" : "http://codehub.devcloud.{region}.huaweicloud.com/2d09f712e9504b61b034cc8f40e475a8/javaweb.git",
    "git_url" : "git@codehub.devcloud.{region}.huaweicloud.com:2d09f712e9504b61b034cc8f40e475a8/javaweb.git",
    "branch" : "master",
    "language" : "java",
    "endpoint_id" : ""
  } ],
  "is_followed" : null,
  "creator_id" : "05d8ca972f114765a8984795a8aa4d41",
  "creator_name" : "p_test_north5",
  "create_time" : "1719321282",
  "updater_id" : "05d8ca972f114765a8984795a8aa4d41",
  "updater_name" : "p_test_north5",
  "update_time" : "1719321282"
}

Status Codes

Status Code

Description

200

Response body for creating a microservice.

Error Codes

See Error Codes.