-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from rbw0/branch0.4.2
Version 0.4.2
- Loading branch information
Showing
16 changed files
with
113 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,48 @@ | ||
:: | ||
.. code-block:: | ||
______ __ __ ______ __ __ ______ __ __ | ||
/\ == \ /\ \_\ \ /\ ___\ /\ "-.\ \ /\ __ \ /\ \ _ \ \ | ||
\ \ _-/ \ \____ \ \ \___ \ \ \ \-. \ \ \ \/\ \ \ \ \/ ".\ \ | ||
\ \_\ \/\_____\ \/\_____\ \ \_\\"\_\ \ \_____\ \ \__/".~\_\ | ||
\/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ | ||
- a Python library for the ServiceNow REST API | ||
|
||
.. image:: https://travis-ci.org/rbw0/pysnow.svg?branch=master | ||
:target: https://travis-ci.org/rbw0/pysnow | ||
.. image:: https://coveralls.io/repos/github/rbw0/pysnow/badge.svg?branch=master | ||
:target: https://coveralls.io/github/rbw0/pysnow?branch=master | ||
|
||
:target: https://coveralls.io/github/rbw0/pysnow?branch=master | ||
.. image:: https://badge.fury.io/py/pysnow.svg | ||
:target: https://pypi.python.org/pypi/pysnow | ||
|
||
Installation | ||
^^^^^^^^^^^^ | ||
------------ | ||
# pip install pysnow | ||
|
||
|
||
Usage examples | ||
^^^^^^^^^^^^^^ | ||
-------------- | ||
Go `here <http://pysnow.readthedocs.io/en/latest/usage>`_ for usage examples | ||
|
||
|
||
Documentation | ||
^^^^^^^^^^^^^ | ||
------------- | ||
The full documentation is available `here <http://pysnow.readthedocs.org/>`_ | ||
|
||
|
||
Compatibility | ||
^^^^^^^^^^^^^ | ||
------------- | ||
Python 2 and 3. Tested: Python 2.6+ and Python 3.3+ | ||
|
||
Contributors | ||
^^^^^^^^^^^^ | ||
------------ | ||
lingfish, jcpunk, AMMullan, amontalban, ryancurrah, jdugan1024 | ||
|
||
|
||
JetBrains | ||
^^^^^^^^^ | ||
--------- | ||
Thank you Jetbrains (www.jetbrains.com) for supporting with IDE licenses! | ||
|
||
Author | ||
^^^^^^ | ||
------ | ||
Created by Robert Wikman <[email protected]> in 2016 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
.. automodule:: pysnow | ||
.. autoclass:: Request | ||
:members: | ||
.. autoexception:: pysnow.exceptions.UnexpectedResponse | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Deleting a record | ||
----------------- | ||
|
||
See the :meth:`pysnow.Request.delete` documentation for more details. | ||
|
||
.. code-block:: python | ||
import pysnow | ||
# Create client object | ||
s = pysnow.Client(instance='myinstance', user='myusername', password='mypassword') | ||
# Delete record with number 'INC012345' | ||
res = s.query(table='incident', query={'number': 'INC012345'}).delete() | ||
# Print out the result | ||
print(res) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,19 @@ | ||
Getting multiple records using the query builder | ||
------------------------------------------------ | ||
Getting multiple records | ||
------------------------ | ||
|
||
Check out the :meth:`get_all() documentation <pysnow.Request.get_all>` for more info | ||
See the :meth:`pysnow.Request.get_all` documentation for more details. | ||
|
||
.. code-block:: python | ||
import pysnow | ||
from datetime import datetime as dt | ||
from datetime import timedelta as td | ||
# Create client object | ||
s = pysnow.Client(instance='myinstance', user='myusername', password='mypassword') | ||
# Set start and end range | ||
start = dt(1970, 1, 1) | ||
end = dt.now() - td(days=20) | ||
# Get all incidents | ||
r = s.query('incident', query={}) | ||
# Query incident records with number starting with 'INC0123', created between 1970-01-01 and 20 days back in time | ||
qb = pysnow.QueryBuilder()\ | ||
.field('number').starts_with('INC0123')\ | ||
.AND()\ | ||
.field('sys_created_on').between(start, end) | ||
r = s.query('incident', query=qb) | ||
# Iterate over the result and print out number | ||
for record in r.get_all(): | ||
# Set the limit of records returned from server to 20, then iterate over the result and print out number | ||
for record in r.get_all(limit=20): | ||
print(record['number']) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Using the query builder | ||
----------------------- | ||
|
||
See the :meth:`pysnow.Request.get_all` and :meth:`pysnow.QueryBuilder` documentation for more details. | ||
|
||
.. code-block:: python | ||
import pysnow | ||
from datetime import datetime as dt | ||
from datetime import timedelta as td | ||
# Create client object | ||
s = pysnow.Client(instance='myinstance', user='myusername', password='mypassword') | ||
# Set start and end range | ||
start = dt(1970, 1, 1) | ||
end = dt.now() - td(days=20) | ||
# Query incident records with number starting with 'INC0123', created between 1970-01-01 and 20 days back in time | ||
qb = pysnow.QueryBuilder()\ | ||
.field('number').starts_with('INC0123')\ | ||
.AND()\ | ||
.field('sys_created_on').between(start, end) | ||
r = s.query('incident', query=qb) | ||
# Iterate over the result and print out number | ||
for record in r.get_all(): | ||
print(record['number']) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
Usage examples | ||
============== | ||
Usage | ||
^^^^^ | ||
|
||
.. toctree:: | ||
:caption: Usage | ||
|
||
client | ||
query | ||
request | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Full usage examples | ||
:caption: Full examples | ||
|
||
full/get_one | ||
full/get_all | ||
full/create | ||
full/query_builder | ||
full/update | ||
full/delete | ||
full/clone | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
from pysnow.exceptions import * | ||
|
||
__author__ = "Robert Wikman <[email protected]>" | ||
__version__ = "0.4.1" | ||
__version__ = "0.4.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters