Skip to content

Commit 22a8b09

Browse files
chore: update services to version 3.97.0 of sdk generator
1 parent ed8859a commit 22a8b09

11 files changed

+416
-256
lines changed

ibm_watson/assistant_v1.py

Lines changed: 286 additions & 145 deletions
Large diffs are not rendered by default.

ibm_watson/discovery_v2.py

Lines changed: 97 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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.85.0-75c38f8f-20240206-210220
17+
# IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029
1818
"""
1919
IBM Watson® Discovery is a cognitive search and content analytics engine that you can
2020
add to applications to identify patterns, trends and actionable insights to drive better
@@ -4112,6 +4112,9 @@ class AnalyzedResult:
41124112
Result of the document analysis.
41134113

41144114
:param dict metadata: (optional) Metadata that was specified with the request.
4115+
4116+
This type supports additional properties of type object. The remaining key-value
4117+
pairs.
41154118
"""
41164119

41174120
# The set of defined properties for the class
@@ -4121,27 +4124,41 @@ def __init__(
41214124
self,
41224125
*,
41234126
metadata: Optional[dict] = None,
4124-
**kwargs,
4127+
**kwargs: Optional[object],
41254128
) -> None:
41264129
"""
41274130
Initialize a AnalyzedResult object.
41284131

41294132
:param dict metadata: (optional) Metadata that was specified with the
41304133
request.
4131-
:param **kwargs: (optional) Any additional properties.
4134+
:param object **kwargs: (optional) The remaining key-value pairs.
41324135
"""
41334136
self.metadata = metadata
4134-
for _key, _value in kwargs.items():
4135-
setattr(self, _key, _value)
4137+
for k, v in kwargs.items():
4138+
if k not in AnalyzedResult._properties:
4139+
if not isinstance(v, object):
4140+
raise ValueError(
4141+
'Value for additional property {} must be of type object'
4142+
.format(k))
4143+
setattr(self, k, v)
4144+
else:
4145+
raise ValueError(
4146+
'Property {} cannot be specified as an additional property'.
4147+
format(k))
41364148

41374149
@classmethod
41384150
def from_dict(cls, _dict: Dict) -> 'AnalyzedResult':
41394151
"""Initialize a AnalyzedResult object from a json dictionary."""
41404152
args = {}
41414153
if (metadata := _dict.get('metadata')) is not None:
41424154
args['metadata'] = metadata
4143-
args.update(
4144-
{k: v for (k, v) in _dict.items() if k not in cls._properties})
4155+
for k, v in _dict.items():
4156+
if k not in cls._properties:
4157+
if not isinstance(v, object):
4158+
raise ValueError(
4159+
'Value for additional property {} must be of type object'
4160+
.format(k))
4161+
args[k] = v
41454162
return cls(**args)
41464163

