
    Vh                         d dl mZmZmZ eZdZdZdZd dl	Z	dZ
	 d dlZdZd dlmZmZ d d	lmZ d
 Zedk(  r e        yy# e$ r  e	j                         Z
dZY 9w xY w)    )absolute_importdivisionprint_functionaG  
module: github_release
short_description: Interact with GitHub Releases
description:
  - Fetch metadata about GitHub Releases.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  token:
    description:
      - GitHub Personal Access Token for authenticating. Mutually exclusive with O(password).
    type: str
  user:
    description:
      - The GitHub account that owns the repository.
    type: str
    required: true
  password:
    description:
      - The GitHub account password for the user. Mutually exclusive with O(token).
    type: str
  repo:
    description:
      - Repository name.
    type: str
    required: true
  action:
    description:
      - Action to perform.
    type: str
    required: true
    choices: ['latest_release', 'create_release']
  tag:
    description:
      - Tag name when creating a release. Required when using O(action=create_release).
    type: str
  target:
    description:
      - Target of release when creating a release.
    type: str
  name:
    description:
      - Name of release when creating a release.
    type: str
  body:
    description:
      - Description of the release when creating a release.
    type: str
  draft:
    description:
      - Sets if the release is a draft or not. (boolean).
    type: bool
    default: false
  prerelease:
    description:
      - Sets if the release is a prerelease or not. (boolean).
    type: bool
    default: false

author:
  - "Adrian Moisey (@adrianmoisey)"
requirements:
  - "github3.py >= 1.0.0a3"
a  
- name: Get latest release of a public repository
  community.general.github_release:
    user: ansible
    repo: ansible
    action: latest_release

- name: Get latest release of testuseer/testrepo
  community.general.github_release:
    token: tokenabc1234567890
    user: testuser
    repo: testrepo
    action: latest_release

- name: Get latest release of test repo using username and password
  community.general.github_release:
    user: testuser
    password: secret123
    repo: testrepo
    action: latest_release

- name: Create a new release
  community.general.github_release:
    token: tokenabc1234567890
    user: testuser
    repo: testrepo
    action: create_release
    tag: test
    target: master
    name: My Release
    body: Some description
zl
tag:
  description: Version of the created/latest release.
  type: str
  returned: success
  sample: 1.1.0
NTF)AnsibleModulemissing_required_lib)	to_nativec                     t        t        t        d      t        d      t        d      t        d      t        dddg      t        d      t        d      t        d      t        d      t        d	d
      t        d	d
            dddddgfddddgdfg      } t        s | j                  t	        d      t
               | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }| j                  j                  d      }	| j                  j                  d      }
| j                  j                  d      }	 |rt        j                  ||      }n-|rt        j                  |      }nt        j                         }|s|r|j                          j                  ||      }|s| j                  d!|d"|d#$       |dk(  rA|j!                         }|r| j#                  |j$                  %       n| j#                  d %       |dk(  rs|j'                  |      }|r| j#                  d
d&|z  '       |j)                  ||||	|
|      }|r| j#                  d|j$                  (       y | j#                  d
d (       y y # t        j                  j                  $ r-}| j                  dt        |      z  d|z          Y d }~1d }~ww xY w))NT)required)no_loglatest_releasecreate_release)r
   choicesstr)typeboolF)r   default)repouserpasswordtokenactiontagtargetnamebodydraft
prerelease))r   r   r   r   r   r   )argument_specsupports_check_modemutually_exclusiverequired_ifzgithub3.py >= 1.0.0a3)msg	exceptionr   r   r   r   r   r   r   )r   )r   zFailed to connect to GitHub: %sz=Please check username and password or token for repository %s)r"   detailszRepository /z doesn't exist)r"   )r   z"Release for tag %s already exists.)changedr"   )r&   r   )r   dictHAS_GITHUB_API	fail_jsonr   GITHUB_IMP_ERRparamsgetgithub3loginGitHubme
exceptionsAuthenticationFailedr   
repositoryr   	exit_jsontag_namerelease_from_tagr   )moduler   r   r   login_tokenr   r   r   r   r   r   r   gh_objer3   releaserelease_existss                    t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/github_release.pymainr>      s   t$t$&d#(8:J'KM% U#5!5!FE27
 !3 05': 0:w2GNP#F* 12IJ#1 	 	3 == D== D}}Z(H--(K]]8$F
--

E
"C]]x(F==V$D==V$DMMg&E""<0J=]]4(;F]]5F^^%F {IIK ""4.JtLM!!++-!1!12&!!#44S9U0TWZ0Z[++tUJ8Tw/?/?@U5 "# 22 =>1M"57;"< 	 	= 	==s   7AK> >M"MM__main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURN	tracebackr*   r-   r(   ImportError
format_excansible.module_utils.basicr   r   +ansible.module_utils.common.text.convertersr   r>   __name__     r=   <module>rM      s    A @DLB
 N
 K AM6` zF q  )Y))+NNs   ? AA