Skip to content

Commit

Permalink
feat(CompareComply): remove before and after from list feedback
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove before and after from list feedback
  • Loading branch information
mamoonraja committed Nov 16, 2020
1 parent 59e7ded commit 5af17b7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 69 deletions.
113 changes: 48 additions & 65 deletions ibm_watson/compare_comply_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import json
from ibm_cloud_sdk_core.authenticators.authenticator import Authenticator
from .common import get_sdk_headers
from datetime import date
from datetime import datetime
from enum import Enum
from ibm_cloud_sdk_core import BaseService
Expand All @@ -44,10 +43,10 @@ class CompareComplyV1(BaseService):
DEFAULT_SERVICE_NAME = 'compare_comply'

def __init__(
self,
version: str,
authenticator: Authenticator = None,
service_name: str = DEFAULT_SERVICE_NAME,
self,
version: str,
authenticator: Authenticator = None,
service_name: str = DEFAULT_SERVICE_NAME,
) -> None:
"""
Construct a new client for the Compare Comply service.
Expand Down Expand Up @@ -370,8 +369,6 @@ def add_feedback(self,
def list_feedback(self,
*,
feedback_type: str = None,
before: date = None,
after: date = None,
document_title: str = None,
model_id: str = None,
model_version: str = None,
Expand All @@ -394,12 +391,6 @@ def list_feedback(self,
:param str feedback_type: (optional) An optional string that filters the
output to include only feedback with the specified feedback type. The only
permitted value is `element_classification`.
:param date before: (optional) An optional string in the format
`YYYY-MM-DD` that filters the output to include only feedback that was
added before the specified date.
:param date after: (optional) An optional string in the format `YYYY-MM-DD`
that filters the output to include only feedback that was added after the
specified date.
:param str document_title: (optional) An optional string that filters the
output to include only feedback from the document with the specified
`document_title`.
Expand Down Expand Up @@ -461,8 +452,6 @@ def list_feedback(self,
params = {
'version': self.version,
'feedback_type': feedback_type,
'before': before,
'after': after,
'document_title': document_title,
'model_id': model_id,
'model_version': model_version,
Expand Down Expand Up @@ -1731,27 +1720,33 @@ class Category():
:attr str label: (optional) The category of the associated element.
:attr List[str] provenance_ids: (optional) Hashed values that you can send to
IBM to provide feedback or receive support.
:attr str modification: (optional) The type of modification of the feedback
entry in the updated labels response.
"""

def __init__(self,
*,
label: str = None,
provenance_ids: List[str] = None) -> None:
provenance_ids: List[str] = None,
modification: str = None) -> None:
"""
Initialize a Category object.
:param str label: (optional) The category of the associated element.
:param List[str] provenance_ids: (optional) Hashed values that you can send
to IBM to provide feedback or receive support.
:param str modification: (optional) The type of modification of the
feedback entry in the updated labels response.
"""
self.label = label
self.provenance_ids = provenance_ids
self.modification = modification

