Commit 23759d0f authored by Luciano Cauzzi's avatar Luciano Cauzzi

added get function -> single document management

parent adcf9d2b
......@@ -120,6 +120,29 @@ class AppPyramidManager:
except Exception as e:
return AppPyramidManager.__generate_generic_error__(operation_name, e)
def get(self, doc_id) -> NetworkResult:
operation_name = "get document"
self.__perform_auth_if_needed__()
try:
url = "{}/{}/{}".format(self.__base_url__, self.__res_url__, doc_id)
headers = self.__get_auth_header__()
s = self.__network_manager__.get_session()
response = s.get(url, headers=headers, timeout=AppPyramidManager.TIMEOUT)
if response.status_code == 401:
self.login()
return self.get(doc_id)
json_obj = json.loads(response.text)
if response.status_code != 200:
return NetworkResult(success=False, status_code=response.status_code, message="", result=None)
elif json_obj["found"]:
return NetworkResult(success=True, status_code=response.status_code, message=response.text,
result=True)
else:
return NetworkResult(success=True, status_code=response.status_code, message="", result=False)
except Exception as e:
return AppPyramidManager.__generate_generic_error__(operation_name, e)
def __get_auth_header__(self):
if self.__app_token__ is None:
raise Exception("User should be authenticated")
......
dependency_injector==3.14.6
setuptools==41.0.1
setuptools
requests==2.22.0
git+http://github/innovation-that-excites/logger_library.git
\ No newline at end of file
......@@ -3,7 +3,7 @@ import setuptools
setup(
name='network_manager',
version='0.1.11',
version='0.1.12',
packages=setuptools.find_packages(),
dependency_links=[],
install_requires=['logger_library', 'dependency_injector', 'requests'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment