Create Allocation
9 min
what is an allocation? an allocation is a temporary reservation for a device park device a session cannot normally be started until a device has been allocated create an allocation when your application or test runner is ready to use a device the allocation keeps the selected device available for your test flow until the allocation expires or you release it one allocation can be used to create more than one session while the allocation remains active for example, you can stop the first session and start another session with the same allocationid without requesting a new device do not delete the allocation between those sessions before you begin select one of these inputs a serial from list devices /devices/list devices a pool id from list pools /pools/list pools platform criteria such as android 14 create the allocation only when the test runner is ready to use the device allocations are temporary and include an expiration time how device selection works you can request one exact device with serial any suitable device in a pool with devicepoolid a matching device with platform , platformversion , manufacturer or model use at least one meaningful target priority controls queue order from 1 (highest) to 5 (lowest) and defaults to 3 sdk method java node js client allocations() create(request) await client allocations() create(request) request fields field required description serial conditional exact device serial devicepoolid conditional device pool identifier platform conditional android or ios platformversion no required operating system version manufacturer no required manufacturer model no required device model priority no queue priority, default 3 exact device example allocation allocation = client allocations() create( deviceallocationrequest builder() serial("r58m123456a") priority(3) build() ); system out println(allocation allocationid());import { deviceallocationrequestbuilder } from "@devicepark/public sdk"; const allocation = await client allocations() create( new deviceallocationrequestbuilder() serial("r58m123456a") priority(3) build() ); console log(allocation allocationid); pool example allocation allocation = client allocations() create( deviceallocationrequest builder() devicepoolid("android regression") priority(3) build() );const allocation = await client allocations() create( new deviceallocationrequestbuilder() devicepoolid("android regression") priority(3) build() ); result and queue behavior field meaning allocationid identifier used for sessions and cleanup deviceserial assigned device; can be null while waiting requestid allocation request identifier position queue position when assignment is pending expiresat time after which the allocation is no longer valid if no matching device is immediately available, the allocation can enter a queue keep the same allocationid and inspect it with list allocations /allocations/list allocations do not create duplicate allocations while waiting store and reuse the first allocationid while waiting creating another allocation can reserve an additional device or create another queue entry important rules store allocationid immediately start sessions only while the allocation is active multiple sessions can use the same active allocation stop active sessions before releasing the allocation release the allocation in cleanup code when no more sessions are needed continue with start session /sessions/start session
