
    4                     L    d Z ddlmZ dZdZdZdZdeded	efd
Z	 G d d      Z
y)z5Client for interacting with Storage Intelligence API.    )apiszedition_config,filterfoldersorganizationsprojectsresource_typeresource_idreturnc                     |  d| dS )z$Returns the full id of the resource./z$/locations/global/intelligenceConfig r   r   s     >lib/googlecloudsdk/api_lib/storage/storage_intelligence_api.py_get_full_id_stringr      s    ?!K=(L	MM    c                        e Zd ZdZ fdZ	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 ddZd Zd Z	d Z
d	 Zd
 Zd Z	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ xZS )StorageIntelligenceApiz$Client for Storage Intelligence API.c                     t         t        |           t        j                  dd      | _        t        j                  dd      | _        y )Nstoragev2)superr   __init__	core_apisGetClientInstanceclientGetMessagesModulemessages)self	__class__s    r   r   zStorageIntelligenceApi.__init__"   s9    	
 $02--i>DK//	4@DMr   c                     | j                   j                         }| j                   j                  j                  j                  |_        ||_         ||t        |      } ||      S )z-Disables Intelligence for the given resource.intelligenceConfig
updateMaskname)r   IntelligenceConfigEditionConfigValueValuesEnumDISABLEDeditionConfigr#   _FULL_UPDATE_MASK)r   full_idrequest_message_classpatch_methodintelligence_configrequests         r   _disable_intelligencez,StorageIntelligenceApi._disable_intelligence'   sc     --::<((EENN %  '#.$G   r   c                    | j                   j                         |_        d}|r4| j                   j                  j                  j
                  |_        |dz   S |r*| j                   j                  j                  j                  n)| j                   j                  j                  j                  |_        |0| j                   j                  |      |j                  _
        |dz  }|0| j                   j                  |      |j                  _        |dz  }|0| j                   j                  |      |j                  _        |dz  }|0| j                   j                  |      |j                  _        |dz  }|S )	a  Updates the Intelligence filter and returns update_mask.

    Args:
      intelligence_config: The Intelligence Config object to be updated.
      inherit_from_parent: Whether to inherit config from the parent.
      trial_edition: Whether to enable Storage Intelligence for TRIAL edition.
      include_locations: List of locations to be included in the filter.
      exclude_locations: List of locations to be excluded in the filter.
      include_bucket_id_regexes: List of bucket id regexes to be included in the
        filter.
      exclude_bucket_id_regexes: List of bucket id regexes to be excluded in the
        filter.

    Returns:
      The update mask to be used for the request.
    edition_configz,filter)	locationsz(,filter.included_cloud_storage_locationsz(,filter.excluded_cloud_storage_locations)bucketIdRegexesz&,filter.included_cloud_storage_bucketsz&,filter.excluded_cloud_storage_buckets)r   Filterfilterr$   r%   INHERITr'   TRIALSTANDARDCloudStorageLocationsincludedCloudStorageLocationsexcludedCloudStorageLocationsCloudStorageBucketsincludedCloudStorageBucketsexcludedCloudStorageBuckets)	r   r,   inherit_from_parenttrial_editioninclude_locationsexclude_locationsinclude_bucket_id_regexesexclude_bucket_id_regexesupdate_masks	            r   _set_intelligence_filterz/StorageIntelligenceApi._set_intelligence_filter<   s   6 "&!5!5!7"K 
--
*
*
G
G
O
O ' ""  	((EEKK]]--JJSS % $
--
-
-8I
-
J   > ??k$
--
-
-8I
-
J   > ??k !,
--
+
+7 ,    <
 ==k ,
--
+
+7 ,    <
 ==kr   c
           	          | j                   j                         }
