
                            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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*                  " \	R,                  R.                  \	R,                  R0                  \	R,                  R2                  5      \	R4                   " S S\	R6                  5      5       5       rS rS rg)z=Command for creating a Cloud Security Command Center Finding.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)util)log)
properties)timesc                   V   \ rS rSrSrSS\R                  R                  R                  R                  5        S\R                  R                  R                  R                  5        S\R                  R                  R                  R                  5        S3SS.r
\S	 5       rS
 rSrg)Create!   z)Create a Security Command Center finding.a  
          Create an ACTIVE finding `testFinding` with category: XSS_SCRIPTING
          attached to project with project number `9876` under organization `123456` and source
          `5678`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --state=ACTIVE --category='XSS_SCRIPTING'
            --event-time=2023-01-11T07:00:06.861Z
            --resource-name='//cloudresourcemanager.a  /projects/9876'

          Create an ACTIVE finding `testFinding` with category: XSS_SCRIPTING
          attached to project with project number `9876` under organization `123456` and source
          `5678` using the full resource name:

          $ {command} organizations/123456/sources/5678/findings/testFinding
            --state=ACTIVE --category='XSS_SCRIPTING'
            --event-time=2023-01-11T07:00:06.861Z
            --resource-name='//cloudresourcemanager.a  /projects/9876'

          Create an ACTIVE finding `testFinding` with category: `XSS_SCRIPTING`
          attached to project with project number`9876` under organization `123456`, source
          `5678` and `location=eu`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --state=ACTIVE --category='XSS_SCRIPTING'
            --event-time=2023-01-11T07:00:06.861Z
            --resource-name='//cloudresourcemanager.z/projects/9876' --location=euz
      This command uses the Security Command Center API. For more information,
      see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest))DESCRIPTIONEXAMPLESzAPI REFERENCEc                    [         R                  " 5       R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [         R
                  R                  U 5        [         R                  R                  U 5        [        R                  R                  U 5        [        R                  R                  U 5        U R                  SSSS9  U R                  SSSS9  g )Nz
--categoryz[
        Taxonomy group within findings from a given source. Example:
        XSS_SCRIPTINGT)helprequiredz--resource-namez^
        Full resource name of the Google Cloud Platform resource this finding is
        for.)r	   CreateFindingArgAddToParserEXTERNAL_URI_FLAGSOURCE_PROPERTIES_FLAG
STATE_FLAGEVENT_TIME_FLAG_REQUIRED	scc_flagsAPI_VERSION_FLAGLOCATION_FLAGadd_argument)parsers    "lib/surface/scc/findings/create.pyArgsCreate.ArgsK   s     
((0	''/	  ,,V4	  (	""..v6**62''/
           c                     [         R                  " XR                  5      nUS:X  a  [        U5      nO[	        U5      n[
        R                  " U5      nUR                  R                  U5      n[        R                  R                  S5        U$ )Nv1zCreated.)scc_utilGetVersionFromArgumentsfinding+_V1GenerateRequestArgumentsForCreateCommand+_V2GenerateRequestArgumentsForCreateCommandr   	GetClientorganizations_sources_findingsr   r   statusPrint)selfargsversionrequestclientresponses         r!   Run
Create.Rune   sn    ..t\\BG$;DAg;DAg",,W5F44;;GDHJJZ Or$    N)__name__
__module____qualname____firstlineno____doc__r   VALUEScoreuniverse_domainGetdetailed_helpstaticmethodr"   r6   __static_attributes__r8   r$   r!   r   r   !   s    
 2 A5 6@5F5F5K5K5[5[5_5_5a4b 	c5 6@5F5F5K5K5[5[5_5_5a4b 	c5 6@5F5F5K5K5[5[5_5_5a4bb5C8r=!-F  2	r$   r   c                 d   [         R                  " S5      nUR                  5       nUR                  U R                  U R
                  [        R                  " U R                  S5      S9Ul	        U R                  UR                  l        U R                  S5      (       a0  [        R                  " U R                  S5      UR                  l        [         R"                  " U R$                  5      n[         R&                  " U5      UR                  l        [        R*                  " U 5        [        R,                  " U S5      n[        R.                  " US5      Ul        [        R2                  " U5      Ul        UR                  (       d  UR                  5       Ul	        XBR                  l        U$ )zGenerate the request's finding name, finding ID, parent and v2 googleCloudSecuritycenterV2Finding using specified arguments.

Args:
  args: (argparse namespace)

Returns:
  req: Modified request
v2categoryresourceNamestatesource_properties)r   GetMessages7SecuritycenterOrganizationsSourcesFindingsCreateRequest"GoogleCloudSecuritycenterV2FindingrH   resource_namer
   ConvertStateInputrJ   "googleCloudSecuritycenterV2Findingexternal_uriexternalUriIsKnownAndSpecifiedConvertSourcePropertiesrK   sourcePropertiesr   ParseDateTime
event_timeFormatDateTime	eventTime.ValidateMutexOnFindingAndSourceAndOrganizationGetFullFindingNameGetSourceParentFromFindingNameparentGetFindingIdFromName	findingIdnamer1   messagesr3   event_time_dtfinding_names        r!   r+   r+   q   sZ    #..t4(LLN'11==))&&tzz48 2  
, <@;L;L',,8	122$$T%;%;TB ..?
 %%doo6-9>9M9M:',,6 55d;((t4,66|TJ'.//='		3	3335 . 5A,,1	.r$   c                 d   [         R                  " S5      nUR                  5       nUR                  U R                  U R
                  [        R                  " U R                  S5      S9Ul	        U R                  UR                  l        U R                  S5      (       a0  [        R                  " U R                  S5      UR                  l        [         R"                  " U R$                  5      n[         R&                  " U5      UR                  l        [        R*                  " U 5        [        R,                  " U S5      n[        R.                  " US5      Ul        [        R2                  " U5      Ul        UR                  (       d  UR                  5       Ul	        XBR                  l        U$ )zGenerate the request's finding name, finding ID, parent and v1 Finding using specified arguments.

Args:
  args: (argparse namespace)

Returns:
  req: Modified request
r&   rG   rK   )r   rL   rM   FindingrH   rO   r
   rP   rJ   r)   rR   rS   rT   rU   rK   rV   r   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   s        r!   r*   r*      s?    #..t4(LLN'$$}}%%""4::t4 % '/
 !% 1 1'//	122'+'C'C(GOO$
 %%doo6-#22=A'//55d;((t4,66|TJ'.//='	&&(GO%//	.r$   N)r=   
__future__r   r   r   r   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r   r
   r'   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.corer   r   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackGABETAALPHAUniverseCompatibleCreateCommandr   r+   r*   r8   r$   r!   <module>rv      s    D &  % ' < ( = ; 9 8 # * * $++00$2C2C2I2I IT I IX(V"r$   