
                         8   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  ej                  ej                  j                   ej                  j"                  ej                  j$                         G d
 dej&                               Zy)z(Updates a AlloyDB user's superuser role.    )absolute_import)division)unicode_literals)api_util)base)flags)user_helper)
propertiesc                   0    e Zd ZdZdddZed        Zd Zy)UpdatezJUpdate an AlloyDB user's superuser role within a given cluster and region.z{description}z      To update a user's superuser role, run:

        $ {command} my-username --cluster=my-cluster --region=us-central1 --superuser=true/false
      )DESCRIPTIONEXAMPLESc                     t        j                  |       t        j                  |       t        j                  |d       t        j                  |       y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    FN)r   AddUsername	AddRegion
AddClusterAddSetSuperuser)clsparsers     *lib/surface/alloydb/users/set_superuser.pyArgszUpdate.Args+   s<     
f	OOF	VU#	&!    c                    t        j                  | j                               }|j                  }|j                  }|j
                  j                  dt        j                  j                  j                  j                  |j                  |j                  |j                        }|j                  |j!                               }|j"                  j%                  |      }d|j&                  v }||j(                  k(  r|S |j&                  |_        t-        j.                  |||      }	|j"                  j1                  |	      S )zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
        arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made.
    z)alloydb.projects.locations.clusters.users)
projectsIdlocationsId
clustersIdusersId)namealloydbsuperuser)r   AlloyDBClientReleaseTrackalloydb_clientalloydb_messagesresource_parserCreater
   VALUEScoreproject	GetOrFailregionclusterusername/AlloydbProjectsLocationsClustersUsersGetRequestRelativeName!projects_locations_clusters_usersGetdatabaseRoles	superuserdb_rolesr	   ConstructPatchRequestFromArgsPatch)
selfargsclientr"   r#   user_refrequseris_superuseruser_reqs
             r   Runz
Update.Run7   s    ##D$5$5$78F**N..%%,,3$$))11;;KK<< - H 
J
J""$ K C ;;??DD%););;Lt~~%k ((dm::
Hdh ==CCHMMr   N)__name__
__module____qualname____doc__detailed_helpclassmethodr   r>    r   r   r   r      s3     S %
- 	" 	""Nr   r   N)rB   
__future__r   r   r   googlecloudsdk.api_lib.alloydbr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.alloydbr   r	   googlecloudsdk.corer
   ReleaseTracksr!   ALPHABETAGAUpdateCommandr   rE   r   r   <module>rP      s~    / &  ' 3 ( 4 : * T..33T5F5F5I5I:NT :N:Nr   