altimeter.qj package¶
Subpackages¶
Submodules¶
altimeter.qj.client module¶
Client for the QJ API
-
class
QJAPIClient
(host, port=443, scheme='https', api_key=None)¶ Bases:
object
Client for the QJ API
-
create_or_update_active_job
(job_in)¶ This method ensures that an active Job as described by JobCreate exists. If the Job does not exist it will be created. If a Job which can be updated exists (e.g. query is the same but perhaps category is different) that job will be updated. The created or updated job will be activated. Note that for finding a job candidate to update, only active jobs are considered - an inactive job will never be updated and used, instead a new version would be created. If an update was made, a Job object is returned, otherwise None
- Return type
Optional
[Job
]
-
delete_expired_result_sets
()¶ Delete all expired ResultSets
- Return type
-
get_auth
()¶ Get the currently used api auth token. This can be used to validate that the client’s key is valid
- Return type
str
-
-
exception
QJAPIClientError
¶ Bases:
Exception
General QJ API Client exception
-
raise_client_error
(response, exception)¶ Raise an QJAPIClientError based on a Response and Exception
- Return type
None
altimeter.qj.config module¶
Global Settings
-
class
APIConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.QJConfig
Configuraton for the API service and consumers
-
api_host
: str¶
-
api_port
: int¶
-
-
class
APIKeyRotatorConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.APIConfig
Configuraton for the APIKeyRotator lambda
-
account_id_key
: str¶
-
api_host
: str¶
-
api_port
: int¶
-
app_name
: str¶
-
region
: str¶
-
-
class
APIServiceConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.APIConfig
,altimeter.qj.config.DBConfig
,altimeter.qj.config.LimitsConfig
,altimeter.qj.config.SecurityConfig
Configuration for the API service
-
classmethod
check_max_graph_age_sec
(values)¶ Validate that max_graph_age_sec_default does not exceed max_graph_age_sec_limit
- Return type
Dict
[str
,Any
]
-
classmethod
check_max_result_age_sec
(values)¶ Validate that max_result_age_sec_default does not exceed max_result_age_sec_limit
- Return type
Dict
[str
,Any
]
-
classmethod
check_result_expiration_sec
(values)¶ Validate that result_expiration_sec_default does not exceed result_expiration_sec_limit
- Return type
Dict
[str
,Any
]
-
db_ro_user
: str¶
-
classmethod
-
class
DBConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
pydantic.env_settings.BaseSettings
Configuraton for the DB
-
db_host
: str¶
-
db_name
: str¶
-
db_password
: str¶
-
db_user
: str¶
-
get_db_uri
()¶ Get a db uri for this DBConfig
- Return type
str
-
-
class
ExecutorConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.APIConfig
Configuraton for the Executor lambda
-
query_queue_url
: str¶
-
-
class
LimitsConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
pydantic.env_settings.BaseSettings
Limit configurations
-
max_graph_age_sec_default
: int¶
-
max_graph_age_sec_limit
: int¶
-
max_result_age_sec_default
: int¶
-
max_result_age_sec_limit
: int¶
-
max_result_set_results
: int¶
-
max_result_size_bytes
: int¶
-
result_expiration_sec_default
: int¶
-
result_expiration_sec_limit
: int¶
-
-
class
PrunerConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.APIConfig
,altimeter.qj.config.SecurityConfig
Configuraton for the Pruner lambda
-
account_id_key
: str¶
-
api_host
: str¶
-
api_port
: int¶
-
app_name
: str¶
-
region
: str¶
-
-
class
QJConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
pydantic.env_settings.BaseSettings
General high level configuration
-
account_id_key
: str¶
-
app_name
: str¶
-
region
: str¶
-
-
class
QueryConfig
(_env_file='<object object>', _env_file_encoding=None, _secrets_dir=None, **values)¶ Bases:
altimeter.qj.config.APIConfig
,altimeter.qj.config.SecurityConfig
Configuraton for the Query lambda
-
neptune_host
: str¶
-
neptune_port
: int¶
-
neptune_region
: str¶
-
altimeter.qj.exceptions module¶
QJ Exception Classes
-
exception
ActiveJobVersionNotFound
¶ Bases:
altimeter.qj.exceptions.QJException
An active JobVersion for a specified Job could not be found
-
exception
JobInvalid
¶ Bases:
altimeter.qj.exceptions.QJException
A specified Job is invalid
-
exception
JobNotFound
¶ Bases:
altimeter.qj.exceptions.QJException
A specified Job could not be found
-
exception
JobQueryInvalid
¶ Bases:
altimeter.qj.exceptions.QJException
A Job’s query is invalid SPARQL
-
exception
JobQueryMissingAccountId
¶ Bases:
altimeter.qj.exceptions.QJException
A Job’s query is missing the required account_id field
-
exception
JobVersionNotFound
¶ Bases:
altimeter.qj.exceptions.QJException
A specified JobVersion could not be found
-
exception
QJException
¶ Bases:
Exception
Base exception class for all QJ thrown exceptions
-
exception
ResultSetNotFound
¶ Bases:
altimeter.qj.exceptions.QJException
A specified ResultSet could not be found
-
exception
ResultSetResultsLimitExceeded
¶ Bases:
altimeter.qj.exceptions.QJException
The number of Results in a ResultSet exceeds the configured maximum
-
exception
ResultSizeExceeded
¶ Bases:
altimeter.qj.exceptions.QJException
The size of an individual result exceeds the configured maximum
altimeter.qj.log module¶
LogEvent for QJ events.
-
class
QJLogEvents
(InitConfig=EventName(name='InitConfig'), GetJobs=EventName(name='GetJobs'), ScheduleJob=EventName(name='ScheduleJob'), DeleteStart=EventName(name='DeleteStart'), DeleteEnd=EventName(name='DeleteEnd'), InitJob=EventName(name='InitJob'), RunQueryStart=EventName(name='RunQueryStart'), RunQueryEnd=EventName(name='RunQueryEnd'), CreateResultSetStart=EventName(name='CreateResultSetStart'), CreateResultSetEnd=EventName(name='CreateResultSetEnd'), CreateJob=EventName(name='CreateJob'), DeleteJob=EventName(name='DeleteJob'), GetActiveJob=EventName(name='GetActiveJob'), GetJobVersion=EventName(name='GetJobVersion'), GetJobVersions=EventName(name='GetJobVersions'), UpdateJob=EventName(name='UpdateJob'), CreateView=EventName(name='CreateView'), DropView=EventName(name='DropView'), CreateResultSet=EventName(name='CreateResultSet'), DeleteExpiredResultSets=EventName(name='DeleteExpiredResultSets'), GetExpiredResultSets=EventName(name='GetExpiredResultSets'), GetResultSet=EventName(name='GetResultSet'), GetLatestResultSetForActiveJob=EventName(name='GetLatestResultSetForActiveJob'), APIError=EventName(name='APIError'), HTTPRequest=EventName(name='HTTPRequest'))¶ Bases:
altimeter.core.log.BaseLogEvent
QJ Log event names
-
APIError
: altimeter.core.log.EventName = EventName(name='APIError')¶
-
CreateJob
: altimeter.core.log.EventName = EventName(name='CreateJob')¶
-
CreateResultSet
: altimeter.core.log.EventName = EventName(name='CreateResultSet')¶
-
CreateResultSetEnd
: altimeter.core.log.EventName = EventName(name='CreateResultSetEnd')¶
-
CreateResultSetStart
: altimeter.core.log.EventName = EventName(name='CreateResultSetStart')¶
-
CreateView
: altimeter.core.log.EventName = EventName(name='CreateView')¶
-
DeleteEnd
: altimeter.core.log.EventName = EventName(name='DeleteEnd')¶
-
DeleteExpiredResultSets
: altimeter.core.log.EventName = EventName(name='DeleteExpiredResultSets')¶
-
DeleteJob
: altimeter.core.log.EventName = EventName(name='DeleteJob')¶
-
DeleteStart
: altimeter.core.log.EventName = EventName(name='DeleteStart')¶
-
DropView
: altimeter.core.log.EventName = EventName(name='DropView')¶
-
GetActiveJob
: altimeter.core.log.EventName = EventName(name='GetActiveJob')¶
-
GetExpiredResultSets
: altimeter.core.log.EventName = EventName(name='GetExpiredResultSets')¶
-
GetJobVersion
: altimeter.core.log.EventName = EventName(name='GetJobVersion')¶
-
GetJobVersions
: altimeter.core.log.EventName = EventName(name='GetJobVersions')¶
-
GetJobs
: altimeter.core.log.EventName = EventName(name='GetJobs')¶
-
GetLatestResultSetForActiveJob
: altimeter.core.log.EventName = EventName(name='GetLatestResultSetForActiveJob')¶
-
GetResultSet
: altimeter.core.log.EventName = EventName(name='GetResultSet')¶
-
HTTPRequest
: altimeter.core.log.EventName = EventName(name='HTTPRequest')¶
-
InitConfig
: altimeter.core.log.EventName = EventName(name='InitConfig')¶
-
InitJob
: altimeter.core.log.EventName = EventName(name='InitJob')¶
-
RunQueryEnd
: altimeter.core.log.EventName = EventName(name='RunQueryEnd')¶
-
RunQueryStart
: altimeter.core.log.EventName = EventName(name='RunQueryStart')¶
-
ScheduleJob
: altimeter.core.log.EventName = EventName(name='ScheduleJob')¶
-
UpdateJob
: altimeter.core.log.EventName = EventName(name='UpdateJob')¶
-
altimeter.qj.middleware module¶
FastAPI middlewares
altimeter.qj.security module¶
Security related functions
-
get_api_key
(region_name, version_stage='AWSCURRENT')¶ Get the current API key from SecretsManager
- Return type
str
altimeter.qj.settings module¶
Settings