@classmethod
def from_dict(cls, _dict: Dict) -> 'Category':
"""Initialize a Category object from a json dictionary."""
args = {}
valid_keys = ['label', 'provenance_ids']
valid_keys = ['label', 'provenance_ids', 'modification']
bad_keys = set(_dict.keys()) - set(valid_keys)
if bad_keys:
raise ValueError(
Expand All @@ -1761,6 +1756,8 @@ def from_dict(cls, _dict: Dict) -> 'Category':
args['label'] = _dict.get('label')
if 'provenance_ids' in _dict:
args['provenance_ids'] = _dict.get('provenance_ids')
if 'modification' in _dict:
args['modification'] = _dict.get('modification')
return cls(**args)

@classmethod
Expand All @@ -1775,6 +1772,8 @@ def to_dict(self) -> Dict:
_dict['label'] = self.label
if hasattr(self, 'provenance_ids') and self.provenance_ids is not None:
_dict['provenance_ids'] = self.provenance_ids
if hasattr(self, 'modification') and self.modification is not None:
_dict['modification'] = self.modification
return _dict

def _to_dict(self):
Expand Down Expand Up @@ -1825,6 +1824,14 @@ class LabelEnum(Enum):
TERM_TERMINATION = "Term & Termination"
WARRANTIES = "Warranties"

class ModificationEnum(Enum):
"""
The type of modification of the feedback entry in the updated labels response.
"""
ADDED = "added"
UNCHANGED = "unchanged"
REMOVED = "removed"


class CategoryComparison():
"""
Expand Down Expand Up @@ -5243,16 +5250,12 @@ class OriginalLabelsOut():
the element and whom it affects.
:attr List[Category] categories: (optional) List of functional categories into
which the element falls; in other words, the subject matter of the element.
:attr str modification: (optional) A string identifying the type of modification
the feedback entry in the `updated_labels` array. Possible values are `added`,
`not_changed`, and `removed`.
"""

def __init__(self,
*,
types: List['TypeLabel'] = None,
categories: List['Category'] = None,
modification: str = None) -> None:
categories: List['Category'] = None) -> None:
"""
Initialize a OriginalLabelsOut object.
Expand All @@ -5261,19 +5264,15 @@ def __init__(self,
:param List[Category] categories: (optional) List of functional categories
into which the element falls; in other words, the subject matter of the
element.
:param str modification: (optional) A string identifying the type of
modification the feedback entry in the `updated_labels` array. Possible
values are `added`, `not_changed`, and `removed`.
"""
self.types = types
self.categories = categories
self.modification = modification

@classmethod
def from_dict(cls, _dict: Dict) -> 'OriginalLabelsOut':
"""Initialize a OriginalLabelsOut object from a json dictionary."""
args = {}
valid_keys = ['types', 'categories', 'modification']
valid_keys = ['types', 'categories']
bad_keys = set(_dict.keys()) - set(valid_keys)
if bad_keys:
raise ValueError(
Expand All @@ -5287,8 +5286,6 @@ def from_dict(cls, _dict: Dict) -> 'OriginalLabelsOut':
args['categories'] = [
Category._from_dict(x) for x in (_dict.get('categories'))
]
if 'modification' in _dict:
args['modification'] = _dict.get('modification')
return cls(**args)

@classmethod
Expand All @@ -5303,8 +5300,6 @@ def to_dict(self) -> Dict:
_dict['types'] = [x._to_dict() for x in self.types]
if hasattr(self, 'categories') and self.categories is not None:
_dict['categories'] = [x._to_dict() for x in self.categories]
if hasattr(self, 'modification') and self.modification is not None:
_dict['modification'] = self.modification
return _dict

def _to_dict(self):
Expand All @@ -5325,15 +5320,6 @@ def __ne__(self, other: 'OriginalLabelsOut') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other

class ModificationEnum(Enum):
"""
A string identifying the type of modification the feedback entry in the
`updated_labels` array. Possible values are `added`, `not_changed`, and `removed`.
"""
ADDED = "added"
NOT_CHANGED = "not_changed"
REMOVED = "removed"


class Pagination():
"""
Expand Down Expand Up @@ -6775,12 +6761,15 @@ class TypeLabel():
and the `party` object identifies the affected party.
:attr List[str] provenance_ids: (optional) Hashed values that you can send to
IBM to provide feedback or receive support.
:attr str modification: (optional) The type of modification of the feedback
entry in the updated labels response.
"""

def __init__(self,
*,
label: 'Label' = None,
provenance_ids: List[str] = None) -> None:
provenance_ids: List[str] = None,
modification: str = None) -> None:
"""
Initialize a TypeLabel object.
Expand All @@ -6789,15 +6778,18 @@ def __init__(self,
`party`, and the `party` object identifies the affected party.
:param List[str] provenance_ids: (optional) Hashed values that you can send
to IBM to provide feedback or receive support.
:param str modification: (optional) The type of modification of the
feedback entry in the updated labels response.
"""
self.label = label
self.provenance_ids = provenance_ids
self.modification = modification

