Skip to content

Commit ab880f0

Browse files
fix(disco_v1): update type of status to reflect service changes
1 parent 9954e59 commit ab880f0

File tree

2 files changed

+159
-51
lines changed

2 files changed

+159
-51
lines changed

ibm_watson/discovery_v1.py

Lines changed: 85 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,7 @@ def create_credentials(self,
33683368
*,
33693369
source_type: str = None,
33703370
credential_details: 'CredentialDetails' = None,
3371-
status: str = None,
3371+
status: 'StatusDetails' = None,
33723372
**kwargs) -> DetailedResponse:
33733373
"""
33743374
Create credentials.
@@ -3393,11 +3393,8 @@ def create_credentials(self,
33933393
:param CredentialDetails credential_details: (optional) Object containing
33943394
details of the stored credentials.
33953395
Obtain credentials for your source from the administrator of the source.
3396-
:param str status: (optional) The current status of this set of
3397-
credentials. `connected` indicates that the credentials are available to
3398-
use with the source configuration of a collection. `invalid` refers to the
3399-
credentials (for example, the password provided has expired) and must be
3400-
corrected before they can be used with a collection.
3396+
:param StatusDetails status: (optional) Object that contains details about
3397+
the status of the authentication process.
34013398
:param dict headers: A `dict` containing the request headers
34023399
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
34033400
:rtype: DetailedResponse with `dict` result representing a `Credentials` object
@@ -3407,6 +3404,8 @@ def create_credentials(self,
34073404
raise ValueError('environment_id must be provided')
34083405
if credential_details is not None:
34093406
credential_details = convert_model(credential_details)
3407+
if status is not None:
3408+
status = convert_model(status)
34103409
headers = {}
34113410
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
34123411
service_version='V1',
@@ -3494,7 +3493,7 @@ def update_credentials(self,
34943493
*,
34953494
source_type: str = None,
34963495
credential_details: 'CredentialDetails' = None,
3497-
status: str = None,
3496+
status: 'StatusDetails' = None,
34983497
**kwargs) -> DetailedResponse:
34993498
"""
35003499
Update credentials.
@@ -3520,11 +3519,8 @@ def update_credentials(self,
35203519
:param CredentialDetails credential_details: (optional) Object containing
35213520
details of the stored credentials.
35223521
Obtain credentials for your source from the administrator of the source.
3523-
:param str status: (optional) The current status of this set of
3524-
credentials. `connected` indicates that the credentials are available to
3525-
use with the source configuration of a collection. `invalid` refers to the
3526-
credentials (for example, the password provided has expired) and must be
3527-
corrected before they can be used with a collection.
3522+
:param StatusDetails status: (optional) Object that contains details about
3523+
the status of the authentication process.
35283524
:param dict headers: A `dict` containing the request headers
35293525
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
35303526
:rtype: DetailedResponse with `dict` result representing a `Credentials` object
@@ -3536,6 +3532,8 @@ def update_credentials(self,
35363532
raise ValueError('credential_id must be provided')
35373533
if credential_details is not None:
35383534
credential_details = convert_model(credential_details)
3535+
if status is not None:
3536+
status = convert_model(status)
35393537
headers = {}
35403538
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
35413539
service_version='V1',
@@ -5077,19 +5075,16 @@ class Credentials():
50775075
:attr CredentialDetails credential_details: (optional) Object containing details
50785076
of the stored credentials.
50795077
Obtain credentials for your source from the administrator of the source.
5080-
:attr str status: (optional) The current status of this set of credentials.
5081-
`connected` indicates that the credentials are available to use with the source
5082-
configuration of a collection. `invalid` refers to the credentials (for example,
5083-
the password provided has expired) and must be corrected before they can be used
5084-
with a collection.
5078+
:attr StatusDetails status: (optional) Object that contains details about the
5079+
status of the authentication process.
50855080
"""
50865081

50875082
def __init__(self,
50885083
*,
50895084
credential_id: str = None,
50905085
source_type: str = None,
50915086
credential_details: 'CredentialDetails' = None,
5092-
status: str = None) -> None:
5087+
status: 'StatusDetails' = None) -> None:
50935088
"""
50945089
Initialize a Credentials object.
50955090

@@ -5107,11 +5102,8 @@ def __init__(self,
51075102
:param CredentialDetails credential_details: (optional) Object containing
51085103
details of the stored credentials.
51095104
Obtain credentials for your source from the administrator of the source.
5110-
:param str status: (optional) The current status of this set of
5111-
credentials. `connected` indicates that the credentials are available to
5112-
use with the source configuration of a collection. `invalid` refers to the
5113-
credentials (for example, the password provided has expired) and must be
5114-
corrected before they can be used with a collection.
5105+
:param StatusDetails status: (optional) Object that contains details about
5106+
the status of the authentication process.
51155107
"""
51165108
self.credential_id = credential_id
51175109
self.source_type = source_type
@@ -5130,7 +5122,7 @@ def from_dict(cls, _dict: Dict) -> 'Credentials':
51305122
args['credential_details'] = CredentialDetails.from_dict(
51315123
_dict.get('credential_details'))
51325124
if 'status' in _dict:
5133-
args['status'] = _dict.get('status')
5125+
args['status'] = StatusDetails.from_dict(_dict.get('status'))
51345126
return cls(**args)
51355127

51365128
@classmethod
@@ -5151,7 +5143,7 @@ def to_dict(self) -> Dict:
51515143
'credential_details') and self.credential_details is not None:
51525144
_dict['credential_details'] = self.credential_details.to_dict()
51535145
if hasattr(self, 'status') and self.status is not None:
5154-
_dict['status'] = self.status
5146+
_dict['status'] = self.status.to_dict()
51555147
return _dict
51565148

51575149
def _to_dict(self):
@@ -5190,16 +5182,6 @@ class SourceTypeEnum(str, Enum):
51905182
WEB_CRAWL = 'web_crawl'
51915183
CLOUD_OBJECT_STORAGE = 'cloud_object_storage'
51925184

5193-
class StatusEnum(str, Enum):
5194-
"""
5195-
The current status of this set of credentials. `connected` indicates that the
5196-
credentials are available to use with the source configuration of a collection.
5197-
`invalid` refers to the credentials (for example, the password provided has
5198-
expired) and must be corrected before they can be used with a collection.
5199-
"""
5200-
CONNECTED = 'connected'
5201-
INVALID = 'invalid'
5202-
52035185

52045186
class CredentialsList():
52055187
"""
@@ -11981,6 +11963,74 @@ class StatusEnum(str, Enum):
1198111963
UNKNOWN = 'unknown'
1198211964

1198311965

11966+
class StatusDetails():
11967+
"""
11968+
Object that contains details about the status of the authentication process.
11969+
11970+
:attr bool authentication: (optional) Indicates whether the credential is
11971+
accepted by the target data source.
11972+
:attr str error_message: (optional) If `authentication` is `false`, a message
11973+
describes why the authentication was unsuccessful.
11974+
"""
11975+
11976+
def __init__(self,
11977+
*,
11978+
authentication: bool = None,
11979+
error_message: str = None) -> None:
11980+
"""
11981+
Initialize a StatusDetails object.
11982+
11983+
:param bool authentication: (optional) Indicates whether the credential is
11984+
accepted by the target data source.
11985+
:param str error_message: (optional) If `authentication` is `false`, a
11986+
message describes why the authentication was unsuccessful.
11987+
"""
11988+
self.authentication = authentication
11989+
self.error_message = error_message
11990+
11991+
@classmethod
11992+
def from_dict(cls, _dict: Dict) -> 'StatusDetails':
11993+
"""Initialize a StatusDetails object from a json dictionary."""
11994+
args = {}
11995+
if 'authentication' in _dict:
11996+
args['authentication'] = _dict.get('authentication')
11997+
if 'error_message' in _dict:
11998+
args['error_message'] = _dict.get('error_message')
11999+
return cls(**args)
12000+
12001+
@classmethod
12002+
def _from_dict(cls, _dict):
12003+
"""Initialize a StatusDetails object from a json dictionary."""
12004+
return cls.from_dict(_dict)
12005+
12006+
def to_dict(self) -> Dict:
12007+
"""Return a json dictionary representing this model."""
12008+
_dict = {}
12009+
if hasattr(self, 'authentication') and self.authentication is not None:
12010+
_dict['authentication'] = self.authentication
12011+
if hasattr(self, 'error_message') and self.error_message is not None:
12012+
_dict['error_message'] = self.error_message
12013+
return _dict
12014+
12015+
def _to_dict(self):
12016+
"""Return a json dictionary representing this model."""
12017+
return self.to_dict()
12018+
12019+
def __str__(self) -> str:
12020+
"""Return a `str` version of this StatusDetails object."""
12021+
return json.dumps(self.to_dict(), indent=2)
12022+
12023+
def __eq__(self, other: 'StatusDetails') -> bool:
12024+
"""Return `true` when self and other are equal, false otherwise."""
12025+
if not isinstance(other, self.__class__):
12026+
return False
12027+
return self.__dict__ == other.__dict__
12028+
12029+
def __ne__(self, other: 'StatusDetails') -> bool:
12030+
"""Return `true` when self and other are not equal, false otherwise."""
12031+
return not self == other
12032+
12033+
1198412034
class TokenDictRule():
1198512035
"""
1198612036
An object defining a single tokenizaion rule.

0 commit comments

Comments
 (0)