Skip to content

Commit

Permalink
Merge branch 'dev' into foca_change
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed May 2, 2021
2 parents 4a0ae6a + 37e38dc commit 756e726
Show file tree
Hide file tree
Showing 9 changed files with 815 additions and 5 deletions.
148 changes: 148 additions & 0 deletions drs_filer/api/20200131.11d2c12.service-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
swagger: '2.0'
basePath: '/ga4gh/drs/v1'
info:
title: GA4GH service-info API specification
description: A way for a service to describe basic metadata concerning a service
alongside a set of capabilities and/or limitations of the service. More information
on [GitHub](https://github.com/ga4gh-discovery/ga4gh-service-info/).
version: 1.0.0
license:
name: Apache 2.0
url: https://raw.githubusercontent.com/ga4gh-discovery/ga4gh-service-info/develop/LICENSE
contact:
name: GA4GH Discovery Networks Team
email: ga4gh-discovery-networks@ga4gh.org
schemes:
- https
- http
consumes:
- application/json
produces:
- application/json
paths:
"/service-info":
get:
summary: Show information about this service. It is assumed that removing this
endpoint from a URL will result in a valid URL to query against
operationId: getServiceInfo
tags:
- service-info
responses:
'200':
description: A successful operation to request the service information about
this running service.
schema:
"$ref": "#/definitions/Service"
parameters: []
produces:
- application/json
x-swagger-router-controller: ga4gh.drs.server
definitions:
Service:
description: GA4GH service
type: object
required:
- id
- name
- type
- organization
- version
properties:
id:
type: string
description: Unique ID of this service. Reverse domain name notation is recommended,
though not required. The identifier should attempt to be globally unique
so it can be used in downstream aggregator services e.g. Service Registry.
example: org.ga4gh.myservice
name:
type: string
description: Name of this service. Should be human readable.
example: My project
type:
"$ref": "#/definitions/ServiceType"
description:
type: string
description: Description of the service. Should be human readable and provide
information about the service.
example: This service provides...
organization:
type: object
description: Organization providing the service
required:
- name
- url
properties:
name:
type: string
description: Name of the organization responsible for the service
example: My organization
url:
type: string
format: uri
description: URL of the website of the organization (RFC 3986 format)
example: https://example.com
contactUrl:
type: string
format: uri
description: URL of the contact for the provider of this service, e.g. a link
to a contact form (RFC 3986 format), or an email (RFC 2368 format).
example: mailto:support@example.com
documentationUrl:
type: string
format: uri
description: URL of the documentation of this service (RFC 3986 format). This
should help someone learn how to use your service, including any specifics
required to access data, e.g. authentication.
example: https://docs.myservice.example.com
createdAt:
type: string
format: date-time
description: Timestamp describing when the service was first deployed and
available (RFC 3339 format)
example: '2019-06-04T12:58:19Z'
updatedAt:
type: string
format: date-time
description: Timestamp describing when the service was last updated (RFC 3339
format)
example: '2019-06-04T12:58:19Z'
environment:
type: string
description: Environment the service is running in. Use this to distinguish
between production, development and testing/staging deployments. Suggested
values are prod, test, dev, staging. However this is advised and not enforced.
example: test
version:
type: string
description: Version of the service being described. Semantic versioning is
recommended, but other identifiers, such as dates or commit hashes, are
also allowed. The version should be changed whenever the service is updated.
example: 1.0.0
ServiceType:
description: Type of a GA4GH service
type: object
required:
- group
- artifact
- version
properties:
group:
type: string
description: Namespace in reverse domain name format. Use `org.ga4gh` for
implementations compliant with official GA4GH specifications. For services
with custom APIs not standardized by GA4GH, or implementations diverging
from official GA4GH specifications, use a different namespace (e.g. your
organization's reverse domain name).
example: org.ga4gh
artifact:
type: string
description: Name of the API or GA4GH specification implemented. Official
GA4GH types should be assigned as part of standards approval process. Custom
artifacts are supported.
example: beacon
version:
type: string
description: Version of the API or specification. GA4GH specifications use
semantic versioning.
example: 1.0.0
x-components: {}
124 changes: 124 additions & 0 deletions drs_filer/api/additional.data_repository_service.swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
paths:
'/service-info':
post:
summary: Register service info.
description: Create or update the service info.
operationId: postServiceInfo
tags:
- DRS-Filer
parameters:
- in: body
required: true
name: Service info to add.
description: Data object metadata.
schema:
$ref: '#/definitions/ServiceRegister'
responses:
'201':
description: The service info was successfully created.
'400':
description: The request is malformed.
schema:
$ref: '#/definitions/Error'
'401':
description: The request is unauthorized.
schema:
$ref: '#/definitions/Error'
'403':
description: The requester is not authorized to perform this action.
schema:
$ref: '#/definitions/Error'
'500':
description: An unexpected error occurred.
schema:
$ref: '#/definitions/Error'
x-swagger-router-controller: ga4gh.drs.server
'/objects':
post:
summary: Create object.
Expand Down Expand Up @@ -158,6 +192,96 @@ paths:
- DRS-Filer
x-swagger-router-controller: ga4gh.drs.server
definitions:
ServiceRegister:
description: 'GA4GH service'
type: object
required:
- id
- name
- type
- organization
- version
additionalProperties: false
properties:
id:
type: string
description: 'Unique ID of this service. Reverse domain name notation is recommended, though not required. The identifier should attempt to be globally unique so it can be used in downstream aggregator services e.g. Service Registry.'
example: 'org.ga4gh.myservice'
name:
type: string
description: 'Name of this service. Should be human readable.'
example: 'My project'
type:
$ref: '#/definitions/ServiceTypeRegister'
description:
type: string
description: 'Description of the service. Should be human readable and provide information about the service.'
example: 'This service provides...'
organization:
type: object
description: 'Organization providing the service'
required:
- name
- url
properties:
name:
type: string
description: 'Name of the organization responsible for the service'
example: 'My organization'
url:
type: string
format: uri
description: 'URL of the website of the organization (RFC 3986 format)'
example: 'https://example.com'
contactUrl:
type: string
format: uri
description: 'URL of the contact for the provider of this service, e.g. a link to a contact form (RFC 3986 format), or an email (RFC 2368 format).'
example: 'mailto:support@example.com'
documentationUrl:
type: string
format: uri
description: 'URL of the documentation of this service (RFC 3986 format). This should help someone learn how to use your service, including any specifics required to access data, e.g. authentication.'
example: 'https://docs.myservice.example.com'
createdAt:
type: string
format: date-time
description: 'Timestamp describing when the service was first deployed and available (RFC 3339 format)'
example: '2019-06-04T12:58:19Z'
updatedAt:
type: string
format: date-time
description: 'Timestamp describing when the service was last updated (RFC 3339 format)'
example: '2019-06-04T12:58:19Z'
environment:
type: string
description: 'Environment the service is running in. Use this to distinguish between production, development and testing/staging deployments. Suggested values are prod, test, dev, staging. However this is advised and not enforced.'
example: 'test'
version:
type: string
description: 'Version of the service being described. Semantic versioning is recommended, but other identifiers, such as dates or commit hashes, are also allowed. The version should be changed whenever the service is updated.'
example: '1.0.0'
ServiceTypeRegister:
description: 'Type of a GA4GH service'
type: object
required:
- group
- artifact
- version
additionalProperties: false
properties:
group:
type: string
description: 'Namespace in reverse domain name format. Use `org.ga4gh` for implementations compliant with official GA4GH specifications. For services with custom APIs not standardized by GA4GH, or implementations diverging from official GA4GH specifications, use a different namespace (e.g. your organization''s reverse domain name).'
example: 'org.ga4gh'
artifact:
type: string
description: 'Name of the API or GA4GH specification implemented. Official GA4GH types should be assigned as part of standards approval process. Custom artifacts are supported.'
example: 'beacon'
version:
type: string
description: 'Version of the API or specification. GA4GH specifications use semantic versioning.'
example: '1.0.0'
DrsObjectRegister:
type: object
additionalProperties: false
Expand Down
10 changes: 10 additions & 0 deletions drs_filer/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
"""Main app module."""

import logging

from foca.foca import foca

from drs_filer.ga4gh.drs.endpoints.service_info import RegisterServiceInfo

logger = logging.getLogger(__name__)


def main():
app = foca("config.yaml")

# register service info
with app.app.app_context():
service_info = RegisterServiceInfo()
service_info.set_service_info_from_config()
# start app
app.run(port=app.port)


Expand Down
24 changes: 24 additions & 0 deletions drs_filer/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ db:
id: 1
options:
'unique': True
service_info:
indexes:
- keys:
id: 1
options:
'unique': True

api:
specs:
- path:
- api/20200131.11d2c12.service-info.yaml
- api/20200622.383121d.data_repository_service.swagger.yaml
- api/additional.data_repository_service.swagger.yaml
append: null
Expand Down Expand Up @@ -64,6 +71,23 @@ endpoints:
access_methods:
id_charset: 'string.ascii_letters + string.digits + ".-_~"'
id_length: 6
service_info:
id: "TEMPID1"
name: "TEMP_STUB"
type:
group: "TEMP_GROUP"
artifact: "TEMP_ARTIFACT"
version: "v1"
description: "Description of service."
organization:
name: "Parent organization"
url: "parent/abc"
contactUrl: "contact/abc"
documentationUrl: "docs/abc"
createdAt: "2020-01-01"
updatedAt: "2020-01-01"
environment: "ENV"
version: "0.0.0"
url_prefix: http
external_host: 193.166.24.114
external_port: 8080
Expand Down
4 changes: 4 additions & 0 deletions drs_filer/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class URLNotFound(NotFound):
pass


class ValidationError(Exception):
"""Value or object is not compatible with required type or schema."""


exceptions = {
Exception: {
"msg": "An unexpected error occurred.",
Expand Down
Loading

0 comments on commit 756e726

Please sign in to comment.