Lease Validator

Lease validator tracks lease usage in intermediate services.

class bosdyn.client.lease_validator.LeaseValidator(robot)[source]

Bases: object

Lease validator tracks lease usage in intermediate services.

Track the most recent leases seen for each lease resource and test incoming leases against this state.

Parameters:

robot (Robot) – The robot object for which leases are associated to.

get_active_lease(resource)[source]

Get the latest active lease.

Parameters:

resource (string) – the resource for the specific lease to be returned.

Returns:

A Lease class object representing the most recent lease for the requested resource, or None if no lease has been seen.

test_active_lease(incoming_lease, allow_super_leases, allow_different_epoch=False)[source]

Compare an incoming lease to the latest active lease.

Parameters:
  • incoming_lease (Lease object or lease_pb2.Lease) – The incoming lease to test.

  • allow_super_leases (boolean) – Should the comparison function consider a super lease as ok.

Returns:

The LeaseUseResult proto message representing if the incoming lease is ok.

test_and_set_active_lease(incoming_lease, allow_super_leases, allow_different_epoch=False)[source]

Compare an incoming lease to the latest active lease, and if it is ok then set it as the latest lease.

Parameters:
  • incoming_lease (Lease object or lease_pb2.Lease) – The incoming lease to test.

  • allow_super_leases (boolean) – Should the comparison function consider a super lease as ok.

Returns:

The LeaseUseResult proto message representing if the incoming lease is ok. Additionally, if the result is STATUS_OK, then update the latest active lease to this incoming lease.

class bosdyn.client.lease_validator.LeaseValidatorResponseProcessor(lease_validator)[source]

Bases: object

LeaseValidatorResponseProcessor updates the lease validator using the latest_known_lease from the response’s LeaseUseResult.

Parameters:

lease_validator (LeaseValidator) – validator for a specific robot to be updated.

mutate(response)[source]

Update the lease validator if a response has a lease_use_result.