
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SS	K	Jr  SS
K	Jr  SSK	Jr  SSK	Jr  SSK	Jr  SSKJr  SSKJr  SSKJr  SSKJr  \R.                  \R0                  " \R2                  R4                  \R2                  R6                  5      \R8                   " S S\R:                  5      5       5       5       rg)z@Command for remediating a Cloud Security Command Center Finding.    )absolute_import)division)print_function)unicode_literalsN)Any)findings)git)llm)prompt)pull_requests)	terraform)base)errors)flags)logc                   D    \ rS rSrSrSSS.r\S 5       rS\SS4S	 jr	S
r
g)Create%   z-Remediates a Security Command Center finding.a\  
          Sample usage:

          $ {{command}} scc iac-remediation create --finding-org-id=123456789
          --finding-name=projects/123456789/sources/123456789/locations/global/findings/123456789
          --tfstate-file-paths=/path/to/file1.tfstate,/path/to/file2.tfstate --project-id=my-proj
          --git-config-path=/path/to/config.yaml)DESCRIPTIONEXAMPLESc                 :   [         R                  R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [         R
                  R                  U 5        [         R                  R                  U 5        g )N)r   FINDING_ORG_ID_FLAGAddToParserFINDING_NAME_FLAGLLM_PROJ_ID_FLAGTFSTATE_FILE_PATHS_LIST_FLAGGIT_CONFIG_FILE_PATH_FLAG)parsers    )lib/surface/scc/iac_remediation/create.pyArgsCreate.Args6   sf    	))&1	''/	&&v.	&&226:	##//7    argsreturnNc           
         [         R                  " 5       u  p#U(       d  [        R                  " 5       e[         R                  " UR
                  5        UR
                  n[        R                  " U5        [        R                  " SU5        [        R                  " UR                  UR                  5      n[        R                  " U5      n[        R                  " U5      n[        R                  " U5      n[         R"                  " UR$                  U5      n	U	(       d  [        R                  " S5        g[         R&                  " XyU5      n
U
(       d  U	 H  nSU;   d  M  Sn
M     [         R(                  " U5      n[         R*                  " U5      nUR-                  5        GH5  u  pSnU
(       a	  X;   a  X   n[.        R0                  " UUUUU5      n[2        R4                  " UUR6                  5      n[.        R8                  " U5      n[         R:                  " U5      u  nnU(       d,  [         R<                  " U5        [        R>                  " U5      e[        R                  " U5        [         R@                  " U[B        RD                  " X^5      US   US   [        RF                  " UR                  5      -   5        [         R<                  " U5        GM8     [         RH                  " [B        RJ                  " U5      [B        RJ                  " U5      US   US   [        RF                  " UR                  5      -   US   5        [         R<                  " U5        g)	zXRemediates a Security Command Center finding.

Args:
  args: Arguments for the command.
zrepo_root_dir: zNo TFState files found.Ngoogle_project_iam_policy remotezbranch-prefixzmain-branch-name)&r	   is_git_repor   GitRepoNotFoundErrorvalidate_git_configgit_config_pathr   Printr   MakeApiCallfinding_org_idfinding_namejsonloadsFetchIAMBindingFetchResourceNamer   fetch_tfstate_listtfstate_file_paths"get_tfstate_information_per_memberfind_tf_filesread_original_files_contentitemsr   fetch_input_promptr
   MakeLLMCall
project_idllm_response_parservalidate_tf_filesupdate_tf_filesInvalidLLMResponseErrorpush_commitr   CreateCommitMessage	ParseNameraise_prCreatePRMessage)selfr#   git_flagrepo_root_dirgit_config_dataresp	json_respiam_bindingsresource_nametfstate_json_listtfstate_informationtfstate_jsontf_filesoriginal_files_contentmember	role_datatfstate_datainput_promptresponseresponse_dictchecks                        r   Run
Create.Run>   s    "oo/H''))D001**OIIoII/ 3 3T5F5FGD

4 I++I6L..y9M!44 	ii)*#FF +,&,6 ;
 , &&}5H&BB8L)//1l	!>*2..




l t?h00:m!33MBoeX!!"89,,X66		(--d;H%O,  !2!234		
 	!!-05 26 LL%%d+%%d+!(


T..
/	0*+ 45r"    )__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr    r   r[   __static_attributes__r]   r"   r   r   r   %   sC     6 E4	- 8 8C6c C6d C6r"   r   )rb   
__future__r   r   r   r   r1   typingr   *googlecloudsdk.api_lib.scc.iac_remediationr   r	   r
   r   r   r   googlecloudsdk.callioper   .googlecloudsdk.command_lib.scc.iac_remediationr   r   googlecloudsdk.corer   HiddenReleaseTracksReleaseTrackALPHAGAUniverseCompatibleCreateCommandr   r]   r"   r   <module>rs      s    G &  % '   ? : : = D @ ( A @ # D%%++T->->-A-ABY6T Y6  C Y6r"   