2019-03-28 13:51:58 +03:00
|
|
|
.. _metadata_apis:
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
Schema / Metadata API Reference
|
|
|
|
===============================
|
2018-10-08 17:12:03 +03:00
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
.. contents:: Table of contents
|
|
|
|
:backlinks: none
|
|
|
|
:depth: 1
|
|
|
|
:local:
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
The Schema / Metadata API provides the following features:
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
1. Execute SQL on the underlying Postgres database, supports schema modifying actions.
|
|
|
|
2. Modify Hasura metadata (permissions rules and relationships).
|
|
|
|
|
|
|
|
This is primarily intended to be used as an ``admin`` API to manage Hasura schema and metadata.
|
|
|
|
|
|
|
|
Endpoint
|
|
|
|
--------
|
|
|
|
|
|
|
|
All requests are ``POST`` requests to the ``/v1/query`` endpoint.
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
Request structure
|
|
|
|
-----------------
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
.. code-block:: http
|
|
|
|
|
|
|
|
POST /v1/query HTTP/1.1
|
|
|
|
|
|
|
|
{
|
2018-10-29 12:12:44 +03:00
|
|
|
"type": "<query-type>",
|
2018-10-08 17:12:03 +03:00
|
|
|
"args": <args-object>
|
|
|
|
}
|
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
Request body
|
|
|
|
^^^^^^^^^^^^
|
2018-10-08 17:12:03 +03:00
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
.. parsed-literal::
|
2018-10-08 17:12:03 +03:00
|
|
|
|
2019-02-06 09:39:36 +03:00
|
|
|
Query_
|
|
|
|
|
|
|
|
.. _Query:
|
|
|
|
|
|
|
|
Query
|
|
|
|
*****
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
.. list-table::
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
* - Key
|
|
|
|
- Required
|
|
|
|
- Schema
|
|
|
|
- Description
|
|
|
|
* - type
|
|
|
|
- true
|
|
|
|
- String
|
|
|
|
- Type of the query
|
|
|
|
* - args
|
|
|
|
- true
|
|
|
|
- JSON Value
|
|
|
|
- The arguments to the query
|
|
|
|
|
|
|
|
The various types of queries are listed in the following table:
|
|
|
|
|
|
|
|
.. list-table::
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
* - ``type``
|
|
|
|
- ``args``
|
2019-02-06 09:39:36 +03:00
|
|
|
- Synopsis
|
|
|
|
|
|
|
|
* - **bulk**
|
|
|
|
- :ref:`Query <Query>` array
|
|
|
|
- Execute multiple operations in a single query
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
* - :ref:`run_sql`
|
|
|
|
- :ref:`run_sql_args <run_sql_syntax>`
|
|
|
|
- Run SQL directly on Postgres
|
|
|
|
|
2018-10-17 08:27:11 +03:00
|
|
|
* - :ref:`track_table`
|
|
|
|
- :ref:`TableName <TableName>`
|
|
|
|
- Add a table/view
|
|
|
|
|
|
|
|
* - :ref:`untrack_table`
|
|
|
|
- :ref:`untrack_table_args <untrack_table_syntax>`
|
|
|
|
- Remove a table/view
|
|
|
|
|
2019-01-25 06:31:54 +03:00
|
|
|
* - :ref:`track_function`
|
|
|
|
- :ref:`FunctionName <FunctionName>`
|
|
|
|
- Add a SQL function
|
|
|
|
|
|
|
|
* - :ref:`untrack_function`
|
|
|
|
- :ref:`FunctionName <FunctionName>`
|
|
|
|
- Remove a SQL function
|
|
|
|
|
2018-10-08 17:12:03 +03:00
|
|
|
* - :ref:`create_object_relationship`
|
|
|
|
- :ref:`create_object_relationship_args <create_object_relationship_syntax>`
|
|
|
|
- Define a new object relationship
|
|
|
|
|
|
|
|
* - :ref:`create_array_relationship`
|
|
|
|
- :ref:`create_array_relationship_args <create_array_relationship_syntax>`
|
|
|
|
- Define a new array relationship
|
|
|
|
|
|
|
|
* - :ref:`drop_relationship`
|
|
|
|
- :ref:`drop_relationship_args <drop_relationship_syntax>`
|
|
|
|
- Drop an existing relationship
|
|
|
|
|
|
|
|
* - :ref:`set_relationship_comment`
|
|
|
|
- :ref:`set_relationship_comment_args <set_relationship_comment_syntax>`
|
|
|
|
- Set comment on an existing relationship
|
|
|
|
|
|
|
|
* - :ref:`create_insert_permission`
|
|
|
|
- :ref:`create_insert_permission_args <create_insert_permission_syntax>`
|
|
|
|
- Specify insert permission
|
|
|
|
|
|
|
|
* - :ref:`drop_insert_permission`
|
|
|
|
- :ref:`drop_insert_permission_args <drop_insert_permission_syntax>`
|
|
|
|
- Remove existing insert permission
|
|
|
|
|
|
|
|
* - :ref:`create_select_permission`
|
|
|
|
- :ref:`create_select_permission_args <create_select_permission_syntax>`
|
|
|
|
- Specify select permission
|
|
|
|
|
|
|
|
* - :ref:`drop_select_permission`
|
|
|
|
- :ref:`drop_select_permission_args <drop_select_permission_syntax>`
|
|
|
|
- Remove existing select permission
|
|
|
|
|
|
|
|
* - :ref:`create_update_permission`
|
|
|
|
- :ref:`create_update_permission_args <create_update_permission_syntax>`
|
|
|
|
- Specify update permission
|
|
|
|
|
|
|
|
* - :ref:`drop_update_permission`
|
|
|
|
- :ref:`drop_update_permission_args <drop_update_permission_syntax>`
|
|
|
|
- Remove existing update permission
|
|
|
|
|
|
|
|
* - :ref:`create_delete_permission`
|
|
|
|
- :ref:`create_delete_permission_args <create_delete_permission_syntax>`
|
|
|
|
- Specify delete permission
|
|
|
|
|
|
|
|
* - :ref:`drop_delete_permission`
|
|
|
|
- :ref:`drop_delete_permission_args <drop_delete_permission_syntax>`
|
|
|
|
- Remove existing delete permission
|
|
|
|
|
|
|
|
* - :ref:`set_permission_comment`
|
|
|
|
- :ref:`set_permission_comment_args <set_permission_comment_syntax>`
|
|
|
|
- Set comment on an existing permission
|
|
|
|
|
2018-10-25 10:22:51 +03:00
|
|
|
* - :ref:`create_event_trigger`
|
|
|
|
- :ref:`create_event_trigger_args <create_event_trigger_syntax>`
|
|
|
|
- Create or replace event trigger
|
|
|
|
|
|
|
|
* - :ref:`delete_event_trigger`
|
|
|
|
- :ref:`delete_event_trigger_args <delete_event_trigger_syntax>`
|
|
|
|
- Delete existing event trigger
|
|
|
|
|
2019-03-28 13:51:58 +03:00
|
|
|
* - :ref:`export_metadata`
|
|
|
|
- ``{}``
|
|
|
|
- Export the current metadata
|
|
|
|
|
|
|
|
* - :ref:`replace_metadata`
|
|
|
|
- :ref:`replace_metadata_args <replace_metadata_syntax>`
|
|
|
|
- Import and replace existing metadata
|
|
|
|
|
|
|
|
* - :ref:`reload_metadata`
|
|
|
|
- ``{}``
|
|
|
|
- Reload changes to the underlying Postgres DB
|
|
|
|
|
|
|
|
* - :ref:`clear_metadata`
|
|
|
|
- ``{}``
|
|
|
|
- Clear/wipe-out the current metadata state form server
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
**See:**
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
- :doc:`Run SQL <run-sql>`
|
2018-10-17 08:27:11 +03:00
|
|
|
- :doc:`Tables/Views <table-view>`
|
2019-01-25 06:31:54 +03:00
|
|
|
- :doc:`Custom SQL Functions <custom-functions>`
|
2018-10-08 17:12:03 +03:00
|
|
|
- :doc:`Relationships <relationship>`
|
|
|
|
- :doc:`Permissions <permission>`
|
2018-10-25 10:22:51 +03:00
|
|
|
- :doc:`Event Triggers <event-triggers>`
|
2019-03-28 13:51:58 +03:00
|
|
|
- :doc:`Manage Metadata <manage-metadata>`
|
2018-10-08 17:12:03 +03:00
|
|
|
|
|
|
|
Response structure
|
|
|
|
------------------
|
|
|
|
|
|
|
|
.. list-table::
|
|
|
|
:widths: 10 10 30
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
* - Status code
|
|
|
|
- Description
|
|
|
|
- Response structure
|
|
|
|
|
|
|
|
* - ``200``
|
|
|
|
- Success
|
|
|
|
- .. parsed-literal::
|
|
|
|
|
|
|
|
Request specific
|
|
|
|
|
|
|
|
* - ``400``
|
|
|
|
- Bad request
|
|
|
|
- .. code-block:: haskell
|
|
|
|
|
|
|
|
{
|
|
|
|
"path" : String,
|
|
|
|
"error" : String
|
|
|
|
}
|
|
|
|
|
|
|
|
* - ``401``
|
|
|
|
- Unauthorized
|
|
|
|
- .. code-block:: haskell
|
|
|
|
|
|
|
|
{
|
|
|
|
"error" : String
|
|
|
|
}
|
|
|
|
|
|
|
|
* - ``500``
|
|
|
|
- Internal server error
|
|
|
|
- .. code-block:: haskell
|
|
|
|
|
|
|
|
{
|
|
|
|
"error" : String
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Error codes
|
|
|
|
-----------
|
|
|
|
|
|
|
|
.. csv-table::
|
|
|
|
:file: dataerrors.csv
|
|
|
|
:widths: 10, 20, 70
|
|
|
|
:header-rows: 1
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 1
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
Run SQL <run-sql>
|
2018-10-17 08:27:11 +03:00
|
|
|
Tables/Views <table-view>
|
2019-01-25 06:31:54 +03:00
|
|
|
Custom Functions <custom-functions>
|
2018-10-08 17:12:03 +03:00
|
|
|
Relationships <relationship>
|
|
|
|
Permissions <permission>
|
2018-10-25 10:22:51 +03:00
|
|
|
Event Triggers <event-triggers>
|
2019-03-28 13:51:58 +03:00
|
|
|
Manage Metadata <manage-metadata>
|
2018-10-08 17:12:03 +03:00
|
|
|
Syntax definitions <syntax-defs>
|
|
|
|
|