
    VhX{                        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Zd dl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	 d dlmZ d	ZdZ	 d dlZd	ZdZ	 d dl m!Z!m"Z" d	Z#d dl$m%Z%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z,m-Z-m.Z. d Z/d Z0 G d de1      Z2 G d d      Z3d Z4e5dk(  r e4        yy# e$ r  ej6                         Zd
ZY zw xY w# e$ r  ej6                         Zd
ZY w xY w# e$ r  ej6                         Zd
Z#Y w xY w)    )absolute_importdivisionprint_functiona  
module: maven_artifact
short_description: Downloads an Artifact from a Maven Repository
description:
  - Downloads an artifact from a maven repository given the maven coordinates provided to the module.
  - Can retrieve snapshots or release versions of the artifact and will resolve the latest available version if one is not
    available.
author: "Chris Schmidt (@chrisisbeef)"
requirements:
  - lxml
  - boto if using a S3 repository (V(s3://...))
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  group_id:
    type: str
    description:
      - The Maven groupId coordinate.
    required: true
  artifact_id:
    type: str
    description:
      - The maven artifactId coordinate.
    required: true
  version:
    type: str
    description:
      - The maven version coordinate.
      - Mutually exclusive with O(version_by_spec).
  version_by_spec:
    type: str
    description:
      - The maven dependency version ranges.
      - See supported version ranges on U(https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution).
      - The range type V((,1.0],[1.2,\)) and V((,1.1\),(1.1,\)) is not supported.
      - Mutually exclusive with O(version).
    version_added: '0.2.0'
  classifier:
    type: str
    description:
      - The maven classifier coordinate.
    default: ''
  extension:
    type: str
    description:
      - The maven type/extension coordinate.
    default: jar
  repository_url:
    type: str
    description:
      - The URL of the Maven Repository to download from.
      - Use V(s3://...) if the repository is hosted on Amazon S3.
      - Use V(file://...) if the repository is local.
    default: https://repo1.maven.org/maven2
  username:
    type: str
    description:
      - The username to authenticate as to the Maven Repository. Use AWS secret key of the repository is hosted on S3.
    aliases: ["aws_secret_key"]
  password:
    type: str
    description:
      - The password to authenticate with to the Maven Repository. Use AWS secret access key of the repository is hosted on
        S3.
    aliases: ["aws_secret_access_key"]
  headers:
    description:
      - Add custom HTTP headers to a request in hash/dict format.
    type: dict
  force_basic_auth:
    description:
      - C(httplib2), the library used by the URI module only sends authentication information when a webservice responds to an
        initial request with a 401 status. Since some basic auth services do not properly send a 401, logins will fail. This
        option forces the sending of the Basic authentication header upon initial request.
    default: false
    type: bool
    version_added: '0.2.0'
  dest:
    type: path
    description:
      - The path where the artifact should be written to.
      - If file mode or ownerships are specified and destination path already exists, they affect the downloaded file.
    required: true
  state:
    type: str
    description:
      - The desired state of the artifact.
    default: present
    choices: [present, absent]
  timeout:
    type: int
    description:
      - Specifies a timeout in seconds for the connection attempt.
    default: 10
  validate_certs:
    description:
      - If V(false), SSL certificates will not be validated. This should only be set to V(false) when no other option exists.
    type: bool
    default: true
  client_cert:
    description:
      - PEM formatted certificate chain file to be used for SSL client authentication.
      - This file can also include the key as well, and if the key is included, O(client_key) is not required.
    type: path
    version_added: '1.3.0'
  client_key:
    description:
      - PEM formatted file that contains your private key to be used for SSL client authentication.
      - If O(client_cert) contains both the certificate and key, this option is not required.
    type: path
    version_added: '1.3.0'
  keep_name:
    description:
      - If V(true), the downloaded artifact's name is preserved, in other words the version number remains part of it.
      - This option only has effect when O(dest) is a directory and O(version) is set to V(latest) or O(version_by_spec) is
        defined.
    type: bool
    default: false
  verify_checksum:
    type: str
    description:
      - If V(never), the MD5/SHA1 checksum will never be downloaded and verified.
      - If V(download), the MD5/SHA1 checksum will be downloaded and verified only after artifact download. This is the default.
      - If V(change), the MD5/SHA1 checksum will be downloaded and verified if the destination already exist, to verify if
        they are identical. This was the behaviour before 2.6. Since it downloads the checksum before (maybe) downloading
        the artifact, and since some repository software, when acting as a proxy/cache, return a 404 error if the artifact
        has not been cached yet, it may fail unexpectedly. If you still need it, you should consider using V(always) instead
        - if you deal with a checksum, it is better to use it to verify integrity after download.
      - V(always) combines V(download) and V(change).
    required: false
    default: 'download'
    choices: ['never', 'download', 'change', 'always']
  checksum_alg:
    type: str
    description:
      - If V(md5), checksums will use the MD5 algorithm. This is the default.
      - If V(sha1), checksums will use the SHA1 algorithm. This can be used on systems configured to use FIPS-compliant algorithms,
        since MD5 will be blocked on such systems.
    default: 'md5'
    choices: ['md5', 'sha1']
    version_added: 3.2.0
  unredirected_headers:
    type: list
    elements: str
    version_added: 5.2.0
    description:
      - A list of headers that should not be included in the redirection. This headers are sent to the C(fetch_url) function.
      - On ansible-core version 2.12 or later, the default of this option is V([Authorization, Cookie]).
      - Useful if the redirection URL does not need to have sensitive headers in the request.
      - Requires ansible-core version 2.12 or later.
  directory_mode:
    type: str
    description:
      - Filesystem permission mode applied recursively to O(dest) when it is a directory.
extends_documentation_fragment:
  - ansible.builtin.files
  - community.general.attributes
a  
- name: Download the latest version of the JUnit framework artifact from Maven Central
  community.general.maven_artifact:
    group_id: junit
    artifact_id: junit
    dest: /tmp/junit-latest.jar

- name: Download JUnit 4.11 from Maven Central
  community.general.maven_artifact:
    group_id: junit
    artifact_id: junit
    version: 4.11
    dest: /tmp/junit-4.11.jar

- name: Download an artifact from a private repository requiring authentication
  community.general.maven_artifact:
    group_id: com.company
    artifact_id: library-name
    repository_url: 'https://repo.company.com/maven'
    username: user
    password: pass
    dest: /tmp/library-name-latest.jar

- name: Download an artifact from a private repository requiring certificate authentication
  community.general.maven_artifact:
    group_id: com.company
    artifact_id: library-name
    repository_url: 'https://repo.company.com/maven'
    client_cert: /path/to/cert.pem
    client_key: /path/to/key.pem
    dest: /tmp/library-name-latest.jar

- name: Download a WAR File to the Tomcat webapps directory to be deployed
  community.general.maven_artifact:
    group_id: com.company
    artifact_id: web-app
    extension: war
    repository_url: 'https://repo.company.com/maven'
    dest: /var/lib/tomcat7/webapps/web-app.war

- name: Keep a downloaded artifact's name, i.e. retain the version
  community.general.maven_artifact:
    version: latest
    artifact_id: spring-core
    group_id: org.springframework
    dest: /tmp/
    keep_name: true

- name: Download the latest version of the JUnit framework artifact from Maven local
  community.general.maven_artifact:
    group_id: junit
    artifact_id: junit
    dest: /tmp/junit-latest.jar
    repository_url: "file://{{ lookup('env','HOME') }}/.m2/repository"

- name: Download the latest version between 3.8 and 4.0 (exclusive) of the JUnit framework artifact from Maven Central
  community.general.maven_artifact:
    group_id: junit
    artifact_id: junit
    version_by_spec: "[3.8,4.0)"
    dest: /tmp/
N)LooseVersion)__version__)match)etreeTF)VersionSpec)AnsibleModulemissing_required_lib)urlparse)	fetch_url)to_bytes	to_nativeto_textc                    t         j                  j                  |       \  }}t        |d      }t         j                  j	                  |      s|| k(  rd|gfS t        |      \  }}n||gfS |j                  |       ||fS )zi
    Return the first pre-existing directory and a list of the new directories that will be created.
    surrogate_or_stricterrorsN)ospathsplitr   existssplit_pre_existing_dirappend)dirnameheadtailb_headpre_existing_dirnew_directory_lists         t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/maven_artifact.pyr   r     s     w'JD$d#89F77>>&!7?$<5KD5Q21dV|d#///    c                     |r\|j                  d      }| s|}n t        j                  j                  | |      }||d<   |j	                  ||      }t        |||||      }|S )z]
    Walk the new directories list and make sure that permissions are as we would expect
    r   r   )popr   r   joinset_fs_attributes_if_different&adjust_recursive_directory_permissions)r!   r"   moduledirectory_argschangedfirst_sub_dirworking_dirs          r#   r)   r)   ,  sk     *..q1'K'',,'7GK!,v77P8FXZ`bpryzNr$   c                   F    e Zd Zd	dZd Zd
