How to Get 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
GetOrganisation is a method that allows you to get an organisation from the IR21 database. The organisation is identified by its UUID.
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 GetOrganisation 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 '
{
"datasetUuid": "rM/IlHhOSQiHoQFiUHv6ww==",
"organisationUuid": "2lm3Uz7WQk2MW4mtRGO0WA=="
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.ir21.v1.Ir21Service/GetOrganisation
package com.example.ir21
import com.google.protobuf.ByteString
import com.wgtwo.api.v1.ir21.Ir21ServiceGrpcKt
import com.wgtwo.api.v1.ir21.getOrganisationRequest
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 get organisation example"
}
val createDatasetResponse = stub.createDataset(createDatasetRequest)
val createdDatasetUuid = createDatasetResponse.uuid
val createOrganisationRequest = com.wgtwo.api.v1.ir21.createOrUpdateOrganisationRequest {
datasetUuid = createdDatasetUuid
organisation = organisation {
name = "Example Organisation"
countryName = "Sweden"
countryInitials = "SWE"
comment = "Example organisation comment"
}
}
val createOrganisationResponse = stub.createOrUpdateOrganisation(createOrganisationRequest)
val createdOrganisationUuid = createOrganisationResponse.uuid
val getOrganisationRequest = getOrganisationRequest {
datasetUuid = createdDatasetUuid
organisationUuid = createdOrganisationUuid
}
println("getOrganisationRequest:
$getOrganisationRequest")
val getOrganisationResponse = stub.getOrganisation(getOrganisationRequest)
println("getOrganisationResponse:
$getOrganisationResponse")
// Print organisation details
val organisation = getOrganisationResponse.organisation
println("Organisation UUID: ${organisation.uuid.toStringUtf8()}")
println("Organisation Name: ${organisation.name}")
println("Country: ${organisation.countryName}")
println("Comment: ${organisation.comment}")
// Test error case - empty organisation UUID
val getOrganisationRequestWithEmptyOrganisation = getOrganisationRequest {
datasetUuid = createdDatasetUuid
organisationUuid = ByteString.EMPTY
}
val exception = assertFailsWith<StatusException>("exception is not a StatusException") {
stub.getOrganisation(getOrganisationRequestWithEmptyOrganisation)
}
assert(exception.status.code == Status.INVALID_ARGUMENT.code) {
"status code is not INVALID_ARGUMENT: ${exception.status.code}"
}
}
Example Results Success
{
"organisation": {
"uuid": "2lm3Uz7WQk2MW4mtRGO0WA==",
"name": "Example Organisation",
"countryName": "Sweden",
"countryInitials": "SWE",
"comment": "Example organisation comment"
}
}
organisation {
uuid: "2lm3Uz7WQk2MW4mtRGO0WA=="
name: "Example Organisation"
country_name: "Sweden"
country_initials: "SWE"
comment: "Example organisation comment"
}
Example Results Error
ERROR:
Code: InvalidArgument
Message: organisation_uuid is required
Status code: INVALID_ARGUMENT
Status description: organisation_uuid is required