From 372b5b54c10e1635d4ffb750df042c7b23ba8e65 Mon Sep 17 00:00:00 2001 From: Rob Dominguez Date: Tue, 30 May 2023 06:02:27 -0500 Subject: [PATCH] docs: add admin secret header PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9323 GitOrigin-RevId: c4b08adcd75d0cc67551615c9e71c1dd7ab2ee05 --- docs/docs/api-reference/pgdump.mdx | 36 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/docs/docs/api-reference/pgdump.mdx b/docs/docs/api-reference/pgdump.mdx index 81ea516b83d..2daf8f834d7 100644 --- a/docs/docs/api-reference/pgdump.mdx +++ b/docs/docs/api-reference/pgdump.mdx @@ -13,13 +13,11 @@ keywords: ## Introduction -The PG Dump API is an admin-only endpoint that can be used to execute -`pg_dump` on the Postgres instance that Hasura is configured with. +The PG Dump API is an **admin-only** endpoint that can be used to execute `pg_dump` on the Postgres instance that Hasura +is configured with. -The primary motive of this API is to provide convenience methods to -initialize Migrations from an existing Hasura instance. But the -functionality can be later expanded to do other things such as taking a -data dump etc. +The primary motive of this API is to provide convenience methods to initialize Migrations from an existing Hasura +instance. But the functionality can be later expanded to do other things such as taking a data dump, etc. ## Endpoint @@ -33,6 +31,7 @@ All requests are `POST` requests to the `/v1alpha1/pg_dump` endpoint. POST /v1alpha1/pg_dump HTTP/1.1 Content-Type: application/json X-Hasura-Role: admin +X-Hasura-Admin-Secret: { "opts": ["-O", "-x", "--schema-only", "--schema", "public"], @@ -41,15 +40,15 @@ X-Hasura-Role: admin } ``` -- `opts`: Arguments to be passed to the `pg_dump` tool. Represented as - array of strings. The underlying command that is executed is: +- `opts`: Arguments to be passed to the `pg_dump` tool. Represented as array of strings. The underlying command that is + executed is: ```bash pg_dump $DATABASE_URL $OPTS -f $FILENAME ``` -- `clean_output`: When this optional argument is set to `true`, the - output SQL from the command is cleaned to remove the following: +- `clean_output`: When this optional argument is set to `true`, the output SQL from the command is cleaned to remove the + following: - SQL front matter, like SET statements. - `CREATE SCHEMA public`. @@ -57,8 +56,7 @@ X-Hasura-Role: admin - Comments (`--`) and empty newlines. - Postgres triggers created by Hasura for Event Triggers. -- `source`: the name of the connected database on which to run - `pg_dump` on. If skipped, it is set to `default` +- `source`: the name of the connected database on which to run `pg_dump` on. If skipped, it is set to `default` ### Sample response @@ -84,13 +82,12 @@ ALTER TABLE ONLY public.author ALTER COLUMN id SET DEFAULT nextval('public.autho ## Disabling PG Dump API -Since this API can be used to dump all the Postgres data and schema, it -can be disabled, especially in production deployments. +Since this API can be used to dump all the Postgres data and schema, it can be disabled, especially in production +deployments. -The `enabled-apis` flag or the `HASURA_GRAPHQL_ENABLED_APIS` env var can -be used to enable/disable this API. By default, The PG DumpAPI is -enabled. To disable it, you need to explicitly state that this API is -not enabled. i.e. remove it from the list of enabled APIs. +The `enabled-apis` flag or the `HASURA_GRAPHQL_ENABLED_APIS` env var can be used to enable/disable this API. By default, +The PG DumpAPI is enabled. To disable it, you need to explicitly state that this API is not enabled. i.e. remove it from +the list of enabled APIs. ```bash # enable only graphql & Metadata apis, disable pgdump @@ -98,4 +95,5 @@ not enabled. i.e. remove it from the list of enabled APIs. HASURA_GRAPHQL_ENABLED_APIS="graphql,metadata" ``` -See [GraphQL Engine server config reference](/deployment/graphql-engine-flags/reference.mdx) for info on setting the above flag/env var. +See [GraphQL Engine server config reference](/deployment/graphql-engine-flags/reference.mdx) for info on setting the +above flag/env var.