Querying a Service List

Function

This API is used to obtain model services.

URI

GET /v1/{project_id}/services

Table 1 describes the required parameters.

Table 1 Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Table 2 Parameters

Parameter

Mandatory

Type

Description

service_id

No

String

Service ID

service_name

No

String

Service name

model_id

No

String

Model ID

cluster_id

No

String

Dedicated resource pool ID, which is left blank by default

workspace_id

No

String

Workspace ID. Default value: 0

infer_type

No

String

Inference mode. The value can be real-time or batch. By default, this parameter is left blank.

status

No

String

Service status. By default, the service status is not filtered. You can query information by service status. The possible values are running, deploying, concerning, failed, stopped, and finished.

offset

No

Integer

Start page of the paging list. Default value: 0

limit

No

Integer

Maximum number of records returned on each page. The default value is 1000. The recommended value ranges from 10 to 50.

sort_by

No

String

Sorting mode. The value can be publish_at or service_name. Default value: publish_at

order

No

String

Sorting order. The value can be asc or desc, indicating ascending or descending order. Default value: desc

Request Body

None

Response Body

Table 3 describes the response parameters.

Table 3 Parameters

Parameter

Type

Description

total_count

Integer

Total number of services that meet the search criteria when no paging is implemented

count

Integer

Number of services in the query result. If offset and limit are not set, the values of count and total_count are the same.

services

service array

Collection of the queried services. For details, see Table 4.

Table 4 service parameters

Parameter

Type

Description

service_id

String

Service ID

service_name

String

Service name

description

String

Service description

tenant

String

Tenant to which a service belongs

project

String

Project to which a service belongs

owner

String

User to which a service belongs

publish_at

Long

Latest service release time, in milliseconds calculated from 1970.1.1 0:0:0 UTC

infer_type

String

Inference mode. The value can be real-time or batch.

workspace_id

String

Workspace ID. Default value: 0

status

String

Service status. The value can be running, deploying, concerning, failed, stopped, or finished.

  • running: The service is running properly.

  • deploying: The service is being deployed or scheduling resources are being deployed.

  • concerning: The backend instances are abnormal. For example, if there are multiple instances and some instances are abnormal, the normal instances will consume resources. In this case, the service status is concerning.

  • failed: The service fails to be deployed. For details about the failure cause, see the event and log tab pages.

  • stopped: The service has been stopped.

  • finished: This state is displayed only for the batch service, indicating that the service running is complete.

start_time

Number

Batch service start time, in milliseconds calculated from 1970.1.1 0:0:0 UTC. This parameter is returned only when the service is a batch service.

finished_time

Number

Batch service end time, in milliseconds calculated from 1970.1.1 0:0:0 UTC. This parameter is returned only when the service is a batch service.

progress

integer

Deployment progress. This parameter is returned when the status is deploying.

invocation_times

Long

Total number of service calls

failed_times

Long

Number of failed service calls

is_shared

Boolean

Whether a service is subscribed

shared_count

Number

Number of subscribed services

schedule

schedule array

Service scheduling. For details, see Table 5.

due_time

number

Time when a real-time service automatically stops, in milliseconds calculated from 1970.1.1 0:0:0 UTC.

operation_time

number

Operation time of a request

is_opened_sample_collection

String

Whether to enable data collection. The default value is false.

transition_at

number

Time when the service status changes

is_free

Boolean

Whether a service uses the free-of-charge flavor

additional_properties

Map<String, Object>

Additional service attribute. If this parameter is not set, no value is returned.

Table 5 schedule parameters

Parameter

Mandatory

Type

Description

type

Yes

String

Scheduling type. Only the value stop is supported.

time_unit

Yes

String

Scheduling time unit. Options:

  • DAYS

  • HOURS

  • MINUTES

duration

Yes

Integer

Value that maps to the time unit. For example, if the task stops after two hours, set time_unit to HOURS and duration to 2.

Samples

The following shows how to query model services.

  • Sample request

    GET    https://endpoint/v1/{project_id}/services
    
  • Sample response

    {
        "count": 2,
        "total_count": 2,
        "services": [
            {
                "service_id": "8da30673-908d-45a7-90a4-65f98e69fc34",
                "service_name": "service-demo",
                "tenant": "xxx",
                "project": "xxx",
                "owner": "xxx",
                "publish_at": 1584622900171,
                "infer_type": "real-time",
                "status": "stopped",
                "progress": 100,
                "invocation_times": 0,
                "failed_times": 0,
                "is_shared": false,
                "shared_count": 0,
                "workspace_id": "0",
                "schedule": [
                    {
                        "type": "stop",
                        "duration": 1,
                        "time_unit": "HOURS"
                    }
                ],
                "due_time": 1584626633902,
                "operation_time": 1586250354961,
                "is_opened_sample_collection": false,
                "additional_properties": {},
                "is_free": false,
                "transition_at": 1584623163721
            },
            {
                "service_id": "912f1a4a-5962-455c-b11c-5fdf06045cb3",
                "service_name": "service-demo2",
                "tenant": "xxx",
                "project": "xxx",
                "owner": "xxx",
                "publish_at": 1584618274410,
                "infer_type": "real-time",
                "status": "stopped",
                "progress": 100,
                "invocation_times": 0,
                "failed_times": 0,
                "is_shared": false,
                "shared_count": 0,
                "workspace_id": "0",
                "schedule": [
                    {
                        "type": "stop",
                        "duration": 1,
                        "time_unit": "HOURS"
                    }
                ],
                "due_time": 1584622027673,
                "operation_time": 1586250354961,
                "is_opened_sample_collection": false,
                "additional_properties": {},
                "is_free": false,
                "transition_at": 1584618498528
            }
        ]
    }
    

Status Code

For details about the status code, see Table 1.

Error Codes

See Error Codes.