How to List Number Blocks
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
ListNumberBlocks
is a method that allows you to list number blocks.
This method is part of the Number Portability API and belongs to the NumberBlockService
.
Prerequisites
Code Dependencies
curl -sL https://github.com/working-group-two/wgtwoapis/releases/latest/download/mobility.binpb --output mobility.binpb
<dependency>
<groupId>com.wgtwo.api.v1.grpc</groupId>
<artifactId>number_portability</artifactId>
<version>1.10.1</version>
</dependency>
Code
The examples below demonstrate how to use the ListNumberBlocks
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 \
--protoset mobility.binpb \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '
{
"destinationId": "f8f31775-c245-4d0b-9f18-3e74eea9d430",
"status": "A_ALLOCATED",
"prefix": "1234"
}
' \
sandbox.api.shamrock.wgtwo.com:443 \
wgtwo.number_portability.v1.NumberBlockService/ListNumberBlocks
package com.example.numberPortability
import com.wgtwo.api.v1.number_portability.NumberBlockServiceGrpcKt
import com.wgtwo.api.v1.number_portability.NumberBlockStatus
import com.wgtwo.api.v1.number_portability.listNumberBlocksRequest
import io.grpc.ManagedChannelBuilder
import kotlinx.coroutines.runBlocking
private val channel = ManagedChannelBuilder.forAddress("sandbox.api.shamrock.wgtwo.com", 443).build()
private val stub = NumberBlockServiceGrpcKt.NumberBlockServiceCoroutineStub(channel)
fun main() = runBlocking {
val listNumberBlocksRequest = listNumberBlocksRequest {
destinationId = "f8f31775-c245-4d0b-9f18-3e74eea9d430" // filter by destination id
status = NumberBlockStatus.A_ALLOCATED // and/or filter by status
prefix = "1234" // and/or filter by prefix
}
println("listNumberBlocksRequest:
$listNumberBlocksRequest")
val listNumberBlocksResponse = stub.listNumberBlocks(listNumberBlocksRequest)
println("listNumberBlocksResponse:
$listNumberBlocksResponse")
assert(listNumberBlocksResponse.blocksCount > 0) { "No number blocks returned" }
}
Example Results Success
{
"blocks": [
{
"destinationId": "2ba196da-3976-4197-b5d6-09048fc8beb2",
"prefix": "3475",
"status": "A_ALLOCATED",
"assignmentDate": "2024-11-08T12:02:53.308247Z"
},
{
"destinationId": "4a008b4b-d348-487a-b161-f4db75baec0b",
"prefix": "240",
"status": "R_RESERVED",
"assignmentDate": "2024-11-08T12:02:53.308263Z"
}
]
}
blocks {
destination_id: "e87c4215-e7aa-4ce9-b13d-e86d6b66da8f"
prefix: "3252"
status: A_ALLOCATED
assignment_date {
seconds: 1731067438
nanos: 657491000
}
}
blocks {
destination_id: "583f59fe-e671-473b-a6d8-41556a86c170"
prefix: "294"
status: R_RESERVED
assignment_date {
seconds: 1731067438
nanos: 657553000
}
}