41474164
@classmethod
@@ -4154,39 +4171,45 @@ def to_dict(self) -> Dict:
41544171
_dict = {}
41554172
if hasattr(self, 'metadata') and self.metadata is not None:
41564173
_dict['metadata'] = self.metadata
4157-
for _key in [
4158-
k for k in vars(self).keys()
4159-
if k not in AnalyzedResult._properties
4174+
for k in [
4175+
_k for _k in vars(self).keys()
4176+
if _k not in AnalyzedResult._properties
41604177
]:
4161-
_dict[_key] = getattr(self, _key)
4178+
_dict[k] = getattr(self, k)
41624179
return _dict
41634180

41644181
def _to_dict(self):
41654182
"""Return a json dictionary representing this model."""
41664183
return self.to_dict()
41674184

41684185
def get_properties(self) -> Dict:
4169-
"""Return a dictionary of arbitrary properties from this instance of AnalyzedResult"""
4186+
"""Return the additional properties from this instance of AnalyzedResult in the form of a dict."""
41704187
_dict = {}
4171-
4172-
for _key in [
4173-
k for k in vars(self).keys()
4174-
if k not in AnalyzedResult._properties
4188+
for k in [
4189+
_k for _k in vars(self).keys()
4190+
if _k not in AnalyzedResult._properties
41754191
]:
4176-
_dict[_key] = getattr(self, _key)
4192+
_dict[k] = getattr(self, k)
41774193
return _dict
41784194

41794195
def set_properties(self, _dict: dict):
4180-
"""Set a dictionary of arbitrary properties to this instance of AnalyzedResult"""
4181-
for _key in [
4182-
k for k in vars(self).keys()
4183-
if k not in AnalyzedResult._properties
4196+
"""Set a dictionary of additional properties in this instance of AnalyzedResult"""
4197+
for k in [
4198+
_k for _k in vars(self).keys()
4199+
if _k not in AnalyzedResult._properties
41844200
]:
4185-
delattr(self, _key)
4186-
4187-
for _key, _value in _dict.items():
4188-
if _key not in AnalyzedResult._properties:
4189-
setattr(self, _key, _value)
4201+
delattr(self, k)
4202+
for k, v in _dict.items():
4203+
if k not in AnalyzedResult._properties:
4204+
if not isinstance(v, object):
4205+
raise ValueError(
4206+
'Value for additional property {} must be of type object'
4207+
.format(k))
4208+
setattr(self, k, v)
4209+
else:
4210+
raise ValueError(
4211+
'Property {} cannot be specified as an additional property'.
4212+
format(k))
41904213

41914214
def __str__(self) -> str:
41924215
"""Return a `str` version of this AnalyzedResult object."""
@@ -10266,6 +10289,9 @@ class QueryResult:
1026610289
:param List[QueryResultPassage] document_passages: (optional) Passages from the
1026710290
document that best matches the query. Returned if **passages.per_document** is
1026810291
`true`.
10292+
10293+
This type supports additional properties of type object. The remaining key-value
10294+
pairs.
1026910295
"""
1027010296

1027110297
# The set of defined properties for the class
@@ -10279,7 +10305,7 @@ def __init__(
1027910305
*,
1028010306
metadata: Optional[dict] = None,
1028110307
document_passages: Optional[List['QueryResultPassage']] = None,
10282-
**kwargs,
10308+
**kwargs: Optional[object],
1028310309
) -> None:
1028410310
"""
1028510311
Initialize a QueryResult object.
@@ -10290,14 +10316,23 @@ def __init__(
1029010316
:param List[QueryResultPassage] document_passages: (optional) Passages from
1029110317
the document that best matches the query. Returned if
1029210318
**passages.per_document** is `true`.
10293-
:param **kwargs: (optional) Any additional properties.
10319+
:param object **kwargs: (optional) The remaining key-value pairs.
1029410320
"""
1029510321
self.document_id = document_id
1029610322
self.metadata = metadata
1029710323
self.result_metadata = result_metadata
1029810324
self.document_passages = document_passages
10299-
for _key, _value in kwargs.items():
10300-
setattr(self, _key, _value)
10325+
for k, v in kwargs.items():
10326+
if k not in QueryResult._properties:
10327+
if not isinstance(v, object):
10328+
raise ValueError(
10329+
'Value for additional property {} must be of type object'
10330+
.format(k))
10331+
setattr(self, k, v)
10332+
else:
10333+
raise ValueError(
10334+
'Property {} cannot be specified as an additional property'.
10335+
format(k))
1030110336

1030210337
@classmethod
1030310338
def from_dict(cls, _dict: Dict) -> 'QueryResult':
@@ -10322,8 +10357,13 @@ def from_dict(cls, _dict: Dict) -> 'QueryResult':
1032210357
args['document_passages'] = [
1032310358
QueryResultPassage.from_dict(v) for v in document_passages
1032410359
]
10325-
args.update(
10326-
{k: v for (k, v) in _dict.items() if k not in cls._properties})
10360+
for k, v in _dict.items():
10361+
if k not in cls._properties:
10362+
if not isinstance(v, object):
10363+
raise ValueError(
10364+
'Value for additional property {} must be of type object'
10365+
.format(k))
10366+
args[k] = v
1032710367
return cls(**args)
1032810368

1032910369
@classmethod
@@ -10353,36 +10393,45 @@ def to_dict(self) -> Dict:
1035310393
else:
1035410394
document_passages_list.append(v.to_dict())
1035510395
_dict['document_passages'] = document_passages_list
10356-
for _key in [
10357-
k for k in vars(self).keys() if k not in QueryResult._properties
10396+
for k in [
10397+
_k for _k in vars(self).keys()
10398+
if _k not in QueryResult._properties
1035810399
]:
10359-
_dict[_key] = getattr(self, _key)
10400+
_dict[k] = getattr(self, k)
1036010401
return _dict
1036110402

1036210403
def _to_dict(self):
1036310404
"""Return a json dictionary representing this model."""
1036410405
return self.to_dict()
1036510406

1036610407
def get_properties(self) -> Dict:
10367-
"""Return a dictionary of arbitrary properties from this instance of QueryResult"""
10408+
"""Return the additional properties from this instance of QueryResult in the form of a dict."""
1036810409
_dict = {}
10369-
10370-
for _key in [
10371-
k for k in vars(self).keys() if k not in QueryResult._properties
10410+
for k in [
10411+
_k for _k in vars(self).keys()
10412+
if _k not in QueryResult._properties
1037210413
]:
10373-
_dict[_key] = getattr(self, _key)
10414+
_dict[k] = getattr(self, k)
1037410415
return _dict
1037510416

1037610417
def set_properties(self, _dict: dict):
10377-
"""Set a dictionary of arbitrary properties to this instance of QueryResult"""
10378-
for _key in [
10379-
k for k in vars(self).keys() if k not in QueryResult._properties
10418+
"""Set a dictionary of additional properties in this instance of QueryResult"""
10419+
for k in [
10420+
_k for _k in vars(self).keys()
10421+
if _k not in QueryResult._properties
1038010422
]:
10381-
delattr(self, _key)
10382-
10383-
for _key, _value in _dict.items():
10384-
if _key not in QueryResult._properties:
10385-
setattr(self, _key, _value)
10423+
delattr(self, k)
10424+
for k, v in _dict.items():
10425+
if k not in QueryResult._properties:
10426+
if not isinstance(v, object):
10427+
raise ValueError(
10428+
'Value for additional property {} must be of type object'
10429+
.format(k))
10430+
setattr(self, k, v)
10431+
else:
10432+
raise ValueError(
10433+
'Property {} cannot be specified as an additional property'.
10434+
format(k))
1038610435

1038710436
def __str__(self) -> str:
1038810437
"""Return a `str` version of this QueryResult object."""

ibm_watson/natural_language_understanding_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.85.0-75c38f8f-20240206-210220
17+
# IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029
1818
"""
1919
Analyze various features of text content at scale. Provide text, raw HTML, or a public URL
2020
and IBM Watson Natural Language Understanding will give you results for the features you

ibm_watson/speech_to_text_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.85.0-75c38f8f-20240206-210220
17+
# IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029
1818
"""
1919
The IBM Watson™ Speech to Text service provides APIs that use IBM's
2020
speech-recognition capabilities to produce transcripts of spoken audio. The service can

ibm_watson/text_to_speech_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.85.0-75c38f8f-20240206-210220
17+
# IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029
1818
"""
1919
The IBM Watson™ Text to Speech service provides APIs that use IBM's speech-synthesis
2020
capabilities to synthesize text into natural-sounding speech in a variety of languages,

test/integration/test_natural_language_understanding_v1.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
import json
77
import time
88
from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
9+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
910

10-
@pytest.mark.skipif(os.getenv('NATURAL_LANGUAGE_UNDERSTANDING_APIKEY') is None,
11-
reason='requires NATURAL_LANGUAGE_UNDERSTANDING_APIKEY')
1211
class TestNaturalLanguageUnderstandingV1(TestCase):
1312

1413
def setUp(self):
15-
self.natural_language_understanding = ibm_watson.NaturalLanguageUnderstandingV1(version='2018-03-16')
16-
self.natural_language_understanding.set_default_headers({
17-
'X-Watson-Learning-Opt-Out': '1',
18-
'X-Watson-Test': '1'
19-
})
14+
15+
with open('./auth.json') as f:
16+
data = json.load(f)
17+
nlu_auth = data.get("nlu")
18+
19+
self.authenticator = IAMAuthenticator(nlu_auth.get("apikey"))
20+
self.natural_language_understanding = ibm_watson.NaturalLanguageUnderstandingV1(version='2018-03-16', authenticator=self.authenticator)
21+
self.natural_language_understanding.set_default_headers({
22+
'X-Watson-Learning-Opt-Out': '1',
23+
'X-Watson-Test': '1'
24+
})
2025

2126
def test_analyze(self):
2227
response = self.natural_language_understanding.analyze(

test/unit/test_assistant_v1.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,13 @@ def preprocess_url(operation_path: str):
4747
The returned request URL is used to register the mock response so it needs
4848
to match the request URL that is formed by the requests library.
4949
"""
50-
# First, unquote the path since it might have some quoted/escaped characters in it
51-
# due to how the generator inserts the operation paths into the unit test code.
52-
operation_path = urllib.parse.unquote(operation_path)
5350

54-
# Next, quote the path using urllib so that we approximate what will
55-
# happen during request processing.
56-
operation_path = urllib.parse.quote(operation_path, safe='/')
57-
58-
# Finally, form the request URL from the base URL and operation path.
51+
# Form the request URL from the base URL and operation path.
5952
request_url = _base_url + operation_path
6053

6154
# If the request url does NOT end with a /, then just return it as-is.
6255
# Otherwise, return a regular expression that matches one or more trailing /.
63-
if re.fullmatch('.*/+', request_url) is None:
56+
if not request_url.endswith('/'):
6457
return request_url
6558
return re.compile(request_url.rstrip('/') + '/+')
6659

@@ -8539,7 +8532,7 @@ def test_context_serialization(self):
85398532
expected_dict = {'foo': 'testString'}
85408533
context_model.set_properties(expected_dict)
85418534
actual_dict = context_model.get_properties()
8542-
assert actual_dict == expected_dict
8535+
assert actual_dict.keys() == expected_dict.keys()
85438536

85448537

85458538
class TestModel_Counterexample:
@@ -8995,7 +8988,7 @@ def test_dialog_node_context_serialization(self):
89958988
expected_dict = {'foo': 'testString'}
89968989
dialog_node_context_model.set_properties(expected_dict)
89978990
actual_dict = dialog_node_context_model.get_properties()
8998-
assert actual_dict == expected_dict
8991+
assert actual_dict.keys() == expected_dict.keys()
89998992

90008993

90018994
class TestModel_DialogNodeNextStep:
@@ -9088,7 +9081,7 @@ def test_dialog_node_output_serialization(self):
90889081
expected_dict = {'foo': 'testString'}
90899082
dialog_node_output_model.set_properties(expected_dict)
90909083
actual_dict = dialog_node_output_model.get_properties()
9091-
assert actual_dict == expected_dict
9084+
assert actual_dict.keys() == expected_dict.keys()
90929085

90939086

90949087
class TestModel_DialogNodeOutputConnectToAgentTransferInfo:
@@ -10476,7 +10469,7 @@ def test_message_input_serialization(self):
1047610469
expected_dict = {'foo': 'testString'}
1047710470
message_input_model.set_properties(expected_dict)
1047810471
actual_dict = message_input_model.get_properties()
10479-
assert actual_dict == expected_dict
10472+
assert actual_dict.keys() == expected_dict.keys()
1048010473

1048110474

1048210475
class TestModel_MessageRequest:
@@ -10819,7 +10812,7 @@ def test_output_data_serialization(self):
1081910812
expected_dict = {'foo': 'testString'}
1082010813
output_data_model.set_properties(expected_dict)
1082110814
actual_dict = output_data_model.get_properties()
10822-
assert actual_dict == expected_dict
10815+
assert actual_dict.keys() == expected_dict.keys()
1082310816

1082410817

1082510818
class TestModel_Pagination:
@@ -11823,7 +11816,7 @@ def test_workspace_system_settings_serialization(self):
1182311816
expected_dict = {'foo': 'testString'}
1182411817
workspace_system_settings_model.set_properties(expected_dict)
1182511818
actual_dict = workspace_system_settings_model.get_properties()
11826-
assert actual_dict == expected_dict
11819+
assert actual_dict.keys() == expected_dict.keys()
1182711820

1182811821

1182911822
class TestModel_WorkspaceSystemSettingsDisambiguation:

0 commit comments

Comments
 (0)