Skip to content

Commit 2e0e8f5

Browse files
committed
feat(Discovery): New method get_stopword_list_status
1 parent 3279cec commit 2e0e8f5

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

test/unit/test_discovery_v1.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,12 @@ def test_stopword_operations():
12291229
responses.DELETE,
12301230
url,
12311231
status=200)
1232+
responses.add(
1233+
responses.GET,
1234+
url,
1235+
body='{"status": "ready", "type": "stopwords"}',
1236+
status=200,
1237+
content_type='application_json')
12321238

12331239
discovery = watson_developer_cloud.DiscoveryV1('2017-11-07', username="username", password="password")
12341240

@@ -1237,10 +1243,13 @@ def test_stopword_operations():
12371243
discovery.create_stopword_list('envid', 'colid', file)
12381244
assert responses.calls[0].response.json() == {"status": "pending", "type": "stopwords"}
12391245

1246+
discovery.get_stopword_list_status('envid', 'colid')
1247+
assert responses.calls[1].response.json() == {"status": "ready", "type": "stopwords"}
1248+
12401249
discovery.delete_stopword_list('envid', 'colid')
1241-
assert responses.calls[1].response.status_code == 200
1250+
assert responses.calls[2].response.status_code == 200
12421251

1243-
assert len(responses.calls) == 2
1252+
assert len(responses.calls) == 3
12441253

12451254
@responses.activate
12461255
def test_gateway_configuration():

watson_developer_cloud/discovery_v1.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,42 @@ def delete_tokenization_dictionary(self, environment_id, collection_id,
11791179
accept_json=True)
11801180
return response
11811181

1182+
def get_stopword_list_status(self, environment_id, collection_id, **kwargs):
1183+
"""
1184+
Get stopword list status.
1185+
1186+
Returns the current status of the stopword list for the specified collection.
1187+
1188+
:param str environment_id: The ID of the environment.
1189+
:param str collection_id: The ID of the collection.
1190+
:param dict headers: A `dict` containing the request headers
1191+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
1192+
:rtype: DetailedResponse
1193+
"""
1194+
1195+
if environment_id is None:
1196+
raise ValueError('environment_id must be provided')
1197+
if collection_id is None:
1198+
raise ValueError('collection_id must be provided')
1199+
1200+
headers = {}
1201+
if 'headers' in kwargs:
1202+
headers.update(kwargs.get('headers'))
1203+
headers[
1204+
'X-IBMCloud-SDK-Analytics'] = 'service_name=discovery;service_version=V1;operation_id=get_stopword_list_status'
1205+
1206+
params = {'version': self.version}
1207+
1208+
url = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format(
1209+
*self._encode_path_vars(environment_id, collection_id))
1210+
response = self.request(
1211+
method='GET',
1212+
url=url,
1213+
headers=headers,
1214+
params=params,
1215+
accept_json=True)
1216+
return response
1217+
11821218
def get_tokenization_dictionary_status(self, environment_id, collection_id,
11831219
**kwargs):
11841220
"""

0 commit comments

Comments
 (0)