Skip to content

Commit 4239cb9

Browse files
fix/feat(Search): regenerated services with latest API definition
Signed-off-by: Fabrizio Leoni <fabrizio_leoni@it.ibm.com>
1 parent 00c81c5 commit 4239cb9

File tree

2 files changed

+51
-67
lines changed

2 files changed

+51
-67
lines changed

ibm_platform_services/global_search_v2.py

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2024.
3+
# (C) Copyright IBM Corp. 2025.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# IBM OpenAPI SDK Code Generator Version: 3.87.0-91c7c775-20240320-213027
17+
# IBM OpenAPI SDK Code Generator Version: 3.100.0-2ad7a784-20250212-162551
1818

1919
"""
2020
Search for resources with the global and shared resource properties repository that is
@@ -61,7 +61,9 @@ def new_instance(
6161
parameters and external configuration.
6262
"""
6363
authenticator = get_authenticator_from_environment(service_name)
64-
service = cls(authenticator)
64+
service = cls(
65+
authenticator
66+
)
6567
service.configure_service(service_name)
6668
return service
6769

@@ -96,7 +98,6 @@ def search(
9698
sort: Optional[List[str]] = None,
9799
is_deleted: Optional[str] = None,
98100
is_reclaimed: Optional[str] = None,
99-
is_public: Optional[str] = None,
100101
impersonate_user: Optional[str] = None,
101102
can_tag: Optional[str] = None,
102103
is_project_resource: Optional[str] = None,
@@ -106,21 +107,17 @@ def search(
106107
Find instances of resources (v3).
107108
108109
Find IAM-enabled resources or storage and network resources that run on classic
109-
infrastructure in a specific account ID. You can apply query strings if necessary.
110-
To filter results, you can insert a string by using the Lucene syntax and the
111-
query string is parsed into a series of terms and operators. A term can be a
112-
single word or a phrase, in which case the search is performed for all the words,
113-
in the same order. To filter for a specific value regardless of the property that
114-
contains it, type the search term without specifying a field. Only resources that
115-
belong to the account ID and that are accessible by the client are returned.
110+
infrastructure in a specific account ID.
116111
You must use `/v3/resources/search` when you need to fetch more than `10000`
117112
resource items. On the first call, the operation returns a live cursor on the data
118113
that you must use on all the subsequent calls to get the next batch of results
119114
until you get the empty result set.
120-
By default, the fields that are returned for every resource are `crn`, `name`,
121-
`family`, `type`, and `account_id`. You can specify the subset of the fields you
122-
want in your request using the `fields` request body attribute. Set `"fields":
123-
["*"]` to discover the set of fields which are available to request.
115+
To filter results, you can apply query strings following the *Lucene* query
116+
syntax.
117+
By default, the fields that are returned for every resource are **crn**, **name**,
118+
**family**, **type**, and **account_id**. You can specify the subset of the fields
119+
you want in your request using the `fields` request body attribute. Set `"fields":
120+
["*"]` to discover the complete set of fields which are available to request.
124121
125122
:param str query: (optional) The Lucene-formatted query string. Default to
126123
'*' if not set.
@@ -132,7 +129,8 @@ def search(
132129
:param str search_cursor: (optional) An opaque cursor that is returned on
133130
each call and that must be set on the subsequent call to get the next batch
134131
of items. If the search returns no items, then the search_cursor is not
135-
present in the response.
132+
present in the response. NOTE: any other properties present in the body
133+
will be ignored.
136134
:param str x_request_id: (optional) An alphanumeric string that is used to
137135
trace the request. The value may include ASCII alphanumerics and any of
138136
following segment separators: space ( ), comma (,), hyphen, (-), and
@@ -169,10 +167,6 @@ def search(
169167
(default), true or any. If false, only not reclaimed documents are
170168
returned; if true, only reclaimed documents are returned; If any, both
171169
reclaimed and not reclaimed documents are returned.
172-
:param str is_public: (optional) Determines if public resources should be
173-
included in result set or not. Possible values are false (default), true or
174-
any. If false, do not search public resources; if true, search only public
175-
resources; If any, search also public resources.
176170
:param str impersonate_user: (optional) The user on whose behalf the search
177171
must be performed. Only a GhoST admin can impersonate a user, so be sure
178172
you set a GhoST admin IAM token in the Authorization header if you set this
@@ -212,7 +206,6 @@ def search(
212206
'sort': convert_list(sort),
213207
'is_deleted': is_deleted,
214208
'is_reclaimed': is_reclaimed,
215-
'is_public': is_public,
216209
'impersonate_user': impersonate_user,
217210
'can_tag': can_tag,
218211
'is_project_resource': is_project_resource,
@@ -261,7 +254,6 @@ class IsDeleted(str, Enum):
261254
TRUE = 'true'
262255
FALSE = 'false'
263256
ANY = 'any'
264-
265257
class IsReclaimed(str, Enum):
266258
"""
267259
Determines if reclaimed documents should be included in result set or not.
@@ -273,18 +265,6 @@ class IsReclaimed(str, Enum):
273265
TRUE = 'true'
274266
FALSE = 'false'
275267
ANY = 'any'
276-
277-
class IsPublic(str, Enum):
278-
"""
279-
Determines if public resources should be included in result set or not. Possible
280-
values are false (default), true or any. If false, do not search public resources;
281-
if true, search only public resources; If any, search also public resources.
282-
"""
283-
284-
TRUE = 'true'
285-
FALSE = 'false'
286-
ANY = 'any'
287-
288268
class CanTag(str, Enum):
289269
"""
290270
Determines if the result set must return the resources that the user can tag or
@@ -296,7 +276,6 @@ class CanTag(str, Enum):
296276

297277
TRUE = 'true'
298278
FALSE = 'false'
299-
300279
class IsProjectResource(str, Enum):
301280
"""
302281
Determines if documents belonging to Project family should be included in result
@@ -322,6 +301,8 @@ class ResultItem:
322301
other properties that depend on the resource type.
323302
324303
:param str crn: Resource identifier in CRN format.
304+
305+
This type supports additional properties of type object.
325306
"""
326307

327308
# The set of defined properties for the class
@@ -330,17 +311,22 @@ class ResultItem:
330311
def __init__(
331312
self,
332313
crn: str,
333-
**kwargs,
314+
**kwargs: Optional[object],
334315
) -> None:
335316
"""
336317
Initialize a ResultItem object.
337318
338319
:param str crn: Resource identifier in CRN format.
339-
:param **kwargs: (optional) Any additional properties.
320+
:param object **kwargs: (optional) Additional properties of type object
340321
"""
341322
self.crn = crn
342-
for _key, _value in kwargs.items():
343-
setattr(self, _key, _value)
323+
for k, v in kwargs.items():
324+
if k not in ResultItem._properties:
325+
if not isinstance(v, object):
326+
raise ValueError('Value for additional property {} must be of type object'.format(k))
327+
setattr(self, k, v)
328+
else:
329+
raise ValueError('Property {} cannot be specified as an additional property'.format(k))
344330

345331
@classmethod
346332
def from_dict(cls, _dict: Dict) -> 'ResultItem':
@@ -350,7 +336,11 @@ def from_dict(cls, _dict: Dict) -> 'ResultItem':
350336
args['crn'] = crn
351337
else:
352338
raise ValueError('Required property \'crn\' not present in ResultItem JSON')
353-
args.update({k: v for (k, v) in _dict.items() if k not in cls._properties})
339+
for k, v in _dict.items():
340+
if k not in cls._properties:
341+
if not isinstance(v, object):
342+
raise ValueError('Value for additional property {} must be of type object'.format(k))
343+
args[k] = v
354344
return cls(**args)
355345

356346
@classmethod
@@ -363,30 +353,32 @@ def to_dict(self) -> Dict:
363353
_dict = {}
364354
if hasattr(self, 'crn') and self.crn is not None:
365355
_dict['crn'] = self.crn
366-
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
367-
_dict[_key] = getattr(self, _key)
356+
for k in [_k for _k in vars(self).keys() if _k not in ResultItem._properties]:
357+
_dict[k] = getattr(self, k)
368358
return _dict
369359

370360
def _to_dict(self):
371361
"""Return a json dictionary representing this model."""
372362
return self.to_dict()
373363

374364
def get_properties(self) -> Dict:
375-
"""Return a dictionary of arbitrary properties from this instance of ResultItem"""
365+
"""Return the additional properties from this instance of ResultItem in the form of a dict."""
376366
_dict = {}
377-
378-
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
379-
_dict[_key] = getattr(self, _key)
367+
for k in [_k for _k in vars(self).keys() if _k not in ResultItem._properties]:
368+
_dict[k] = getattr(self, k)
380369
return _dict
381370

382371
def set_properties(self, _dict: dict):
383-
"""Set a dictionary of arbitrary properties to this instance of ResultItem"""
384-
for _key in [k for k in vars(self).keys() if k not in ResultItem._properties]:
385-
delattr(self, _key)
386-
387-
for _key, _value in _dict.items():
388-
if _key not in ResultItem._properties:
389-
setattr(self, _key, _value)
372+
"""Set a dictionary of additional properties in this instance of ResultItem"""
373+
for k in [_k for _k in vars(self).keys() if _k not in ResultItem._properties]:
374+
delattr(self, k)
375+
for k, v in _dict.items():
376+
if k not in ResultItem._properties:
377+
if not isinstance(v, object):
378+
raise ValueError('Value for additional property {} must be of type object'.format(k))
379+
setattr(self, k, v)
380+
else:
381+
raise ValueError('Property {} cannot be specified as an additional property'.format(k))
390382

391383
def __str__(self) -> str:
392384
"""Return a `str` version of this ResultItem object."""

test/unit/test_global_search_v2.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2024.
2+
# (C) Copyright IBM Corp. 2025.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -29,7 +29,9 @@
2929
from ibm_platform_services.global_search_v2 import *
3030

3131

32-
_service = GlobalSearchV2(authenticator=NoAuthAuthenticator())
32+
_service = GlobalSearchV2(
33+
authenticator=NoAuthAuthenticator()
34+
)
3335

3436
_base_url = 'https://api.global-search-tagging.cloud.ibm.com'
3537
_service.set_service_url(_base_url)
@@ -42,15 +44,8 @@ def preprocess_url(operation_path: str):
4244
The returned request URL is used to register the mock response so it needs
4345
to match the request URL that is formed by the requests library.
4446
"""
45-
# First, unquote the path since it might have some quoted/escaped characters in it
46-
# due to how the generator inserts the operation paths into the unit test code.
47-
operation_path = urllib.parse.unquote(operation_path)
4847

49-
# Next, quote the path using urllib so that we approximate what will
50-
# happen during request processing.
51-
operation_path = urllib.parse.quote(operation_path, safe='/')
52-
53-
# Finally, form the request URL from the base URL and operation path.
48+
# Form the request URL from the base URL and operation path.
5449
request_url = _base_url + operation_path
5550

5651
# If the request url does NOT end with a /, then just return it as-is.
@@ -127,7 +122,6 @@ def test_search_all_params(self):
127122
sort = ['testString']
128123
is_deleted = 'false'
129124
is_reclaimed = 'false'
130-
is_public = 'false'
131125
impersonate_user = 'testString'
132126
can_tag = 'false'
133127
is_project_resource = 'false'
@@ -145,7 +139,6 @@ def test_search_all_params(self):
145139
sort=sort,
146140
is_deleted=is_deleted,
147141
is_reclaimed=is_reclaimed,
148-
is_public=is_public,
149142
impersonate_user=impersonate_user,
150143
can_tag=can_tag,
151144
is_project_resource=is_project_resource,
@@ -164,7 +157,6 @@ def test_search_all_params(self):
164157
assert 'sort={}'.format(','.join(sort)) in query_string
165158
assert 'is_deleted={}'.format(is_deleted) in query_string
166159
assert 'is_reclaimed={}'.format(is_reclaimed) in query_string
167-
assert 'is_public={}'.format(is_public) in query_string
168160
assert 'impersonate_user={}'.format(impersonate_user) in query_string
169161
assert 'can_tag={}'.format(can_tag) in query_string
170162
assert 'is_project_resource={}'.format(is_project_resource) in query_string
@@ -281,7 +273,7 @@ def test_result_item_serialization(self):
281273
expected_dict = {'foo': 'testString'}
282274
result_item_model.set_properties(expected_dict)
283275
actual_dict = result_item_model.get_properties()
284-
assert actual_dict == expected_dict
276+
assert actual_dict.keys() == expected_dict.keys()
285277

286278

287279
class TestModel_ScanResult:

0 commit comments

Comments
 (0)