||
_        | j                  |
||||||      } |	 ||
||            S )z7Updates the Intelligence Config for the given resource.r    )r   r$   r#   rE   )r   r)   r>   r?   r@   rA   rB   rC   r*   r+   r,   rD   s               r   _update_intelligence_configz2StorageIntelligenceApi._update_intelligence_config   se     --::<&//!!K 2"	
 r   c                     t        t        |      }| j                  j                  |      }| j                  j
                  j                  |      S )zGets the Intelligence Config for the given sub folder.

    Args:
      folder_id: Id of the GCP hierarchy folder.

    Returns:
      The Intelligence Config object.
    r   r#   )r   _FOLDER_RESOURCE_TYPEr   3StorageFoldersLocationsGetIntelligenceConfigRequestr   folders_locationsGetIntelligenceConfig)r   	folder_id	full_namer-   s       r   "get_sub_folder_intelligence_configz9StorageIntelligenceApi.get_sub_folder_intelligence_config   sO     $+I mmOO P G ;;((>>wGGr   c                     t        t        |      }| j                  j                  |      }| j                  j
                  j                  |      S )zGets the Intelligence Config for the given project.

    Args:
      project_name: Name of the GCP project.

    Returns:
      The Intelligence Config object.
    r   rI   )r   _PROJECT_RESOURCE_TYPEr   4StorageProjectsLocationsGetIntelligenceConfigRequestr   projects_locationsrM   )r   project_namerO   r-   s       r   get_project_intelligence_configz6StorageIntelligenceApi.get_project_intelligence_config   sR     $,,I
 	JJ 	K 	
 
 ;;))??HHr   c                     t        t        |      }| j                  j                  |      }| j                  j
                  j                  |      S )zGets the Intelligence Config for the given organization.

    Args:
      organization_id: Id of the GCP organization.

    Returns:
      The Intelligence Config object.
    r   rI   )r   _ORGANIZATION_RESOURCE_TYPEr   9StorageOrganizationsLocationsGetIntelligenceConfigRequestr   organizations_locationsrM   )r   organization_idrO   r-   s       r   $get_organization_intelligence_configz;StorageIntelligenceApi.get_organization_intelligence_config   sR     $1I
 	OO 	P 	
 
 ;;..DDWMMr   c                     t        t        |      }| j                  || j                  j                  | j
                  j                  j                        S )zDisables the Storage Intelligence for the given project.

    Args:
      project_name: Name of the GCP project.

    Returns:
      The Intelligence Config object.
    r   r)   r*   r+   )r   rR   r.   r   7StorageProjectsLocationsUpdateIntelligenceConfigRequestr   rT   UpdateIntelligenceConfig)r   rU   rO   s      r   #disable_project_intelligence_configz:StorageIntelligenceApi.disable_project_intelligence_config   sP     $,,I %%"mmcc[[33LL &  r   c                     t        t        |      }| j                  || j                  j                  | j
                  j                  j                        S )zDisables the Storage Intelligence for the given organization.

    Args:
      organization_id: Id of the GCP organization.

    Returns:
      The Intelligence Config object.
    r   r^   )r   rX   r.   r   <StorageOrganizationsLocationsUpdateIntelligenceConfigRequestr   rZ   r`   )r   r[   rO   s      r   (disable_organization_intelligence_configz?StorageIntelligenceApi.disable_organization_intelligence_config   sP     $1I %%"mmhh[[88QQ &  r   c                     t        t        |      }| j                  || j                  j                  | j
                  j                  j                        S )zDisables the Storage Intelligence for the given sub folder.

    Args:
      sub_folder_id: Id of the GCP hierarchy folder.

    Returns:
      The Intelligence Config object.
    r   r^   )r   rJ   r.   r   6StorageFoldersLocationsUpdateIntelligenceConfigRequestr   rL   r`   )r   sub_folder_idrO   s      r   &disable_sub_folder_intelligence_configz=StorageIntelligenceApi.disable_sub_folder_intelligence_config  sP     $+I %%"mmbb[[22KK &  r   c                     t        d|      }| j                  |||||||| j                  j                  | j                  j
                  j                  	      S )a  Updates the Intelligence Config for the given GCP project.

    Args:
      project: Name of the GCP project.
      inherit_from_parent: Whether to inherit config from the parent.
      trial_edition: Whether to enable Storage Intelligence for TRIAL edition.
      include_locations: List of locations to be included in the filter.
      exclude_locations: List of locations to be excluded in the filter.
      include_bucket_id_regexes: List of bucket id regexes to be included in the
        filter.
      exclude_bucket_id_regexes: List of bucket id regexes to be excluded in the
        filter.

    Returns:
      The Intelligence Config object.
    r   r   )r   rG   r   r_   r   rT   r`   )	r   projectr>   r?   r@   rA   rB   rC   rO   s	            r   "update_project_intelligence_configz9StorageIntelligenceApi.update_project_intelligence_config  s]    6 $ gI ++!!MM&&??
 
r   c                     t        d|      }| j                  |||||||| j                  j                  | j                  j
                  j                  	      S )a  Updates the Intelligence Config for the given GCP sub folder.

    Args:
      sub_folder: The GCP sub folder name.
      inherit_from_parent: Whether to inherit config from the parent.
      trial_edition: Whether to enable Storage Intelligence for TRIAL edition.
      include_locations: List of locations to be included in the filter.
      exclude_locations: List of locations to be excluded in the filter.
      include_bucket_id_regexes: List of bucket id regexes to be included in the
        filter.
      exclude_bucket_id_regexes: List of bucket id regexes to be excluded in the
        filter.

    Returns:
      The Intelligence Config object.
    r   r   )r   rG   r   rf   r   rL   r`   )	r   
sub_folderr>   r?   r@   rA   rB   rC   rO   s	            r   %update_sub_folder_intelligence_configz<StorageIntelligenceApi.update_sub_folder_intelligence_configE  s]    4 $ZI ++!!LL%%>>
 
r   c                     t        d|      }| j                  |||||||| j                  j                  | j                  j
                  j                  	      S )a  Updates the Intelligence Config for the given GCP organization.

    Args:
      organization: The GCP organization name.
      inherit_from_parent: Whether to inherit config from the parent.
      trial_edition: Whether to enable Storage Intelligence for TRIAL edition.
      include_locations: List of locations to be included in the filter.
      exclude_locations: List of locations to be excluded in the filter.
      include_bucket_id_regexes: List of bucket id regexes to be included in the
        filter.
      exclude_bucket_id_regexes: List of bucket id regexes to be excluded in the
        filter.

    Returns:
      The Intelligence Config object.
    r   r   )r   rG   r   rc   r   rZ   r`   )	r   organizationr>   r?   r@   rA   rB   rC   rO   s	            r   'update_organization_intelligence_configz>StorageIntelligenceApi.update_organization_intelligence_configo  s]    4 $%<I ++!!RR++DD
 
r   )NNN)FFNNNN)	NFFNNNNNN)__name__
__module____qualname____doc__r   r.   rE   rG   rP   rV   r\   ra   rd   rh   rk   rn   rq   __classcell__)r   s   @r   r   r      s    ,A  	!0   $ $GV  $ $  DH$I(N(&&,   $ $)\   $ $(Z   $ $(r   r   N)ru   googlecloudsdk.api_lib.utilr   r   r(   rJ   rX   rR   strr   r   r   r   r   <module>ry      sQ    < 9 , ! - # Ns N N N
x xr   