From 9c8b901487447bfa99c8f6d2647e107c25398055 Mon Sep 17 00:00:00 2001 From: Robert Wikman Date: Thu, 13 Jun 2019 00:38:33 +0200 Subject: [PATCH] Add field filter usage example --- docs/full_examples/filtering.rst | 21 +++++++++++++++++++++ docs/index.rst | 1 + 2 files changed, 22 insertions(+) create mode 100644 docs/full_examples/filtering.rst diff --git a/docs/full_examples/filtering.rst b/docs/full_examples/filtering.rst new file mode 100644 index 0000000..5cea072 --- /dev/null +++ b/docs/full_examples/filtering.rst @@ -0,0 +1,21 @@ +Filtering fields +================ + +The `fields` parameter can be used for selecting which fields to return in the response. + + +.. code-block:: python + + import pysnow + + # Create client object + c = pysnow.Client(instance='myinstance', user='myusername', password='mypassword') + + # Define a resource, here we'll use the incident table API + incident = c.resource(api_path='/table/incident') + + # Query for incidents with state 3 + response = incident.get(query={'state': 3}, fields=['sys_id', 'number', 'description']) + + # Print out the first match + print(response.first()) diff --git a/docs/index.rst b/docs/index.rst index 30387dd..9101300 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -49,6 +49,7 @@ ServiceNow HTTP client library written in Python. full_examples/update full_examples/delete full_examples/sorting + full_examples/filtering full_examples/oauth_client full_examples/query_builder full_examples/attachments