Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ for r in gr:
print(r.sys_id)
```

## Aggregate Queries

Use `GlideAggregate` for aggregate queries via the Stats API (`/api/now/stats/{table}`), mirroring the server-side `GlideAggregate`:

```python
from pysnc import ServiceNowClient

client = ServiceNowClient('https://dev0000.service-now.com', ('integration.user', password))

ga = client.GlideAggregate('incident')
ga.add_active_query()
ga.add_aggregate('COUNT')
ga.add_aggregate('AVG', 'reassignment_count')
ga.group_by('priority')
ga.query()
for row in ga:
print(row.get_value('priority'), row.get_aggregate('COUNT'), row.get_aggregate('AVG', 'reassignment_count'))
```

## Documentation

Full documentation currently available at [https://servicenow.github.io/PySNC/](https://servicenow.github.io/PySNC/)
Expand Down Expand Up @@ -69,8 +88,6 @@ The following will not be implemented:

# Feature Wants and TODO

* GlideAggregate support (`/api/now/stats/{tableName}`)

And we want to:

* Improve documentation
12 changes: 12 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ GlideRecord
.. autoclass:: GlideElement
:inherited-members:

GlideAggregate
--------------

.. autoclass:: GlideAggregate
:inherited-members:

.. autoclass:: AggregateType

Attachment
----------

Expand Down Expand Up @@ -47,6 +55,10 @@ These are 'internal' but you may as well know about them
:inherited-members:
:undoc-members:

.. autoclass:: StatsAPI
:inherited-members:
:undoc-members:

Exceptions
----------

Expand Down
1 change: 1 addition & 0 deletions pysnc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .client import *
from .record import *
from .auth import *
from .aggregate import *
#from .exceptions import *

from .__version__ import __version__
Loading