Python flask_restplus.fields.List() Examples

The following are 8 code examples of flask_restplus.fields.List(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module flask_restplus.fields , or try the search function .
Example #1
Source File: api_endpoints.py    From indras_net with GNU General Public License v3.0 5 votes vote down vote up
def get(self):
        """
        List our endpoints.
        """
        endpoints = sorted(rule.rule for rule in api.app.url_map.iter_rules())
        return {"Available endpoints": endpoints} 
Example #2
Source File: base.py    From gordo with GNU Affero General Public License v3.0 5 votes vote down vote up
def tags(self) -> typing.List[SensorTag]:
        """
        The input tags for this model

        Returns
        -------
        typing.List[SensorTag]
        """
        return normalize_sensor_tags(
            g.metadata["dataset"]["tag_list"],
            asset=g.metadata["dataset"].get("asset"),
            default_asset=g.metadata["dataset"].get("default_asset"),
        ) 
Example #3
Source File: base.py    From gordo with GNU Affero General Public License v3.0 5 votes vote down vote up
def target_tags(self) -> typing.List[SensorTag]:
        """
        The target tags for this model

        Returns
        -------
        typing.List[SensorTag]
        """
        if "target_tag_list" in g.metadata["dataset"]:
            return normalize_sensor_tags(
                g.metadata["dataset"]["target_tag_list"],
                asset=g.metadata["dataset"].get("asset"),
                default_asset=g.metadata["dataset"].get("default_asset"),
            )
        else:
            return [] 
Example #4
Source File: main.py    From envoy_discovery with Apache License 2.0 5 votes vote down vote up
def get(self):
        '''List all resources'''        
        return DAO.services 
Example #5
Source File: main.py    From envoy_discovery with Apache License 2.0 5 votes vote down vote up
def get(self, service_name):
        '''List hosts for service'''
        try:
          return DAO.services[service_name]        
        except KeyError: 
          api.abort(404, "Service {} doesn't exist".format(service_name)) 
Example #6
Source File: product.py    From flask-shop with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get(self):
        """List all products"""
        page = request.args.get("page", 1, int)
        products = Product.query.paginate(page, per_page=8).items
        return products 
Example #7
Source File: trace.py    From treadmill with Apache License 2.0 5 votes vote down vote up
def init(api, cors, impl):
    """Configures REST handlers for state resource."""
    namespace = webutils.namespace(
        api, __name__, 'Trace REST operations'
    )

    model = {
        'name': fields.String(description='Application name'),
        'instances': fields.List(
            fields.String(description='Instance IDs')
        ),
    }
    trace_model = api.model(
        'Trace', model
    )

    @namespace.route('/<app_name>')
    @api.doc(params={'app_name': 'Application name'})
    class _TraceAppResource(restplus.Resource):
        """Treadmill application trace information resource.
        """

        @webutils.get_api(api, cors,
                          marshal=api.marshal_with,
                          resp_model=trace_model)
        def get(self, app_name):
            """Return trace information of a Treadmill application.
            """
            trace_info = impl.get(app_name)
            if trace_info is None:
                raise exc.NotFoundError(
                    'No trace information available for {}'.format(app_name)
                )
            return trace_info 
Example #8
Source File: dns.py    From treadmill with Apache License 2.0 3 votes vote down vote up
def init(api, cors, impl):
    """Configures REST handlers for DNS resource."""

    namespace = webutils.namespace(
        api, __name__, 'DNS REST operations'
    )

    server_model = fields.String(description='Server')

    model = {
        '_id': fields.String(
            description='Name',
            max_length=32),
        'location': fields.String(description='Location'),
        'nameservers': fields.List(server_model),
        'rest-server': fields.List(server_model),
        'zkurl': fields.String(description='Zookeeper URL'),
        'fqdn': fields.String(description='FQDN'),
        'ttl': fields.String(description='Time To Live'),
    }

    dns_model = api.model(
        'DNS', model
    )

    @namespace.route('/')
    class _DNSList(restplus.Resource):
        """Treadmill DNS resource"""

        @webutils.get_api(api, cors,
                          marshal=api.marshal_list_with,
                          resp_model=dns_model)
        def get(self):
            """Returns list of configured DNS servers."""
            return impl.list()

    @namespace.route('/<dns>')
    @api.doc(params={'dns': 'DNS ID/name or FQDN'})
    class _DNSResource(restplus.Resource):
        """Treadmill DNS resource."""

        @webutils.get_api(api, cors,
                          marshal=api.marshal_with,
                          resp_model=dns_model)
        def get(self, dns):
            """Return Treadmill cell configuration."""
            return impl.get(dns)