示例#1
0
class ExecucaoMinListApi(Resource):

    parser = api.parser()
    parser.add_argument('state', type=bool, help='State or not state')
    parser.add_argument('capcor', type=bool, help='Capital or Corrente')

    def get(self, year):
        '''Basic information about all geolocated values in a year.
        This endpoint is usefull to plot all the points in a map and use the
        codes to get more information about specific points. Using parameters
        it is possible to get more information about all the points. Only codes
        and latlons are returned by default.'''

        args = self.parser.parse_args()
        return_state = args['state']
        return_cap_cor = args['capcor']

        fields = filter(lambda i: i is not None, [
            Execucao.code,
            Execucao.point.ST_AsGeoJSON(3),
            Execucao.state if return_state else None,
            Execucao.cap_cor if return_cap_cor else None,
        ])

        items = (db.session.query(*fields).filter(
            Execucao.get_year() == year).filter(Execucao.point_found()).all())

        # import IPython; IPython.embed()

        return {
            'FeatureColletion': [
                {
                    'type':
                    'Feature',
                    'properties':
                    dict(
                        filter(
                            lambda i: i[1],
                            (
                                # Add required properties
                                ('uid', v.code),
                                ('state', v.state if return_state else None),
                                ('cap_cor',
                                 v.cap_cor if return_cap_cor else None),
                            ))),
                    'geometry':
                    json.loads(v[1])
                } for v in items
            ]
        }
示例#2
0
def create_parser(*args):
    """Create a parser for the passed arguments."""
    parser = api.parser()
    for arg in args:
        parser.add_argument(arg, **arguments[arg])
    return parser
示例#3
0
                     ('uid', v.code),
                     ('state', v.state if return_state else None),
                     ('cap_cor', v.cap_cor if return_cap_cor else None),
                 ))),
                 'geometry': json.loads(v[1])}
                for v in items
            ]
        }


# execucao_fields = api.model('Todo', {
    # 'sld_orcado_ano': fields.Float(required=True,
    #                                description='The task details')
# })

parser = api.parser()
parser.add_argument('code', type=str, help='Code doc!!!')
parser.add_argument('year', type=int, help='Years doc!!!')
parser.add_argument('page', type=int, default=0, help='Page doc!!!')
parser.add_argument('per_page_num', type=int, default=100, help='PPN doc!!!')


@ns.route('/list')
# @api.doc(params={'id': 'An ID'})
class ExecucaoAPI(Resource):

    @api.doc(parser=parser)
    # @marshal_with(execucao_fields, envelope='data')
    def get(self):
        # Extract the argumnets in GET request
        args = parser.parse_args()
示例#4
0
                      static_url_path='/contrato/static')


# Create the restful API
contratos_api = restful.Api(contratos)

ns = api.namespace('api/v1/contrato', 'API para os contrato de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
_filter_parser = api.parser()
_filter_parser.add_argument('cnpj')
_filter_parser.add_argument('orgao')
_filter_parser.add_argument('modalidade')
_filter_parser.add_argument('evento')
_filter_parser.add_argument('objeto')
_filter_parser.add_argument('processo_administrativo')
_filter_parser.add_argument('nome_fornecedor')
_filter_parser.add_argument('licitacao')
_filter_parser.add_argument('group_by', default='')

_order_by_parser = api.parser()
_order_by_parser.add_argument('order_by')

_pagination_parser = api.parser()
_pagination_parser.add_argument('page', type=int, default=0)
示例#5
0
def create_parser(*args):
    '''Create a parser for the passed arguments.'''
    parser = api.parser()
    for arg in args:
        parser.add_argument(arg, **arguments[arg])
    return parser
示例#6
0
                                ('cap_cor',
                                 v.cap_cor if return_cap_cor else None),
                            ))),
                    'geometry':
                    json.loads(v[1])
                } for v in items
            ]
        }


# execucao_fields = api.model('Todo', {
# 'sld_orcado_ano': fields.Float(required=True,
#                                description='The task details')
# })

parser = api.parser()
parser.add_argument('code', type=str, help='Code doc!!!')
parser.add_argument('year', type=int, help='Years doc!!!')
parser.add_argument('page', type=int, default=0, help='Page doc!!!')
parser.add_argument('per_page_num', type=int, default=100, help='PPN doc!!!')


@ns.route('/list')
# @api.doc(params={'id': 'An ID'})
class ExecucaoAPI(Resource):
    @api.doc(parser=parser)
    # @marshal_with(execucao_fields, envelope='data')
    def get(self):
        # Extract the argumnets in GET request
        args = parser.parse_args()
        page = args['page']
示例#7
0
                      static_folder='static',
                      static_url_path='/contrato/static')

# Create the restful API
contratos_api = restful.Api(contratos)

ns = api.namespace('api/v1/contrato', 'API para os contrato de São Paulo')

# receita_api.decorators = [cors.crossdomain(origin='*')]

# class Date(fields.Raw):
#     def format(self, value):
#         return str(value)

# Parser for RevenueAPI arguments
_filter_parser = api.parser()
_filter_parser.add_argument('cnpj')
_filter_parser.add_argument('orgao')
_filter_parser.add_argument('modalidade')
_filter_parser.add_argument('evento')
_filter_parser.add_argument('objeto')
_filter_parser.add_argument('processo_administrativo')
_filter_parser.add_argument('nome_fornecedor')
_filter_parser.add_argument('licitacao')
_filter_parser.add_argument('group_by', default='')

_order_by_parser = api.parser()
_order_by_parser.add_argument('order_by')

_pagination_parser = api.parser()
_pagination_parser.add_argument('page', type=int, default=0)