Ë
    ÇVho  ã                   ó€   — d dl mZmZmZ eZdZdZd dlZd dl	Z	d dl
Z
d dlmZ d dlmZ d dlmZ d„ Zed	k(  r e«        yy)
é    )Úabsolute_importÚdivisionÚprint_functionaj  
module: bigpanda
author: "Hagai Kariti (@hkariti)"
short_description: Notify BigPanda about deployments
description:
  - Notify BigPanda when deployments start and end (successfully or not). Returns a deployment object containing all the parameters
    for future module calls.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  component:
    type: str
    description:
      - 'The name of the component being deployed. Ex: V(billing).'
    required: true
    aliases: ['name']
  version:
    type: str
    description:
      - The deployment version.
    required: true
  token:
    type: str
    description:
      - API token.
    required: true
  state:
    type: str
    description:
      - State of the deployment.
    required: true
    choices: ['started', 'finished', 'failed']
  hosts:
    type: str
    description:
      - Name of affected host name. Can be a list.
      - If not specified, it defaults to the remote system's hostname.
    required: false
    aliases: ['host']
  env:
    type: str
    description:
      - The environment name, typically V(production), V(staging), and so on.
    required: false
  owner:
    type: str
    description:
      - The person responsible for the deployment.
    required: false
  description:
    type: str
    description:
      - Free text description of the deployment.
    required: false
  url:
    type: str
    description:
      - Base URL of the API server.
    required: false
    default: "https://api.bigpanda.io"
  validate_certs:
    description:
      - If V(false), SSL certificates for the target URL will not be validated. This should only be used on personally controlled
        sites using self-signed certificates.
    required: false
    default: true
    type: bool
  deployment_message:
    type: str
    description:
      - Message about the deployment.
    version_added: '0.2.0'
  source_system:
    type: str
    description:
      - Source system used in the requests to the API.
    default: ansible

# informational: requirements for nodes
requirements: []
a–  
- name: Notify BigPanda about a deployment
  community.general.bigpanda:
    component: myapp
    version: '1.3'
    token: '{{ bigpanda_token }}'
    state: started

- name: Notify BigPanda about a deployment
  community.general.bigpanda:
    component: myapp
    version: '1.3'
    token: '{{ bigpanda_token }}'
    state: finished

# If outside servers aren't reachable from your machine, use delegate_to and override hosts:
- name: Notify BigPanda about a deployment
  community.general.bigpanda:
    component: myapp
    version: '1.3'
    token: '{{ bigpanda_token }}'
    hosts: '{{ ansible_hostname }}'
    state: started
  delegate_to: localhost
  register: deployment

- name: Notify BigPanda about a deployment
  community.general.bigpanda:
    component: '{{ deployment.component }}'
    version: '{{ deployment.version }}'
    token: '{{ deployment.token }}'
    state: finished
  delegate_to: localhost
N)ÚAnsibleModule)Ú	to_native)Ú	fetch_urlc                  óF  — t        t        t        ddg¬«      t        d¬«      t        dd¬«      t        dg d¢¬«      t        dd	g¬«      t        d¬«      t        d¬«      t        d¬«      t        d¬«      t        dd
¬«      t        dd¬«      t        dd¬«      ¬«      d¬«      } | j                  d   }| j                  d   }| j                  d   }t        «       }dD ]  }| j                  |   }|€Œ|||<   Œ |j                  d«      €t	        j
                  «       g|d<   t        |d   t        «      s	|d   g|d<   |dk(  r$dD ]  }| j                  |   }|€Œ|||<   Œ |dz   }n+| j                  d   }|||d<   |dk(  rd|d<   nd|d<   |dz   }t        ||¬ «      }	|	j                  |«       d|	v r|	j                  d«      }||	d!<   | j                  r | j                  d*d"di|	¤Ž t        j                  |«      }
