How to Delete 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

DeleteDataset is a method that allows you to delete a dataset from the IR21 database. The dataset is identified by its UUID.

This method is part of the IR21 API and belongs to the Ir21Service.

Prerequisites

  1. An OAuth 2.0 client
  2. A client access token

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 DeleteDataset function.

You can test our APIs without authorization by targeting sandbox.api.shamrock.wgtwo.com instead of api.{region}.wgtwo.com and removing any authorization from the request/code sample.


#!/usr/bin/env bash
grpcurl \
  -d '
  {
    "uuid": "rM/IlHhOSQiHoQFiUHv6ww=="
  }
  ' \
  sandbox.api.shamrock.wgtwo.com:443 \
  wgtwo.ir21.v1.Ir21Service/DeleteDataset

package com.example.ir21

import com.google.protobuf.ByteString
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.deleteDatasetRequest
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 to delete
    val createRequest = com.wgtwo.api.v1.ir21.createDatasetRequest {
        comment = "Dataset to be deleted"
    }
    val createResponse = stub.createDataset(createRequest)
    val createdDatasetUuid = createResponse.uuid

    val deleteDatasetRequest = deleteDatasetRequest {
        uuid = createdDatasetUuid
    }
    println("deleteDatasetRequest:
$deleteDatasetRequest")

    val deleteDatasetResponse = stub.deleteDataset(deleteDatasetRequest)
    println("deleteDatasetResponse:
$deleteDatasetResponse")

    // Test error case - empty UUID
    val deleteDatasetRequestWithEmptyUuid = deleteDatasetRequest {
        uuid = ByteString.EMPTY
    }

    val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
        stub.deleteDataset(deleteDatasetRequestWithEmptyUuid)
    }

    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: uuid is required
Status code: INVALID_ARGUMENT
Status description: uuid is required

Read More