Help Center> ServiceStage> API Reference> CSE API> Microservice Instance> Registering a Microservice Instance

Registering a Microservice Instance

Function

This API is used to register a microservice instance after a microservice is created. To register a microservice instance, you need to provide its information as required. The instance ID can be customized. If it is customized, all contents are overwritten upon re-registration. If it is not customized, the system automatically generates an instance ID. If the endpoint content is duplicate, the original ID is used.

URI

POST /v4/{project_id}/registry/microservices/{service_id}/instances

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Unique ID of a tenant sub-project. Length: 1–64 characters.

service_id

Yes

String

Microservice ID, which must be unique. Length: 1–64 characters. Regular expression: ^.*$

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

x-domain-name

Yes

String

Tenant account name.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

instance

No

MicroServiceInstance object

Microservice instance information.

Table 4 MicroServiceInstance

Parameter

Mandatory

Type

Description

instanceId

No

String

Instance ID, which must be unique. During instance creation, instanceId is generated by the service center.

serviceId

No

String

Microservice ID, which must be unique. During instance creation, the service ID in the URL instead of the service ID here is used.

version

No

String

Microservice version.

hostName

Yes

String

Host information.

endpoints

Yes

Array of strings

Access address.

status

No

String

Instance status. Value: UP (default), DOWN, STARTING, or OUTOFSERVICE.

properties

No

Object

Extended attribute. You can customize a key and value. The value contains at least 1 byte.

healthCheck

No

HealthCheck object

Health check information.

dataCenterInfo

No

DataCenterInfo object

Data center information.

timestamp

No

String

Instance creation timestamp, which is automatically generated.

modTimestamp

No

String

Update time.

Table 5 HealthCheck

Parameter

Mandatory

Type

Description

mode

Yes

String

Heartbeat mode. Value: push or pull.

port

No

Integer

Port.

interval

Yes

Integer

Interval for sending heartbeat messages, in seconds.

times

Yes

Integer

Number of failures that are allowed.

Table 6 DataCenterInfo

Parameter

Mandatory

Type

Description

name

Yes

String

Region name.

region

Yes

String

Region.

availableZone

Yes

String

AZ.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

instanceId

String

Instance ID.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error information.

detail

String

Location details.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error information.

detail

String

Location details.

Example Requests

POST https://{endpoint}/v4/{project_id}/registry/existence

{
  "instance" : {
    "endpoints" : [ "grpc://127.0.1.312:9980", "rest://127.0.0.111:8081" ],
    "hostName" : "localhost",
    "status" : "UP",
    "stage" : "dev",
    "properties" : {
      "_TAGS" : "A, B",
      "attr1" : "a",
      "nodeIP" : "127.0.0.1"
    },
    "dataCenterInfo" : {
      "name" : "dc",
      "region" : "r1",
      "availableZone" : "az1"
    },
    "healthCheck" : {
      "mode" : "push",
      "interval" : 30,
      "times" : 3
    }
  }
}

Example Responses

Status code: 200

OK

"{\n  \"instanceId\": \"string\"\n}"

Status Codes

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Codes

See Error Codes.