
    Y                     r    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 rS r	S	 r
SS
 jrS r SS jrg)zUtils for common error logic.    )absolute_import)division)unicode_literals)errors)storage_urlc                 n    [         R                  " SR                  SR                  U 5      XU5      5      e)a~  Raises error for user input mismatched with command resource type.

Example message:

"gcloud storage buckets" create only accepts bucket URLs.
Example: "gs://bucket"
Received: "gs://user-bucket/user-object.txt"

Args:
  command_list (list[str]): The command being run. Can be gotten from an
    argparse object with `args.command_path`.
  expected_resource_type (str): Raise an error because we did not get this.
  example: (str): An example of a URL to a resource with the correct type.
  url (StorageUrl): The erroneous URL received.

Raises:
  InvalidUrlError: Explains that the user entered a URL for the wrong type
    of resource.
z7"{}" only accepts {} URLs.
Example: "{}"
Received: "{}" )r   InvalidUrlErrorformatjoin)command_listexpected_resource_typeexampleurls       5lib/googlecloudsdk/command_lib/storage/errors_util.py$_raise_error_for_wrong_resource_typer      s6    . 	AHH
((<
 "83	     c                     [        U[        R                  5      (       a  UR                  5       (       d  [	        U SSU5        g g )Nbucketgs://bucket)
isinstancer   CloudUrl	is_bucketr   r   r   s     r   raise_error_if_not_bucketr   7   s6    
S+..
/
/CMMOO(hs 5Dr   c                     [        U[        R                  5      (       a  UR                  5       (       d  [	        U SSU5        g g )Nobjectzgs://bucket/object.txt)r   r   r   	is_objectr   r   s     r   raise_error_if_not_cloud_objectr   >   s7    
S+..
/
/CMMOO(h 8# 5Dr   c                     [        U[        R                  5      (       a'  UR                  [        R                  R
                  L d  [        U SX!5        g g )NzGoogle Cloud Storage)r   r   r   schemeProviderPrefixGCSr   )r   r   r   s      r   raise_error_if_not_gcsr$   E   sB    k**++
**2266
6(,g 7r   c                 0    [        X5        [        X5        g )N)r$   r   r   s     r   raise_error_if_not_gcs_bucketr&   O   s    +L.r   c                     [        XSS9  [        U[        R                  5      (       a  UR	                  5       (       d  [        U SR                  U5      SU5        g g )Nzgs://bucket/folder/)r   zGoogle Cloud Storage {})r$   r   r   r   r   r   r   )r   r   folder_types      r   "raise_error_if_not_gcs_folder_typer)   T   sQ     4IJ
S+..
/
/CMMOO(!((5	 5Dr   N)r   )zmanaged folder)__doc__
__future__r   r   r   "googlecloudsdk.command_lib.storager   r   r   r   r   r$   r&   r)    r   r   <module>r.      s<    $ &  ' 5 :</ $4
r   