dZd ZddZd Ze	d        Z
y)Artifactc                     |st        d      |st        d      || _        || _        || _        || _        || _        |sd| _        y || _        y )Nzgroup_id must be setzartifact_id must be setjar)
ValueErrorgroup_idartifact_idversionversion_by_spec
classifier	extension)selfr4   r5   r6   r7   r8   r9   s          r#   __init__zArtifact.__init__=  sV    344677 &.$"DN&DNr$   c                 T    | j                   xr | j                   j                  d      S )NSNAPSHOT)r6   endswith)r:   s    r#   is_snapshotzArtifact.is_snapshotN  s     ||A 5 5j AAr$   c                 n   t        j                  | j                  j                  dd      | j                        }|rx| j
                  rlt        j                  d| j
                        }|r*t        j                  ||j                  d      dz         }|S t        j                  || j
                        }|S )N./z#^(.*-)?([0-9]{8}\.[0-9]{6}-[0-9]+)$   r=   )		posixpathr'   r4   replacer5   r6   rer   group)r:   with_versionbasetimestamp_version_matchs       r#   r   zArtifact.pathQ  s    ~~dmm33C=t?O?OPDLL&(hh/UW[WcWc&d#& ~~d,C,I,I!,Lz,YZ  !~~dDLL9r$   c                     | j                   dz   | j                  z   dz   | j                  z   }| j                  s| j                   dz   | j                  z   }|S )N-rA   )r5   r8   r9   r:   filenames     r#   _generate_filenamezArtifact._generate_filename[  sN    ##c)DOO;cADNNR''#->Hr$   Nc                     |s| j                         }|S t        j                  j                  |      r.t        j                  j	                  || j                               }|S N)rO   r   r   isdirr'   rM   s     r#   get_filenamezArtifact.get_filenamea  sN    ..0H  WW]]8$ww||Hd.E.E.GHHr$   c           	      ~   | j                   d| j                  d| j                  }| j                  rD| j                   d| j                  d| j                  d| j                  d| j                  	}|S | j                  dk7  r5| j                   d| j                  d| j                  d| j                  }|S )N:r2   )r4   r5   r6   r8   r9   )r:   results     r#   __str__zArtifact.__str__h  s    #}}d.>.>M??)-8H8H$..Z^ZiZikokwkwxF  ^^u$&*mmT5E5Et~~W[WcWcdFr$   c                     | j                  d      }t        |      dk\  rM|d   }|d   }|d   }d }d }t        |      dk(  r|d   }t        |      dk(  r
