Database abstraction objects for Forseti Server.
Model
(*args, **kwargs)[source]¶Bases: sqlalchemy.ext.declarative.api.Base
Explain model object in database.
__repr__
()[source]¶String representation.
Returns: |
|
---|---|
Return type: | str |
_sa_class_manager
= {'created_at_datetime': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe5290>, 'description': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe5110>, 'etag_seed': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe5470>, 'handle': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe1cb0>, 'message': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe51d0>, 'name': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe1e90>, 'state': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe5530>, 'warnings': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe5ad0>, 'watchdog_timer_datetime': <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x7f1c63fe50b0>}¶add_description
(description)[source]¶Add new description to the model
Parameters: | description (str) – the description to be added in json format |
---|
add_warning
(warning)[source]¶Add a warning to the model.
Parameters: | warning (str) – Warning message |
---|
created_at_datetime
¶description
¶etag_seed
¶handle
¶message
¶name
¶set_done
(message='')[source]¶Indicate a finished import.
Parameters: | message (str) – Success message or ‘’ |
---|
state
¶warnings
¶watchdog_timer_datetime
¶ModelManager
(dbengine)[source]¶Bases: object
The Central class to create,list,get and delete models.
ModelManager is mostly used to do the lookup from model name to the session cache which is given in each client’s request.
_create_model_session
()[source]¶Create a session to read from the models table.
Returns: | db session created |
---|---|
Return type: | object |
_get
(handle)[source]¶Get model data by name internal.
Parameters: | handle (str) – the model handle |
---|---|
Returns: | the model in the session maker |
Return type: | Model |
Raises: | KeyError – model handle not available |
_models
(expunge=False)[source]¶Return the list of models from the database.
Parameters: | expunge (bool) – Whether or not to detach the object from the session for use in another session. |
---|---|
Returns: | list of Models in the db |
Return type: | list |
add_description
(model_name, new_description, session=None)[source]¶Add description to a model.
Parameters: |
|
---|
create
(**kw)¶Decorated functionality, mutexing wrapped function.
Parameters: |
|
---|---|
Returns: | the execution results of f |
Return type: | object |
delete
(**kw)¶Decorated functionality, mutexing wrapped function.
Parameters: |
|
---|---|
Returns: | the execution results of f |
Return type: | object |
get
(model)[source]¶Get model data by handle.
Parameters: | model (str) – model handle |
---|---|
Returns: | session and ModelAccess object |
Return type: | tuple |
get_description
(model_name, session=None)[source]¶Get the description to a model.
Parameters: |
|
---|---|
Returns: | Dictionary of the model description. |
Return type: | json |
get_model
(model, expunge=True, session=None)[source]¶Get model from database by name or handle.
Parameters: |
|
---|---|
Returns: | the dbo of the queried model |
Return type: |
get_readonly_session
()[source]¶Get read-only session.
Returns: | The read-only session. |
---|---|
Return type: | Session |
model
(model_name, expunge=True, session=None)[source]¶Get model from database by name.
Parameters: |
|
---|---|
Returns: | the dbo of the queried model |
Return type: |
create_engine
(*args, **kwargs)[source]¶Create engine wrapper to patch database options.
Parameters: |
|
---|---|
Returns: | Engine. |
Return type: | object |
define_model
(model_name, dbengine, model_seed)[source]¶Defines table classes which point to the corresponding model.
This means, for each model being accessed this function needs to be called in order to generate a full set of table definitions.
Models are name spaced via a random model seed such that multiple models can exist within the same database. In order to implement the name spacing in an abstract way.
Parameters: |
|
---|---|
Returns: | (sessionmaker, ModelAccess) |
Return type: | tuple |
generate_model_handle
()[source]¶Generate random model handle.
Returns: | random bytes for handle |
---|---|
Return type: | str |
session_creator
(model_name, filename=None, seed=None, echo=False)[source]¶Create a session maker for the model and db file.
Parameters: |
|
---|---|
Returns: | session_maker and the ModelAccess object |
Return type: | tuple |