How to Create Dataset
Warning: Beta software This API is in beta stage and may be subject to change. Therefore, we do not recommend using this in production.
Interested in this feature? Please reach out to mobility-services-developer@cisco.com
CreateDataset is a method that allows you to create a dataset in the IR21 database.
Datasets are collections of Organisations. You can manage which records a specific tenant has access to by having different datasets for different groups of tenants.
This method is part of the IR21 API and belongs to the Ir21Service.
Prerequisites
Code Dependencies
<dependency>
<groupId>com.wgtwo.api.v1.grpc</groupId>
<artifactId>ir21</artifactId>
<version>1.16.3</version>
</dependency>
Code
The examples below demonstrate how to use the CreateDataset function.
You can test our APIs without authorization by targeting
sandbox.api.shamrock.wgtwo.cominstead ofapi.{region}.wgtwo.comand removing any authorization from the request/code sample.
#!/usr/bin/env bash
grpcurl \
-d '
{
"comment": "Example dataset for IR21 documentation"
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.ir21.v1.Ir21Service/CreateDataset
package com.example.ir21
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.createDatasetRequest
import io.grpc.ManagedChannelBuilder
import io.grpc.Status
import io.grpc.StatusException
import kotlinx.coroutines.runBlocking
import kotlin.test.assertFailsWith
private val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
private val stub = Ir21ServiceGrpcKt.Ir21ServiceCoroutineStub(channel)
fun main() = runBlocking {
val createDatasetRequest = createDatasetRequest {
comment = "Example dataset for IR21 documentation"
}
println("createDatasetRequest:
$createDatasetRequest")
val createDatasetResponse = stub.createDataset(createDatasetRequest)
println("createDatasetResponse:
$createDatasetResponse")
// Test error case - empty comment should still work, but we can test with invalid UUID
val createDatasetRequestWithSpecificUuid = createDatasetRequest {
uuid = com.google.protobuf.ByteString.copyFromUtf8("invalid-uuid")
comment = "Dataset with invalid UUID"
}
val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
stub.createDataset(createDatasetRequestWithSpecificUuid)
}
assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
"status code is not INVALID_ARGUMENT: ${exception.status.code}"
}
}
Example Results Success
{
"uuid": "rM/IlHhOSQiHoQFiUHv6ww=="
}
uuid: "rM/IlHhOSQiHoQFiUHv6ww=="
Example Results Error
ERROR:
Code: InvalidArgument
Message: Invalid dataset UUID
Status code: INVALID_ARGUMENT
Status description: Invalid dataset UUID