
    "                        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 Z ej0                  ej2                  j4                         G d dej6                               Z ej0                  ej2                  j:                         G d de             Zy)z,Command to create a Dataplex asset resource.    )absolute_import)division)unicode_literals)asset)util)
exceptions)base)flags)resource_args)	arg_utils)labels_util)logc                 8   t        j                  | d       | j                  dddd       | j                  dd	       | j                  d
d	       t        j                  |        t
        j                  j                  |        t        j                  |        y)zCreate a common args.z
to create.z--validate-only
store_trueFz:Validate the create action, but don't actually perform it.)actiondefaulthelpz--descriptionzDescription of the assetr   z--display-namezDisplay name of the assetN)
r   AddAssetResourceArgadd_argumentr
   AddDiscoveryArgsr	   
ASYNC_FLAGAddToParserr   AddCreateLabelsFlags)parsers    %lib/surface/dataplex/assets/create.py_CommonArgsr       s    ##FL9G	   	o,FG&-HI //f%""6*    c                   ^    e Zd ZdZddiZed        Zd Z ej                  d      d        Z
y)	Create  Create a Dataplex asset resource.

  An asset represents a cloud resource that is being managed within a lake as a
  member of a zone.

  This asset ID will be used to generate names such as table names when
  publishing metadata to Hive Metastore and BigQuery.
   * Must contain only lowercase letters, numbers, and hyphens.
   * Must start with a letter.
   * Must end with a number or a letter.
   * Must be between 1-63 characters.
   * Must be unique within the zone.
  EXAMPLES            To create a Dataplex asset with name `test-asset`, within zone
          `test-zone`, in lake `test-lake`, in location `us-central1`, with
          resource type `STORAGE_BUCKET`, with resource name
          `projects/test-project/buckets/test-bucket`, run:

            $ {command} test-asset --location=us-central --lake=test-lake --zone=test-zone --resource-type=STORAGE_BUCKET --resource-name=projects/test-project/buckets/test-bucket

          To create a Dataplex asset with name `test-asset`, within zone
          `test-zone`, in lake `test-lake`, in location `us-central1`, with
          resource type `STORAGE_BUCKET`, with resource name
          `projects/test-project/buckets/test-bucket`, with discovery-enabled,
          and discovery schedule `0 * * * *`, run:

            $ {command} test-asset --location=us-central --lake=test-lake --zone=test-zone --resource-type=STORAGE_BUCKET --resource-name=projects/test-project/buckets/test-bucket --discovery-enabled --discovery-schedule="0 * * * *"
          c                    t        |        | j                  dd      }|j                  dd       |j                  dddd	d
t        j                  d       |j                  dddddt        j                  d       y NTz?Specification of the resource that is referenced by this asset.)requiredr   z--resource-namez"Relative name of the cloud resource that contains the data that
                 is being managed within a lake. For example:
                 `projects/{project_number}/buckets/{bucket_id}` or  `projects/{project_number}/datasets/{dataset_id}`r   z--resource-typezCloud Storage BucketzBigQuery Dataset)STORAGE_BUCKETBIGQUERY_DATASETType)r&   choicestyper   z--resource-read-access-modeFz,Data is accessed directly using storage APIszAData is accessed through a managed interface using BigQuery APIs.)DIRECTMANAGEDzRead access moder   	add_groupr   r   ChoiceToEnumNamer   resource_specs     r   ArgszCreate.ArgsT       $$N % M z   4 2
 ''  	 %D
 ''  r   c                 ,    t        j                  |      S N)r   GenerateAssetForCreateRequestselfargss     r   GenerateRequestzCreate.GenerateRequesty   s    ..t44r   z-Status code: {status_code}. {status_message}.c           
      4   |j                   j                  j                         }t        j                         }|j
                  j                  t        j                         j                  |j                         |j                         j                         |j                  | j                  |                  }t        |dd      }|r t        j                   j#                  d       y t        |dd      }|sft        j$                  |       t        j&                  |j                         dj)                  |j                         j                                      y t        j                   j#                  dj)                  ||j*                               y )	N)assetIdparentvalidateOnlygoogleCloudDataplexV1Assetvalidate_onlyFzValidation complete.async_zAsset created in [{0}])detailsz$Creating [{0}] with operation [{1}].)CONCEPTSr   Parsedataplex_utilGetClientInstance%projects_locations_lakes_zones_assetsr    GetMessageModule6DataplexProjectsLocationsLakesZonesAssetsCreateRequestNameParentRelativeNamerA   r;   getattrr   statusPrintWaitForOperationCreatedResourceformatname)r9   r:   	asset_refdataplex_clientcreate_req_oprA   rB   s          r   Runz
Create.Run|   sB    ##))+I#557O#IIPP&&(__NN$##%224++'+';';D'A	 	` 	
M D/59M	jj-.T8U+F]+	
..
*6)""$11346 JJ;BB=%%' (r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr3   r;   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrX    r   r   r    r    0   sW     -( " "H5 54457(7(r   r    c                   .    e Zd ZdZddiZd Zed        Zy)CreateAlphar!   r"   r#   c                 ,    t        j                  |      S r6   )r   "GenerateAssetForCreateRequestAlphar8   s     r   r;   zCreateAlpha.GenerateRequest   s    33D99r   c                    t        |        | j                  dd      }|j                  dd       |j                  dddd	d
t        j                  d       |j                  dddddt        j                  d       y r%   r.   r1   s     r   r3   zCreateAlpha.Args   r4   r   N)rY   rZ   r[   r\   r]   r;   r^   r3   ra   r   r   rc   rc      s1      -&: " "r   rc   N)r\   
__future__r   r   r   googlecloudsdk.api_lib.dataplexr   r   rF   googlecloudsdk.api_lib.utilr   r_   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataplexr
   r   $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   ReleaseTracksReleaseTrackGACommandr    ALPHArc   ra   r   r   <module>rt      s    3 &  ' 1 A F ( 5 = : < #+  D%%(()g(T\\ g( *g(T D%%++,H& H -Hr   