Python flask_restplus.fields.String() Examples

The following are 3 code examples of flask_restplus.fields.String(). 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: 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 #2
Source File: endpoint.py    From treadmill with Apache License 2.0 4 votes vote down vote up
def init(api, cors, impl):
    """Configures REST handlers for endpoint resource."""
    # Disable too many branches warning.
    #
    # pylint: disable=R0912
    namespace = webutils.namespace(
        api, __name__, 'Endpoint state REST operations'
    )

    endpoint_model = {
        'endpoint': fields.String(description='Endpoint name'),
        'name': fields.String(description='Application name'),
        'port': fields.Integer(description='Endpoint port'),
        'proto': fields.String(description='Application endpoint protocol'),
        'host': fields.String(description='Endpoint host'),
        'state': fields.Boolean(description='Endpoint state'),
    }

    response_model = api.model(
        'Endpoint', endpoint_model
    )

    @namespace.route(
        '/<pattern>',
    )
    @api.doc(params={'pattern': 'Application pattern'})
    class _EndpointList(restplus.Resource):
        """Treadmill Endpoint resource"""

        @webutils.get_api(api, cors,
                          marshal=api.marshal_list_with,
                          resp_model=response_model)
        def get(self, pattern):
            """Return all endpoints"""
            ret = impl.list(pattern, None, None)
            return ret

    @namespace.route('/<pattern>/<proto>/<endpoint>')
    @api.doc(params={
        'pattern': 'Application pattern',
        'proto': 'Application endpoint protocol',
        'endpoint': 'Application endpoint name',
    })
    class _EndpointResource(restplus.Resource):
        """Treadmill Endpoint resource"""

        @webutils.get_api(api, cors,
                          marshal=api.marshal_list_with,
                          resp_model=response_model)
        def get(self, pattern, proto, endpoint):
            """Return Treadmill app endpoint state"""
            ret = impl.list(pattern, proto, endpoint)
            return ret 
Example #3
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)