Extract logic from drain hook to bring it under test

It is not yet under test, but we plan to do this shortly

Signed-off-by: Kai Zhang <kaizhang@cn.ibm.com>
Add unit tests for Drain class in lib/cloud_controller

[#63767870]

Signed-off-by: Eric Malm <emalm@pivotallabs.com>
Move services business logic from app/models to lib and change namespace

-now lives under VCAP::Services
[#66460516]
Rearrange logging to make extracting deletion logic easier

[#68820074]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Introduce Repository for AppUsageEvents

So code to create these live close to each other and we can see discrepencies more easily

[#68820074]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Respect UAA scopes during access control
Include order-direction in next_url and prev_url

[#68475096]
Retrofit specs for extracted AppUsageEventRepository

[#68820074]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
AppUsageEvent guid is now unique

No longer reuses the app guid

[#68851718]

Signed-off-by: Matthew Sykes <matthew.sykes@gmail.com>
Revert to using the app guid as the event guid after a purge

- The SecureRandom uuid was being run too early so was giving every event the same guid!
- The old "hack" of using the app's guid ensures that every event gets a unique guid

Signed-off-by: Kai Zhang <kaizhang@cn.ibm.com>
Work around pg vs mysql inconsistency

Creating an App in a STARTED state on mysql and sqlite result in an AppUsageEvent being created but on pg there is no event

[#68851718]

Signed-off-by: Kai Zhang <kaizhang@cn.ibm.com>
Temporarily disable specs, they are not reliable on mysql

We retrofitted these yesterday, the functionality under test is already exercised by controller specs
and we will re-enabled these specs as part of [#68852028]

Signed-off-by: Kai Zhang <kaizhang@cn.ibm.com>