|d   }|d   }t        |||||      S y )	NrU      r   rC            )r   lenr0   )inputpartsgavtcs          r#   parsezArtifact.parsep  s    C u:?aAaAb	AAA5zQ!H5zQ!H!HAq!Q**r$   ) r2   TrQ   )__name__
__module____qualname__r;   r?   r   rO   rS   rW   staticmethodrf    r$   r#   r0   r0   <  s5    '"B  r$   r0   c                   T    e Zd ZddZd Zd Zd ZddZddZddZ	dd	Z
dd
Zd Zy)MavenDownloaderNc                     || _         |j                  d      r|j                  d      }|| _        || _        || _        dj                  t              | _        d | _	        |rd| _
        y d| _
        y )NrB   zAnsible {0} maven_artifactzmaven-metadata-local.xmlzmaven-metadata.xml)r*   r>   rstriprI   localheadersformatansible_version
user_agentlatest_version_foundmetadata_file_name)r:   r*   rI   rr   rs   s        r#   r;   zMavenDownloader.__init__  se    ==;;s#D	
6==oN$(!@E"<K_r$   c           	         d|j                  d      d| j                  }| j                  | j                  |z   d|z         }t	        j
                  |      }|j                  d      }g }|D ]'  }	 |j                  t        j                  |             ) ddddd	d
