Add query support to alarm history API

Allow alarm history retrieval to be constrained by
user, project, change type or timestamp.

Partially implements bp alarm-audit-api

Change-Id: Iba303b422a2893ed63375c79d9dc4b93711cf215
Merge "Add query support to alarm history API"
Add group by statistics in API v2

Implements blueprint api-group-by

Add group by statistics in API v2 and group by statistics tests in
API v2 tests as a new class TestGroupByInstance

The tests use the same data and test cases as the groupby storage
tests in class StatisticsGroupByTest

The tests implemented are group by

 1) single field, "user-id"
 2) single field, "resource-id"
 3) single field, "project-id"
 4) single field, "source" (*)
 5) single field with invalid/unknown field value
 6) multiple fields
 7) single field groupby with query filter
 8) multiple field group by with multiple query filters
 9) single field with start timestamp after all samples
10) single field with end timestamp before all samples
11) single field with start timestamp
12) single field with end timestamp
13) single field with start and end timestamps
14) single field with start and end timestamps and query filter
15) single field with start and end timestamps and period
16) single field with start and end timestamps, query filter, and period

(*) Group by source isn't supported in SQLAlchemy at this time, so
    we have to put this test in its own class TestGroupBySource

Group by metadata fields is not implemented at this time.

Also adds a method _validate_groupby_fields() to process the groupby
part of the request, and tests for _validate_groupby_fields().

Change-Id: Ibce1978cfdf70ab068af43a548241546a85bd464
Merge "Add group by statistics in API v2"