pyEDSM/edsm/systemApi.py

83 lines
1.8 KiB
Python
Raw Normal View History

import requests
from . import base
from . import exception
from . import models
class Bodies(base.ApiEndpoint):
"""
2019-11-02 00:58:48 +01:00
The bodies endpoint of the system API
:attribute url: the API endpoint URL
"""
url = base.ApiEndpoint.url + "system-v1/bodies"
@classmethod
def query(cls, params):
try:
json = super().query(params)
except exception.NotFoundError:
raise exception.SystemNotFoundError(params)
return json
@classmethod
def getBodies(cls, systemName):
"""
Requests information about the bodies in a system.
:param systemName: name of the system in question
"""
json = cls.query({'systemName': systemName})
return json
@classmethod
def getBodiesById(cls, systemId):
"""
Requests information about the bodies in a system.
:param systemId: ID of the system in question
"""
json = cls.query({'systemId': str(systemId)})
return json
2022-02-27 01:45:07 +01:00
class Traffic(base.ApiEndpoint):
"""
The "traffic" endpoint of the "system" API
:attribute url: the API endpoint URL
"""
url = base.ApiEndpoint.url + "system-v1/traffic"
@classmethod
def query(cls, params):
try:
json = super().query(params)
except exception.NotFoundError:
raise exception.SystemNotFoundError(params)
return json
@classmethod
def getTraffic(cls, systemName):
"""
Requests information about traffic in a system.
:param systemName: name of the system in question
"""
json = cls.query({'systemName': systemName})
return json
@classmethod
def getTrafficById(cls, systemId):
2022-02-27 01:45:07 +01:00
"""
Requests information about traffic in a system.
:param systemName: ID of the system in question
"""
json = cls.query({'systemId' : str(systemId)})
2022-03-11 23:54:54 +01:00
return json