d}|j                         D ]  \  }	}
t        |	|j                        }|st         |
j                  di |j!                               }|j#                  |      }|s$t        dj                  |j                              t%        |      |vrd |_        t%        |      c S  t        dj                  |j                              # t        $ r Y w xY w)NrB   F,Failed to retrieve the maven metadata file: z,/metadata/versioning/versions/version/text()z<={upper_bound}z~={version}z=={version}z>={lower_bound},<={upper_bound}z>={lower_bound},<{upper_bound}z>={lower_bound})z^\(,(?P<upper_bound>[0-9.]*)]$z^(?P<version>[0-9.]*)$z^\[(?P<version>[0-9.]*)\]$z:^\[(?P<lower_bound>[0-9.]*),\s*(?P<upper_bound>[0-9.]*)\]$z:^\[(?P<lower_bound>[0-9.]*),\s*(?P<upper_bound>[0-9.]+)\)$z^\[(?P<lower_bound>[0-9.]*),\)$z,No version found with this spec version: {0}z'The spec version {0} is not supported! rm   )r   rx   _getContentrI   r	   
fromstringxpathr   r
   coercer3   itemsr   r7   r   rt   	groupdictselectstrpatch)r:   artifactr   contentxmloriginal_versionsversionsr6   parse_versions_syntaxregexspec_formatregex_resultspecselected_versions                 r#   find_version_by_specz$MavenDownloader.find_version_by_spec  s   #==/1H1HI""499t#35cfj5jkw'II&TU( 	Gw 78	 0A'4+8KlKk0A!
 #8"="="? 	-E; (@(@AL.K..J1G1G1IJK#';;x#8 '$%S%Z%Z[c[s[s%tuu '(0AA-1$*+,,	- BII(JbJbcddE  s   2$E66	FFc                 (   | j                   r| j                   S d|j                  d      d| j                  }| j                  | j                  |z   d|z         }t        j                  |      }|j                  d      }|r|d   | _         |d   S y )NrB   Frz   z4/metadata/versioning/versions/version[last()]/text()r   )rw   r   rx   r{   rI   r	   r|   r}   )r:   r   r   r   r   rc   s         r#   find_latest_version_availablez-MavenDownloader.find_latest_version_available  s    $$,,, %#==/1H1HI""499t#35cfj5jkw'IILM()!D%Q4K r$   c                    |j                   r| j                  |      |_        |j                  dk(  r| j                  |      |_        |j	                         rl| j
                  r| j                  ||j                        S d|j                         d| j                  }| j                  | j                  |z   d|z         }t        j                  |      }|j                  d      D ]{  }|j                  d      }|r|d   nd}|j                  d      }|r|d   nd}	||j                  k(  sG|	|j                  k(  sW| j                  ||j                  d	      d         c S  |j                  d
      }
|
rK|
d   }|j                  d      d   }| j                  ||j                  j!                  d|dz   |z               S | j                  ||j                        S )NlatestrB   rz   z5/metadata/versioning/snapshotVersions/snapshotVersionzclassifier/text()r   rg   zextension/text()zvalue/text()z./metadata/versioning/snapshot/timestamp/text()z0/metadata/versioning/snapshot/buildNumber/text()r=   rL   )r7   r   r6   r   r?   rr   _uri_for_artifactr   rx   r{   rI   r	   r|   r}   r8   r9   rE   )r:   r   r   r   r   snapshotArtifactr8   artifact_classifierr9   artifact_extensiontimestamp_xmlpath	timestampbuild_numbers                r#   find_uri_for_artifactz%MavenDownloader.find_uri_for_artifact  s   ###88BHx'#AA(KH!zz--h8H8HII '}}0G0GHD&&tyy4'79gjn9noG""7+C$'II.e$f g -334GH
7Ajmr#,223EF	5>Yq\B"&(*=*==BTX`XjXjBj11(<L<R<RSa<bcd<effg !$		*Z [ -a0	"yy)[\]^_--h8H8H8P8PQ[]fil]lo{]{8|}}%%h0@0@AAr$   c                     |j                         r|st        dt        |      z         |j                         s|j                  }|j                  r_t        j                  | j                  |j                         |j                  dz   |z   dz   |j                  z   dz   |j                  z         S t        j                  | j                  |j                         |j                  dz   |z   dz   |j                  z         S )Nz-Expected uniqueversion for snapshot artifact rL   rA   )r?   r3   r   r6   r8   rD   r'   rI   r   r5   r9   )r:   r   r6   s      r#   r   z!MavenDownloader._uri_for_artifact  s    !'LsS[}\]]%%'&&G>>$))X]]_h>R>RUX>X[b>beh>hksk~k~>~  BE  ?E  HP  HZ  HZ  ?Z  [  [~~dii(:N:NQT:TW^:^ad:dgogygy:yzzr$   c                    | j                   rt        |      }t        j                  j	                  |j                        r:t        j                  |j                  d      5 }|j                         cd d d        S |rt        |dz   |z         y | j                  |||      }|r|j                         S y # 1 sw Y   CxY w)Nrbz because can not find file: )
rr   r   r   r   isfileioopenreadr3   _request)r:   urlfailmsgforce
parsed_urlfresponses          r#   r{   zMavenDownloader._getContent  s    ::!#Jww~~joo.WWZ__d3 $q668$ $ +I!IC!OPP==gu5==?"$ $s   !B55B>c                    |}t        |      }|j                  dk(  rt        |      }|j                  }|j                  dd  }t	        j
                  d| j                  j                  j                  dd      | j                  j                  j                  dd            }|j                  d||dd	
      }| j                  j                  j                  d      }	| j                  j                  j                  dd      | j                  j                  d<   | j                  j                  j                  dd      | j                  j                  d<   | j                  | j                  j                  d<   i }
