How to List Organisations

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

ListOrganisations is a method that allows you to list organisations from a dataset in the IR21 database.

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 ListOrganisations 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=="
  }
  ' \
  sandbox.api.shamrock.wgtwo.com:443 \
  wgtwo.ir21.v1.Ir21Service/ListOrganisations

package com.example.ir21

import com.google.protobuf.ByteString
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.listOrganisationsRequest
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 listing organisations"
    }
    val createDatasetResponse = stub.createDataset(createDatasetRequest)
    val createdDatasetUuid = createDatasetResponse.uuid

    val listOrganisationsRequest = listOrganisationsRequest {
        datasetUuid = createdDatasetUuid
    }
    println("listOrganisationsRequest:
$listOrganisationsRequest")

    val listOrganisationsResponse = stub.listOrganisations(listOrganisationsRequest)
    println("listOrganisationsResponse:
$listOrganisationsResponse")

    // Print dataset info
    println("Dataset UUID: ${listOrganisationsResponse.dataset.uuid.toStringUtf8()}")
    println("Dataset Comment: ${listOrganisationsResponse.dataset.comment}")

    // Print each organisation
    listOrganisationsResponse.organisationsList.forEach { organisation ->
        println("Organisation UUID: ${organisation.uuid.toStringUtf8()}")
        println("Organisation Name: ${organisation.name}")
        println("Country: ${organisation.countryName}")
        println("---")
    }

    // Test error case - empty dataset UUID
    val listOrganisationsRequestWithEmptyDataset = listOrganisationsRequest {
        datasetUuid = ByteString.EMPTY
    }

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

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

Example Results Success

{
  "dataset": {
    "uuid": "rM/IlHhOSQiHoQFiUHv6ww==",
    "comment": "A dataset comment"
  },
  "organisations": [
    {
      "uuid": "rfbkn0pTRn+gvIupmIHS2A==",
      "name": "Test Organisation",
      "countryName": "Norway",
      "countryInitials": "NOR",
      "tadigs": [
        {
          "tadig": "NOR01",
          "mccmncs": [
            {
              "mcc": "242",
              "mnc": "01"
            }
          ],
          "realms": [
            "epc.mnc001.mcc242.3gppnetwork.org"
          ],
          "gtPrefixes": [
            "12345"
          ]
        }
      ],
      "comment": "Organisation comment"
    },
    {
      "uuid": "tXhg7iIORfm10xpw2QP7cA==",
      "name": "Another Organisation",
      "countryName": "Sweden",
      "countryInitials": "SWE",
      "tadigs": [
        {
          "tadig": "SWE01",
          "mccmncs": [
            {
              "mcc": "240",
              "mnc": "01"
            }
          ],
          "realms": [
            "epc.mnc001.mcc240.3gppnetwork.org"
          ],
          "gtPrefixes": [
            "54321"
          ]
        }
      ],
      "comment": "Another organisation comment"
    }
  ]
}
dataset {
  uuid: "rM/IlHhOSQiHoQFiUHv6ww=="
  comment: "A dataset comment"
}
organisations {
  uuid: "rfbkn0pTRn+gvIupmIHS2A=="
  name: "Test Organisation"
  country_name: "Norway"
  country_initials: "NOR"
  tadigs {
    tadig: "NOR01"
    mccmncs {
      mcc: "242"
      mnc: "01"
    }
    realms: "epc.mnc001.mcc242.3gppnetwork.org"
    gt_prefixes: "12345"
  }
  comment: "Organisation comment"
}
organisations {
  uuid: "tXhg7iIORfm10xpw2QP7cA=="
  name: "Another Organisation"
  country_name: "Sweden"
  country_initials: "SWE"
  tadigs {
    tadig: "SWE01"
    mccmncs {
      mcc: "240"
      mnc: "01"
    }
    realms: "epc.mnc001.mcc240.3gppnetwork.org"
    gt_prefixes: "54321"
  }
  comment: "Another organisation comment"
}

Example Results Error

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

Read More