Help Center> RES> API Reference> API> Data Source> Creating a Data Source

Creating a Data Source

Function

This API is used to create a data source in a specified workspace.

URI

POST /v2.0/{project_id}/workspaces/{workspace_id}/data-sources

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

workspace_id

Yes

String

Workspace ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Content type. The value is application/json.

X-Auth-Token

Yes

String

User token. For details on how to obtain the user token, see Obtaining a User Token Through Password Authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

datasource_name

Yes

String

Data source name, which is a string of 1 to 64 characters and contains letters, digits, underscores (_), and hyphens (-)

Minimum: 1

Maximum: 64

specs_config

Yes

SpecsConfig object

Computing specifications settings

data_config

Yes

DataConfig object

Data source settings

Table 4 SpecsConfig

Parameter

Mandatory

Type

Description

offline

Yes

String

Offline computing specifications

nearline

No

String

Real-time computing specifications

rank

No

String

Deep learning computing specifications

online_tps

No

Integer

Max. number of concurrent online services

Table 5 DataConfig

Parameter

Mandatory

Type

Description

offline

Yes

Offline object

Offline computing specifications

nearline

No

Nearline object

Nearline data source

Table 6 Offline

Parameter

Mandatory

Type

Description

user_url

Yes

String

User data URL

item_url

Yes

String

Item data URL

behavior_url

Yes

String

Behavior data URL

Table 7 Nearline

Parameter

Mandatory

Type

Description

item_topic

No

Topic object

Item topic

user_topic

No

Topic object

User topic

behavior_topic

No

Topic object

Behavior topic

Table 8 Topic

Parameter

Mandatory

Type

Description

name

No

String

Name

id

No

String

ID

Response Parameters

Status code: 200

Table 9 Response body parameters

Parameter

Type

Description

is_success

Boolean

Whether the request is successful

datasource

Datasource object

Data source information

message

String

Response message (This field is not returned when the request is successful.)

error_code

String

Error code (This parameter is not returned when the request is successful.)

Table 10 Datasource

Parameter

Type

Description

datasource_name

String

Data source name

workspace_id

String

Workspace ID

datasource_id

String

Data source ID

status

String

Status

created_at

Long

Creation time

Example Requests

This API is used to create a data source.

/v2.0/testuuidxxxxxxxxxxxxxxxxxxxxxxxx/workspaces/testuuidxxxxxxxxxxxxxxxxxxxxxxxx/data-sources

{
  "data_config" : {
    "offline" : {
      "user_url" : "<OBS path for storing user data>",
      "item_url" : "<OBS path for storing item data>",
      "behavior_url" : "<OBS path for storing behavior data>"
    }
  },
  "specs_config" : {
    "offline" : "4CU"
  },
  "datasource_name" : "test"
}

Example Responses

Status code: 200

OK

{
  "is_success" : true,
  "datasource" : {
    "datasource_name" : "test",
    "workspace_id" : "06a7c49afc00d4972ff1c0113d8c49ba",
    "datasource_id" : "51d48ed2da324cefa1c8336136b36557",
    "status" : "Draft",
    "created_at" : 1588850804912
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.