readme & license

This commit is contained in:
Evgenii Alekseev 2019-09-06 01:33:11 +03:00
parent 9f19519b75
commit df8fa43344
27 changed files with 324 additions and 12 deletions

29
LICENSE Normal file
View File

@ -0,0 +1,29 @@
Copyright (c) 2019, Evgeniy Alekseev
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ffxivbis nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

99
README.md Normal file
View File

@ -0,0 +1,99 @@
# FFXIV BiS
Service which allows to manage savage loot distribution easy.
## REST API
### Party API
* `GET /api/v1/party`
Get party list. Parameters:
* `nick`: player full nickname to filter, string, optional.
* `POST /api/v1/party`
Add or remove party member. Parameters:
* `action`: action to do, string, required. One of `add`, `remove`.
* `job`: player job name, string, required.
* `nick`: player nickname, string, required.
* `link`: link to ariyala set to parse BiS, string, optional.
### BiS API
* `GET /api/v1/party/bis`
Get party/player BiS. Parameters:
* `nick`: player full nickname to filter, string, optional.
* `POST /api/v1/party/bis`
Add or remove item to/from BiS. Parameters:
* `action`: action to do, string, required. One of `add`, `remove`.
* `job`: player job name, string, required.
* `nick`: player nickname, string, required.
* `is_tome`: is item tome gear or not, bool, required.
* `piece`: item name, string, required.
* `PUT /api/v1/party/bis`
Create BiS from ariyala link. Parameters:
* `job`: player job name, string, required.
* `nick`: player nickname, string, required.
* `link`: link to ariyala set to parse BiS, string, required.
### Loot API
* `GET /api/v1/party/loot`
Get party/player loot. Parameters:
* `nick`: player full nickname to filter, string, optional.
* `POST /api/v1/party/loot`
Add or remove item to/from loot list. Parameters:
* `action`: action to do, string, required. One of `add`, `remove`.
* `job`: player job name, string, required.
* `nick`: player nickname, string, required.
* `is_tome`: is item tome gear or not, bool, required.
* `piece`: item name, string, required.
* `PUT /api/v1/party/loot`
Suggest players to get loot. Parameters:
* `is_tome`: is item tome gear or not, bool, required.
* `piece`: item name, string, required.
## Configuration
* `settings` section
General project settings.
* `include`: path to include configuration directory, string, optional.
* `logging`: path to logging configuration, see `logging.ini` for reference, string, optional.
* `database`: database provide name, string, required. Allowed values: `sqlite`.
* `priority`: methods of `Player` class which will be called to sort players for loot priority, space separated list of strings, required.
* `web` section
Web server related settings.
* `host`: address to bind, string, required.
* `port`: port to bind, int, required.
* `sqlite` section
Database settings for `sqlite` provider.
* `database_path`: path to sqlite database, string, required.
* `migrations_path`: path to database migrations, string, required.

2
TODO.md Normal file
View File

@ -0,0 +1,2 @@
[ ] postgres support
[ ] pretty UI

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from enum import Enum from enum import Enum
from json import JSONEncoder from json import JSONEncoder
from typing import Any from typing import Any

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from aiohttp.web import Application from aiohttp.web import Application
from .views.bis import BiSView from .views.bis import BiSView

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import json import json
from aiohttp.web import Response from aiohttp.web import Response

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from aiohttp.web import Response, View from aiohttp.web import Response, View
from typing import Iterable, Optional from typing import Iterable, Optional
@ -33,7 +41,7 @@ class BiSView(View):
except Exception: except Exception:
data = dict(await self.request.post()) data = dict(await self.request.post())
required = ['action', 'job', 'nick'] required = ['action', 'is_tome', 'job', 'nick', 'piece']
if any(param not in data for param in required): if any(param not in data for param in required):
return wrap_invalid_param(required, data) return wrap_invalid_param(required, data)
player_id = PlayerId(Job[data['job']], data['nick']) player_id = PlayerId(Job[data['job']], data['nick'])
@ -42,20 +50,11 @@ class BiSView(View):
if action not in ('add', 'remove'): if action not in ('add', 'remove'):
return wrap_invalid_param(['action'], data) return wrap_invalid_param(['action'], data)
piece: Optional[Piece] = None
try: try:
piece = Piece.get(data) # type: ignore
if action == 'add': if action == 'add':
if 'is_tome' not in data or 'piece' not in data:
return wrap_invalid_param(['is_tome', 'piece'], data)
piece = Piece.get(data) # type: ignore
self.request.app['party'].set_item_bis(player_id, piece) self.request.app['party'].set_item_bis(player_id, piece)
elif action == 'remove': elif action == 'remove':
if 'is_tome' not in data or 'piece' not in data:
return wrap_invalid_param(['is_tome', 'piece'], data)
piece = Piece.get(data) # type: ignore
self.request.app['party'].remove_item_bis(player_id, piece) self.request.app['party'].remove_item_bis(player_id, piece)
except Exception as e: except Exception as e:

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from aiohttp.web import Response, View from aiohttp.web import Response, View
from typing import Iterable from typing import Iterable
@ -45,7 +53,6 @@ class LootView(View):
piece = Piece.get(data) piece = Piece.get(data)
if action == 'add': if action == 'add':
self.request.app['party'].set_item(player_id, piece) self.request.app['party'].set_item(player_id, piece)
elif action == 'remove': elif action == 'remove':
self.request.app['party'].remove_item(player_id, piece) self.request.app['party'].remove_item(player_id, piece)

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from aiohttp.web import Response, View from aiohttp.web import Response, View
from typing import Iterable from typing import Iterable

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import logging import logging
from aiohttp import web from aiohttp import web

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from service.core.config import Configuration from service.core.config import Configuration
from .core import Application from .core import Application

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import logging import logging
from service.api.web import run_server, setup_service from service.api.web import run_server, setup_service

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import os import os
import requests import requests

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import configparser import configparser
import os import os

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from __future__ import annotations from __future__ import annotations
import datetime import datetime

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from typing import Any, Mapping from typing import Any, Mapping

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from typing import Iterable, List, Tuple, Union from typing import Iterable, List, Tuple, Union
from service.models.player import Player, PlayerIdWithCounters from service.models.player import Player, PlayerIdWithCounters

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from __future__ import annotations from __future__ import annotations
from threading import Lock from threading import Lock

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from typing import List, Optional, Union from typing import List, Optional, Union
from service.models.bis import BiS from service.models.bis import BiS

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
# because sqlite3 does not support context management # because sqlite3 does not support context management
import sqlite3 import sqlite3

View File

@ -1 +1,9 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
__version__ = '0.1.0' __version__ = '0.1.0'

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
import itertools import itertools
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from __future__ import annotations from __future__ import annotations
from enum import Enum, auto from enum import Enum, auto

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from dataclasses import dataclass from dataclasses import dataclass
from typing import Union from typing import Union

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from dataclasses import dataclass from dataclasses import dataclass
from typing import List, Optional, Union from typing import List, Optional, Union

View File

@ -1,3 +1,11 @@
#
# Copyright (c) 2019 Evgeniy Alekseev.
#
# This file is part of ffxivbis
# (see https://github.com/arcan1s/ffxivbis).
#
# License: 3-clause BSD, see https://opensource.org/licenses/BSD-3-Clause
#
from enum import Enum, auto from enum import Enum, auto
from typing import List from typing import List