How to Delete Organisation

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

DeleteOrganisation is a method that allows you to delete an organisation from the IR21 database. The organisation is identified by its UUID and is part of a dataset.

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 DeleteOrganisation 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 '
  {
    "datasetUuid": "rM/IlHhOSQiHoQFiUHv6ww==",
    "organisationUuid": "2lm3Uz7WQk2MW4mtRGO0WA=="
  }
  ' \
  sandbox.api.shamrock.wgtwo.com:443 \
  wgtwo.ir21.v1.Ir21Service/DeleteOrganisation

package com.example.ir21

import com.google.protobuf.ByteString
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.deleteOrganisationRequest
import com.wgtwo.api.v1.ir21.organisation
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 and organisation
    val createDatasetRequest = com.wgtwo.api.v1.ir21.createDatasetRequest {
        comment = "Dataset for delete organisation example"
    }
    val createDatasetResponse = stub.createDataset(createDatasetRequest)
    val createdDatasetUuid = createDatasetResponse.uuid

    val createOrganisationRequest = com.wgtwo.api.v1.ir21.createOrUpdateOrganisationRequest {
        datasetUuid = createdDatasetUuid
        organisation = organisation {
            name = "Organisation to be deleted"
            countryName = "Norway"
            countryInitials = "NOR"
            comment = "This organisation will be deleted"
        }
    }
    val createOrganisationResponse = stub.createOrUpdateOrganisation(createOrganisationRequest)
    val createdOrganisationUuid = createOrganisationResponse.uuid

    val deleteOrganisationRequest = deleteOrganisationRequest {
        datasetUuid = createdDatasetUuid
        organisationUuid = createdOrganisationUuid
    }
    println("deleteOrganisationRequest:
$deleteOrganisationRequest")

    val deleteOrganisationResponse = stub.deleteOrganisation(deleteOrganisationRequest)
    println("deleteOrganisationResponse:
$deleteOrganisationResponse")

    // Test error case - empty organisation UUID
    val deleteOrganisationRequestWithEmptyOrganisation = deleteOrganisationRequest {
        datasetUuid = createdDatasetUuid
        organisationUuid = ByteString.EMPTY
    }

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

    assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
        "status code is not INVALID_ARGUMENT: ${exception.status.code}"
    }
}

Example Results Success

{
  "uuid": "2lm3Uz7WQk2MW4mtRGO0WA=="
}
uuid: "2lm3Uz7WQk2MW4mtRGO0WA=="

Example Results Error

ERROR:
  Code: InvalidArgument
  Message: organisation_uuid is required
Status code: INVALID_ARGUMENT
Status description: organisation_uuid is required

Read More