Uuid command#
Help#
The help text for the uuid
subcommand can be shown by passing the -h
flag.
[1]:
%%bash
metacatalog uuid -h
usage: metacatalog uuid [-h] [--version] [--connection CONNECTION] [--verbose]
[--quiet] [--dev] [--logfile LOGFILE] [--json]
uuid
positional arguments:
uuid Version 4 UUID of the requested resource
optional arguments:
-h, --help show this help message and exit
--version, -v Returns the module version
--connection CONNECTION, -C CONNECTION
Connection string to the database instance.Follows the
syntax: driver://user:password@host:port/database
--verbose, -V Activate extended output.
--quiet, -q Suppress any kind of output.
--dev Development mode. Unexpected errors will not be
handled and the full traceback is printed to the
screen.
--logfile LOGFILE If a file is given, output will be written to that
file instead of printed to StdOut.
--json If set, the object will be returned as JSON
Prerequisites#
The uuid
command assumes that metadata records have been added using `add
<cli_add.ipynb>`__.
Usage#
The uuid
command can be used to search the database for an object of given UUID. metacatalog
always refers to UUID version 4. The command will search records across models for the reqeusted resource. Currently, the following model instances can be found:
Entry
EntryGroup
Keyword
Example#
The following example shows how a keyword can be found by UUID and related keywords can be searched. If the database included the GCMD Keywords
on `init
<cli_init.ipynb>`__, there will be an controlled keyword of UUID 885735f3-121e-4ca0-ac8b-f37dbc972f03
, which tags the hydrosphere.
[2]:
%%bash
metacatalog uuid 885735f3-121e-4ca0-ac8b-f37dbc972f03
Using session: Engine(postgresql://postgres:***@localhost:5432/metacatalog)
EARTH SCIENCE > TERRESTRIAL HYDROSPHERE
By passing the --json
flag, the output can be transformed to json, giving us more information
[3]:
%%bash
metacatalog uuid --json 885735f3-121e-4ca0-ac8b-f37dbc972f03
Using session: Engine(postgresql://postgres:***@localhost:5432/metacatalog)
{
"id": 25,
"uuid": "885735f3-121e-4ca0-ac8b-f37dbc972f03",
"value": "TERRESTRIAL HYDROSPHERE",
"path": "EARTH SCIENCE > TERRESTRIAL HYDROSPHERE",
"children": [
"099ab1ae-f4d2-48cc-be2f-86bd58ffc4ca",
"734f8f27-6976-4b67-8794-c7fc79d6161e",
"50b8fe04-9149-4b7f-a8b2-b33b1e3aa192",
"5debb283-51e4-435e-b2a2-e8e2a977220d",
"8c02f5d1-ce86-4bf5-84d5-b3496cdba6ad"
],
"thesaurus_id": 1
}
Now we can easily check the children keywords:
[4]:
%%bash
metacatalog uuid --json 5debb283-51e4-435e-b2a2-e8e2a977220d
Using session: Engine(postgresql://postgres:***@localhost:5432/metacatalog)
{
"id": 214,
"uuid": "5debb283-51e4-435e-b2a2-e8e2a977220d",
"value": "SURFACE WATER",
"path": "EARTH SCIENCE > TERRESTRIAL HYDROSPHERE > SURFACE WATER",
"children": [
"1baa552d-c563-43fb-b618-54651f8b07e6",
"959f1861-a776-41b1-ba6b-d23c71d4d1eb",
"9d86cd70-062a-4c39-b3f3-226abebc07f7",
"c84b61fe-720a-4240-b6c8-8dcc9ae24a36"
],
"thesaurus_id": 1
}
[5]:
%%bash
metacatalog uuid --json 9d86cd70-062a-4c39-b3f3-226abebc07f7
Using session: Engine(postgresql://postgres:***@localhost:5432/metacatalog)
{
"id": 6220,
"uuid": "9d86cd70-062a-4c39-b3f3-226abebc07f7",
"value": "SURFACE WATER PROCESSES/MEASUREMENTS",
"path": "EARTH SCIENCE > TERRESTRIAL HYDROSPHERE > SURFACE WATER > SURFACE WATER PROCESSES/MEASUREMENTS",
"children": [
"3609b843-d840-460c-b1a3-d4fcc69a32f6",
"36a2999b-2255-4d4e-a249-40df3b7b3aaf",
"269c7277-fa8f-4c1c-bd8b-ab772c1df4e5",
"7fdc339e-017f-4e4b-89a3-12e441a40bad",
"960037c5-57b1-4cdf-84be-4542beee7d5a",
"d4e8b5c5-9203-4982-82bc-2611b517ffdb",
"c6c0c5dd-c0ca-4670-bbaa-c22d39e73570",
"5cb5d5b9-0c0b-497f-a4ea-a8cece52d13d",
"6f52de55-f5f2-45c0-b83f-59dbfb1fe221",
"42aa1fa1-56a9-4e96-8063-077bd7ba88d8",
"84784fef-5b76-45a0-91e0-28788e09fea6",
"04922ba6-8f00-4f54-b80c-ce2414c91e2e",
"f6a54329-486b-4d5f-b105-c639cec42351"
],
"thesaurus_id": 1
}