Anons79 Mini Shell

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

�
�Udac@`s-ddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
d
Zydd
l
Z
eZWn#ek
r�e
j�ZeZnXddlmZmZddlmZdd
lmZddlmZd
d
d
d
ed
d
d�Zd�Zedkr)e�nd
S(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
version_added: "2.0"
module: sendgrid
short_description: Sends an email with the SendGrid API
description:
   - "Sends an email with a SendGrid account through their API, not through
     the SMTP service."
notes:
   - "This module is non-idempotent because it sends an email through the
     external API. It is idempotent only in the case that the module fails."
   - "Like the other notification modules, this one requires an external
     dependency to work. In this case, you'll need an active SendGrid
     account."
   - "In order to use api_key, cc, bcc, attachments, from_name, html_body, headers
     you must pip install sendgrid"
   - "since 2.2 username and password are not required if you supply an api_key"
requirements:
  - sendgrid python library
options:
  username:
    description:
      - username for logging into the SendGrid account.
      - Since 2.2 it is only required if api_key is not supplied.
  password:
    description:
      - password that corresponds to the username
      - Since 2.2 it is only required if api_key is not supplied.
  from_address:
    description:
      - the address in the "from" field for the email
    required: true
  to_addresses:
    description:
      - a list with one or more recipient email addresses
    required: true
  subject:
    description:
      - the desired subject for the email
    required: true
  api_key:
    description:
      - sendgrid API key to use instead of username/password
    version_added: 2.2
  cc:
    description:
      - a list of email addresses to cc
    version_added: 2.2
  bcc:
    description:
      - a list of email addresses to bcc
    version_added: 2.2
  attachments:
    description:
      - a list of relative or explicit paths of files you want to attach (7MB limit as per SendGrid docs)
    version_added: 2.2
  from_name:
    description:
      - the name you want to appear in the from field, i.e 'John Doe'
    version_added: 2.2
  html_body:
    description:
      - whether the body is html content that should be rendered
    version_added: 2.2
    type: bool
    default: 'no'
  headers:
    description:
      - a dict to pass on as headers
    version_added: 2.2
author: "Matt Makai (@makaimc)"
s
# send an email to a single recipient that the deployment was successful
- sendgrid:
    username: "{{ sendgrid_username }}"
    password: "{{ sendgrid_password }}"
    from_address: "[email protected]"
    to_addresses:
      - "[email protected]"
    subject: "Deployment success."
    body: "The most recent Ansible deployment was successful."
  delegate_to: localhost

# send an email to more than one recipient that the build failed
- sendgrid:
      username: "{{ sendgrid_username }}"
      password: "{{ sendgrid_password }}"
      from_address: "[email protected]"
      to_addresses:
        - "[email protected]"
        - "[email protected]"
      subject: "Build failure!."
      body: "Unable to pull source repository from Git server."
  delegate_to: localhost
N(t
AnsibleModuletmissing_required_lib(t	urlencode(tto_bytes(t	fetch_urlc	C`s$ts�d}d}i|d6|d6|d6|d6|d6}t|�}d}x.|D]&}t|d	d
�}|d|7}qTW||7}i|d6d
d6dd6}
t||d|d|
dd�S|r�tj|�}ntj||�}tj�}|j|�x|D]}|j|�qW|rJx|D]}|j	|�q0Wn|	rqx|	D]}|j
|�qWWn|
r�|j|
�n|
r�x3|
D](}tj
j|�}|j||�q�Wn|r�|jd||f�n
|j|�|r|j|�n
|j|�|j|�SdS(Ns+https://api.sendgrid.com/api/mail.send.jsontAnsibletapi_usertapi_keytfromtsubjectttexttterrorstsurrogate_or_stricts&to[]=%ss
User-Agents!application/x-www-form-urlencodedsContent-typesapplication/jsontAccepttdatatheaderstmethodtPOSTs%s <%s.(tHAS_SENDGRIDR
RRtsendgridtSendGridClienttMailtset_subjecttadd_totadd_cctadd_bcctset_headerstostpathtbasenametadd_attachmenttset_fromtset_htmltset_texttsend(tmoduletusernametpasswordtfrom_addresstto_addressesRtbodyRtcctbcctattachmentst	html_bodyt	from_nameRtSENDGRID_URItAGENTRtencoded_datatto_addresses_apit	recipienttsgtmessagetreciptftname((sI/usr/lib/python2.7/site-packages/ansible/modules/notification/sendgrid.pytpost_sendgrid_api�sR










c!C`stdtdtdt�dtdtdt�dtdtdt�dtdtdd	�d
tdtdd	�dtdtdd�d
tdt�dtdt�dtdtdd	�dtdt�dtdt�dtdtdtdd�dtdtdd	��
dtdddgddggdddgg�}|jd}|jd}|jd}|jd}|jd
}|jd}|jd}|jd
}|jd}	|jd}
|jd}|jd}|jd}
|||||||
g}td�|D��rDtrDd}|jdtdd|�dt	�nt
|||||	|
|d|
d|d
|d|d|d|�\}}ts�|dd kr�|jdd!|d�q�n'|d kr�|jdd!|d"�n|jd|
d#t�dS($Nt
argument_specR-trequiredR.tno_logRR3ttypetlistR2RtdictR/R6R0RR1R5tdefaulttboolR4tsupports_check_modetmutually_exclusivetrequired_togethercs`s|]}|dk	VqdS(N(tNone(t.0tlib_arg((sI/usr/lib/python2.7/site-packages/ansible/modules/notification/sendgrid.pys	<genexpr>�ssgwhen using any of the following arguments: api_key, bcc, cc, headers, from_name, html_body, attachmentstmsgRtreasont	exceptionRi�s-unable to send email through SendGrid API: %sR=tchanged(RRGtFalsetTruetparamstanyRt	fail_jsonR	tSENDGRID_IMP_ERRRAt	exit_json(R,R-R.RR3R2RR6R/R0RR1R5R4tsendgrid_lib_argsRQtresponsetinfo((sI/usr/lib/python2.7/site-packages/ansible/modules/notification/sendgrid.pytmain�s\	













't__main__(t
__future__RRRREt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESR$t	tracebackRMRYRRURtImportErrort
format_excRTtansible.module_utils.basicRR	t+ansible.module_utils.six.moves.urllib.parseR
tansible.module_utils._textRtansible.module_utils.urlsRRAR^t__name__(((sI/usr/lib/python2.7/site-packages/ansible/modules/notification/sendgrid.pyt<module>s0


J


>	=

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