
    3!                        d Z ddlmZ ddlmZ ddlmZ ddl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$                  ej&                  j(                         G d dej*                                      Z ej$                  ej&                  j.                         G d de             Z ej$                  ej&                  j2                         G d de             Zy)z%bigtable app profiles create command.    )absolute_import)division)unicode_literalsN)	HttpError)app_profiles)util)base)	arguments)logc                   T    e Zd ZdZd ej
                  d      iZed        Zd Z	d Z
y)CreateAppProfile"Create a new Bigtable app profile.EXAMPLESa            To create an app profile with a multi-cluster routing policy, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any

          To create an app profile with a single-cluster routing policy which
          routes all requests to `my-cluster-id`, run:

            $ {command} my-single-cluster-app-profile --instance=my-instance-id --route-to=my-cluster-id

          To create an app profile with a friendly description, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --description="Routes requests for my use case"

          To create an app profile with a request priority of PRIORITY_MEDIUM,
          run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --priority=PRIORITY_MEDIUM

          To create an app profile with row-affinity routing enabled, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity

          To create an app profile with Data Boost enabled which bills usage to the host project, run:

            $ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS

          c                     t        j                  | d       t        j                  |       j                  dd      j	                         j                         j                  d       y Nz	to createapp profileF)requiredcreater
   AddAppProfileResourceArgArgAdderAddDescriptionAddAppProfileRoutingAddIsolationAddForceparsers    +lib/surface/bigtable/app_profiles/create.pyArgszCreateAppProfile.ArgsC   H    &&v{;6"		6					(	    c                 
   t        j                  ||j                  |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                        S a  Creates an AppProfile with the given arguments.

    Args:
      app_profile_ref: A resource reference of the new app profile.
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Raises:
      ConflictingArgumentsException,
      OneOfArgumentsRequiredException:
        See app_profiles.Create(...)

    Returns:
      Created app profile resource object.
    )
clusterdescriptionmulti_clusterrestrict_totransactional_writesrow_affinitypriority
data_boost data_boost_compute_billing_ownerforcer   Createroute_tor%   	route_anyr'   r(   r)   r*   r+   r,   r-   selfapp_profile_refargss      r   _CreateAppProfilez"CreateAppProfile._CreateAppProfileN   j      $$nn$$!66&&??)-)N)Njj r!   c                    |j                   j                  j                         }	 | j                  ||      }t	        j
                  |j                         d       |S # t        $ r}t        j                  |       Y d}~yd}~ww xY w)aW  This 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.

    Raises:
      ConflictingArgumentsException,
      OneOfArgumentsRequiredException:
        See _CreateAppProfile(...)

    Returns:
      Created resource.
    r   )kindN)
CONCEPTSapp_profileParser6   r   CreatedResourceNamer   r   FormatErrorMessages)r3   r5   r4   resultes        r   RunzCreateAppProfile.Runl   sv     mm//557O%%ot<f 
/..0}Em	  "
q!!"s   A 	B(BBN)__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r6   rB    r!   r   r   r      sC     + /(// # ->  <r!   r   c                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)CreateAppProfileBetar   r   a            To create an app profile with a multi-cluster routing policy, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any

          To create an app profile with a single-cluster routing policy which
          routes all requests to `my-cluster-id`, run:

            $ {command} my-single-cluster-app-profile --instance=my-instance-id --route-to=my-cluster-id

          To create an app profile with a friendly description, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --description="Routes requests for my use case"

          To create an app profile with a request priority of PRIORITY_MEDIUM,
          run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --priority=PRIORITY_MEDIUM

          To create an app profile with Data Boost enabled which bills usage to the host project, run:

            $ {command} my-app-profile-id --instance=my-instance-id --data-boost --data-boost-compute-billing-owner=HOST_PAYS

          To create an app profile with row-affinity routing enabled, run:

            $ {command} my-app-profile-id --instance=my-instance-id --route-any --row-affinity

          c                     t        j                  | d       t        j                  |       j                  dd      j	                         j                         j                  d       y r   r   r   s    r   r   zCreateAppProfileBeta.Args   r    r!   c                 
   t        j                  ||j                  |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                        S r#   r.   r2   s      r   r6   z&CreateAppProfileBeta._CreateAppProfile   r7   r!   N)
rC   rD   rE   rF   rG   rH   rI   rJ   r   r6   rK   r!   r   rM   rM      s<    * /(// # ->  r!   rM   c                   &    e Zd ZdZed        Zd Zy)CreateAppProfileAlphar   c                     t        j                  | d       t        j                  |       j                  dd      j	                         j                         j                  d       y r   r   r   s    r   r   zCreateAppProfileAlpha.Args   r    r!   c                 
   t        j                  ||j                  |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                        S r#   r.   r2   s      r   r6   z'CreateAppProfileAlpha._CreateAppProfile   r7   r!   N)rC   rD   rE   rF   rJ   r   r6   rK   r!   r   rQ   rQ      s    * r!   rQ   )rF   
__future__r   r   r   rG   apitools.base.py.exceptionsr   googlecloudsdk.api_lib.bigtabler   r   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.bigtabler
   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackGACreateCommandr   BETArM   ALPHArQ   rK   r!   r   <module>ra      s    , &  '  1 8 0 ( 9 # D%%(()at)) a * aH D%%**+I+ I ,IX D%%++,*0 * -*r!   