Skip to main content

This package name is reserved by LOGYCA company

Project description

Logyca

LOGYCA public libraries

Package version Python


About us


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: 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

Quick install

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

Example of concepts using library APIResult

# 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:
{
"dataError":false,
"resultObject":null,
"resultToken":"Not Null"
}
  1. if you get data correctly
{
"dataError":false,
"resultObject"="Not Null"
"resultToken"=null
}
  1. if you don't get because the operation was cancelled
{
"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

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

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

# Library installation

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

# Run it
pytest -s

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Types of changes

  • Added for new features.
  • Changed for changes in existing functionality.
  • Deprecated for soon-to-be removed features.
  • Removed for now removed features.
  • Fixed for any bug fixes.
  • Security in case of vulnerabilities.

[0.1.8] - 2023-10-03

Fixed

  • Due to a link error in the readme to internal documents in pypi, we chose to leave the changelog at the end of the readme.

[0.1.7] - 2023-10-02

Fixed

  • The url address for the logyca logo is corrected
  • Adjust return code for LogycaStatusEnum class: LogycaStatusEnum.Created==HTTPStatus.CREATED
  • Adjust return code for LogycaStatusEnum class: LogycaStatusEnum.InProcess==HTTPStatus.ACCEPTED
  • Adjust return code for LogycaStatusEnum class: LogycaStatusEnum.Partial==HTTPStatus.ACCEPTED
  • Empty files init.py removed

[0.1.6] - 2023-09-11

Fixed

  • Pydantic restriction for versions lower than 2.0 is removed

[0.1.5] - 2023-03-27

Added

  • Release ready for production

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logyca-0.1.8.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

logyca-0.1.8-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page