| j                  j                  d   r| j                  j                  d   |
d<   t        | j                  |f|	| j                  d|
\  }}|d   dk(  r|S |rt        |dz   |d   z   dz   |z         y )Ns3rC   usernamerg   password)aws_access_key_idaws_secret_access_key
get_object)BucketKey
   )Params	ExpiresIntimeouturl_usernameurl_password
http_agentunredirected_headers)r   rs   status   z because of msgzfor URL )r   schemenetlocr   boto3clientr*   paramsgetgenerate_presigned_urlrv   r   rs   r3   )r:   r   r   r   
url_to_user   bucket_namekey_namer   req_timeoutkwargsr   infos                r#   r   zMavenDownloader._request  s   
c]
$!#J$++K!qr*H\\$$++:L:L:P:PQ[]_:`x|  yD  yD  yK  yK  yO  yO  PZ  \^  y_  `F66|WbksLt  AC6  DJkk((,,Y7 .2[[-?-?-C-CJPR-S>*-1[[-?-?-C-CJPR-S>*+/??<(;;45-1[[-?-?@V-WF)*"KK
  LL	

 
$ >S OW~5UCjPS]]^^r$   c                    |j                   s|j                  r|j                   dk(  rGt        |j                  |j                  | j                  |      d |j                  |j                        }| j                  |      }t        j                  |      \  }}	 | j                  rdt        |      }	t        j                  j                  |	j                        r!t!        j"                  |	j                  |       nbd|	j                  z   S | j%                  |dt'        |      z         }
t        j(                  |d      5 }t!        j*                  |
|       d d d        |r,| j-                  |||      }|rt        j.                  |       |S t!        j2                  ||j5                  |             y # 1 sw Y   ]xY w# t0        $ r}t        j.                  |       |d }~ww xY w)Nr   )dirzCan not find local file: zFailed to download artifact wb)r6   r7   r0   r4   r5   r   r8   r9   r   tempfilemkstemprr   r   r   r   r   shutilcopy2r   r   fdopencopyfileobjis_invalid_checksumremove	ExceptionmoverS   )r:   tmpdirr   verify_downloadrN   checksum_algr   tempfdtempnamer   r   r   invalid_checksumes                 r#   downloadzMavenDownloader.download"  s     )A)AhFVFVZbFb 1 183G3GIkIkltIuw{ ( 3 3X5G5GIH((2#++7	zz%c]
77>>*//2LL(;6HH==.LsS[}.\]YYvt, 4&&x34 #'#;#;Hc<#X #IIh'++ 	Hh33H=>4 4  	IIhG	s7   A/F= 
4F= >F15F= 1F:6F= =	G"GG"c           	      0   t         j                  j                  |      r| j                  ||      }| j                  r(t        |      }| j                  ||j                        }n/	 t        | j                  |dz   |z   dd      d      }|sd	|d|S 	 |j                  d d
      d   }|}|j                         |j                         k(  ry d|z   dz   |z   S d|z   S # t        $ r}d|d|dt        |      cY d }~S d }~ww xY w# t        $ r Y gw xY w)NrA   zFailed to retrieve checksumFstrictr   zCannot retrieve a valid z checksum from z: zCannot find rC   r   z%Checksum does not match: we computed z but the repository states zPath does not exist: )r   r   r   _local_checksumrr   r   r   r{   UnicodeErrorr   r   
IndexErrorlower)	r:   file
remote_urlr   local_checksumr   remote_checksumr   _remote_checksums	            r#   r   z#MavenDownloader.is_invalid_checksumD  sA   77>>$!11,ENzz%j1
"&"6"6|Z__"Ux&-d.>.>zC?OR^?^`}  @E  /F  OW  'XO '@LjYY#2#8#8q#A!#D "2
 ##%)>)>)@@>ORoo  sB  B  B&--# $ xP\^hjstujvwwx  s0   '$C D	 	D(D;DD		DDc                    |j                         dk(  rt        j                         }n6|j                         dk(  rt        j                         }nt	        d|z        t        j                  |d      5 t        fdd      D ]  }|j                  |        	 d d d        |j                         S # 1 sw Y   |j                         S xY w)Nmd5sha1zUnknown checksum_alg %sr   c                  &     j                  d      S )Ni    )r   )r   s   r#   <lambda>z1MavenDownloader._local_checksum.<locals>.<lambda>h  s    affTl r$   r$   )
r   hashlibr   r   r3   r   r   iterupdate	hexdigest)r:   r   r   hashchunkr   s        @r#   r   zMavenDownloader._local_checksum`  s    5(;;=D!V+<<>D6EFFWWT4  	#A2C8 #E"#	# ~~	# ~~s   6&B55C)FNrQ   rh   )Nr   )r   )ri   rj   rk   r;   r   r   r   r   r{   r   r   r   r   rm   r$   r#   ro   ro     s;    	`+eZ	B:{"H D.8
 r$   ro   c                     t        t        dTi dt        d      dt        d      dt        d       dt        d       dt        d	      d
t        d      dt        d      dt        d dg      dt        d ddg      dt        d      dt        dd      dt        dddg      dt        d d!      d"t        d#d$      d%t        ddd&      d't        d#d$      d(t        d#d$      d)t        ddd&      d*t        dd+g d,-      d.t        dd/d/d0g-      d1t        d2d3d4      d5t        d3      dd6g7      } t        t              t        d8      k  r!| j                  d1   r| j                  d9:       t        t              t        d8      k\  r | j                  d1   d;d<g| j                  d1<   t        s | j                  t        d=      t        >       | j                  d   r&t        s | j                  t        d?      t        >       | j                  d   }|sd}	 t        |      }j                  dAk(  }|j                  dBk(  r(t        s"| j                  t        dCdDE      t        >       | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }	| j                  d
   }
