
    %                     Z    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\	5      r
g	)
z5API utilities for gcloud compute ssl-policy commands.    )absolute_import)division)unicode_literals)poller)waiterc                   x    \ rS rSrSrS r\S 5       r\S 5       rS r	   SS jr
S	 rS
 rS rS rS rS rSrg)SslPolicyHelper   z1Helper for SSL policy service in the Compute API.c                 H    UR                   U l        UR                  U l        g)zxInitializes the helper for SSL policy operations.

Args:
  holder: Object representing the Compute API holder instance.
N)client_compute_client	resources
_resources)selfholders     Elib/googlecloudsdk/api_lib/compute/ssl_policies/ssl_policies_utils.py__init__SslPolicyHelper.__init__   s     "==D&&DO    c                 .    U R                   R                  $ N)r   apitools_clientr   s    r   _clientSslPolicyHelper._client%   s    ///r   c                 .    U R                   R                  $ r   )r   messagesr   s    r   	_messagesSslPolicyHelper._messages)   s    (((r   c                     U R                   R                  UUU R                   R                  R                  U5      U R                   R                  R                  U5      US9$ )au  Returns the SslPolicy message for an insert request.

Args:
  name: String representing the name of the SSL policy resource.
  description: String representing the description for the SSL policy
    resource.
  profile: String representing the SSL policy profile. Can be one of
    'COMPATIBLE', 'MODERN', 'RESTRICTED' or 'CUSTOM'.
  min_tls_version: String representing the minimum TLS version of the SSL
    policy. Can be one of 'TLS_1_0', 'TLS_1_1', 'TLS_1_2'.
  custom_features: The list of strings representing the custom features to
    use.

Returns:
  The SslPolicy message object that can be used in an insert request.
)namedescriptionprofileminTlsVersioncustomFeatures)r   	SslPolicyProfileValueValuesEnumMinTlsVersionValueValuesEnum)r   r!   r"   r#   min_tls_versioncustom_featuress         r   GetSslPolicyForInsert%SslPolicyHelper.GetSslPolicyForInsert-   s\    $ >>##((??Hnn..KK& $ ( (r   Nc                     U R                   nUR                  US9nU(       a   UR                  R                  U5      Ul        U(       a   UR                  R	                  U5      Ul        Ub  XFl        U$ )a  Returns the SslPolicy message for a patch request.

Args:
  fingerprint: String representing the existing fingerprint of the SSL
    policy resource.
  profile: String representing the SSL policy profile. Can be one of
    'COMPATIBLE', 'MODERN', 'RESTRICTED' or 'CUSTOM'.
  min_tls_version: String representing the minimum TLS version of the SSL
    policy. Can be one of 'TLS_1_0', 'TLS_1_1', 'TLS_1_2'.
  custom_features: The list of strings representing the custom features to
    use.
)fingerprint)r   r&   r'   r#   r(   r$   r%   )r   r.   r#   r)   r*   r   
ssl_policys          r   GetSslPolicyForPatch$SslPolicyHelper.GetSslPolicyForPatchG   sm    " ~~H###<J#--DDWMj



9
9/
J ""1r   c                 2   UR                  5       S:X  aB  [        R                  " U R                  R                  U5      n[
        R                  " XBU5      $ [        R                  " U R                  R                  U5      n[
        R                  " XBU5      $ )an  Waits for the specified operation to complete and returns the target.

Args:
  ssl_policy_ref: The SSL policy reference object.
  operation_ref: The operation reference object to wait for.
  wait_message: String representing the wait message to display while the
    operation is in progress.

Returns:
  The resulting resource object after the operation completes.
compute.regionSslPolicies)
Collectionr   Pollerr   regionSslPoliciesr   WaitForsslPolicies)r   ssl_policy_refoperation_refwait_messageoperation_pollers        r   WaitForOperation SslPolicyHelper.WaitForOperationc   ss       "&AAt||'E'E'57^^,\JJ}}T\\%=%=~N>>*<HHr   c                    UR                  5       S:X  ax  U R                  R                  UR                  UR                  US9nU R
                  R                  R                  U5      nU R                  R                  UR                  SS9$ U R                  R                  UR                  US9nU R
                  R                  R                  U5      nU R                  R                  UR                  SS9$ )a  Sends an Insert request for an SSL policy and returns the operation.

Args:
  ref: The SSL policy reference object.
  ssl_policy: The SSL policy message object to use in the insert request.

Returns:
  The operation reference object for the insert request.
