Skip to content

Commit

Permalink
KZOO-11: Audit Summary Enhancements (#6161)
Browse files Browse the repository at this point in the history
1. Change`../audit_summary` path spec to conform to convention
`../audit/summary`
1. Updated API docs for new path spec.
1. Added `kazoo_yodb` modules for year only databases to store service
audits
1. Updated `kz_services.erl` to log quantity changes to reseller YODB

```
"data": [
    {
      "account": {
        "2019-12-05": {
          "addition": 1,
          "last_timestamp": 63742805754,
          "quantity": 2,
          "removal": 0,
          "sum_quantity": false
        },
        "2019-12-09": {
          "addition": 1,
          "last_timestamp": 63743140658,
          "quantity": 2,
          "removal": 1,
          "sum_quantity": false
        }
      },
      "mailbox": {
        "2019-12-09": {
          "addition": 3,
          "last_timestamp": 63743140695,
          "quantity": 3,
          "removal": 0,
          "sum_quantity": false
        }
      },
      "softphone": {
        "2019-12-09": {
          "addition": 1,
          "last_timestamp": 63743140580,
          "quantity": 3,
          "removal": 0,
          "sum_quantity": false
        }
      },
      "user": {
        "2019-12-09": {
          "addition": 1,
          "last_timestamp": 63743140695,
          "quantity": 2,
          "removal": 0,
          "sum_quantity": false
        }
      }
    }
  ],
```
```
"data": [
    {
      "2019-12-09": {
        "addition": 1,
        "last_timestamp": 63743140658,
        "quantity": 2,
        "removal": 1,
        "sum_quantity": false
      }
    },
    {
      "2019-12-05": {
        "addition": 1,
        "last_timestamp": 63742805754,
        "quantity": 2,
        "removal": 0,
        "sum_quantity": false
      }
    }
  ],
```
  • Loading branch information
mk1s authored and jamesaimonetti committed May 4, 2020
1 parent e29ef15 commit d73820e
Show file tree
Hide file tree
Showing 40 changed files with 2,086 additions and 284 deletions.
28 changes: 14 additions & 14 deletions applications/crossbar/doc/ref/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,6 @@ curl -v -X POST \

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/services/audit_summary
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary
```

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/services/audit
```shell
Expand Down Expand Up @@ -198,21 +188,31 @@ curl -v -X GET \

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/services/audit_summary/{SOURCE_SERVICE}
> GET /v2/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}
```

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/services/audit/summary
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary/{SOURCE_SERVICE}
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary
```

## Fetch

> GET /v2/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}
> GET /v2/accounts/{ACCOUNT_ID}/services/audit/summary/{SOURCE_SERVICE}
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary/{SOURCE_SERVICE}
```

144 changes: 39 additions & 105 deletions applications/crossbar/doc/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ curl -v -X GET \

Using this API you can a list of services changes (additions/removal/usage) summary per day.

> GET /v2/accounts/{ACCOUNT_ID}/services/audit_summary
> GET /v2/accounts/{ACCOUNT_ID}/services/audit/summary
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary
```