| j                  d   }| j                  d   }| j                  d"   }t!        |dFG      }| j                  d)   }| j                  d*   }|dHv }|dIv }| j                  d.   }t#        | |||      }|s|sdJ}	 t%        |||||	|
      }d}d}|j+                  t,        j.                        rt!        |dFG      }t,        j0                  j3                  |      sit5        |      \  }}t-        j6                  |       | j9                  | j                        }| j                  d5   }|||dL<   nd |dL<   t;        ||| ||      }t,        j0                  j=                  |      r|}|dJk(  r|j?                        }n|r|jA                        }dMjC                  ||rdNjC                  |      nd	|	rdNjC                  |	      nd	|
O      }tE        jF                  ||      }t!        |dFG      }t,        j0                  jI                  |      r&|r"|jK                  ||jM                        |      sd}|dk(  r:	 |jO                  | jP                  |||      }|d}n| j                  dP|z   :       | j9                  | j                  |Q      }| jS                  ||      }|r| jU                  ||||||	|
||R	       y | jU                  |||S       y # t        $ r }| j                  d@|z  :       Y d }~d }~ww xY w# t&        $ r*}| j                  |j(                  dK   :       Y d }~d }~ww xY w# t&        $ r)}| j                  |j(                  dK   :       Y d }~d }~ww xY w)UNr4   T)requiredr5   r6   )defaultr7   r8   rg   r9   r2   repository_urlzhttps://repo1.maven.org/maven2r   aws_secret_key)r   aliasesr   r   )r   no_logr   rs   dict)typeforce_basic_authFbool)r   r   statepresentabsent)r   choicesr   r   intdestr   )r   r   validate_certs)r   r   r   client_cert
client_key	keep_nameverify_checksumr   )neverr   changealways)r   r   r  r   r   r   r   listr   )r   elementsr   directory_mode)r6   r7   )argument_specadd_file_common_argsmutually_exclusivez2.12zsUnredirected Headers parameter provided, but your ansible-core version does not support it. Minimum version is 2.12)r   AuthorizationCookielxml)r   	exceptionsemantic_versionzurl parsing went wrong %sr   r   r   z when using s3:// repository URLs)reasonr   r   )r   r  )r  r  r   r   modez3{artifact_id}{version_part}{classifier}.{extension}z-{0})r5   version_partr8   r9   z-Cannot retrieve the artifact to destination: )r   )	r  r  r4   r5   r6   r8   r9   r   r,   )r  r  r,   rm   )+r   r   r   ru   r   	fail_jsonHAS_LXML_ETREEr   LXML_ETREE_IMP_ERRHAS_SEMANTIC_VERSIONSEMANTIC_VERSION_IMP_ERRr   AttributeErrorr   HAS_BOTOBOTO_IMP_ERRr   ro   r0   r3   argsr>   r   sepr   r   r   makedirsload_file_common_argumentsr)   rR   r   r   rt   rD   r'   lexistsr   r   r   r   r(   	exit_json) r*   r   r   r   rr   r4   r5   r6   r7   r8   r9   rs   r  r  b_destr
  r  r   verify_changer   
