
                         V   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  \	R                  \	R                  " \	R                   R"                  \	R                   R$                  \	R                   R&                  5       " S
 S\	R(                  5      5       5       rg)z!'logging buckets create' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)log)
console_ioc                   4    \ rS rSrSr\S 5       rS rS rSr	g)Create   an  Create a bucket.

After creating a bucket, use a log sink to route logs into the bucket.

## EXAMPLES

To create a bucket 'my-bucket' in location 'global', run:

  $ {command} my-bucket --location=global --description="my custom bucket"

To create a bucket with extended retention, run:

  $ {command} my-bucket --location=global --retention-days=365

To create a bucket in cloud region 'us-central1', run:

  $ {command} my-bucket --location=us-central1

To create a bucket with custom index of 'jsonPayload.foo', run:

  $ {command} my-bucket
    --index=fieldPath=jsonPayload.foo,type=INDEX_TYPE_STRING

To create a bucket with custom CMEK, run:

  $ {command} my-bucket --location=us-central1
    --cmek-kms-key-name=CMEK_KMS_KEY_NAME

To asynchronously create a bucket enrolled into Log Analytics, run:

  $ {command} my-bucket --location=global --async --enable-analytics
c           
      x   U R                  SSS9  U R                  SSS9  U R                  SS[        R                  " 5       SS	9  U R                  S
[        [        R                  " SSS9S9  U R                  SS[        R
                  " [        [        R                  S.SS/S9SSS9  U R                  SSS9  U R                  SSS[        R                  " SSS9S9  [        R                  R                  U 5        [        R                  " U SS 5        [        R                  " 5       R                  U 5        g)!z Register flags for this command.	BUCKET_IDzID of the bucket to create.)helpz--descriptionz%A textual description for the bucket.z--restricted-fieldszComma-separated list of field paths that require permission checks in this bucket. The following fields and their children are eligible: textPayload, jsonPayload, protoPayload, httpRequest, labels, sourceLocation.RESTRICTED_FIELD)r   typemetavarz--retention-daysziThe period logs will be retained, after which logs will automatically be deleted. The default is 30 days.zThis is not available.
)defaultuniverse_help)r   r   z--indexappend)	fieldPathr   r   r   )specrequired_keyszKEY=VALUE, ...a?  Specify an index to be added to the log bucket. This flag can be repeated. The ``fieldPath'' and ``type'' attributes are required. For example:  --index=fieldPath=jsonPayload.foo,type=INDEX_TYPE_STRING. The following keys are accepted:

*fieldPath*::: The LogEntry field path to index. For example: jsonPayload.request.status. Paths are limited to 800 characters and can include only letters, digits, underscores, hyphens, and periods.

*type*::: The type of data in this index. For example: INDEX_TYPE_STRING Supported types are INDEX_TYPE_STRING and INDEX_TYPE_INTEGER. 

 )actionr   r   r   z--cmek-kms-key-namez7A valid `kms_key_name` will enable CMEK for the bucket.z--enable-analytics
store_trueNzmWhether to opt the bucket into Log Analytics. Once opted in, the bucket cannot be opted out of Log Analytics.)r   r   r   TzcLocation in which to create the bucket. Once the bucket is created, the location cannot be changed.)add_argumentr   ArgListintUniverseHelpTextArgDictstrr   IndexTypeToEnumr   
ASYNC_FLAGAddToParserAddBucketLocationArg
GetTagsArg)parsers    %lib/surface/logging/buckets/create.pyArgsCreate.ArgsB   sv    *GH
E  G
   ""   ))E 5
  
    ,, '/1 !(  *0 F  H ))D 5
	   	OO'	*+ 	OO!!&)    c                 h   0 nUR                  S5      (       a  UR                  US'   UR                  S5      (       a  UR                  US'   UR                  S5      (       a  UR                  US'   UR                  S5      (       a  UR                  US'   UR                  S5      (       a  UR
                  US	'   UR                  S
5      (       aB  [        R                  " U[        R                  " 5       R                  R                  5      nX2S
'   UR                  S5      (       aE  [        R                  " SSS9  [        R                  " 5       R                  UR                  S9nXBS'   UR                  (       a  [        R                   " 5       R"                  R%                  [        R                  " 5       R'                  UR(                  [        R*                  " [        R,                  " UR.                  5      R1                  5       SUR2                  5      [        R                  " 5       R                  " S0 UD6S95      n[4        R6                  " UR8                  SSS9  U$ [        R                   " 5       R"                  R;                  [        R                  " 5       R=                  UR(                  [        R*                  " [        R,                  " UR.                  5      R1                  5       SUR2                  5      [        R                  " 5       R                  " S0 UD6S95      $ )Nretention_daysretentionDaysdescriptionrestricted_fieldsrestrictedFieldsindexindexConfigsenable_analyticsanalyticsEnabledtagscmek_kms_key_namez1CMEK cannot be disabled on a bucket once enabled.T)cancel_on_no)
kmsKeyNamecmekSettings	locations)bucketIdparent	logBucketbucket)is_async )IsSpecifiedr-   r/   r0   r2   r4   r   GetTagsFromArgsGetMessages	LogBucket	TagsValuer
   PromptContinueCmekSettingsr7   async_	GetClientprojects_locations_bucketsCreateAsync1LoggingProjectsLocationsBucketsCreateAsyncRequestr   CreateResourceNameGetProjectResourceprojectRelativeNamelocationr	   CreatedResourcenamer   ,LoggingProjectsLocationsBucketsCreateRequest)selfargsbucket_datar6   cmek_settingsresults         r(   _RunCreate._Run   s   K())%)%8%8k/"&&#'#3#3k- +,,(,(>(>k$%  $(JJk.!*++(,(=(=k$%!!$(8(8(:(D(D(N(NOd &+,,
= &&(55++ 6 -m$1.!{{~~::FF




N
N~~,,))$,,7DDF--
 ((*44C{C O 
f 
&++x$?m^^88??




I
I~~,,))$,,7DDF--
 ((*44C{C J 
 
r+   c                 $    U R                  U5      $ )zThis is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  The created bucket.
)r[   )rV   rW   s     r(   Run
Create.Run   s     99T?r+   rA   N)
__name__
__module____qualname____firstlineno____doc__staticmethodr)   r[   r^   __static_attributes__rA   r+   r(   r   r      s*    
B E* E*N3j
r+   r   N)rd   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   googlecloudsdk.core.consoler
   UniverseCompatibleReleaseTracksReleaseTrackALPHABETAGACreateCommandr   rA   r+   r(   <module>rs      s    ( &  ' / / ( # 2 T..33T5F5F5I5IiT i ir+   