�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
d d
l m Z y d d l Z Wn e k
r� n Xd e f d � � YZ d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bysr
---
module: snow_record_find
short_description: Search for multiple records from ServiceNow
version_added: "2.9"
description:
- Gets multiple records from a specified table from ServiceNow based on a query dictionary.
options:
table:
description:
- Table to query for records.
type: str
required: false
default: incident
query:
description:
- Dict to query for records.
type: dict
required: true
max_records:
description:
- Maximum number of records to return.
type: int
required: false
default: 20
order_by:
description:
- Field to sort the results on.
- Can prefix with "-" or "+" to change descending or ascending sort order.
type: str
default: "-created_on"
required: false
return_fields:
description:
- Fields of the record to return in the json.
- By default, all fields will be returned.
type: list
required: false
requirements:
- python pysnow (pysnow)
author:
- Tim Rightnour (@garbled1)
extends_documentation_fragment: service_now.documentation
s
- name: Search for incident assigned to group, return specific fields
snow_record_find:
username: ansible_test
password: my_password
instance: dev99999
table: incident
query:
assignment_group: d625dccec0a8016700a222a0f7900d06
return_fields:
- number
- opened_at
- name: Using OAuth, search for incident assigned to group, return specific fields
snow_record_find:
username: ansible_test
password: my_password
client_id: "1234567890abcdef1234567890abcdef"
client_secret: "Password1!"
instance: dev99999
table: incident
query:
assignment_group: d625dccec0a8016700a222a0f7900d06
return_fields:
- number
- opened_at
- name: Find open standard changes with my template
snow_record_find:
username: ansible_test
password: my_password
instance: dev99999
table: change_request
query:
AND:
equals:
active: "True"
type: "standard"
u_change_stage: "80"
contains:
u_template: "MY-Template"
return_fields:
- sys_id
- number
- sys_created_on
- sys_updated_on
- u_template
- active
- type
- u_change_stage
- sys_created_by
- description
- short_description
s�
record:
description: The full contents of the matching ServiceNow records as a list of records.
type: dict
returned: always
( t
AnsibleModule( t ServiceNowClient( t to_nativeNt
BuildQueryc B` sD e Z d Z d � Z d � Z d � Z d � Z d � Z d � Z RS( sw
This is a BuildQuery manipulation class that constructs
a pysnow.QueryBuilder object based on data input.
c C` s� | | _ d d d g | _ i | j d 6| j d 6| j d 6| j d 6| j d 6| j d 6| j d
6| j d 6| _ | j j � | _ t | _ t | _ | j
d | _ d S(
Nt ANDt ORt NQt equalst
not_equalst containst not_containst starts_witht ends_witht greater_thant less_thant query( t modulet logic_operatorst _condition_closuret condition_operatort keyst accepted_cond_opst Falset append_operatort Truet simple_queryt paramst data( t selfR ( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/notification/snow_record_find.pyt __init__� s
c C` s* | j j | � t | j | � | � d S( N( t qbt fieldt getattr( R$ t condt query_fieldt query_value( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/notification/snow_record_find.pyR � s c C` s� t | t � rn xo | j � D]K \ } } | j rG t | j | � � n | j | | | | � t | _ q Wn | j j d d � d S( Nt msgs"