mirror of https://gitlab.com/openlp/openlp.git
Start looking into a webbackend
This commit is contained in:
parent
832a189f35
commit
41a62b22a1
|
@ -40,6 +40,130 @@ class WebServiceSynchronizer(Synchronizer):
|
|||
self.manager = registry.Registry().get('songs_manager')
|
||||
registry.Registry().register('remote_synchronizer', self)
|
||||
|
||||
def connect(self):
|
||||
pass
|
||||
|
||||
def disconnect(self):
|
||||
pass
|
||||
|
||||
def check_configuration(self):
|
||||
return False
|
||||
|
||||
def check_connection(self):
|
||||
"""
|
||||
Check that it is possible to connect to the remote server/folder.
|
||||
"""
|
||||
return False
|
||||
|
||||
def initialize_remote(self):
|
||||
"""
|
||||
Setup connection to the remote server and do remote initialization.
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_remote_song_changes(self):
|
||||
"""
|
||||
Check for changes in the remote/shared folder. If a changed/new item is found it is fetched using the
|
||||
fetch_song method, and if a conflict is detected the mark_item_for_conflict is used. If items has been deleted
|
||||
remotely, they are also deleted locally.
|
||||
:return: True if one or more songs was updated, otherwise False
|
||||
"""
|
||||
# GET song/list
|
||||
pass
|
||||
|
||||
def send_song(self, song, song_uuid, last_known_version, first_sync_attempt, prev_lock_id):
|
||||
"""
|
||||
Sends a song to the remote location
|
||||
:param song: The song object to synchronize
|
||||
:param song_uuid: The uuid of the song
|
||||
:param last_known_version: The last known version of the song
|
||||
:param first_sync_attempt: If the song has been attempted synchronized before,
|
||||
this is the timestamp of the first sync attempt.
|
||||
:param prev_lock_id: If the song has been attempted synchronized before, this is the id of the lock that
|
||||
prevented the synchronization.
|
||||
:return: The new version.
|
||||
"""
|
||||
# PUT song/<uuid>
|
||||
pass
|
||||
|
||||
def fetch_song(self, song_uuid, song_id):
|
||||
"""
|
||||
Fetch a specific song from the remote location and saves it to the song db.
|
||||
:param song_uuid: uuid of the song
|
||||
:param song_id: song db id, None if song does not yet exists in the song db
|
||||
:return: The song object
|
||||
"""
|
||||
# GET song/<uuid>
|
||||
pass
|
||||
|
||||
def delete_song(self, song_uuid, first_del_attempt, prev_lock_id):
|
||||
"""
|
||||
Delete song from the remote location
|
||||
:param song_uuid:
|
||||
:type str:
|
||||
:param first_del_attempt:
|
||||
:type DateTime:
|
||||
:param prev_lock_id:
|
||||
:type str:
|
||||
"""
|
||||
# DELETE song/<uuid>
|
||||
pass
|
||||
|
||||
def get_remote_custom_changes(self):
|
||||
"""
|
||||
Check for changes in the remote/shared folder. If a changed/new item is found it is fetched using the
|
||||
fetch_song method, and if a conflict is detected the mark_item_for_conflict is used. If items has been deleted
|
||||
remotely, they are also deleted locally.
|
||||
:return: True if one or more songs was updated, otherwise False
|
||||
"""
|
||||
# GET custom/list
|
||||
pass
|
||||
|
||||
def send_custom(self, custom, custom_uuid, last_known_version, first_sync_attempt, prev_lock_id):
|
||||
"""
|
||||
Sends a custom slide to the remote location.
|
||||
:param custom: The custom object to synchronize
|
||||
:param custom_uuid: The uuid of the custom slide
|
||||
:param last_known_version: The last known version of the custom slide
|
||||
:param first_sync_attempt: If the custom slide has been attempted synchronized before,
|
||||
this is the timestamp of the first sync attempt.
|
||||
:param prev_lock_id: If the custom slide has been attempted synchronized before, this is the id of the lock
|
||||
that prevented the synchronization.
|
||||
:return: The new version.
|
||||
"""
|
||||
# PUT custom/<uuid>
|
||||
pass
|
||||
|
||||
def fetch_custom(self, custom_uuid, custom_id):
|
||||
"""
|
||||
Fetch a specific custom slide from the remote location and stores it in the custom db
|
||||
:param custom_uuid: uuid of the custom slide
|
||||
:param custom_id: custom db id, None if the custom slide does not yet exists in the custom db
|
||||
:return: The custom object
|
||||
"""
|
||||
# GET custom/<uuid>
|
||||
pass
|
||||
|
||||
def delete_custom(self, custom_uuid, first_del_attempt, prev_lock_id):
|
||||
"""
|
||||
Delete custom slide from the remote location.
|
||||
:param custom_uuid:
|
||||
:type str:
|
||||
:param first_del_attempt:
|
||||
:type DateTime:
|
||||
:param prev_lock_id:
|
||||
:type str:
|
||||
"""
|
||||
# DELETE custom/<uuid>
|
||||
pass
|
||||
|
||||
def send_service(self, service):
|
||||
pass
|
||||
|
||||
def fetch_service(self):
|
||||
pass
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _handle(response, expected_status_code=200):
|
||||
if response.status_code != expected_status_code:
|
||||
|
|
|
@ -0,0 +1,350 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: OpenLP Remote Sync Api - OpenAPI 3.0
|
||||
description: |-
|
||||
This is the description for the OpenLP remote sync API.
|
||||
|
||||
Some useful links:
|
||||
- [The OpenLP remotesync MR](https://gitlab.com/openlp/openlp/-/merge_requests/9)
|
||||
termsOfService: http://swagger.io/terms/
|
||||
contact:
|
||||
email: dev@openlp.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
version: 1.0.11
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: https://sync-service.openlp.io/api/v1
|
||||
tags:
|
||||
- name: song
|
||||
description: Operations about songs
|
||||
paths:
|
||||
/{churchId}/song/list:
|
||||
get:
|
||||
tags:
|
||||
- song
|
||||
summary: Get list of songs
|
||||
description: ''
|
||||
operationId: getSongList
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ItemList'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ItemList'
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Song not found
|
||||
/{churchId}/song/{uuid}:
|
||||
get:
|
||||
tags:
|
||||
- song
|
||||
summary: Get song by uuid
|
||||
description: 'fwef'
|
||||
operationId: getSong
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: 'The uuid of the song that needs to be fetched.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Song not found
|
||||
put:
|
||||
tags:
|
||||
- song
|
||||
summary: Update or create song
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateSong
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: uuid of song that need to be deleted
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
description: Update an existent song in the db
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
delete:
|
||||
tags:
|
||||
- song
|
||||
summary: Delete song
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteSong
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: The uuid of the song to delete
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Song not found
|
||||
/{churchId}/custom/list:
|
||||
get:
|
||||
tags:
|
||||
- custom
|
||||
summary: Get list of custom slides
|
||||
description: ''
|
||||
operationId: getCustomslideList
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ItemList'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ItemList'
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Custom slide not found
|
||||
/{churchId}/custom/{uuid}:
|
||||
get:
|
||||
tags:
|
||||
- custom
|
||||
summary: Get custom slide by uuid
|
||||
description: 'fwef'
|
||||
operationId: getCustomslide
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: 'The uuid of the custom slide that needs to be fetched.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Custom slide not found
|
||||
put:
|
||||
tags:
|
||||
- custom
|
||||
summary: Update or create custom slide
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateCustomslide
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: uuid of custom slide that need to be deleted
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
description: Update an existent custom slide in the db
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
delete:
|
||||
tags:
|
||||
- custom
|
||||
summary: Delete custom slide
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteCustomslide
|
||||
parameters:
|
||||
- name: churchId
|
||||
in: path
|
||||
description: 'The id of the church.'
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- name: uuid
|
||||
in: path
|
||||
description: The uuid of the custom slide to delete
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'400':
|
||||
description: Invalid uuid supplied
|
||||
'404':
|
||||
description: Custom slide not found
|
||||
|
||||
components:
|
||||
schemas:
|
||||
TextItem:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
example: 43f74822-c620-40c7-8723-0136878bab23
|
||||
version:
|
||||
type: integer
|
||||
format: int32
|
||||
example: 2
|
||||
created:
|
||||
type: string
|
||||
format: date-time
|
||||
updated:
|
||||
type: string
|
||||
format: date-time
|
||||
title:
|
||||
type: string
|
||||
example: Text item title
|
||||
itemxml:
|
||||
type: string
|
||||
description: Text item xml
|
||||
example: <xml>dsf</xml>
|
||||
xml:
|
||||
name: textitem
|
||||
ItemList:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ItemInfo'
|
||||
ItemInfo:
|
||||
type: object
|
||||
properties:
|
||||
uuid:
|
||||
type: string
|
||||
example: 43f74822-c620-40c7-8723-0136878bab23
|
||||
version:
|
||||
type: integer
|
||||
format: int32
|
||||
example: 2
|
||||
created:
|
||||
type: string
|
||||
format: date-time
|
||||
updated:
|
||||
type: string
|
||||
format: date-time
|
||||
ApiResponse:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
xml:
|
||||
name: '##default'
|
||||
requestBodies:
|
||||
Song:
|
||||
description: Song object that needs to be added to the db
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TextItem'
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
type: oauth2
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: https://petstore3.swagger.io/oauth/authorize
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
api_key:
|
||||
type: apiKey
|
||||
name: api_key
|
||||
in: header
|
Loading…
Reference in New Issue