
    
                         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  SS	KJr  SS
KJr   " S S\R$                  5      rg)z'Cloud Pub/Sub schemas rollback command.    )absolute_import)division)unicode_literals)
exceptions)schemas)base)resource_args)util)logc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	Rollback   z3Roll back a Pub/Sub schema to a specified revision.EXAMPLESz          To roll back to an existing schema revision called "key-schema" with revision_id: "0a0b0c0d", run:
                    
$ {command} key-schema --revision-id=0a0b0c0d
          c                 ^    [         R                  " U S5        U R                  S[        SSS9  g )Nzto rollback.z--revision-idzThe revision to roll back to.T)typehelprequired)r	   AddSchemaResourceArgadd_argumentstr)parsers    &lib/surface/pubsub/schemas/rollback.pyArgsRollback.Args*   s3     &&v~>
,	      c                    [         R                  " 5       n[        R                  " UR                  5      n[        USS5      n UR                  X4S9n[        R                  " UR                   SS9  U$ ! [        R                   a^  n[        R                  " U5      n[        R                  " US[        R                  " UR                  R                  5      S9   SnAgSnAff = f)a  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.

Returns:
  A serialized object (dict) describing the results of the operation.
  This description fits the Resource described in the ResourceRegistry under
  'pubsub.projects.schemas'.

Raises:
  util.RequestFailedError: if any of the requests to the API failed.
revision_idN)
schema_refr   zschema revision)kindfailed)r   )r   SchemasClientr
   ParseSchemaNameschemagetattrr   api_ex	HttpErrorr   HttpExceptionr   CreatedResourceCreateFailureErrorMessagepayloadstatus_messagename)selfargsclientr   r   resulterrorexcs           r   RunRollback.Run5   s     ""$F%%dkk2J$t4K	*Nf *;<M  $$U+c	
 //0J0JK
 s   A4 4C&AC!!C& N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r3   __static_attributes__r5   r   r   r   r      s/    ;  -  r   r   N)r:   
__future__r   r   r   apitools.base.pyr   r%   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   !googlecloudsdk.command_lib.pubsubr	   r
   googlecloudsdk.corer   Commandr   r5   r   r   <module>rF      s8    . &  ' 1 1 2 ( ; 2 #4t|| 4r   