
                             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                   G d dej                                Zy)z?Command to provision a new Spectrum Access System's deployment.    )absolute_import)division)unicode_literals)sas_portal_api)base)
exceptions)log)
properties)
console_ioc                   &    e Zd ZdZed        Zd Zy)	ProvisionzProvision a new Spectrum Access System's deployment.

  ## EXAMPLES

  The following command provisions a new SAS deployment:

    $ gcloud cbrs-spectrum-access provision --organization-name=MyOrgName
    --deployment-name=MyDeploymentName
  c                     | j                  ddd       | j                  ddd       | j                  ddt        d	       y )
Nz--organization-nameFzThe display name to use in case a new SAS Portal organization needs to be created. If creating a deployment under an existing organization then the `--organization-id` flag must be set instead.)requiredhelpz--deployment-namezThe display name to use in case a new SAS Portal deployment needs to be created. If not set, a default display name of the form "[ID]" will be used where ID is the current Cloud Platform Project ID.z--organization-idzThe id of the organization to create a new deployment under. If left empty a new organization will be created with the name entered via the `--organization-name` flag. Either this or `--organization-name` must be set.)r   typer   )add_argumentint)parsers    -lib/surface/cbrs_spectrum_access/provision.pyArgszProvision.Args*   sc    
	  	 	  	 2  
    c                    |j                   s$|j                  st        j                  ddgd      |j                   r"|j                  rt        j                  dd      t
        j                  j                  d       t        j                  ddd	
       t        j                          t        j                         j                  }t        j                         }|j!                         }|j                   |_        |j$                  |_        |j                  |_        |j+                  |      }|j,                  st.        j0                  j2                  j5                  d      j7                         }d}|rd|v rd}t.        j0                  j8                  j:                  j7                         }t
        j                  j                  dj=                  ||             |S )Nzorganization-namezorganization-idzEither `--organization-name` or `--organization-id` must be set. Use `--organization-name` when creating a new organization and `--organization-id` when create a deployment under an existing organization.z"organization-name, organization-idzEither `--organization-name` or `--organization-id` must be set but not both. Use `--organization-name` when creating a new organization and `--organization-id` when creating a deployment under an existing organization.a  This command will enable the Spectrum Access System and create a new SAS deployment for your organization. The Spectrum Access System is governed by your Google Cloud Agreement or Cloud Master Agreement and the Spectrum Access System specific terms at cloud.google.com/terms.FTzDo you accept the agreement?)defaultcancel_on_noprompt_string	sasportalzg.co/sasportalzprod-tt-sasportalz0https://wirelessconnectivity.google.com/test-saszA new SAS deployment with userID: {}  has been created. Go to {} to check spectrum availability, pre-register CBSDs, check CBSD status and manage users.)organization_nameorganization_idr   OneOfArgumentsRequiredExceptionInvalidArgumentExceptionr	   statusPrintr   PromptContinuer   EnableUserProjectQuotar   GetClientInstance	customersGetMessagesModule#SasPortalProvisionDeploymentRequestnewOrganizationDisplayNamedeployment_namenewDeploymentDisplayNameorganizationIdProvisionDeploymenterrorMessager
   VALUESapi_endpoint_overridesPropertyGetcoreprojectformat)	selfargsclientmessage_modulereqresultportal_api_overridesas_portal_urlr4   s	            r   RunzProvision.RunL   s   !!$*>*>66 1
2  $"6"6//
.-  JJ	< 4 	!--/99F#557N

<
<
>C%)%;%;C"#'#7#7C --C'',F&--DDMM
  (n	"59L"LK!!&&..224g	jj1171P Mr   N)__name__
__module____qualname____doc__staticmethodr   r>    r   r   r   r      s!      B9r   r   N)rB   
__future__r   r   r   &googlecloudsdk.api_lib.spectrum_accessr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   r
   googlecloudsdk.core.consoler   HiddenDescribeCommandr   rD   r   r   <module>rL      sN     F &  ' A ( . # * 2 f$$ f fr   