
    iT                         S r SSKJr  SSKJrJrJr  SSKrSSKJ	r	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 " S S5      r " S S5      r " S S5      rg)a  
Search for resources with the global and shared resource properties repository that is
integrated in the IBM Cloud platform. The search repository stores and searches cloud
resources attributes, which categorize or classify resources. A resource is a physical or
logical component that can be created or reserved for an application or service instance.
They are owned by resource providers, such as IBM Kubernetes Service, or resource
controller in IBM Cloud. Resources are uniquely identified by a Cloud Resource Name (CRN)
or by an IMS ID. The properties of a resource include tags and system properties. Both
properties are defined in an IBM Cloud billing account, and span across many regions.

API Version: 2.0.1
    )Enum)DictListOptionalN)BaseServiceDetailedResponse)Authenticator)"get_authenticator_from_environment)convert_list   )get_sdk_headersc                   "   \ rS rSrSrSrSr\\4S\SS 4S jj5       r	 SS	\
SS4S
 jjrSSSSSSSSSSSSSSS.S\\   S\\\      S\\   S\\   S\\   S\\   S\\   S\\   S\\\      S\\   S\\   S\\   S\\   S\\   S\4S jjrSrg)GlobalSearchV20   zThe global_search V2 service.z/https://api.global-search-tagging.cloud.ibm.comglobal_searchservice_namereturnc                 N    [        U5      nU " U5      nUR                  U5        U$ )zu