@classmethod
def from_dict(cls, _dict: Dict) -> 'TypeLabel':
"""Initialize a TypeLabel object from a json dictionary."""
args = {}
valid_keys = ['label', 'provenance_ids']
valid_keys = ['label', 'provenance_ids', 'modification']
bad_keys = set(_dict.keys()) - set(valid_keys)
if bad_keys:
raise ValueError(
Expand All @@ -6807,6 +6799,8 @@ def from_dict(cls, _dict: Dict) -> 'TypeLabel':
args['label'] = Label._from_dict(_dict.get('label'))
if 'provenance_ids' in _dict:
args['provenance_ids'] = _dict.get('provenance_ids')
if 'modification' in _dict:
args['modification'] = _dict.get('modification')
return cls(**args)

@classmethod
Expand All @@ -6821,6 +6815,8 @@ def to_dict(self) -> Dict:
_dict['label'] = self.label._to_dict()
if hasattr(self, 'provenance_ids') and self.provenance_ids is not None:
_dict['provenance_ids'] = self.provenance_ids
if hasattr(self, 'modification') and self.modification is not None:
_dict['modification'] = self.modification
return _dict

def _to_dict(self):
Expand All @@ -6841,6 +6837,14 @@ def __ne__(self, other: 'TypeLabel') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other

class ModificationEnum(Enum):
"""
The type of modification of the feedback entry in the updated labels response.
"""
ADDED = "added"
UNCHANGED = "unchanged"
REMOVED = "removed"


class TypeLabelComparison():
"""
Expand Down Expand Up @@ -7124,16 +7128,12 @@ class UpdatedLabelsOut():
the element and whom it affects.
:attr List[Category] categories: (optional) List of functional categories into
which the element falls; in other words, the subject matter of the element.
:attr str modification: (optional) The type of modification the feedback entry
in the `updated_labels` array. Possible values are `added`, `not_changed`, and
`removed`.
"""

def __init__(self,
*,
types: List['TypeLabel'] = None,
categories: List['Category'] = None,
modification: str = None) -> None:
categories: List['Category'] = None) -> None:
"""
Initialize a UpdatedLabelsOut object.
Expand All @@ -7142,19 +7142,15 @@ def __init__(self,
:param List[Category] categories: (optional) List of functional categories
into which the element falls; in other words, the subject matter of the
element.
:param str modification: (optional) The type of modification the feedback
entry in the `updated_labels` array. Possible values are `added`,
`not_changed`, and `removed`.
"""
self.types = types
self.categories = categories
self.modification = modification

