Updated on 2023-03-07 GMT+08:00

Publishing a Data Set

Function

This API is used to publish a data set. Watermarking is not supported.

URI

POST /v1/datashare/dataset

Request Parameters

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

orgID

Yes

String

Organization ID.

channelID

Yes

String

Channel ID.

cryptoMethod

Yes

String

Encryption method, which is fixed at SW.

cert

Yes

String

Certificate.

sk

Yes

String

Private key.

timestamp

Yes

String

Timestamp.

provider

Yes

String

Data publisher identifier.

providerName

No

String

Data publisher name.

productName

Yes

String

Product name.

productID

Yes

String

Product ID.

sampleUrl

Yes

String

Sample data storage location.

sampleSize

No

String

Sample data size.

sampleType

No

String

Sample data type.

sampleName

No

String

Sample data name.

fileType

No

String

Data file type.

dataUrl

Yes

String

Data storage location.

dataHash

No

String

Data hash value.

dataSize

No

String

Data size.

dataName

No

String

Data name.

description

No

String

Data set description. When using ABE for encryption, describe the encryption policy in detail.

plainData

Yes

String

Plaintext of the Base64-encoded data.

category

No

String

Encryption type. The options are abe and symmetric. The default value is symmetric. If abe is used, policy is mandatory.

watermarkType

No

String

Watermark type, which can be visible or blind. Specify this parameter if you want to embed a watermark. The embedded watermark is in the format of Publisher DID_Product ID.

file

No

File

File to embed a watermark in. If the file has a watermark, the plainData parameter does not take effect.

policy

No

policy object

ABE policy.

Table 2 policy

Parameter

Mandatory

Type

Description

Threshold

Yes

Integer

Attribute threshold that a policy must meet.

Children

Yes

Array of policy-children objects

Sub-attribute list.

Table 3 policy-children

Parameter

Mandatory

Type

Description

name

Yes

String

Attribute name.

type

Yes

String

Attribute type (plain, comparable, or policy.)

value

Yes

policy-children-comparablevalue object

Attribute value, which is determined based on the attribute type. When the attribute type is plain, the value is a string. When the attribute type is policy, the value is a sub-policy. When the attribute type is comparable, the value contains op, value, and maxValue.

Table 4 policy-children-comparablevalue

Parameter

Mandatory

Type

Description

op

No

String

Comparison operator (>, <, or =). This parameter is mandatory when type is set to comparable.

value

Yes

String

Attribute value of the comparison type. The value must be an integer.

maxValue

No

String

Upper limit of value. This parameter is mandatory when the attribute type is comparable.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

provider

String

Data set provider identifier.

providerName

String

Data set provider name.

productName

String

Data set product name.

productID

String

Data set product ID.

sampleUrl

String

Sample data URL.

sampleSize

String

Sample data size.

sampleType

String

Sample data type.

sampleName

String

Sample data name.

fileType

String

File type.

dataUrl

String

Data URL.

dataHash

String

Data hash value.

dataSize

String

Data size.

dataName

String

Data name.

description

String

Data description.

price

String

Data price.

encryptedAesKey

String

Private key.

status

String

Status.

publishTime

String

Data publishing time.

dataFiles

Array of DataFile objects

Data file list.

sampleFiles

Array of DataFile objects

Sample file list.

category

String

Encryption type.

encryptData

String

Encrypted data.

Table 6 DataFile

Parameter

Type

Description

fileType

String

File type.

dataUrl

String

Data URL.

dataHash

String

Data hash value.

dataSize

String

Data size.

dataName

String

Data name.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMsg

String

Error description.

Example Requests

An ABE example policy. In this example policy, decryption can be performed only when the decrypting party matches the "att1==hello" attribute or conforms to a sub-policy, where the value of attribute att3 is larger than 16.

{
  "orgID" : "ce0ac69b0c8648cd25b44a551780409767c8890b",
  "channelID" : "mychannel",
  "cryptoMethod" : "SW",
  "cert" : "-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----",
  "sk" : "-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----",
  "timestamp" : "2020-10-27T17:28:16+08:00",
  "provider" : "did:example:DHkJjyD5wZwya6sd6BNBnG",
  "providerName" : "huawei",
  "productName" : "prodname",
  "productID" : "product2",
  "sampleUrl" : "http://hwcloud.com/sample.com/prodname2",
  "sampleSize" : "10KB",
  "sampleType" : "csv",
  "sampleName" : "data_sub1",
  "fileType" : "csv",
  "dataUrl" : "http://hwcloud.com/prodname2",
  "dataHash" : "2282ba7a1a2ef5700609214a997d3d4237a03bfd3632c6d089e57e7b6f467969",
  "dataSize" : "100MB",
  "dataName" : "mydata1",
  "description" : "this is my second prod",
  "plainData" : "base64 encoding string",
  "category" : "abe",
  "watermarkType" : "string",
  "file" : "string",
  "policy" : "{\"threshold\" : 1,\"children\" : [{\"name\" : \"att1\", \"type\" : \"plain\",\"value\" : \"hello\"}, {\"name\" : \"policy\", \"type\" : \"policy\",\"value\" : {\"Threshold\" : 1,\"Children\" : [{\"name\" : \"att3\", \"type\" :\"comparable\", \"value\" : {\"op\" : \">\", \"value\" : \"16\", \"maxValue\" : \"10000\"}}]}}]}"
}

Example Responses

Status code: 200

Data set information.

{
  "provider" : "did:example:DHkJjyD5wZwya6sd6BNBnG",
  "providerName" : "aws",
  "productName" : "prodname2",
  "productID" : "product2",
  "sampleUrl" : "http://hwcloud.com/sample.com/prodname2",
  "sampleSize" : "10KB",
  "sampleType" : "csv",
  "sampleName" : "data_sub1",
  "fileType" : "csv",
  "dataUrl" : "http://hwcloud.com/prodname2",
  "dataHash" : "2282ba7a1a2ef5700609214a997d3d4237a03bfd3632c6d089e57e7b6f467969",
  "dataSize" : "100MB",
  "dataName" : "mydata",
  "description" : "this is second prod",
  "price" : "0",
  "encryptedAesKey" : "BA4Ub3t3IskN8uKcEMa+4cbtsDS8OzF4V/qqb4OcPMeMvp7IL+HClzAbL6lPnhbDg/AnrStBlf0qFzRj+qvk6ZH0c7wP0aS48fSoNtecG79aFpFx0dg7rFdVYXWWzgeyI03eD3gFdXlQ/ovpxKJG5ALK39OCazUqDrawZHSDGyIlw0hGh88Q+GVORVSp+6V5Ag==",
  "status" : "ready",
  "publishTime" : "1607157244",
  "dataFiles" : [ {
    "fileType" : "csv",
    "dataUrl" : "http://hwcloud.com/prodname2",
    "dataHash" : "2282ba7a1a2ef5700609214a997d3d4237a03bfd3632c6d089e57e7b6f467969",
    "dataSize" : "100MB",
    "dataName" : "mydata"
  } ],
  "sampleFiles" : [ {
    "fileType" : "csv",
    "dataUrl" : "http://hwcloud.com/prodname2",
    "dataHash" : "2282ba7a1a2ef5700609214a997d3d4237a03bfd3632c6d089e57e7b6f467969",
    "dataSize" : "100MB",
    "dataName" : "mydata"
  } ],
  "category" : "string",
  "encryptData" : "string"
}

Status code: 500

Error response.

{
  "errorCode" : "BCS.5002046",
  "errorMsg" : "Incorrect number of arguments"
}

Status Codes

Status Code

Description

200

Data set information.

500

Error response.

Error Codes

See Error Codes.