Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/notification/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/notification/snow_record.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZmZddlmZyddlZWnek
r�nXd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysG
---
module: snow_record
short_description: Manage records in ServiceNow
version_added: "2.5"
description:
    - Creates, deletes and updates a single record in ServiceNow.
options:
    table:
      description:
      - Table to query for records.
      required: false
      default: incident
      type: str
    state:
      description:
      - If C(present) is supplied with a C(number) argument, the module will attempt to update the record with the supplied data.
      - If no such record exists, a new one will be created.
      - C(absent) will delete a record.
      choices: [ present, absent ]
      required: true
      type: str
    data:
      description:
      - key, value pairs of data to load into the record. See Examples.
      - Required for C(state:present).
      type: dict
    number:
      description:
      - Record number to update.
      - Required for C(state:absent).
      required: false
      type: str
    lookup_field:
      description:
      - Changes the field that C(number) uses to find records.
      required: false
      default: number
      type: str
    attachment:
      description:
      - Attach a file to the record.
      required: false
      type: str
requirements:
    - python pysnow (pysnow)
author:
    - Tim Rightnour (@garbled1)
extends_documentation_fragment: service_now.documentation
sm
- name: Grab a user record
  snow_record:
    username: ansible_test
    password: my_password
    instance: dev99999
    state: present
    number: 62826bf03710200044e0bfc8bcbe5df1
    table: sys_user
    lookup_field: sys_id

- name: Grab a user record using OAuth
  snow_record:
    username: ansible_test
    password: my_password
    client_id: "1234567890abcdef1234567890abcdef"
    client_secret: "Password1!"
    instance: dev99999
    state: present
    number: 62826bf03710200044e0bfc8bcbe5df1
    table: sys_user
    lookup_field: sys_id

- name: Create an incident
  snow_record:
    username: ansible_test
    password: my_password
    instance: dev99999
    state: present
    data:
      short_description: "This is a test incident opened by Ansible"
      severity: 3
      priority: 2
  register: new_incident

- name: Delete the record we just made
  snow_record:
    username: admin
    password: xxxxxxx
    instance: dev99999
    state: absent
    number: "{{new_incident['record']['number']}}"

- name: Delete a non-existant record
  snow_record:
    username: ansible_test
    password: my_password
    instance: dev99999
    state: absent
    number: 9872354
  failed_when: false

- name: Update an incident
  snow_record:
    username: ansible_test
    password: my_password
    instance: dev99999
    state: present
    number: INC0000055
    data:
      work_notes : "Been working all day on this thing."

- name: Attach a file to an incident
  snow_record:
    username: ansible_test
    password: my_password
    instance: dev99999
    state: present
    number: INC0000055
    attachment: README.md
  tags: attach
s�
record:
   description: Record data from Service Now
   type: dict
   returned: when supported
attached_file:
   description: Details of the file that was attached via C(attachment)
   type: dict
   returned: when supported
N(t
AnsibleModule(tto_bytest	to_native(tServiceNowClientcC`s�tj�}|jdtdddtdd�dtdd	d
gdddt�dtdddtdd�dtdddtdd
�dtdddtdd�dtdddtdd��ddgg}dd
dggg}td|dtd|d|�}t|�}|j�|j	}|j
}|d}|d}|d}	|d}
|d}|d}tdtd|d|d|
d|�}
|ddk	r�|d}t|dd�}tj
j|�s�|jddj|��n||
d<nd}|jr�|
dkr-t|�|
d<t|
d<n�|	d
kr�yL|jd|di|
|6�}|j�}tdt�|
d<t|
d<Wq�tjjk
r�d|
d<q�tk
r�}|jddjt|��|
�q�Xn�yj|jd|di|
|6�}|j�}x.|j�D] \}}|||<t|
d<qW||
d<Wndtjjk
r|d }|jd||
�n5tk
r�}|jddjt|��|
�nX|j|
�n|	d	kr�|
dkr�y"|jd|d!t|��}Wnytjjk
rA}d"j|j|j�}|jd||
�n6tjj k
rv}|jdd#t|�|
�nX||
d<t|
d<n|	d
kr�y/|jd|di|
|6�}|j!�}Wntjjk
r�tdt�}n�tjj"k
r d$}|jd||
�n�tjjk
rc}d%j|j|j�}|jd||
�nptjj k
r�}|jdd&t|�|
�n;tk
r�}d'jt|��}|jd||
�nX||
d<t|
d<n�y�|jd|di|
|6�}|dk	rD|jt|��}||
d<t|
d<n|j�}||
d<|dk	r�|j#|�}t|
d<||
d(<nWntjj"k
r�d$}|jd||
�n�tjjk
r�d }|jd||
�n�tjjk
r1}d)j|j|j�}|jd||
�nptjj k
rf}|jdd*t|�|
�n;tk
r�}d+jt|��}|jd||
�nX|j|
�dS(,Nttablettypetstrtrequiredtdefaulttincidenttstatetchoicestpresenttabsenttnumbertdatatdicttlookup_fieldt
attachmentt	client_idt
client_secrett
argument_spectsupports_check_modetrequired_togethertrequired_iftinstancetchangedterrorstsurrogate_or_stricttmsgsAttachment {0} not foundtrecordtquerytSuccesss$Unknown failure in query record: {0}sRecord does not existtpayloads*Failed to create record: {0}, details: {1}s!Failed to create record due to %ssMultiple record matchs*Failed to delete record: {0}, details: {1}s!Failed to delete record due to %ssFailed to delete record: {0}t
attached_files*Failed to update record: {0}, details: {1}s!Failed to update record due to %ssFailed to update record: {0}($Rtsnow_argument_spectupdateRtFalsetTruetNoneRtlogintconntparamsR	tostpathtexistst	fail_jsontformatt
check_modeR'tget_onetpysnowt
exceptionst	NoResultst	ExceptionR
titemst	exit_jsontinserttUnexpectedResponseFormatt
error_summaryt
error_detailstlegacy_exceptionstUnexpectedResponsetdeletetMultipleResultstattach(tmodule_argstmodule_required_togethertmodule_required_iftmoduletservice_now_clientR1R2R!RRRRRtresultRHtb_attachR&trestdetailtkeytvaluet
snow_errorte((sL/usr/lib/python2.7/site-packages/ansible/modules/notification/snow_record.pyt
run_module�s�		
		





	

	

)
&"!

 





 cC`st�dS(N(RV(((sL/usr/lib/python2.7/site-packages/ansible/modules/notification/snow_record.pytmainHst__main__(t
__future__RRRR
t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR3tansible.module_utils.basicRtansible.module_utils._textR	R
t ansible.module_utils.service_nowRR:tImportErrorRVRWt__name__(((sL/usr/lib/python2.7/site-packages/ansible/modules/notification/snow_record.pyt<module>s(

4I
	�	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]