Ejemplo n.º 1
0
import logging

from flask_restplus import Resource
from src.api.restplus import api

log = logging.getLogger(__name__)

ns = api.namespace('service', description='Operations related to maintenance')


@ns.route('/healthcheck/')
class Healthcheck(Resource):
    def get(self):
        str_health_check = "Health check done"
        return str_health_check, 200
Ejemplo n.º 2
0
import logging
from flask import request
from flask_restplus import Resource, fields
from src.api.users.business import *
from passlib.apps import custom_app_context as pwd_context
from src.api.users.serializers import *
from src.api.restplus import api
from src.database.models import User, Recipe

log = logging.getLogger(__name__)
ns = api.namespace('users', description='Operations related to user accounts')


""" USER """
@ns.route('/register')
@api.response(404, "{'message': 'string'}")
class UserAccountsCollection(Resource):

  @api.expect(user_registration)
  @api.marshal_with(token_response)
  def post(self):
    """
    Creates a new user account.
    """
    return create_user(request.json), 201


@ns.route('/login')
class UserAccountsAuthentication(Resource):

  @api.expect(user_login)
Ejemplo n.º 3
0
import logging
from typing import Set

from flask import request
from flask_restplus import Resource

from src.api.business import Business
from src.api.parsers import Parsers
from src.api.restplus import api
from src.api.serializers import Serializers
from src.database.models import Comparison, GeoName, Hints

log = logging.getLogger(__name__)

ns = api.namespace('geonames/task_', description='Operations related to GeoNames')


@ns.route('1/by_geonameid/<int:geonameid>')
class GeoNameById(Resource):
    @api.response(404, 'GeoName not found.')
    @api.marshal_with(Serializers.geoname)
    def get(self, geonameid: int):
        """
        Returns a GeoName by geonameid.
        """
        return GeoName.query.filter(GeoName.geonameid == geonameid).one()


@ns.route('2/paginated')
class GeoNamePaginated(Resource):
    @api.expect(Parsers.pagination_arguments)
from flask import request
from flask_restplus import Resource
from src.api.service.serializers import current_channel_state, post_current_channel_state
from src.api.service.parsers import ext_account_id_arguments
from src.api.restplus import api

from src.business.business import *
from src.database.models.ccs_model import CurrentChannelState
from src.blockchain.service.blockchain_service import BlockChainService
from src.common.settings import *
from src.blockchain.common.bc_helper import BlockChainHelper
from src.blockchain.common.utils.utils_json import Utils

log = logging.getLogger(__name__)

ns = api.namespace('ccs', description='Current Channel State operations')


@ns.route('/')
class CCSCollection(Resource):

    @api.expect(ext_account_id_arguments, validate=True)
    @api.marshal_with(current_channel_state)
    def get(self):
        """   
       Returns Client System's version of Current Channel State

       This is an optional call
       Use this method to get the receiver's version of the current system state to compare to User's version
        """
import logging
import os
import json

from flask import request
from flask_restplus import Resource
from src.api.service.serializers import channel_snapshot
from src.api.service.parsers import ext_account_id_arguments
from src.api.restplus import api
from src.database.models.channel_model import Channel

log = logging.getLogger(__name__)

ns = api.namespace('channels',
                   description='Operations related to service channels')


@ns.route('/')
class ChannelsCollection(Resource):
    @api.expect(ext_account_id_arguments, validate=True)
    @api.marshal_list_with(channel_snapshot)
    def get(self):
        """   Returns list of channels or single channel"""
        args = ext_account_id_arguments.parse_args(request)
        ext_account_id = args.get('ext_account_id', 1)
        channels = Channel.find_by_ext_account_id(ext_account_id)
        if channels:
            return channels
        else:
            return None
Ejemplo n.º 6
0
import logging
from flask import request
from flask_restplus import Resource
from src.api.service.parsers import ext_account_id_arguments
from src.api.restplus import api
from src.business.business import *
from src.database.models.command_model import Command
from src.common.bc_commands import BCCommands, BCCommandsStatus

log = logging.getLogger(__name__)

ns = api.namespace('withdraw', description='Operations related to settlement')


@ns.route('/')
class Withdraw(Resource):
    @api.expect(ext_account_id_arguments, validate=True)
    def post(self):
        """
        Initiates a new withdrawal.
        """
        args = ext_account_id_arguments.parse_args(request)
        ext_account_id = args.get('ext_account_id', 1)
        account_from_db = Account.find_by_ext_account_id(ext_account_id)
        if account_from_db:
            address_sender = account_from_db.user_public_key
            token_address = account_from_db.token_address
        else:
            return None

        if address_sender: