Welcome to Pacifica Metadata’s documentation!¶
The Pacifica Metadata service provides metadata storage about the files stored in Pacifica.
Installation¶
The Pacifica software is available through PyPi so creating a virtual environment to install is what is shown below. Please keep in mind compatibility with the Pacifica Core services.
Installation in Virtual Environment¶
These installation instructions are intended to work on both Windows, Linux, and Mac platforms. Please keep that in mind when following the instructions.
Please install the appropriate tested version of Python for maximum chance of success.
Linux and Mac Installation¶
mkdir ~/.virtualenvs
python -m virtualenv ~/.virtualenvs/pacifica
. ~/.virtualenvs/pacifica/bin/activate
pip install pacifica-metadata
Windows Installation¶
This is done using PowerShell. Please do not use Batch Command.
mkdir "$Env:LOCALAPPDATA\virtualenvs"
python.exe -m virtualenv "$Env:LOCALAPPDATA\virtualenvs\pacifica"
& "$Env:LOCALAPPDATA\virtualenvs\pacifica\Scripts\activate.ps1"
pip install pacifica-metadata
Configuration¶
The Pacifica Core services require two configuration files. The REST API utilizes CherryPy and review of their configuration documentation is recommended. The service configuration file is a INI formatted file containing configuration for database connections.
CherryPy Configuration File¶
An example of Metadata server CherryPy configuration:
[global]
log.screen: True
log.access_file: 'access.log'
log.error_file: 'error.log'
server.socket_host: '0.0.0.0'
server.socket_port: 8121
[/]
request.dispatch: cherrypy.dispatch.MethodDispatcher()
tools.response_headers.on: True
tools.response_headers.headers: [('Content-Type', 'application/json')]
Service Configuration File¶
The service configuration is an INI file and an example is as follows:
[database]
; This section contains database connection configuration
; peewee_url is defined as the URL PeeWee can consume.
; http://docs.peewee-orm.com/en/latest/peewee/database.html#connecting-using-a-database-url
peewee_url = postgresql://pacifica:metadata@localhost:5432/pacifica_metadata
; connect_attempts are the number of times the service will attempt to
; connect to the database if unavailable.
connect_attempts = 10
; connect_wait are the number of seconds the service will wait between
; connection attempts until a successful connection to the database.
connect_wait = 20
; enable debug logging of database queries
debug_logging = False
[notifications]
; This section describes where the notifications server is.
; Disable eventing for the metadata service.
disabled = False
; URL to the recieve endpoint on the notifications server.
url = http://127.0.0.1:8070/receive
[elasticsearch]
; This section describes configuration to contact elasticsearch
; URL to the elasticsearch server
url = http://127.0.0.1:9200
Starting the Service¶
Starting the Metadata service can be done by two methods. However, understanding the requirements and how they apply to REST services is important to address as well. Using the internal CherryPy server to start the service is recommended for Windows platforms. For Linux/Mac platforms it is recommended to deploy the service with uWSGI.
Deployment Considerations¶
The Metadata service is the authoritative metadata store for all data in Pacifica. This means any queries needed by any other Pacifica services goes through a REST endpoint on this service. As different services require performance characteristics of each endpoint it is important to have a deployment mechanism that behaves consistently.
The CherryPy service works well enough for many of the queries. However, for performance and scalability using uWSGI is preferred. Also putting system memory consumption limits on the service is also recommended. As you get more data in the system some queries will grow to consume memory beyond a single system.
As data volume in Pacifica and load on queries increase the Metadata service works better running in uWSGI. The chance increases of a query consuming all the system memory on the server. As CherryPy is a threaded application Linux will kill the process to free up memory. This results in the service going down entirely and not servicing requests. uWSGI takes care of this by utilizing a forking model for handling requests. Using uWSGI, a child process is killed and a 500 is returned to the client. uWSGI continues handling requests, cleans up the dead child and spawns new ones.
CherryPy Server¶
To make running the Metadata service using the CherryPy’s builtin server easier we have a command line entry point.
$ pacifica-metadata --help
usage: pacifica-metadata [-h] [--cpconfig CPCONFIG] [-c CONFIG] [-p PORT]
[-a ADDRESS]
Run the metadata server.
optional arguments:
-h, --help show this help message and exit
--cpconfig CPCONFIG cherrypy config file
-c CONFIG, --config CONFIG
database config file
-p PORT, --port PORT port to listen on
-a ADDRESS, --address ADDRESS
address to listen on
$ pacifica-metadata-cmd dbsync
$ pacifica-metadata
[09/Jan/2019:09:17:26] ENGINE Listening for SIGTERM.
[09/Jan/2019:09:17:26] ENGINE Bus STARTING
[09/Jan/2019:09:17:26] ENGINE Set handler for console events.
[09/Jan/2019:09:17:26] ENGINE Started monitor thread 'Autoreloader'.
[09/Jan/2019:09:17:26] ENGINE Serving on http://0.0.0.0:8121
[09/Jan/2019:09:17:26] ENGINE Bus STARTED
uWSGI Server¶
To make running the UniqueID service using uWSGI easier we have a module to be included as part of the uWSGI configuration. uWSGI is very configurable and can use this module many different ways. Please consult the uWSGI Configuration documentation for more complicated deployments.
$ pip install uwsgi
$ uwsgi --http-socket :8121 --master --module pacifica.metadata.wsgi
Metadata Model¶
This covers all the objects and their relationships to other objects in the model.
All The Objects¶
Journals¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
impact_factor | FloatField | NOT NULL | |
website_url | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Users¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
first_name | CharField | NOT NULL | |
middle_initial | CharField | NOT NULL | |
last_name | CharField | NOT NULL | |
network_id | CharField | NULL | |
email_address | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Institutions¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
name | TextField | NOT NULL | |
association_cd | CharField | NOT NULL | |
is_foreign | BooleanField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Projects¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | CharField | NOT NULL, PRIMARY KEY | |
title | TextField | NOT NULL | |
short_name | CharField | NULL | |
abstract | TextField | NULL | |
science_theme | CharField | NULL | |
project_type | CharField | NULL | |
submitted_date | ExtendDateTimeField | NOT NULL | |
accepted_date | ExtendDateField | NULL | |
actual_start_date | ExtendDateField | NULL | |
actual_end_date | ExtendDateField | NULL | |
closed_date | ExtendDateField | NULL | |
suspense_date | ExtendDateField | NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Instruments¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
display_name | CharField | NOT NULL | |
name | CharField | NOT NULL | |
name_short | CharField | NOT NULL | |
active | BooleanField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Citations¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
article_title | TextField | NOT NULL | |
journal | ForeignKeyField | Journals.id | NOT NULL |
journal_volume | IntegerField | NOT NULL | |
journal_issue | IntegerField | NOT NULL | |
page_range | CharField | NOT NULL | |
abstract_text | TextField | NOT NULL | |
xml_text | TextField | NOT NULL | |
release_authorization_id | CharField | NOT NULL | |
doi_reference | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Contributors¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
user | ForeignKeyField | Users.id | NOT NULL |
first_name | CharField | NOT NULL | |
middle_initial | CharField | NOT NULL | |
last_name | CharField | NOT NULL | |
dept_code | CharField | NOT NULL | |
institution | ForeignKeyField | Institutions.id | NOT NULL |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Datasets¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
description | TextField | NULL | |
display_name | CharField | NOT NULL | |
suspense_date | ExtendDateField | NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Relationships¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
display_name | CharField | NOT NULL | |
description | TextField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DataSources¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
uri | CharField | NOT NULL | |
display_name | CharField | NOT NULL | |
description | TextField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Keywords¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
keyword | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Groups¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
is_admin | BooleanField | NOT NULL | |
display_name | CharField | NOT NULL | |
description | TextField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
AnalyticalTools¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
InstrumentUser¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
instrument | ForeignKeyField | Instruments.id | NOT NULL |
user | ForeignKeyField | Users.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
InstitutionUser¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
user | ForeignKeyField | Users.id | NOT NULL |
institution | ForeignKeyField | Institutions.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
CitationContributor¶
Column | Type | Reference | Attributes |
---|---|---|---|
citation | ForeignKeyField | Citations.id | NOT NULL |
author | ForeignKeyField | Contributors.id | NOT NULL |
author_precedence | IntegerField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
CitationKeyword¶
Column | Type | Reference | Attributes |
---|---|---|---|
citation | ForeignKeyField | Citations.id | NOT NULL |
keyword | ForeignKeyField | Keywords.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
ProjectInstrument¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
project | ForeignKeyField | Projects.id | NOT NULL |
instrument | ForeignKeyField | Instruments.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
ProjectUser¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
user | ForeignKeyField | Users.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
ProjectGroup¶
Column | Type | Reference | Attributes |
---|---|---|---|
group | ForeignKeyField | Groups.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
CitationProject¶
Column | Type | Reference | Attributes |
---|---|---|---|
citation | ForeignKeyField | Citations.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Transactions¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
description | TextField | NULL | |
suspense_date | ExtendDateField | NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
TransSIP¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | ForeignKeyField | Transactions.id | NOT NULL, PRIMARY KEY |
submitter | ForeignKeyField | Users.id | NOT NULL |
instrument | ForeignKeyField | Instruments.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
TransSAP¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | ForeignKeyField | Transactions.id | NOT NULL, PRIMARY KEY |
submitter | ForeignKeyField | Users.id | NOT NULL |
analytical_tool | ForeignKeyField | AnalyticalTools.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Files¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
name | CharField | NOT NULL | |
subdir | CharField | NOT NULL | |
ctime | ExtendDateTimeField | NOT NULL | |
mtime | ExtendDateTimeField | NOT NULL | |
hashsum | CharField | NOT NULL | |
hashtype | CharField | NOT NULL | |
size | BigIntegerField | NOT NULL | |
transaction | ForeignKeyField | Transactions.id | NOT NULL |
mimetype | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
suspense_date | ExtendDateField | NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Keys¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
key | CharField | NOT NULL | |
display_name | CharField | NOT NULL | |
description | TextField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Values¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
value | CharField | NOT NULL | |
display_name | CharField | NOT NULL | |
description | TextField | NOT NULL | |
encoding | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
FileKeyValue¶
Column | Type | Reference | Attributes |
---|---|---|---|
file | ForeignKeyField | Files.id | NOT NULL |
key | ForeignKeyField | Keys.id | NOT NULL |
value | ForeignKeyField | Values.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
TransactionKeyValue¶
Column | Type | Reference | Attributes |
---|---|---|---|
transaction | ForeignKeyField | Transactions.id | NOT NULL |
key | ForeignKeyField | Keys.id | NOT NULL |
value | ForeignKeyField | Values.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
UserGroup¶
Column | Type | Reference | Attributes |
---|---|---|---|
user | ForeignKeyField | Users.id | NOT NULL |
group | ForeignKeyField | Groups.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DatasetFile¶
Column | Type | Reference | Attributes |
---|---|---|---|
dataset | ForeignKeyField | Datasets.id | NOT NULL |
file | ForeignKeyField | Files.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DatasetProjectUser¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
dataset | ForeignKeyField | Datasets.id | NOT NULL |
user | ForeignKeyField | Users.id | NOT NULL |
project | ForeignKeyField | Projects.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
InstrumentGroup¶
Column | Type | Reference | Attributes |
---|---|---|---|
instrument | ForeignKeyField | Instruments.id | NOT NULL |
group | ForeignKeyField | Groups.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
AToolProject¶
Column | Type | Reference | Attributes |
---|---|---|---|
project | ForeignKeyField | Projects.id | NOT NULL |
analytical_tool | ForeignKeyField | AnalyticalTools.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
AToolTransaction¶
Column | Type | Reference | Attributes |
---|---|---|---|
transaction | ForeignKeyField | Transactions.id | NOT NULL |
analytical_tool | ForeignKeyField | AnalyticalTools.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
TransactionUser¶
Column | Type | Reference | Attributes |
---|---|---|---|
uuid | UUIDField | NOT NULL, PRIMARY KEY | |
user | ForeignKeyField | Users.id | NOT NULL |
transaction | ForeignKeyField | Transactions.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DOIEntries¶
Column | Type | Reference | Attributes |
---|---|---|---|
doi | CharField | NOT NULL, PRIMARY KEY | |
status | CharField | NOT NULL | |
released | BooleanField | NOT NULL | |
site_url | CharField | NOT NULL | |
encoding | CharField | NOT NULL | |
creator | ForeignKeyField | Users.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DOIAuthors¶
Column | Type | Reference | Attributes |
---|---|---|---|
id | AutoField | NOT NULL, PRIMARY KEY | |
last_name | CharField | NOT NULL | |
first_name | CharField | NOT NULL | |
CharField | NULL | ||
affiliation | CharField | NULL | |
orcid | CharField | NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DOITransaction¶
Column | Type | Reference | Attributes |
---|---|---|---|
doi | ForeignKeyField | DOIEntries.doi | NOT NULL, PRIMARY KEY |
transaction | ForeignKeyField | TransactionUser.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
CitationTransaction¶
Column | Type | Reference | Attributes |
---|---|---|---|
citation | ForeignKeyField | Citations.id | NOT NULL |
transaction | ForeignKeyField | TransactionUser.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
CitationDOI¶
Column | Type | Reference | Attributes |
---|---|---|---|
doi | ForeignKeyField | DOIEntries.doi | NOT NULL |
citation | ForeignKeyField | Citations.id | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DOIAuthorMapping¶
Column | Type | Reference | Attributes |
---|---|---|---|
author | ForeignKeyField | DOIAuthors.id | NOT NULL |
doi | ForeignKeyField | DOIEntries.doi | NOT NULL |
author_order | IntegerField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
DOIInfo¶
Column | Type | Reference | Attributes |
---|---|---|---|
doi | ForeignKeyField | DOIEntries.doi | NOT NULL |
key | CharField | NOT NULL | |
value | CharField | NOT NULL | |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
InstrumentDataSource¶
Column | Type | Reference | Attributes |
---|---|---|---|
instrument | ForeignKeyField | Instruments.id | NOT NULL |
data_source | ForeignKeyField | DataSources.uuid | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
InstrumentKeyValue¶
Column | Type | Reference | Attributes |
---|---|---|---|
instrument | ForeignKeyField | Instruments.id | NOT NULL |
key | ForeignKeyField | Keys.id | NOT NULL |
value | ForeignKeyField | Values.id | NOT NULL |
relationship | ForeignKeyField | Relationships.uuid | NOT NULL |
created | ExtendDateTimeField | NOT NULL | |
updated | ExtendDateTimeField | NOT NULL | |
deleted | ExtendDateTimeField | NULL |
Note¶
This document is generated by the GenMetadataModelMD.py
script and needs to
be regenerated whenever changes are made to the model.
Example Usage¶
The API¶
The Pacifica Metadata Services API covers the complete object life-cycle: create, read, update, and delete.
The examples in this section demonstrate the life-cycle of the User
object
using a Pacifica Metadata Services deployment at http://localhost:8121/ (see
“Installing the Service” section).
Creating an Object¶
To create a new User
object, start by generating a new file create.json
to
store the JSON data:
{
"_id": 127,
"email_address": "john@doe.com",
"first_name": "John",
"last_name": "Doe",
"middle_initial": "",
"network_id": "guest"
}
Then, provide the contents of the new file as the body for a HTTP PUT request
using the curl
command:
curl -X PUT -T create.json 'http://localhost:8121/users'
Reading an Object¶
To retrieve the JSON data for the User
object that was just created, send a
HTTP GET request (with the _id
attribute as a query parameter) using the
curl
command:
curl -X GET 'http://localhost:8121/users?_id=127'
The response body is a JSON array of JSON objects.
Because the query uses the _id
attribute, a primary key, the JSON array
contains either zero (no match) or one (match) JSON objects:
[
{
"_id": 127,
"email_address": "john@doe.com",
"encoding": "UTF8",
"first_name": "John",
"last_name": "Doe",
"middle_initial": "",
"network_id": "guest",
"created": 1459204793,
"deleted": null,
"updated": 1459204793
}
]
Optionally, query on any other parts of an object by using its attributes as
query parameters, e.g., to query on both the first_name
and last_name
attributes using the curl
command:
curl -X GET 'http://localhost:8121/users?last_name=Doe&first_name=John'
Response bodies for queries on other parts may contain JSON data for more than one match:
[
{
"_id": 127,
"email_address": "john@doe.com",
"encoding": "UTF8",
"first_name": "John",
"last_name": "Doe",
"middle_initial": "",
"network_id": "guest",
"created": 1459204793,
"deleted": null,
"updated": 1459204793
},
...
]
Pagination¶
By default, Pacifica Metadata Services API endpoints respond with JSON data for all matching objects. Hence, the response size, and therefore, the response time is proportional to the number of matches.
To reduce the response time, but still enable access to all matching objects, all Pacifica Metadata Services API endpoints offer a “pagination” capability, where large responses are subdivided into “pages” with a fixed number of matching objects “per page”.
For example, 100 matching objects are divided into 4 pages of 25 matching objects per page:
- Page 1 = Matching objects 1 to 25
- Page 2 = Matching objects 26 to 50
- Page 3 = Matching objects 51 to 75
- Page 4 = Matching objects 76 to 100
- Page >4 = No matching objects
Use the page_number
and items_per_page
query parameters to specify the
number of pages and the number of matching objects per page, respectively, e.g.,
to retrieve the 7th page of 10 User
s per page using the curl
command:
curl -X GET 'http://localhost:8121/users?items_per_page=10&page_number=7'
Updating an Object¶
To modify a preexisting object, use the query parameters to identify the object
(or objects) and then send a HTTP POST request with the JSON data for the
modified attributes as the request body, e.g., to modify the network_id
attribute, start by generating a new file update.json
to store the JSON data:
{
"network_id": "example"
}
Then, provide the contents of the new file as the body for a HTTP POST request
using the curl
command:
curl -X POST -T update.json 'http://localhost:8121/users?last_name=Doe&first_name=John'
Finally, verify the modifications by retrieving the most recent version of the
object (see “Reading an Object” section), e.g., using the curl
command:
curl -X GET 'http://localhost:8121/users?_id=127'
The updated
attribute is automatically set to the current time when an object
is modified:
[
{
"_id": 127,
"email_address": "john@doe.com",
"encoding": "UTF8",
"first_name": "John",
"last_name": "Doe",
"middle_initial": "",
"network_id": "example",
"created": 1459204793,
"deleted": null,
"updated": 1459205143
}
]
(Soft) Deleting an Object¶
To mark an object as deleted
, i.e., to “soft delete” an object, send a HTTP
DELETE request using the curl
command:
curl -X DELETE 'http://localhost:8121/users?_id=127'
NOTE Don’t worry! The object isn’t really deleted.
Finally, verify the “soft delete” by retrieving the most recent version of the
object (see “Reading an Object” section), e.g., using the curl
command:
curl -X GET 'http://localhost:8121/users?_id=127'
The deleted
attribute is automatically set to the current time when an object
is “soft deleted”:
[
{
"_id": 127,
"email_address": "john@doe.com",
"encoding": "UTF8",
"first_name": "John",
"last_name": "Doe",
"middle_initial": "",
"network_id": "example",
"created": 1459204793,
"deleted": 1459205341,
"updated": 1459205143
}
]