Skip to content

Commit 9b425cc

Browse files
Mike Kistlergermanattanasio
authored andcommitted
Final pass of codegen for v1.0.0 SDK release (#287)
* Generated Python SDK for multiple services * Hand-coded changes to create/updateClassifier * Hand-coded changes to PIV3 profile for text/csv accept type
1 parent 9fb24f2 commit 9b425cc

8 files changed

Lines changed: 204 additions & 2111 deletions

watson_developer_cloud/conversation_v1.py

Lines changed: 2 additions & 807 deletions
Large diffs are not rendered by default.

watson_developer_cloud/discovery_v1.py

Lines changed: 3 additions & 369 deletions
Large diffs are not rendered by default.

watson_developer_cloud/language_translator_v2.py

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
your language, communicate with your customers in their own language, and more.
2121
"""
2222

23+
from __future__ import absolute_import
24+
2325
import json
2426
from .watson_service import WatsonService
2527

@@ -525,97 +527,27 @@ def __ne__(self, other):
525527
return not self == other
526528

527529

528-
class TranslateRequest(object):
529-
"""
530-
TranslateRequest.
531-
532-
:attr list[str] text: Input text in UTF-8 encoding. It is a list so that multiple paragraphs can be submitted. Also accept a single string, instead of an array, as valid input.
533-
:attr str model_id: (optional) The unique model_id of the translation model being used to translate text. The model_id inherently specifies source language, target language, and domain. If the model_id is specified, there is no need for the source and target parameters and the values are ignored.
534-
:attr str source: (optional) Used in combination with target as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
535-
:attr str target: (optional) Used in combination with source as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
536-
"""
537-
538-
def __init__(self, text, model_id=None, source=None, target=None):
539-
"""
540-
Initialize a TranslateRequest object.
541-
542-
:param list[str] text: Input text in UTF-8 encoding. It is a list so that multiple paragraphs can be submitted. Also accept a single string, instead of an array, as valid input.
543-
:param str model_id: (optional) The unique model_id of the translation model being used to translate text. The model_id inherently specifies source language, target language, and domain. If the model_id is specified, there is no need for the source and target parameters and the values are ignored.
544-
:param str source: (optional) Used in combination with target as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
545-
:param str target: (optional) Used in combination with source as an alternative way to select the model for translation. When target and source are set, and model_id is not set, the system chooses a default model with the right language pair to translate (usually the model based on the news domain).
546-
"""
547-
self.text = text
548-
self.model_id = model_id
549-
self.source = source
550-
self.target = target
551-
552-
@classmethod
553-
def _from_dict(cls, _dict):
554-
"""Initialize a TranslateRequest object from a json dictionary."""
555-
args = {}
556-
if 'text' in _dict:
557-
args['text'] = _dict['text']
558-
else:
559-
raise ValueError(
560-
'Required property \'text\' not present in TranslateRequest JSON'
561-
)
562-
if 'model_id' in _dict:
563-
args['model_id'] = _dict['model_id']
564-
if 'source' in _dict:
565-
args['source'] = _dict['source']
566-
if 'target' in _dict:
567-
args['target'] = _dict['target']
568-
return cls(**args)
569-
570-
def _to_dict(self):
571-
"""Return a json dictionary representing this model."""
572-
_dict = {}
573-
if hasattr(self, 'text') and self.text is not None:
574-
_dict['text'] = self.text
575-
if hasattr(self, 'model_id') and self.model_id is not None:
576-
_dict['model_id'] = self.model_id
577-
if hasattr(self, 'source') and self.source is not None:
578-
_dict['source'] = self.source
579-
if hasattr(self, 'target') and self.target is not None:
580-
_dict['target'] = self.target
581-
return _dict
582-
583-
def __str__(self):
584-
"""Return a `str` version of this TranslateRequest object."""
585-
return json.dumps(self._to_dict(), indent=2)
586-
587-
def __eq__(self, other):
588-
"""Return `true` when self and other are equal, false otherwise."""
589-
if not isinstance(other, self.__class__):
590-
return False
591-
return self.__dict__ == other.__dict__
592-
593-
def __ne__(self, other):
594-
"""Return `true` when self and other are not equal, false otherwise."""
595-
return not self == other
596-
597-
598530
class Translation(object):
599531
"""
600532
Translation.
601533
602-
:attr str translation: Translation output in UTF-8.
534+
:attr str translation_output: Translation output in UTF-8.
603535
"""
604536

605-
def __init__(self, translation):
537+
def __init__(self, translation_output):
606538
"""
607539
Initialize a Translation object.
608540
609-
:param str translation: Translation output in UTF-8.
541+
:param str translation_output: Translation output in UTF-8.
610542
"""
611-
self.translation = translation
543+
self.translation_output = translation_output
612544

613545
@classmethod
614546
def _from_dict(cls, _dict):
615547
"""Initialize a Translation object from a json dictionary."""
616548
args = {}
617549
if 'translation' in _dict:
618-
args['translation'] = _dict['translation']
550+
args['translation_output'] = _dict['translation']
619551
else:
620552
raise ValueError(
621553
'Required property \'translation\' not present in Translation JSON'
@@ -625,8 +557,10 @@ def _from_dict(cls, _dict):
625557
def _to_dict(self):
626558
"""Return a json dictionary representing this model."""
627559
_dict = {}
628-
if hasattr(self, 'translation') and self.translation is not None:
629-
_dict['translation'] = self.translation
560+
if hasattr(
561+
self,
562+
'translation_output') and self.translation_output is not None:
563+
_dict['translation'] = self.translation_output
630564
return _dict
631565

632566
def __str__(self):

watson_developer_cloud/natural_language_classifier_v1.py

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
those classes to new inputs.
2121
"""
2222

23+
from __future__ import absolute_import
24+
2325
import json
2426
from .watson_service import WatsonService
2527

@@ -95,9 +97,7 @@ def classify(self, classifier_id, text):
9597
def create_classifier(self,
9698
metadata,
9799
training_data,
98-
training_metadata_content_type=None,
99100
training_metadata_filename=None,
100-
training_data_content_type=None,
101101
training_data_filename=None):
102102
"""
103103
Create classifier.
@@ -107,9 +107,7 @@ def create_classifier(self,
107107
108108
:param file metadata: Metadata in JSON format. The metadata identifies the language of the data, and an optional name to identify the classifier. For details, see the [API reference](https://www.ibm.com/watson/developercloud/natural-language-classifier/api/v1/#create_classifier).
109109
:param file training_data: Training data in CSV format. Each text value must have at least one class. The data can include up to 15,000 records. For details, see [Using your own data](https://www.ibm.com/watson/developercloud/doc/natural-language-classifier/using-your-data.html).
110-
:param str training_metadata_content_type: The content type of training_metadata.
111110
:param str training_metadata_filename: The filename for training_metadata.
112-
:param str training_data_content_type: The content type of training_data.
113111
:param str training_data_filename: The filename for training_data.
114112
:return: A `dict` containing the `Classifier` response.
115113
:rtype: dict
@@ -120,11 +118,11 @@ def create_classifier(self,
120118
raise ValueError('training_data must be provided')
121119
if not training_metadata_filename and hasattr(metadata, 'name'):
122120
training_metadata_filename = metadata.name
123-
mime_type = training_metadata_content_type or 'application/octet-stream'
121+
mime_type = 'application/octet-stream'
124122
metadata_tuple = (training_metadata_filename, metadata, mime_type)
125123
if not training_data_filename and hasattr(training_data, 'name'):
126124
training_data_filename = training_data.name
127-
mime_type = training_data_content_type or 'application/octet-stream'
125+
mime_type = 'application/octet-stream'
128126
training_data_tuple = (training_data_filename, training_data, mime_type)
129127
response = self.request(
130128
method='POST',
@@ -472,51 +470,3 @@ def __eq__(self, other):
472470
def __ne__(self, other):
473471
"""Return `true` when self and other are not equal, false otherwise."""
474472
return not self == other
475-
476-
477-
class ClassifyInput(object):
478-
"""
479-
Request payload to classify.
480-
481-
:attr str text: The submitted phrase.
482-
"""
483-
484-
def __init__(self, text):
485-
"""
486-
Initialize a ClassifyInput object.
487-
488-
:param str text: The submitted phrase.
489-
"""
490-
self.text = text
491-
492-
@classmethod
493-
def _from_dict(cls, _dict):
494-
"""Initialize a ClassifyInput object from a json dictionary."""
495-
args = {}
496-
if 'text' in _dict:
497-
args['text'] = _dict['text']
498-
else:
499-
raise ValueError(
500-
'Required property \'text\' not present in ClassifyInput JSON')
501-
return cls(**args)
502-
503-
def _to_dict(self):
504-
"""Return a json dictionary representing this model."""
505-
_dict = {}
506-
if hasattr(self, 'text') and self.text is not None:
507-
_dict['text'] = self.text
508-
return _dict
509-
510-
def __str__(self):
511-
"""Return a `str` version of this ClassifyInput object."""
512-
return json.dumps(self._to_dict(), indent=2)
513-
514-
def __eq__(self, other):
515-
"""Return `true` when self and other are equal, false otherwise."""
516-
if not isinstance(other, self.__class__):
517-
return False
518-
return self.__dict__ == other.__dict__
519-
520-
def __ne__(self, other):
521-
"""Return `true` when self and other are not equal, false otherwise."""
522-
return not self == other

0 commit comments

Comments
 (0)