
    Vh                         d dl mZmZmZ eZdZdZd dlZdZ		 d dl
mZ d dlmZmZ dZd d	lmZmZ d
 Zedk(  r e        yy# e$ r  ej"                         Z	dZY 3w xY w)    )absolute_importdivisionprint_functiona  
author: "Willy Barro (@willybarro)"
requirements: [pushbullet.py]
module: pushbullet
short_description: Sends notifications to Pushbullet
description:
  - This module sends push notifications through Pushbullet to channels or devices.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  api_key:
    type: str
    description:
      - Push bullet API token.
    required: true
  channel:
    type: str
    description:
      - The channel TAG you wish to broadcast a push notification, as seen on the "My Channels" > "Edit your channel" at Pushbullet
        page.
  device:
    type: str
    description:
      - The device NAME you wish to send a push notification, as seen on the Pushbullet main page.
  push_type:
    type: str
    description:
      - Thing you wish to push.
    default: note
    choices: ["note", "link"]
  title:
    type: str
    description:
      - Title of the notification.
    required: true
  body:
    type: str
    description:
      - Body of the notification, for example details of the fault you are alerting.
  url:
    type: str
    description:
      - URL field, used when O(push_type=link).
notes:
  - Requires C(pushbullet.py) Python package on the remote host. You can install it through C(pip) with C(pip install pushbullet.py).
  - See U(https://github.com/randomchars/pushbullet.py).
a  
- name: Sends a push notification to a device
  community.general.pushbullet:
    api_key: "ABC123abc123ABC123abc123ABC123ab"
    device: "Chrome"
    title: "You may see this on Google Chrome"

- name: Sends a link to a device
  community.general.pushbullet:
    api_key: ABC123abc123ABC123abc123ABC123ab
    device: Chrome
    push_type: link
    title: Ansible Documentation
    body: https://docs.ansible.com/

- name: Sends a push notification to a channel
  community.general.pushbullet:
    api_key: ABC123abc123ABC123abc123ABC123ab
    channel: my-awesome-channel
    title: "Broadcasting a message to the #my-awesome-channel folks"

- name: Sends a push notification with title and body to a channel
  community.general.pushbullet:
    api_key: ABC123abc123ABC123abc123ABC123ab
    channel: my-awesome-channel
    title: ALERT! Signup service is down
    body: Error rate on signup service is over 90% for more than 2 minutes
N)
PushBullet)InvalidKeyError	PushErrorTF)AnsibleModulemissing_required_libc                  j   t        t        t        ddd      t        dd       t        dd       t        ddddg      t        dd      t        dd       t        dd       	      d
dgfd      } | j                  d   }| j                  d
   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }t        s | j	                  t        d      t               	 t        |      }d }	||| j	                  d       |bi }
j                  D ]  }||
|j                  <    ||
v r|
|   }	n6| j	                  d|ddj                  |
j                               d       |bi }j                  D ]  }|||j                  <    ||v r||   }	n6| j	                  d|ddj                  |j                               d       | j                  r| j!                  dd       	 |dk(  r	j#                  |||       n	j%                  ||       | j!                  dd       | j	                  d!       y # t        $ r | j	                  d       Y mw xY w# t&        $ r(}| j	                  d t)        |      z         Y d }~ad }~ww xY w)"NstrT)typerequiredno_log)r   defaultnotelink)r   r   choices)r   r   )api_keychanneldevice	push_typetitlebodyurlr   r   )argument_specmutually_exclusivesupports_check_moder   r   r   r   r   zpushbullet.py)msg	exceptionzInvalid api_key)r   z*You need to provide a channel or a device.zDevice 'z!' not found. Available devices: 'z', ''z	Channel 'z"' not found. Available channels: 'FOK)changedr   z,An error occurred, Pushbullet's response: %szAn unknown error has occurred)r	   dictparamspushbullet_found	fail_jsonr
   PUSHBULLET_IMP_ERRr   r   devicesnicknamejoinkeyschannelschannel_tag
check_mode	exit_json	push_link	push_noter   r   )moduler   r   r   r   r   r   r   pbtargetdevices_by_nicknamedchannels_by_tagces                  p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/pushbullet.pymainr;   q   s   ed4@eT2UD1v?OPED15$/%.
 !
 !F  mmI&GmmI&G]]8$Fk*IMM'"E== D
--
C1/BN`a0 
 ~'/IJ   	0A./

+	0 (((0FU[]c]h]hi|  jB  jB  jD  ^E  "F  G  	/A-.OAMM*	/ o%$W-FW^`f`k`kl{  mA  mA  mC  aD  "E  F D1VUC.UD)D1 89W  0./0P  VKcRSfTUUVs*   I >J I>=I>	J2
J--J2__main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLES	tracebackr'   
pushbulletr   pushbullet.errorsr   r   r%   ImportError
format_excansible.module_utils.basicr	   r
   r;   __name__     r:   <module>rJ      s    A @3j:  %<
  JK:\ zF w  ---/s   A AA