How to Set Active 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
SetActiveDataset
is a method that allows you to set the active dataset for one or more tenants in the IR21 database.
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 SetActiveDataset
function.
You can test our APIs without authorization by targeting
sandbox.api.shamrock.wgtwo.com
instead ofapi.{region}.wgtwo.com
and removing any authorization from the request/code sample.
#!/usr/bin/env bash
grpcurl \
-d '
{
"datasetUuid": "rM/IlHhOSQiHoQFiUHv6ww==",
"tenantUuids": [
"HJrAdY0cTfCY0EzNzquH5g==",
"1nBcnoH1QpavlI4KRqdc5w=="
]
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.ir21.v1.Ir21Service/SetActiveDataset
package com.example.ir21
import com.google.protobuf.ByteString
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.setActiveDatasetRequest
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 {
// First create a dataset
val createDatasetRequest = com.wgtwo.api.v1.ir21.createDatasetRequest {
comment = "Dataset for set active example"
}
val createDatasetResponse = stub.createDataset(createDatasetRequest)
val createdDatasetUuid = createDatasetResponse.uuid
val setActiveDatasetRequest = setActiveDatasetRequest {
datasetUuid = createdDatasetUuid
tenantUuids += ByteString.copyFromUtf8("tenant-uuid-1234-5678-9abc-def012345678")
tenantUuids += ByteString.copyFromUtf8("tenant-uuid-abcd-efgh-ijkl-mnop12345678")
}
println("setActiveDatasetRequest:
$setActiveDatasetRequest")
val setActiveDatasetResponse = stub.setActiveDataset(setActiveDatasetRequest)
println("setActiveDatasetResponse:
$setActiveDatasetResponse")
// Print active datasets
setActiveDatasetResponse.activeDatasetsList.forEach { activeDataset ->
println("Dataset UUID: ${activeDataset.datasetUuid.toStringUtf8()}")
println("Tenant UUID: ${activeDataset.tenantUuid.toStringUtf8()}")
println("---")
}
// Test error case - empty tenant UUIDs
val setActiveDatasetRequestWithEmptyTenants = setActiveDatasetRequest {
datasetUuid = createdDatasetUuid
// No tenant UUIDs added
}
val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
stub.setActiveDataset(setActiveDatasetRequestWithEmptyTenants)
}
assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
"status code is not INVALID_ARGUMENT: ${exception.status.code}"
}
}
Example Results Success
{
"activeDatasets": [
{
"datasetUuid": "rM/IlHhOSQiHoQFiUHv6ww==",
"tenantUuid": "HJrAdY0cTfCY0EzNzquH5g=="
},
{
"datasetUuid": "rM/IlHhOSQiHoQFiUHv6ww==",
"tenantUuid": "1nBcnoH1QpavlI4KRqdc5w=="
}
]
}
active_datasets {
dataset_uuid: "rM/IlHhOSQiHoQFiUHv6ww=="
tenant_uuid: "HJrAdY0cTfCY0EzNzquH5g=="
}
active_datasets {
dataset_uuid: "rM/IlHhOSQiHoQFiUHv6ww=="
tenant_uuid: "1nBcnoH1QpavlI4KRqdc5w=="
}
Example Results Error
ERROR:
Code: InvalidArgument
Message: tenant_uuids is required
Status code: INVALID_ARGUMENT
Status description: tenant_uuids is required