
                             S 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  \	R                    " S S\	R"                  5      5       rg)z7Implementation of create command for inventory reports.    )absolute_import)division)unicode_literalsN)insights_api)base)errors)flags)storage_url)logc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Create   z%Create a new inventory report config.a  
       Create an inventory report config that defines how often
       inventory reports are generated, the metadata fields you want the reports
       to include, and a bucket/prefix in which to store the reports, also known
       as the destination.
      z
       To create an inventory report about "my-bucket" that will store report
       details in "report-bucket" with the prefix "save-path/".

         $ {command} gs://my-bucket --destination=gs://report-bucket/save-path/
      )DESCRIPTIONEXAMPLESc                 X    U R                  S[        SS9  [        R                  " U SS9  g )Nsource_bucket_urlzNURL of the source bucket that will contain the inventory report configuration.)typehelpT)require_create_flags)add_argumentstrr	   add_inventory_reports_flags)parsers    8lib/surface/storage/insights/inventory_reports/create.pyArgsCreate.Args2   s2    
/  0
 
%%f4H    c                    [         R                  " [         R                  " UR                  5      5      n[	        U[         R
                  5      (       a  UR                  5       (       d/  [        R                  " SR                  UR                  5      5      eUR                  b5  [         R                  " [         R                  " UR                  5      5      nO*[         R
                  " UR                  UR                  SS9nUR                  b  UR                  nOZ[        R                  R                  [        R                   R"                  5      [        R$                  " SS9-   R'                  5       nUR(                  b  UR(                  nOU[        R$                  " SS9-   n[*        R,                  " 5       R/                  UR                  U[1        UR2                  5      UUUR4                  UR6                  UR8                  UR:                  UR<                  UR>                  S9n[@        RB                  RE                  SR                  URF                  5      5        g )	NzcInvalid bucket URL: {}. Only bucket URLs are accepted for SOURCE_BUCKET_URL. Example: "gs://bucket"zinventory_reports/)schemebucket_nameresource_name   )daysim  )source_bucketdestination_urlmetadata_fields
start_dateend_date	frequencycsv_delimitercsv_separator
csv_headerparquetdisplay_namez Created report configuration: {})$r
   storage_url_from_stringadd_gcs_scheme_if_missingr   
isinstanceCloudUrl	is_bucketr   InvalidUrlErrorformatdestinationr   r    schedule_startsdatetimenowtimezoneutc	timedeltadateschedule_repeats_untilr   InsightsApicreate_inventory_reportlistr&   schedule_repeatsr*   r+   r,   r-   r.   r   statusPrintname)selfargsr$   r6   r'   r(   report_configs          r   Run
Create.Run;   s   77--d.D.DEGM}k&:&:;;##%%"";;A6$$<&' '
 #77

/
/0@0@
ACk  ((%%#//,.k
 '''j%%))(*;*;*?*?@&&A./04  "".,,hh00c::h ,,.FF#//#T112''((((??&& G M JJ*11-2D2DEGr    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rI   __static_attributes__rK   r   r   r   r      s2    -

- I I,Gr   r   )rP   
__future__r   r   r   r8   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   r	   r
   googlecloudsdk.corer   DefaultUniverseOnlyCommandr   rK   r   r   <module>r[      sS    > &  '  7 ( 5 4 : # GGT\\ GG GGr   