r3   projectregion	sslPolicycompute.regionOperations
collectionrA   rC   compute.globalOperations)r4   r   %ComputeRegionSslPoliciesInsertRequestrA   rB   r   r6   Insertr   ParseselfLinkComputeSslPoliciesInsertRequestr8   )r   refr/   request	operations        r   CreateSslPolicyHelper.Createw   s     ~~66DD++cjjJ E Hg,,0077@i__""


)C # E E nn<<z = 3G((//8I??  'A ! C Cr   c                    UR                  5       S:X  ab  U R                  R                  UR                  UR                  UR                  5       S9nU R                  R                  R                  U5      $ U R                  R                  UR                  UR                  5       S9nU R                  R                  R                  U5      $ )zSends a Get request for an SSL policy and returns the resource.

Args:
  ref: The SSL policy reference object.

Returns:
  The SSL policy resource object.
r3   r@   rG   )r4   r   "ComputeRegionSslPoliciesGetRequestrA   rB   Namer   r6   GetComputeSslPoliciesGetRequestr8   )r   rN   rO   s      r   DescribeSslPolicyHelper.Describe   s     ~~66AA++cjjCHHJ B Hg\\++//88nn99sxxz : 3G<<##''00r   c                 8   / nU(       a  UR                  S5        UR                  5       S:X  a  U R                  R                  UR                  UR
                  UR                  5       US9nU R                  R                  U5         U R                  R                  R                  U5      nSSS5        U R                  R                  WR                  SS9$ U R                  R                  UR                  UR                  5       US9nU R                  R                  U5         U R                  R                  R                  U5      nSSS5        U R                  R                  WR                  SS9$ ! , (       d  f       N= f! , (       d  f       NC= f)	a  Sends a Patch request for an SSL policy and returns the operation.

Args:
  ref: The SSL policy reference object.
  ssl_policy: The SSL policy message object to use in the patch request.
  clear_custom_features: If True, customFeatures field is explicitly cleared
    by including it in the request even if empty. Otherwise it is included
    only if the SSL policy message has non-empty customFeatures field.

Returns:
  The operation reference object for the patch request.
r%   r3   )rA   rB   rC   sslPolicyResourceNrD   rE   )rA   rC   r[   rH   )appendr4   r   $ComputeRegionSslPoliciesPatchRequestrA   rB   rU   r   IncludeFieldsr6   Patchr   rK   rL   ComputeSslPoliciesPatchRequestr8   )r   rN   r/   clear_custom_featurescleared_fieldsrO   rP   s          r   r_   SslPolicyHelper.Patch   sX    N ,-
~~66CC++HHJ&	 D (g
 <<%%n5LL2288A	 6__""


)C # E E nn;;sxxzZ < QG		#	#N	3,,**009i 
4??  'A ! C C 65 
4	3s   &E:(&F:
F
Fc                 ,   UR                  5       S:X  a  U R                  R                  UR                  UR                  UR                  5       S9nU R                  R                  R                  U5      nU R                  R                  UR                  SS9$ U R                  R                  UR                  UR                  5       S9nU R                  R                  R                  U5      nU R                  R                  UR                  SS9$ )zSends a Delete request for an SSL policy and returns the operation.

Args:
  ref: The SSL policy reference object.

Returns:
  The operation reference object for the delete request.
r3   r@   rD   rE   rG   rH   )r4   r   %ComputeRegionSslPoliciesDeleteRequestrA   rB   rU   r   r6   Deleter   rK   rL   ComputeSslPoliciesDeleteRequestr8   )r   rN   rO   rP   s       r   rf   SslPolicyHelper.Delete   s     ~~66DD++cjjCHHJ E Hg,,0077@i__""


)C # E E nn<<sxxz = 3G((//8I??  'A ! C Cr   c                 0   U(       aH  U R                   R                  XS9nU R                  R                  R	                  U5      R
                  $ U R                   R                  US9nU R                  R                  R	                  U5      R
                  $ )a  Sends a ListAvailableFeatures request and returns the features.

Args:
  project: String representing the project to use for the request.
  region: The region to use. If not set, the global scope is used.

Returns:
  List of strings representing the list of available features.
)rA   rB   )rA   )r   4ComputeRegionSslPoliciesListAvailableFeaturesRequestr   r6   ListAvailableFeaturesfeatures.ComputeSslPoliciesListAvailableFeaturesRequestr8   )r   rA   rB   rO   s       r   rk   %SslPolicyHelper.ListAvailableFeatures   s     SS T *g\\++AA
8 nnKK L G<<##99'BKKKr   )r   r   )NNN)__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r+   r0   r=   rQ   rX   r_   rf   rk   __static_attributes__ r   r   r	   r	      sk    9' 0 0 ) )(8 $(+/+/	8I(C.1$$CLC,Lr   r	   N)rs   
__future__r   r   r   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   objectr	   rv   r   r   <module>r{      s)    < &  ' < .ULf ULr   