### Example
Expand All @@ -82,117 +82,60 @@ curl -v -X GET \
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary?created_from=63721540230&created_to=63722160516
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary?created_from=63742805754&created_to=63743140658
```

**Response:**

```json
{
"data": {
"per-minute-voip": [
{
"2019-04-03": {
"last_timestamp": 63721549284,
"quantity": 300,
"sum_quantity": true,
"unit": "sec"
}
},
{
"2019-04-08": {
"last_timestamp": 63721972845,
"quantity": 60,
"sum_quantity": true,
"unit": "sec"
}
},
{
"2019-04-09": {
"last_timestamp": 63722073234,
"quantity": 780,
"sum_quantity": true,
"unit": "sec"
}
},
{
"2019-04-10": {
"last_timestamp": 63722156725,
"quantity": 1500,
"sum_quantity": true,
"unit": "sec"
}
},
{
"2019-04-11": {
"last_timestamp": 63722239192,
"quantity": 960,
"sum_quantity": true,
"unit": "sec"
}
}
],
"phone_number": [
{
"2019-04-04": {
"data": [
{
"account": {
"2019-12-05": {
"addition": 1,
"last_timestamp": 63721611287,
"quantity": 53,
"last_timestamp": 63742805754,
"quantity": 2,
"removal": 0,
"sum_quantity": false
}
}
],
"sip_device": [
{
"2019-04-09": {
"addition": 2,
"last_timestamp": 63722066155,
"quantity": 42,
"removal": 2,
"sum_quantity": false
}
},
{
"2019-04-10": {
},
"2019-12-09": {
"addition": 1,
"last_timestamp": 63722076464,
"quantity": 43,
"removal": 0,
"last_timestamp": 63743140658,
"quantity": 2,
"removal": 1,
"sum_quantity": false
}
}
],
"user": [
{
"2019-04-03": {
"addition": 1,
"last_timestamp": 63721540230,
"quantity": 84,
},
"mailbox": {
"2019-12-09": {
"addition": 3,
"last_timestamp": 63743140695,
"quantity": 3,
"removal": 0,
"sum_quantity": false
}
},
{
"2019-04-09": {
"softphone": {
"2019-12-09": {
"addition": 1,
"last_timestamp": 63722056079,
"quantity": 85,
"last_timestamp": 63743140580,
"quantity": 3,
"removal": 0,
"sum_quantity": false
}
},
{
"2019-04-11": {
"user": {
"2019-12-09": {
"addition": 1,
"last_timestamp": 63722160516,
"quantity": 85,
"removal": 1,
"last_timestamp": 63743140695,
"quantity": 2,
"removal": 0,
"sum_quantity": false
}
}
]
},
}
],
"revision": "{REVISION}",
"timestamp": "{TIMESTAMP}",
"version": "{VERSION}",
Expand All @@ -212,7 +155,7 @@ Using this API you can a list of changes (additions/removal/usage) summary per d
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary/{SOURCE_SERVICE}
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary/{SOURCE_SERVICE}
```

### Example
Expand All @@ -223,7 +166,7 @@ curl -v -X GET \
```shell
curl -v -X GET \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit_summary/user?created_from=63721540230&created_to=63722160516
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/services/audit/summary/user?created_from=63742805754&created_to=63743140658
```

**Response:**
Expand All @@ -232,28 +175,19 @@ curl -v -X GET \
{
"data": [
{
"2019-04-11": {
"2019-12-09": {
"addition": 1,
"last_timestamp": 63722160516,
"quantity": 85,
"last_timestamp": 63743140658,
"quantity": 2,
"removal": 1,
"sum_quantity": false
}
},
{
"2019-04-09": {
"addition": 1,
"last_timestamp": 63722056079,
"quantity": 85,
"removal": 0,
"sum_quantity": false
}
},
{
"2019-04-03": {
"2019-12-05": {
"addition": 1,
"last_timestamp": 63721540230,
"quantity": 84,
"last_timestamp": 63742805754,
"quantity": 2,
"removal": 0,
"sum_quantity": false
}
Expand Down
33 changes: 26 additions & 7 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -39399,6 +39399,25 @@
},
"type": "object"
},
"system_config.yodb": {
"description": "Schema for yodb system_config",
"properties": {
"active_yodbs": {
"default": 6,
"description": "yodb active_yodbs",
"type": "integer"
},
"routines": {
"default": [],
"description": "yodb routines",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"system_configs": {
"description": "Schema for system_config documents",
"properties": {
Expand Down Expand Up @@ -48807,17 +48826,14 @@
}
}
},
"/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}": {
"/accounts/{ACCOUNT_ID}/services/audit/summary": {
"get": {
"parameters": [
{
"$ref": "#/parameters/auth_token_header"
},
{
"$ref": "#/parameters/ACCOUNT_ID"
},
{
"$ref": "#/parameters/AUDIT_ID"
}
],
"responses": {
Expand All @@ -48827,14 +48843,17 @@
}
}
},
"/accounts/{ACCOUNT_ID}/services/audit_summary": {
"/accounts/{ACCOUNT_ID}/services/audit/summary/{SOURCE_SERVICE}": {
"get": {
"parameters": [
{
"$ref": "#/parameters/auth_token_header"
},
{
"$ref": "#/parameters/ACCOUNT_ID"
},
{
"$ref": "#/parameters/SOURCE_SERVICE"
}
],
"responses": {
Expand All @@ -48844,7 +48863,7 @@
}
}
},
"/accounts/{ACCOUNT_ID}/services/audit_summary/{SOURCE_SERVICE}": {
"/accounts/{ACCOUNT_ID}/services/audit/{AUDIT_ID}": {
"get": {
"parameters": [
{
Expand All @@ -48854,7 +48873,7 @@
"$ref": "#/parameters/ACCOUNT_ID"
},
{
"$ref": "#/parameters/SOURCE_SERVICE"
"$ref": "#/parameters/AUDIT_ID"
}
],
"responses": {
Expand Down
21 changes: 21 additions & 0 deletions applications/crossbar/priv/couchdb/schemas/system_config.yodb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"_id": "system_config.yodb",
"description": "Schema for yodb system_config",
"properties": {
"active_yodbs": {
"default": 6,
"description": "yodb active_yodbs",
"type": "integer"
},
"routines": {
"default": [],
"description": "yodb routines",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
14 changes: 14 additions & 0 deletions applications/crossbar/priv/oas3/oas3-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14069,6 +14069,20 @@
'description': whitelabel domains
'type': object
'type': object
'system_config.yodb':
'description': Schema for yodb system_config
'properties':
'active_yodbs':
'default': 6
'description': yodb active_yodbs
'type': integer
'routines':
'default': []
'description': yodb routines
'items':
'type': string
'type': array
'type': object
'system_configs':
'description': Schema for system_config documents
'properties':
Expand Down
Loading

0 comments on commit d73820e

Please sign in to comment.