Repository: watson-developer-cloud/python-sdk

Issue:
[discovery] Add ability to check doc status 
The Discovery API exposes a get doc endpoint to check the status of a document after ingestion (https://www.ibm.com/watson/developercloud/discovery/api/v1/#get-doc) but this is not available via the sdk. 

Discussion:

Patch:
diff --git a/watson_developer_cloud/discovery_v1.py b/watson_developer_cloud/discovery_v1.py
index 45d8851a..2255c395 100644
--- a/watson_developer_cloud/discovery_v1.py
+++ b/watson_developer_cloud/discovery_v1.py
@@ -138,7 +138,7 @@ class DiscoveryV1(WatsonDeveloperCloudService):
             else:
                 return None
         except KeyError:
-            pass # this isn't a problem and supress isn't in 2.7
+            pass  # this isn't a problem and supress isn't in 2.7
         return None
 
     def get_configuration(self, environment_id, configuration_id):
@@ -167,7 +167,10 @@ class DiscoveryV1(WatsonDeveloperCloudService):
                             params={'version': self.version},
                             accept_json=True)
 
-    def update_configuration(self, environment_id, configuration_id, config_data):
+    def update_configuration(self,
+                             environment_id,
+                             configuration_id,
+                             config_data):
 
         format_string = '/v1/environments/{0}/configurations/{1}'
         url_string = format_string.format(environment_id, configuration_id)
@@ -278,7 +281,11 @@ class DiscoveryV1(WatsonDeveloperCloudService):
                                                 'application/json')},
                             accept_json=True)
 
-    def test_document(self, environment_id, fileinfo, configuration_id=None, metadata=None):
+    def test_document(self,
+                      environment_id,
+                      fileinfo,
+                      configuration_id=None,
+                      metadata=None):
         url_string = '/v1/environments/{0}/preview'.format(
             environment_id)
 
@@ -308,8 +315,35 @@ class DiscoveryV1(WatsonDeveloperCloudService):
                                                 'application/json')},
                             accept_json=True)
 
-    def delete_document(self, environment_id, collection_id, document_id):
+    def get_document(self,
+                     environment_id,
+                     collection_id,
+                     document_id):
+        """
+        Get document status
+        :param environment_id the guid of the environment
+        :param collection_id collection guid
+        :param document_id the id of the document
+        :return dict of document info, not the contents.
+        """
         base_url = '/v1/environments/{0}/collections/{1}/documents/{2}'
+
+        url_string = base_url.format(
+            environment_id, collection_id, document_id)
+
+        params = {'version': latest_version}
+
+        return self.request(method='GET',
+                            url=url_string,
+                            params=params,
+                            accept_json=True)
+
+    def delete_document(self,
+                        environment_id,
+                        collection_id,
+                        document_id):
+        base_url = '/v1/environments/{0}/collections/{1}/documents/{2}'
+
         url_string = base_url.format(
             environment_id, collection_id, document_id)
 


Test patch:
diff --git a/test/test_discovery_v1.py b/test/test_discovery_v1.py
index 163d5e8b..058358cc 100644
--- a/test/test_discovery_v1.py
+++ b/test/test_discovery_v1.py
@@ -340,6 +340,11 @@ def test_document():
                   status=200,
                   content_type='application/json')
 
+    responses.add(responses.GET, del_doc_url,
+                  body="{\"body\": []}",
+                  status=200,
+                  content_type='application/json')
+
     responses.add(responses.DELETE, del_doc_url,
                   body="{\"body\": []}",
                   status=200,
@@ -351,24 +356,31 @@ def test_document():
 
     assert len(responses.calls) == 4
 
+    discovery.get_document(environment_id='envid',
+                           collection_id='collid',
+                           document_id='docid')
+
+    assert len(responses.calls) == 5
+
+
     discovery.delete_document(environment_id='envid',
                               collection_id='collid',
                               document_id='docid')
 
-    assert len(responses.calls) == 5
+    assert len(responses.calls) == 6
 
 
     conf_id = discovery.add_document(environment_id='envid', collection_id='collid', file_data='my string of file')
 
 
-    assert len(responses.calls) == 6
+    assert len(responses.calls) == 7
 
     conf_id = discovery.add_document(environment_id='envid', collection_id='collid', file_data='my string of file',
                                      mime_type='application/html')
 
-    assert len(responses.calls) == 7
+    assert len(responses.calls) == 8
 
     conf_id = discovery.add_document(environment_id='envid', collection_id='collid', file_data='my string of file',
                                      mime_type='application/html', metadata={'stuff': 'woot!'})
 
-    assert len(responses.calls) == 8
+    assert len(responses.calls) == 9