Return a new client for the global_search service using the specified
       parameters and external configuration.
)r
   configure_service)clsr   authenticatorservices       `/home/james-whalen/.local/lib/python3.13/site-packages/ibm_platform_services/global_search_v2.pynew_instanceGlobalSearchV2.new_instance6   s+     ;<Hm$!!,/    Nr   c                 B    [         R                  " X R                  US9  g)a4  
Construct a new client for the global_search service.

:param Authenticator authenticator: The authenticator specifies the authentication mechanism.
       Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md
       about initializing the authenticator of your choice.
)service_urlr   N)r   __init__DEFAULT_SERVICE_URL)selfr   s     r   r   GlobalSearchV2.__init__D   s     	T/G/GWder   )queryfieldssearch_cursorx_request_idx_correlation_id
account_idlimittimeoutsort
is_deletedis_reclaimedimpersonate_usercan_tagis_project_resourcer#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   c          
         UUS.n[        U R                  SSS9nUR                  U5        UUU[        U	5      U
UUUUS.	nUUUS.nUR	                  5        VVs0 s H  u  nnUc  M  UU_M     nnn[
        R                  " U5      nSUS'   S	U;   a#  UR                  UR                  S	5      5        US		 SUS
'   SnU R                  SUUUUS9nU R                  " U40 UD6nU$ s  snnf )a  
Find instances of resources (v3).

Find IAM-enabled resources or storage and network resources that run on classic
infrastructure in a specific account ID.
You must use `/v3/resources/search` when you need to fetch more than `10000`
resource items. On the first call, the operation returns a live cursor on the data
that you must use on all the subsequent calls to get the next batch of results
until you get the empty result set.
To filter results, you can apply query strings following the *Lucene* query
syntax.
By default, the fields that are returned for every resource are **crn**, **name**,
**family**, **type**, and **account_id**. You can specify the subset of the fields
you want in your request using the `fields` request body attribute. Set `"fields":
["*"]` to discover the complete set of fields which are available to request.

:param str query: (optional) The Lucene-formatted query string. Default to
       '*' if not set.
:param List[str] fields: (optional) The list of the fields returned by the
       search. By default, the returned fields are the `account_id`, `name`,
       `type`, `family`, and `crn`. For all queries, `crn` is always returned. You
       may set `"fields": ["*"]` to discover the set of fields available to
       request.
:param str search_cursor: (optional) An opaque cursor that is returned on
       each call and that must be set on the subsequent call to get the next batch
       of items. You can stop paging when the search returns less items than the
       specified `limit` or when the `search_cursor` is not present in the
       response. NOTE: when setting this parameter, any other properties present
       in the body will be ignored.
:param str x_request_id: (optional) An alphanumeric string that is used to
       trace the request. The value  may include ASCII alphanumerics and any of
       following segment separators: space ( ), comma (,), hyphen, (-), and
       underscore (_) and may have a length up to 1024 bytes. The value is
       considered invalid and must be ignored if that value includes any other
       character or is longer than 1024 bytes or is fewer than 8 characters. If
       not specified or invalid, it is automatically replaced by a random (version
       4) UUID.
:param str x_correlation_id: (optional) An alphanumeric string that is used
       to trace the request as a part of a larger context: the same value is used
       for downstream requests and retries of those requests. The value may
       include ASCII alphanumerics and any of following segment separators: space
       ( ), comma (,), hyphen, (-), and underscore (_) and may have a length up to
       1024 bytes. The value is considered invalid and must be ignored if that
       value includes any other character or is longer than 1024 bytes or is fewer
       than 8 characters. If not specified or invalid, it is automatically
       replaced by a random (version 4) UUID.
:param str account_id: (optional) The account ID to filter resources.
:param int limit: (optional) The maximum number of hits to return. Defaults
       to 10.
:param int timeout: (optional) A search timeout in milliseconds, bounding
       the search request to run within the specified time value and bail with the
       hits accumulated up to that point when expired. Defaults to the system
       defined timeout.
:param List[str] sort: (optional) Comma separated properties names that are
       used for sorting.
:param str is_deleted: (optional) Determines if deleted documents should be
       included in result set or not. Possible values are false (default), true or
       any. If false, only existing documents are returned; if true, only deleted
       documents are returned; If any, both existing and deleted documents are
       returned. (_for administrators only_).
:param str is_reclaimed: (optional) Determines if reclaimed documents
       should be included in result set or not. Possible values are false
       (default), true or any. If false, only not reclaimed documents are
       returned; if true, only reclaimed documents are returned; If any, both
       reclaimed and not reclaimed documents are returned.
:param str impersonate_user: (optional) The user on whose behalf the search
       must be performed. Only a GhoST admin can impersonate a user, so be sure
       you set a GhoST admin IAM token in the Authorization header if you set this
       parameter. (_for administrators only_).
:param str can_tag: (optional) Determines if the result set must return the
       resources that the user can tag or the resources that the user can view
       (only a GhoST admin can use this parameter). If false (default), only
       resources user can view are returned; if true, only resources that user has
       permissions for tagging are returned (_for administrators only_).
:param str is_project_resource: (optional) Determines if documents
       belonging to Project family should be included in result set or not.
       Possible values are false (default), true or any. If false, documents
       belonging to all families except Project are returned; if true, only
       documents belonging to Project family are returned; if any, documents of
       any family are returned. Only authorized ServiceIds can use this query
       parameter.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `ScanResult` object
)zx-request-idzx-correlation-idV2search)r   service_versionoperation_id)	r(   r)   r*   r+   r,   r-   r.   r/   r0   )r#   r$   r%   zapplication/jsonzcontent-typeheadersAcceptz/v3/resources/searchPOST)methodurlr6   paramsdata)
r   DEFAULT_SERVICE_NAMEupdater   itemsjsondumpsgetprepare_requestsend)r!   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   kwargsr6   sdk_headersr;   r<   kvr:   requestresponses                            r   r3   GlobalSearchV2.searchU   s.   T ) 0
 &22 !

 	{# % &$( 0#6

 *

 $(::<A<!Q11<Azz$"4NN6::i01y!.$&& ' 
 99W//' Bs   
C%(C% )N)__name__
__module____qualname____firstlineno____doc__r    r=   classmethodstrr   r	   r   r   r   intr   r3   __static_attributes__rL   r   r   r   r   0   sx   'K* 1 
  (,f$f 
f(  $&*'+&**.$(#!%$($(&**.!%-1!X }X c#	X
  }X smX #3-X SMX }X #X tCy!X SMX smX #3-X #X  &c]!X$ 
%X Xr   r   c                   x    \ rS rSrSr " S S\\5      r " S S\\5      r " S S\\5      r	 " S	 S
\\5      r
Srg)SearchEnums   z
Enums for search parameters.
c                   $    \ rS rSrSrSrSrSrSrg)SearchEnums.IsDeleted   a1  
Determines if deleted documents should be included in result set or not. Possible
values are false (default), true or any. If false, only existing documents are
returned; if true, only deleted documents are returned; If any, both existing and
deleted documents are returned. (_for administrators only_).
truefalseanyrL   N	rM   rN   rO   rP   rQ   TRUEFALSEANYrU   rL   r   r   	IsDeletedrZ          	 r   rc   c                   $    \ rS rSrSrSrSrSrSrg)SearchEnums.IsReclaimedi  a$  
Determines if reclaimed documents should be included in result set or not.
Possible values are false (default), true or any. If false, only not reclaimed
documents are returned; if true, only reclaimed documents are returned; If any,
both reclaimed and not reclaimed documents are returned.
r\   r]   r^   rL   Nr_   rL   r   r   IsReclaimedrf     rd   r   rg   c                        \ rS rSrSrSrSrSrg)SearchEnums.CanTagi  aJ  
Determines if the result set must return the resources that the user can tag or
the resources that the user can view (only a GhoST admin can use this parameter).
If false (default), only resources user can view are returned; if true, only
resources that user has permissions for tagging are returned (_for administrators
only_).
r\   r]   rL   N)rM   rN   rO   rP   rQ   r`   ra   rU   rL   r   r   CanTagri     s    	 r   rj   c                   $    \ rS rSrSrSrSrSrSrg)SearchEnums.IsProjectResourcei  a  
Determines if documents belonging to Project family should be included in result
set or not. Possible values are false (default), true or any. If false, documents
belonging to all families except Project are returned; if true, only documents
belonging to Project family are returned; if any, documents of any family are
returned. Only authorized ServiceIds can use this query parameter.
r\   r]   r^   rL   Nr_   rL   r   r   IsProjectResourcerl     s    	 r   rm   rL   N)rM   rN   rO   rP   rQ   rS   r   rc   rg   rj   rm   rU   rL   r   r   rW   rW      s?    
C 