downloaderr   r,   
prev_stater!   r"   r+   r  r  rN   download_error	file_argss                                    r#   mainr1  m  s    
4(
d+
 &
 !.	

 B'
 5)
  (HI
 $1A0BC
 $t>U=VW
 f%
 "%f=
 y9h2GH
 %0
 6D1
  6J
  &59!
" %8#
$ E5vF%
& !%Mvw'
( ueeV_U)
* "&6EE!R+
,  U+-
0 ";<5F: O$|F';;Nd@e  S  	TO$V(<<OeAfAn1@(0K,-1&9EWX}}&'0D12DEQij]]#34N9>n-
 'ED 1'Bde#/ 	 	1 }}Z(H--.KmmI&Gmm$56O|,Jk*ImmI&GMM'"E== Dd#89Fk*Imm$56O%)??O#';;M==0L HJ7(Hk7OZYbc GJ}}RVV$'<=ww~~f%5KD5Q21KK#>>v}}MN#]]+;<N))7v&)-v&<=MOaciky  |C  DG	ww}}Vh%CCHML%::8DLHOO#8A|4r4>v}}Z0B	 P 
 ~~dH-$'<=	wwvz?]?]^bdn  eE  eE  FN  eO  Q]  @^
X	,'00/[acopN%  %TWe%e f 11&--d1KI33IwGGu4(P[el  zD#,^U\ 	 	^ 	u4Ao  >81<==>@  (QVVAY''(\  	,++	,sH   6V; %W' !9X ;	W$WW$'	X0XX	Y&Y

Y__main__)6
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESr   r   rD   r   r   r   	tracebackrF   Bansible_collections.community.general.plugins.module_utils.versionr   $ansible.module_utils.ansible_releaser   ru   r   r  r  r	   r  ImportError
format_excr$  r   r#  r!  r  r
   r   r   ansible.module_utils.basicr   r   +ansible.module_utils.six.moves.urllib.parser   ansible.module_utils.urlsr   +ansible.module_utils.common.text.convertersr   r   r   r   r)   objectr0   ro   r1  ri   rm   r$   r#   <module>rA     sL   A @`D=~  	   	   	 [ O  N
 H
   !. K @ / T T0" Dv DNg  g TGBT zF o  ---/N  '9'')LH  !3y335 !s6   B. C 
C* .C	C	C'&C'*DD