Introduced a class - NodeView to achieve REST API required by the

PostgreSQL node(s).

Browser Tree Node (PostgreSQL object) requires more than just CRUD.
i.e.
   - CRUD (Create, Read, Update & Delete)
    - Reversed Engineered SQL for the object
    - Modified Query in edit mode
      i.e. ALTER TABLE ...
    - Statistics
    - List of dependents
    - List of dependencies
    - Children node list

This class can be inherited to achieve the different routes for each of
the object types/collections.

    OPERATION      |              URL       | Method
    ---------------+------------------------+--------
    List           | /obj/[Parent URL]/     | GET
    Properties     | /obj/[Parent URL]/id   | GET
    Create         | /obj/[Parent URL]/     | POST
    Delete         | /obj/[Parent URL]/id   | DELETE
    Update         | /obj/[Parent URL]/id   | PUT

    SQL (Reversed  | /sql/[Parent URL]/id   | GET
    Engineering)   |
    SQL (Modified  | /sql/[Parent URL]/id   | POST
    Properties)    |

    Statistics     | /stats/[Parent URL]/id | GET
    Dependencies   | /deps/[Parent URL]/id  | GET
    Dependents     | /deps/[Parent URL]/id  | POST

    Children Nodes | /nodes/[Parent URL]/id | GET

    NOTE:
    Parent URL can be seen as the path to identify the particular node.

    i.e.
     In order to identify the TABLE object, we requires information
     about the server -> database -> schema objects.

     Hence, the Parent URL for the TABLE object will be something like
     this as below:
     <int:sid>/<str:database>/<str:schema>

Inherited a new classes ServerGroupView and ServerView, which are
inherited from the NodeView for the implementation of above operations.
This commit is contained in:
Ashesh Vashi
2015-06-29 13:41:56 +05:30
parent b626eec0fd
commit 35d01bea3e
12 changed files with 603 additions and 260 deletions

View File

@@ -66,6 +66,19 @@ def do_setup():
server_group = ServerGroup(user_id=user.id, name="Servers")
db.session.merge(server_group)
# TODO:: Remove this server later
# It is here to demo the server listing is workig in
# browser tree.
server_group = ServerGroup.query.filter_by(name='Servers').first()
server = Server(
user_id=user.id, servergroup_id=server_group.id,
name='PostgreSQL 9.3', host='localhost', port=3930,
maintenance_db='postgres', username='asheshvashi',
ssl_mode='prefer'
)
db.session.merge(server)
# Set the schema version
version = Version(name='ConfigDB', value=config.SETTINGS_SCHEMA_VERSION)
db.session.merge(version)