c4 

d 
C r   rW   c                       \ rS rSrSr\" S/5      rS\S\\	   SS4S jr
\S\SS 4S	 j5       r\S
 5       rS\4S jrS rS\4S jrS\4S jrS\4S jrSS S\4S jrSS S\4S jrSrg)
ResultItemi,  z
A resource returned in a search result, which is identified by its `crn`. It contains
other properties that depend on the resource type.

:param str crn: Resource identifier in CRN format.

This type supports additional properties of type object.
crnrE   r   Nc                    Xl         UR                  5        Hn  u  p4U[        R                  ;  a=  [	        U[
        5      (       d  [        SR                  U5      5      e[        XU5        MV  [        SR                  U5      5      e   g)z
Initialize a ResultItem object.

:param str crn: Resource identifier in CRN format.
:param object **kwargs: (optional) Additional properties of type object
7Value for additional property {} must be of type object9Property {} cannot be specified as an additional propertyN)	rp   r?   ro   _properties
isinstanceobject
ValueErrorformatsetattr)r!   rp   rE   rG   rH   s        r   r   ResultItem.__init__9  sp     LLNDA
...!!V,,$%^%e%efg%hii# !\!c!cde!fgg #r   _dictc                    0 nUR                  S5      =nb  X2S'   O[        S5      eUR                  5        HI  u  pEX@R                  ;  d  M  [	        U[
        5      (       d  [        SR                  U5      5      eXRU'   MK     U " S0 UD6$ )6Initialize a ResultItem object from a json dictionary.rp   z6Required property 'crn' not present in ResultItem JSONrr   rL   )rB   rw   r?   rt   ru   rv   rx   )r   r{   argsrp   rG   rH   s         r   	from_dictResultItem.from_dictM  s     99U##C0KWXXKKMDA'!!V,,$%^%e%efg%hiiQ	 "
 {T{r   c                 $    U R                  U5      $ )r}   r   r   r{   s     r   
_from_dictResultItem._from_dict\       }}U##r   c                    0 n[        U S5      (       a  U R                  b  U R                  US'   [        U 5      R                  5        Vs/ s H  o"[        R
                  ;  d  M  UPM     sn H  n[        X5      X'   M     U$ s  snf )1Return a json dictionary representing this model.rp   )hasattrrp   varskeysro   rt   getattrr!   r{   _krG   s       r   to_dictResultItem.to_dicta  ss    4DHH$888E%L#Dz0U0j>T>T4T"0UAt'EH V Vs   B&Bc                 "    U R                  5       $ r   r   r!   s    r   _to_dictResultItem._to_dictj      ||~r   c                     0 n[        U 5      R                  5        Vs/ s H  o"[        R                  ;  d  M  UPM     sn H  n[	        X5      X'   M     U$ s  snf )zXReturn the additional properties from this instance of ResultItem in the form of a dict.)r   r   ro   rt   r   r   s       r   get_propertiesResultItem.get_propertiesn  sP    #Dz0U0j>T>T4T"0UAt'EH V Vs
   AAc                    [        U 5      R                  5        Vs/ s H  o"[        R                  ;  d  M  UPM     sn H  n[	        X5        M     UR                  5        Hn  u  p4U[        R                  ;  a=  [        U[        5      (       d  [        SR                  U5      5      e[        XU5        MV  [        SR                  U5      5      e   gs  snf )zHSet a dictionary of additional properties in this instance of ResultItemrr   rs   N)r   r   ro   rt   delattrr?   ru   rv   rw   rx   ry   )r!   r{   r   rG   rH   s        r   set_propertiesResultItem.set_propertiesu  s    #Dz0U0j>T>T4T"0UAD VKKMDA
...!!V,,$%^%e%efg%hii# !\!c!cde!fgg " Vs
   CCc                 H    [         R                  " U R                  5       SS9$ )z1Return a `str` version of this ResultItem object.   indentr@   rA   r   r   s    r   __str__ResultItem.__str__      zz$,,.33r   otherc                 j    [        XR                  5      (       d  gU R                  UR                  :H  $ z=Return `true` when self and other are equal, false otherwise.Fru   	__class____dict__r!   r   s     r   __eq__ResultItem.__eq__  '    %00}}..r   c                     X:X  + $ zAReturn `true` when self and other are not equal, false otherwise.rL   r   s     r   __ne__ResultItem.__ne__        r   )rp   )rM   rN   rO   rP   rQ   	frozensetrt   rS   r   rv   r   rR   r   r   r   r   r   r   dictr   r   boolr   r   rU   rL   r   r   ro   ro   ,  s     UG$Khh 6"h 
	h( d |   $ $  
hD 
h4 4/L /T /!L !T !r   ro   c            	           \ rS rSrSrSS.S\S\S   S\\   S	S4S
 jjr	\
S\S	S 4S j5       r\
S 5       rS	\4S jrS rS	\4S jrSS S	\4S jrSS S	\4S jrSrg)
ScanResulti  aQ  
The search scan response.

:param str search_cursor: (optional) The search cursor to use on all calls after
      the first one.
:param int limit: Value of the limit parameter specified by the user.
:param List[ResultItem] items: The array of results. Each item represents a
      resource. For each resource, the requested `fields` are returned. If you did not
      set the `fields` request body parameter, then the `account_id`, `name`, `type`,
      `family`, and `crn` are returned. An empty array signals the end of the result
      set, which means there are no more results to fetch.
N)r%   r)   r?   ro   r%   r   c                (    X0l         Xl        X l        g)a\  
Initialize a ScanResult object.

:param int limit: Value of the limit parameter specified by the user.
:param List[ResultItem] items: The array of results. Each item represents a
       resource. For each resource, the requested `fields` are returned. If you
       did not set the `fields` request body parameter, then the `account_id`,
       `name`, `type`, `family`, and `crn` are returned. An empty array signals
       the end of the result set, which means there are no more results to fetch.
:param str search_cursor: (optional) The search cursor to use on all calls
       after the first one.
N)r%   r)   r?   )r!   r)   r?   r%   s       r   r   ScanResult.__init__  s    & +

r   r{   c                 *   0 nUR                  S5      =nb  X2S'   UR                  S5      =nb  XBS'   O[        S5      eUR                  S5      =nb*  U Vs/ s H  n[        R                  U5      PM     snUS'   O[        S5      eU " S0 UD6$ s  snf )6Initialize a ScanResult object from a json dictionary.r%   r)   z8Required property 'limit' not present in ScanResult JSONr?   z8Required property 'items' not present in ScanResult JSONrL   )rB   rw   ro   r   )r   r{   r~   r%   r)   r?   rH   s          r   r   ScanResult.from_dict  s     "YY77MD$1!YYw''E4!MYZZYYw''E4>CDeZ11!4eDDMYZZ{T{ Es   Bc                 $    U R                  U5      $ )r   r   r   s     r   r   ScanResult._from_dict  r   r   c                    0 n[        U S5      (       a  U R                  b  U R                  US'   [        U S5      (       a  U R                  b  U R                  US'   [        U S5      (       am  U R                  b`  / nU R                   HJ  n[	        U[
        5      (       a  UR                  U5        M+  UR                  UR                  5       5        ML     X!S'   U$ )r   r%   r)   r?   )r   r%   r)   r?   ru   r   appendr   )r!   r{   
items_listrH   s       r   r   ScanResult.to_dict  s    4))d.@.@.L%)%7%7E/"4!!djj&<!ZZE'N4!!djj&<JZZa&&%%a(%%aiik2	  
 ('Nr   c                 "    U R                  5       $ r   r   r   s    r   r   ScanResult._to_dict  r   r   c                 H    [         R                  " U R                  5       SS9$ )z1Return a `str` version of this ScanResult object.r   r   r   r   s    r   r   ScanResult.__str__  r   r   r   c                 j    [        XR                  5      (       d  gU R                  UR                  :H  $ r   r   r   s     r   r   ScanResult.__eq__  r   r   c                     X:X  + $ r   rL   r   s     r   r   ScanResult.__ne__  r   r   )r?   r)   r%   )rM   rN   rO   rP   rQ   rT   r   r   rS   r   rR   r   r   r   r   r   r   r   r   r   rU   rL   r   r   r   r     s    $ (, L!
  } 
. d |   $ $ "4 4/L /T /!L !T !r   r   )rQ   enumr   typingr   r   r   r@   ibm_cloud_sdk_corer   r   /ibm_cloud_sdk_core.authenticators.authenticatorr	   $ibm_cloud_sdk_core.get_authenticatorr
   ibm_cloud_sdk_core.utilsr   commonr   r   rW   ro   r   rL   r   r   <module>r      sZ   &  ' '  < I S 1 #}[ }@4 4xa! a!H[! [!r   