
    !                        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ZdZeedZ e
j&                  e
j(                  j*                         G d de
j,                               Zy)GAcquires a SQL Server Reporting Services lease on a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
operations)validate)base)flags)log)
propertieszO    Acquire a SQL Server Reporting Services lease on a Cloud SQL instance.
    z    To acquire a SQL Server Reporting Services lease on an instance:

    $ {command} instance-foo --setup-login=setuplogin --service-login=reportuser --report-database=ReportServer --duration=4h
    )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)AcquireSsrsLeaser   c                 r    | j                  dt        j                  d       t        j                  |        y)a  Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go on
        the command line after this command. Positional arguments are allowed.

    Returns:
      A dict object representing the operations resource describing the acquire
      SSRS lease operation if the operation was successful.
    instancezCloud SQL instance ID.)	completerhelpN)add_argumentr   InstanceCompleterAddSqlServerSsrs)parsers    /lib/surface/sql/instances/acquire_ssrs_lease.pyArgszAcquireSsrsLease.Args3   s6     ))%   
6"    c                    t        j                  t         j                        }|j                  }|j                  }t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }|j                  }|t!        |j                        dz   }|j#                  |j                  |j                  |j%                  |j'                  |j(                  |j*                  |j,                  |                  }|j.                  j1                  |      }|j                  j3                  d	|j4                  |j                  
      }	t6        j8                  j;                  ||	d       t<        j>                  jA                  d       y)aV  Acquires a SQL Server Reporting Services lease on a Cloud SQL instance.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      A dict object representing the operations resource describing the
      acquire-ssrs-lease operation if the acquire-ssrs-lease was successful.
    projectzsql.instances)params
collectionNs)
setupLoginserviceLoginreportDatabaseduration)acquireSsrsLeaseContext)r   r    instancesAcquireSsrsLeaseRequestzsql.operations)	operationr   zAcquiring SSRS leasez"Successfully acquired SSRS lease.
)!r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer   resource_parserParser   VALUEScorer   	GetOrFailr%   str#SqlInstancesAcquireSsrsLeaseRequest InstancesAcquireSsrsLeaseRequestAcquireSsrsLeaseContextsetup_loginservice_loginreport_database	instancesr   CreateoperationIdr   OperationsV1Beta4WaitForOperationr   statuswrite)
selfargsclientr+   r,   instance_refduration_strrequestresultoperation_refs
             r   RunzAcquireSsrsLease.RunG   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 ==L'#-l>>&&$$)5)V)V$0$H$H++!//#33%	 %I % *W * ? 
G !!227;F**11$$$$ 2 &M
   11*m2HJ JJ:;r   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr   rI    r   r   r   r   -   s!    O-# #&/<r   r   N)rM   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   r   r   rN   ReleaseTracksReleaseTrackGACommandr   rQ   r   r   <module>r[      s    N &  ' / 1 / ( 0 # *  D%%(()H<t|| H< *H<r   