Metadata-Version: 2.1
Name: logyca
Version: 0.1.7
Summary: This package name is reserved by LOGYCA company
Project-URL: Homepage, https://github.com/ccc/ccc
Project-URL: Documentation, https://ccc/
Author-email: Jaime Andres Cardona Carrillo <tecnologiaeinformacion@logyca.com>
Maintainer-email: Jaime Andres Cardona Carrillo <tecnologiaeinformacion@logyca.com>
License: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Pydantic
Classifier: Framework :: Pydantic :: 1
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.7
Requires-Dist: pydantic>=1.8
Requires-Dist: pytz>=2022.1
Provides-Extra: logycafeaturesample
Requires-Dist: sqlalchemy<2.0.8,>=1.3.18; extra == 'logycafeaturesample'
Provides-Extra: test
Requires-Dist: pytest<8.0.0,>=7.1.3; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://logyca.com/"><img src="https://logyca.com/sites/default/files/logyca.png" alt="Logyca"></a>
</p>
<p align="center">
    <em>LOGYCA public libraries</em>
</p>

<p align="center">
<a href="https://pypi.org/project/logyca" target="_blank">
    <img src="https://img.shields.io/pypi/v/logyca?color=orange&label=PyPI%20Package" alt="Package version">
</a>
<a href="(https://www.python.org" target="_blank">
    <img src="https://img.shields.io/badge/Python-%5B%3E%3D3.7%2C%3C%3D3.11%5D-orange" alt="Python">
</a>
</p>


---

# About us

* <a href="http://logyca.com" target="_blank">LOGYCA Company</a>
* <a href="https://www.youtube.com/channel/UCzcJtxfScoAtwFbxaLNnEtA" target="_blank">LOGYCA Youtube Channel</a>
* <a href="https://www.linkedin.com/company/logyca" target="_blank"><img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" alt="Linkedin"></a>
* <a href="https://twitter.com/LOGYCA_Org" target="_blank"><img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter"></a>
* <a href="https://www.facebook.com/OrganizacionLOGYCA/" target="_blank"><img src="https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white" alt="Facebook"></a>

---

# What's libraries

* **Traversal libraries**: Standard methods to be used by microservices.
* **Return codes**: Standard methods to report result status codes.
* **Monitoring**: Standard methods to report check health status codes.
* **Helpers**: Standard methods to be used. *

---

# Semantic Versioning

logyca <MAJOR>.<MINOR>.<PATCH>

* **MAJOR**: version when you make incompatible API changes
* **MINOR**: version when you add functionality in a backwards compatible manner
* **PATCH**: version when you make backwards compatible bug fixes

---

# Changelog

[Changelog](CHANGELOG.md)

---

# Quick install

```console
# Windows
python -m pip install logyca
# Linux
pip install logyca
```

---

# Example of concepts using library APIResult

```python
# Example output from ApiResult:
result={
  "resultToken": {
    "token": "",
    "refreshToken": "",
    "result": "",
    "emailActiveDirectory": "",
    "message": ""
  },
  "resultObject": [
    {
      "name": "Database server",
      "status": 0,
      "description": "Connection status fine"
    },
    {
      "name": "Redis server",
      "status": 0,
      "description": "Connection status fine"
    }
  ],
  "apiException": {
    "message": "",
    "isError": false,
    "detail": null,
    "status": 200,
    "logycaStatus": 0
  },
  "resultMessage": "",
  "dataError": false
}
```

## Use cases: you must catch de exception

1. if you get data only the token:
```json
{
"dataError":false,
"resultObject":null,
"resultToken":"Not Null"
}
```

2. if you get data correctly
```json
{
"dataError":false,
"resultObject"="Not Null"
"resultToken"=null
}
```

3. if you don't get because the operation was cancelled
```json
{
"dataError":true,
"resultObject":null,
"resultToken":null,
"apiException.logycaStatus":1,
"apiException.status"=404,
"resultMessage":"exception messages: the operation was cancelled"
}
```
[optional]apiException.message="if needed, return an object with structured failure data other than exception messages"


# Example of using library APIResult + Health Check

```python

from logyca import HealthEnum, LogycaStatusEnum, APIResultDTO, ApiFilterExceptionDTO, HTTPExceptionDTO, HealthDTO, TokensDTO

tokensDTO=TokensDTO()
tokensDTO.token='Token Example'

apiFilterExceptionDTO=ApiFilterExceptionDTO()
apiFilterExceptionDTO.isError=False
apiFilterExceptionDTO.logycaStatus=LogycaStatusEnum.Already_Exists
apiFilterExceptionDTO.status=LogycaStatusEnum.Already_Exists.mappingHttpStatusCode

httpExceptionDTO=HTTPExceptionDTO()
httpExceptionDTO.detail='No Problem'

listHealth=[]

listHealth.append(HealthDTO(name='Check CPU',status=HealthEnum.Ok,description='OK'))
listHealth.append(HealthDTO(name='Check Connect DB',status=HealthEnum.Warning,description='Warning'))
listHealth.append(HealthDTO(name='Check Connect Storage',status=HealthEnum.Critical,description='Critical'))


apiResultDTO=APIResultDTO()
apiResultDTO.resultMessage=httpExceptionDTO.detail
apiResultDTO.resultObject=listHealth
apiResultDTO.dataError=False
apiResultDTO.resultToken=tokensDTO
apiResultDTO.apiException=apiFilterExceptionDTO

print(apiResultDTO.resultToken)
for item in apiResultDTO.resultObject:
    print(f'name={item.name},status={item.status},description={item.description}')
print(apiResultDTO.resultToken)

# output
# token='Token Example' refreshToken='' result='' emailActiveDirectory='' message=''
# name=Check CPU,status=0,description=OK
# name=Check Connect DB,status=1,description=Warning
# name=Check Connect Storage,status=2,description=Critical
# token='Token Example' refreshToken='' result='' emailActiveDirectory='' message=''
```

---

# Example of using helpers

```python
from logyca import buildUrl,convertDateTimeStampUTCtoUTCColombia

url1='https://domain.com'
url2='api/get'
print(f'buildUrl={buildUrl(url1,url2)}')
# ouput
# buildUrl=https://domain.com/api/get

datetimestampUTC=1679729109
print(f'datetimeUTCColombia={convertDateTimeStampUTCtoUTCColombia(datetimestampUTC)}')
# output
# datetimeUTCColombia=2023-03-25 02:25:09-05:00
```

---

# Current library test

```console
# Library installation

# Windows
python -m pip install logyca[test]
# Linux
pip install logyca

# Run it
pytest -s
```