d#|z  d$d%œ}	 t        | ||
|¬&«      \  }}|d   d'k(  r | j                  d*d"di|	¤Ž y | j                  t        j                  |«      ¬(«       y # t         $ r8}| j                  t#        |«      t%        j&                  «       ¬)«       Y d }~y d }~ww xY w)+NTÚname)ÚrequiredÚaliases)r   )r   Úno_log)ÚstartedÚfinishedÚfailed)r   ÚchoicesFÚhostÚansible)r   ÚdefaultÚbool)r   Útypezhttps://api.bigpanda.io)Ú	componentÚversionÚtokenÚstateÚhostsÚenvÚownerÚdescriptionÚdeployment_messageÚsource_systemÚvalidate_certsÚurl)Úargument_specÚsupports_check_moder   r   r"   )r   r   r   r   r   )r    r   r   r   z/data/events/deployments/startr   ÚerrorMessager   ÚsuccessÚstatusÚfailurez/data/events/deployments/end)r   r"   ÚmessageÚchangedz	Bearer %szapplication/json)ÚAuthorizationzContent-Type)ÚdataÚheaderséÈ   )Úmsg)r/   Ú	exception© )r   ÚdictÚparamsÚgetÚsocketÚgethostnameÚ
isinstanceÚlistÚupdateÚpopÚ
check_modeÚ	exit_jsonÚjsonÚdumpsr   Ú	fail_jsonÚ	Exceptionr   Ú	tracebackÚ
format_exc)Úmoduler   r   r"   ÚbodyÚkÚvÚrequest_urlr)   Ú
deploymentr,   r-   ÚresponseÚinfoÚes                  ún/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/bigpanda.pyÚmainrM   ‘   sÂ  € äÜÜ D°6°(Ô;Ü $Ô'Ü ¨TÔ2Ü Ò.OÔPÜ °¨xÔ8Ü˜eÔ$Ü Ô&Ü eÔ,Ü#¨UÔ3Ü¨°yÔAÜ¨°6Ô:Ü˜eÐ-FÔGô
ð !ô€Fð$ M‰M˜'Ñ"€EØM‰M˜'Ñ"€EØ
-‰-˜Ñ
€Cô ‹6€DØ.ò ˆØM‰M˜!ÑˆØ‰=ØˆDŠGðð ‡xxÓÐ Ü×+Ñ+Ó-Ð.ˆˆW‰äd˜7‘m¤TÔ*Ø˜g™˜ˆˆW‰ð 	ÒØAò 	ˆAØ—‘˜aÑ ˆAØ‰}ØQ’ð	ð
 Ð<Ñ<‰à—-‘-Ð 4Ñ5ˆØÐØ#*ˆDÑ àJÒØ&ˆDŠNà&ˆD‰NàÐ:Ñ:ˆô ˜E sÔ+€JØ×ÑdÔØ˜Ñ#Ø—.‘. Ó0ˆØ 'ˆ
9Ñð ×ÒØˆ×ÑÑ4 Ð4¨Ò4ô :‰:dÓ€DØ +¨eÑ 3ÐEWÑX€GðMÜ" 6¨;¸TÈ7ÔS‰ˆ$Ø‰>˜SÒ ØˆF×ÑÑ8 TÐ8¨ZÓ8à×Ñ¤§¡¨DÓ!1ÐÕ2øÜò MØ×ÑœY q›\´Y×5IÑ5IÓ5KÐ×LÑLûðMús   È
.I È9%I É	J É(.JÊJ Ú__main__)Ú
__future__r   r   r   r   Ú__metaclass__ÚDOCUMENTATIONÚEXAMPLESr=   r5   rA   Úansible.module_utils.basicr   Ú+ansible.module_utils.common.text.convertersr   Úansible.module_utils.urlsr   rM   Ú__name__r1   ó    rL   ú<module>rX      sT   ð÷ AÑ @Ø€ðU€ðn!€óL Û Û å 4Ý AÝ /òMMð` ˆzÒÙ…Fð rW   