
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ  e	j*                  e	j,                  j.                  e	j,                  j0                  e	j,                  j2                        e	j4                   G d de	j6                                      Zd Zd Zy)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                   N   e Zd ZdZddej
                  j                  j                  j                          dej
                  j                  j                  j                          dej
                  j                  j                  j                          dddZ	e
d        Zd	 Zy
)Createz)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                    t        j                         j                  |        t         j                  j                  |        t         j                  j                  |        t         j
                  j                  |        t         j                  j                  |        t        j                  j                  |        t        j                  j                  |        | j                  ddd       | j                  ddd       y )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ArgszCreate.ArgsK   s     
((0	''/	  ,,V4	  (	""..v6**62''/
           c                    t        j                  ||j                        }|dk(  rt        |      }nt	        |      }t        j                  |      }|j                  j                  |      }t        j                  j                  d       |S )Nv1zCreated.)scc_utilGetVersionFromArgumentsfinding+_V1GenerateRequestArgumentsForCreateCommand+_V2GenerateRequestArgumentsForCreateCommandr   	GetClientorganizations_sources_findingsr   r   statusPrint)selfargsversionrequestclientresponses         r    Runz
Create.Rune   sp    ..tT\\BG$;DAg;DAg",,W5F44;;GDHJJZ Or"   N)__name__
__module____qualname____doc__r   VALUEScoreuniverse_domainGetdetailed_helpstaticmethodr!   r4    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                 F   t        j                  d      }|j                         }|j                  | j                  | j
                  t        j                  | j                  d            |_	        | j                  |j                  _        | j                  d      r/t        j                  | j                  d      |j                  _        t!        j"                  | j$                        }t!        j&                  |      |j                  _        t        j*                  |        t        j,                  | d      }t        j.                  |d      |_        t        j2                  |      |_        |j                  s|j                         |_	        ||j                  _        |S )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"GoogleCloudSecuritycenterV2FindingrC   resource_namer
   ConvertStateInputrE   "googleCloudSecuritycenterV2Findingexternal_uriexternalUriIsKnownAndSpecifiedConvertSourcePropertiesrF   sourcePropertiesr   ParseDateTime
event_timeFormatDateTime	eventTime.ValidateMutexOnFindingAndSourceAndOrganizationGetFullFindingNameGetSourceParentFromFindingNameparentGetFindingIdFromName	findingIdnamer/   messagesr1   event_time_dtfinding_names        r    r)   r)   q   sY    #..t4(LLN'11==))&&tzz48 2  
, <@;L;L',,8	1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                 F   t        j                  d      }|j                         }|j                  | j                  | j
                  t        j                  | j                  d            |_	        | j                  |j                  _        | j                  d      r/t        j                  | j                  d      |j                  _        t!        j"                  | j$                        }t!        j&                  |      |j                  _        t        j*                  |        t        j,                  | d      }t        j.                  |d      |_        t        j2                  |      |_        |j                  s|j                         |_	        ||j                  _        |S )zGenerate the request's finding name, finding ID, parent and v1 Finding using specified arguments.

  Args:
    args: (argparse namespace)

  Returns:
    req: Modified request
  r$   rB   rF   )r   rG   rH   FindingrC   rJ   r
   rK   rE   r'   rM   rN   rO   rP   rF   rQ   r   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   s        r    r(   r(      s>    #..t4(LLN'$$}}%%""4::t4 % '/
 !% 1 1'//	12'+'C'C(GOO$
 %%doo6-#22=A'//55d;((t4,66|TJ'.//='	&&(GO%'//	.r"   N)r8   
__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(   r?   r"   r    <module>rq      s    D &  % ' < ( = ; 9 8 # * * $++00$2C2C2I2I IT I IX(V"r"   