
                            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  ej"                  ej$                  j&                         G d dej(                               Z ej"                  ej$                  j,                  ej$                  j.                         G d dej(                               Zy)z Command to update a new project.    )absolute_import)division)unicode_literals)projects_api)base)flags)util)labels_util)logc                   &    e Zd ZdZed        Zd Zy)UpdateAlphaa  Update the name and/or labels of a project.

  Update the name and/or labels of the given project.

  This command can fail for the following reasons:
  * There is no project with the given ID.
  * The active account does not have Owner or Editor permissions for the
    given project.

  ## EXAMPLES

  The following command updates a project with the ID
  `example-foo-bar-1` to have the name `Foo Bar & Grill` and removes the
  label `dive`:

    $ {command} example-foo-bar-1 --name="Foo Bar & Grill" --remove-labels=dive

  The following command updates a project with the ID `example-foo-bar-1` to
  have labels `foo` and `bar` with values of `abc` and `def`, respectively:

    $ {command} example-foo-bar-1 --update-labels="foo=abc,bar=def"
  c                 4   t        j                  d      j                  |        | j                  d      }|j	                  dd       |j                  d      }t        j                  |       | j                  j                  t        j                         y )NupdateT)required--nameNew name for the project.)helpzLabels Flags)r   GetProjectIDNumberFlagAddToParser	add_groupadd_argumentr
   AddUpdateLabelsFlagsdisplay_info	AddFormatcommand_lib_utilLIST_FORMAT)parserupdate_flagslabels_groups      lib/surface/projects/update.pyArgszUpdateAlpha.Args7   s{    	  *66v>##T#2Lh-HI)).9L$$\2
!!"2">">?    c                     t         j                  j                  |      }t        j                  |j
                        }t        j                  ||j                  |      }t        j                  |       |S N)namelabels_diff)r
   DiffFromUpdateArgsr   ParseProjectidr   Updater%   r   UpdatedResource)selfargsr&   project_refresults        r    RunzUpdateAlpha.RunA   sZ    ""11$7K"//8K  499-8:F$Mr"   N)__name__
__module____qualname____doc__staticmethodr!   r1    r"   r    r   r      s"    . @ @r"   r   c                   ,    e Zd ZdZd Zed        Zd Zy)r+   a  Update the name of a project.

  Update the name of the given project.

  This command can fail for the following reasons:
  * There is no project with the given ID.
  * The active account does not have Owner or Editor permissions for the
    given project.

  ## EXAMPLES

  The following command updates a project with the ID
  `example-foo-bar-1` to have the name `Foo Bar & Grill`:

    $ {command} example-foo-bar-1 --name="Foo Bar & Grill"
  c                 "    t         j                  S )N)r   ProjectsUriFunc)r-   s    r    
GetUriFunczUpdate.GetUriFunc]   s    +++r"   c                 t    t        j                  d      j                  |        | j                  ddd       y )Nr   r   Tr   )r   r   )r   GetProjectFlagr   r   )r   s    r    r!   zUpdate.Args`   s5    	"..v6
48  :r"   c                     t        j                  |j                        }t        j                  ||j
                  t        j                               }t        j                  |       |S r$   )
r   r)   r*   r   r+   r%   r
   r'   r   r,   )r-   r.   r/   r0   s       r    r1   z
Update.Runf   sN    "//8K  499-8-=-=-?AF$Mr"   N)r2   r3   r4   r5   r;   r6   r!   r1   r7   r"   r    r+   r+   J   s%    ", : :
r"   r+   N)r5   
__future__r   r   r   +googlecloudsdk.api_lib.cloudresourcemanagerr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.projectsr   r	   r   $googlecloudsdk.command_lib.util.argsr
   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHAUpdateCommandr   BETAGAr+   r7   r"   r    <module>rK      s     ' &  ' D ( 5 H < # D%%++,($$$ ( -(V D%%**D,=,=,@,@A T   B r"   