@classmethod
def from_dict(cls, _dict: Dict) -> 'UpdatedLabelsOut':
"""Initialize a UpdatedLabelsOut object from a json dictionary."""
args = {}
valid_keys = ['types', 'categories', 'modification']
valid_keys = ['types', 'categories']
bad_keys = set(_dict.keys()) - set(valid_keys)
if bad_keys:
raise ValueError(
Expand All @@ -7168,8 +7164,6 @@ def from_dict(cls, _dict: Dict) -> 'UpdatedLabelsOut':
args['categories'] = [
Category._from_dict(x) for x in (_dict.get('categories'))
]
if 'modification' in _dict:
args['modification'] = _dict.get('modification')
return cls(**args)

@classmethod
Expand All @@ -7184,8 +7178,6 @@ def to_dict(self) -> Dict:
_dict['types'] = [x._to_dict() for x in self.types]
if hasattr(self, 'categories') and self.categories is not None:
_dict['categories'] = [x._to_dict() for x in self.categories]
if hasattr(self, 'modification') and self.modification is not None:
_dict['modification'] = self.modification
return _dict

def _to_dict(self):
Expand All @@ -7206,15 +7198,6 @@ def __ne__(self, other: 'UpdatedLabelsOut') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other

class ModificationEnum(Enum):
"""
The type of modification the feedback entry in the `updated_labels` array.
Possible values are `added`, `not_changed`, and `removed`.
"""
ADDED = "added"
NOT_CHANGED = "not_changed"
REMOVED = "removed"


class Value():
"""
Expand Down
6 changes: 2 additions & 4 deletions test/unit/test_compare_comply_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,6 @@ def call_service(self, body):
def construct_full_body(self):
body = dict()
body['feedback_type'] = "string1"
body['before'] = datetime.now().date()
body['after'] = datetime.now().date()
body['document_title'] = "string1"
body['model_id'] = "string1"
body['model_version'] = "string1"
Expand Down Expand Up @@ -1035,9 +1033,9 @@ def send_request(obj, body, response, url=None):
fake_response_ClassifyReturn_json = """{"document": {"title": "fake_title", "html": "fake_html", "hash": "fake_hash", "label": "fake_label"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "elements": [], "effective_dates": [], "contract_amounts": [], "termination_dates": [], "contract_types": [], "contract_terms": [], "payment_terms": [], "contract_currencies": [], "tables": [], "document_structure": {"section_titles": [], "leading_sentences": [], "paragraphs": []}, "parties": []}"""
fake_response_TableReturn_json = """{"document": {"html": "fake_html", "title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "tables": []}"""
fake_response_CompareReturn_json = """{"model_id": "fake_model_id", "model_version": "fake_model_version", "documents": [], "aligned_elements": [], "unaligned_elements": []}"""
fake_response_FeedbackReturn_json = """{"feedback_id": "fake_feedback_id", "user_id": "fake_user_id", "comment": "fake_comment", "created": "2017-05-16T13:56:54.957Z", "feedback_data": {"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": [], "modification": "fake_modification"}, "updated_labels": {"types": [], "categories": [], "modification": "fake_modification"}, "pagination": {"refresh_cursor": "fake_refresh_cursor", "next_cursor": "fake_next_cursor", "refresh_url": "fake_refresh_url", "next_url": "fake_next_url", "total": 5}}}"""
fake_response_FeedbackReturn_json = """{"feedback_id": "fake_feedback_id", "user_id": "fake_user_id", "comment": "fake_comment", "created": "2017-05-16T13:56:54.957Z", "feedback_data": {"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}, "pagination": {"refresh_cursor": "fake_refresh_cursor", "next_cursor": "fake_next_cursor", "refresh_url": "fake_refresh_url", "next_url": "fake_next_url", "total": 5}}}"""
fake_response_FeedbackList_json = """{"feedback": []}"""
fake_response_GetFeedback_json = """{"feedback_id": "fake_feedback_id", "created": "2017-05-16T13:56:54.957Z", "comment": "fake_comment", "feedback_data": {"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": [], "modification": "fake_modification"}, "updated_labels": {"types": [], "categories": [], "modification": "fake_modification"}, "pagination": {"refresh_cursor": "fake_refresh_cursor", "next_cursor": "fake_next_cursor", "refresh_url": "fake_refresh_url", "next_url": "fake_next_url", "total": 5}}}"""
fake_response_GetFeedback_json = """{"feedback_id": "fake_feedback_id", "created": "2017-05-16T13:56:54.957Z", "comment": "fake_comment", "feedback_data": {"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}, "pagination": {"refresh_cursor": "fake_refresh_cursor", "next_cursor": "fake_next_cursor", "refresh_url": "fake_refresh_url", "next_url": "fake_next_url", "total": 5}}}"""
fake_response_FeedbackDeleted_json = """{"status": 6, "message": "fake_message"}"""
fake_response_BatchStatus_json = """{"function": "fake_function", "input_bucket_location": "fake_input_bucket_location", "input_bucket_name": "fake_input_bucket_name", "output_bucket_location": "fake_output_bucket_location", "output_bucket_name": "fake_output_bucket_name", "batch_id": "fake_batch_id", "document_counts": {"total": 5, "pending": 7, "successful": 10, "failed": 6}, "status": "fake_status", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z"}"""
fake_response_Batches_json = """{"batches": []}"""
Expand Down

0 comments on commit 5af17b7

Please sign in to comment.