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

Sharing a Data Set

Function

This API is used to publish a data set and create authorized orders. Watermarking is not supported.

URI

POST /v1/datashare/dataset/share

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.

consumer

Yes

String

Order applicant identifier.

orderSeq

No

String

Order number. If this parameter is left empty, the value is generated randomly.

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

String

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

productIDKeywords

No

Array of productIDKeywordsJson objects

Index keyword contained in the product ID, which is in JSON and is used for querying orders by condition.

onChainStore

No

String

Whether to store ciphertext data on the chain. The value can be true or false (default). If this parameter is set to true, sampleUrl and dataUrl will be automatically set. Watermarking is not supported when chain storage is used.

consumerName

No

String

Name of the user.

creatorDID

No

String

DID of the creator of the data set sharing process. This parameter does not need to be set when action is set to new.

processID

No

String

ID of the data set sharing process. This parameter does not need to be set when action is set to new.

stageName

No

String

Name of the data set sharing stage.

action

No

String

Process action. The options are new, append, and "" (N/A). If this parameter is not set, the value is regarded as N/A.

category

No

String

Encryption type, which can be symmetric (default) or abe. If abe is used, specify policy.

policy

No

policy object

ABE policy.

Table 2 productIDKeywordsJson

Parameter

Mandatory

Type

Description

value

No

String

Keyword value.

Table 3 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 4 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 5 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 6 Response body parameters

Parameter

Type

Description

consumer

String

Order applicant identifier.

consumerName

String

Order applicant name.

orderSeq

String

Order number.

provider

String

Order provider identifier.

providerName

String

Order provider name.

productID

String

Data set product ID.

productName

String

Data set product name.

price

String

Order amount.

applyTime

String

Application time.

encryptedAesKey

String

Private key.

status

String

Order status.

reason

String

Order application reason.

lockProof

String

Order lock-up proof.

creatorDID

String

DID of the process creator. If there is no process, the value is "".

processID

String

ID of the process of the current order. If there is no process, the value is "".

encryptData

String

Ciphertext of the Base64-encoded data.

Status code: 500

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMsg

String

Error description.

Example Requests

{
  "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",
  "consumer" : "did:example:3TMWx8owKHARgNwbj4ywmG",
  "orderSeq" : "1",
  "watermarkType" : "string",
  "file" : "string",
  "productIDKeywords" : "[{\"value\":\"taiyuan\"},{\"value\":\"renmin_hospital\"},{\"value\":\"medicine\"}]",
  "onChainStore" : "string",
  "consumerName" : "string"
}

Example Responses

Status code: 200

Order information.

{
  "consumer" : "did:example:3TMWx8owKHARgNwbj4ywmG",
  "consumerName" : "Tyler",
  "orderSeq" : "1",
  "provider" : "did:example:DHkJjyD5wZwya6sd6BNBnG",
  "providerName" : "hw",
  "productID" : "product1",
  "productName" : "prodname1",
  "price" : "0",
  "applyTime" : "1607332359",
  "encryptedAesKey" : "BNGhPwjaTgpM+V7czzw1i4mH21KKN+XLKXHLqVsRIfybUCncqZNfomkRfzX4WEHj+oty1X9oCd4h6xMnRvs8BWE5Tvg6BJ6QTW/km9EO/FSYqzJf2GqQzAleAcLJrTBZ3LRbPaF87CgJ114ae7R+VK9VvfXQ8exuH2KMRD305dXieGpM4VPVv9u1BbL15Jpd/g==",
  "status" : "ready",
  "reason" : "I want product1",
  "lockProof" : "",
  "encryptData" : "base64 encoding string"
}

Status code: 500

Error response.

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

Status Codes

Status Code

Description

200

Order information.

500

Error response.

Error Codes

See Error Codes.