コード例 #1
0
ファイル: groups.py プロジェクト: simhaonline/lxd-api-gateway
                'type': fields.String,
                'id': fields.Integer
            }), as_list=True)
        })),
        'abilities': fields.Nested(api.model('ContainersDataPost', {
            'data': fields.Nested(api.model('ContainersPostData', {
                'type': fields.String,
                'id': fields.Integer
            }), as_list=True)
        }))
    }))
})

_groups_fields_get = api.inherit('GroupsFieldsGet', groups_fields_with_relationships_post_put, {
    'type': fields.String(default='groups'),
    'id': fields.Integer,
    'attributes': fields.Nested(groups_fields_attributes),
})

_groups_fields_post = api.inherit('GroupsFieldsPost', groups_fields_with_relationships_post_put, {
    'type': fields.String(pattern='groups', default='groups'),
    'attributes': fields.Nested(groups_fields_attributes_post),
})

_groups_fields_put = api.inherit('GroupsFieldsPut', groups_fields_with_relationships_post_put, {
    'type': fields.String(pattern='groups', default='groups'),
    'attributes': fields.Nested(groups_fields_attributes),
})


groups_fields_get = api.model('GroupsRootGet', { 'data': fields.Nested(_groups_fields_get) })
コード例 #2
0
"""
Module defines models of json body in post requests
"""

from flask_restx import fields, model

from app import api

wishlist_post_args = api.model(
    "Wishlist", {"name": fields.String(description="Wishlist name")})

wishlist_item_post_args = api.model(
    "Wishlist item", {"text": fields.String(description="Wishlist item text")})

wishlist_item_put_args = api.inherit(
    "Wishlist item put", wishlist_item_post_args, {
        "is_reserved":
        fields.Boolean(
            description=
            "if is_reserved is set to True you can't delete this item"),
    })

share_wishlist_put_args = api.inherit(
    "Wishlist share put", {
        "wishlist_id":
        fields.String(description="Id of wishlist you want to share"),
        "user_id":
        fields.String(
            description="Id of user with whom you want to share wishlist"),
    })
コード例 #3
0
ファイル: serializers.py プロジェクト: grzeslaws/restApi
    "total": fields.Integer(description="Total number of results"),
    "has_prev": fields.Integer(description="Is prev page?"),
    "has_next": fields.Integer(description="Is next page?"),
})

user_model = api.model("user_model", {
    "id": fields.Integer,
    "username": fields.String(required=True, description="User name"),
    "email": fields.String(description="User email"),
    "password": fields.String(description="User password"),
    "role_id": fields.Integer,
    "role": fields.String(attributes="role.name"),
})

user_model_list = api.inherit("Page of blog posts", pagination_model,
                              {"items": fields.List(
                                  fields.Nested(user_model))},
                              )

post_model = api.model("post_model", {
    "id": fields.Integer,
    "title": fields.String(required=True),
    "content": fields.String,
    "author": fields.String,
    "create_at": fields.DateTime(dt_format='rfc822'),
    "category_id": fields.Integer,
    "category": fields.String(attributes="category.category_name")
})

category_model = api.model("category_model", {
    "id": fields.Integer,
    "category_name": fields.String
コード例 #4
0
ファイル: lxdservers.py プロジェクト: Miso-K/lxd-api-gateway
        'relationships':
        fields.Nested(
            api.model(
                'ServersRelationshipsGet', {
                    'instances':
                    fields.Nested(api.model('ContainersDataGet', {
                        'id': fields.Integer,
                        'name': fields.String
                    }),
                                  as_list=True)
                }))
    })

_servers_fields_get = api.inherit(
    'LXDServersGet', servers_fields_with_relationships_get, {
        'type': fields.String(default='servers'),
        'id': fields.Integer,
        'name': fields.String,
        'address': fields.String,
        'exec_address': fields.String,
        'verify': fields.String
    })

lxdservers_fields_get = api.model('ServersRootGet',
                                  {'data': fields.Nested(_servers_fields_get)})
lxdservers_fields_get_many = api.model(
    'ServersRootGetMany',
    {'data': fields.Nested(_servers_fields_get, as_list=True)})
lxdservers_fields_post = api.model(
    'ServersRootPost', {'data': fields.Nested(_servers_fields_post)})
#lxdservers_fields_put = api.model('ServersRootPut', { 'data': fields.Nested(_servers_fields_put) })
コード例 #5
0
ファイル: users.py プロジェクト: gitter-badger/lxc-rest
                'type': fields.String(pattern='groups'),
                'id': fields.Integer
            }), as_list=True)
        })),
        'containers': fields.Nested(api.model('ContainersDataPost', {
            'data': fields.Nested(api.model('ContainersPostData', {
                'type': fields.String(pattern='containers'),
                'id': fields.Integer
            }), as_list=True)
        }))
    }))
})

_users_fields_get = api.inherit('UsersFieldsGet', users_fields_with_relationships_post_put, {
    'type': fields.String,
    'id': fields.Integer,
    'attributes': fields.Nested(users_fields_attributes),
})

_users_fields_post = api.inherit('UsersFieldsPost', users_fields_with_relationships_post_put, {
    'type': fields.String(pattern='users'),
    'attributes': fields.Nested(users_fields_attributes_post),
})

_users_fields_put = api.inherit('UsersFieldsPut', users_fields_with_relationships_post_put, {
    'type': fields.String(pattern='users'),
    'attributes': fields.Nested(users_fields_attributes_put),
})


users_fields_get = api.model('UsersRootGet', { 'data': fields.Nested(_users_fields_get) })
コード例 #6
0
                        api.model(
                            'AbilitiesDataPost', {
                                'data':
                                fields.Nested(api.model(
                                    'AbilitiesPostData', {
                                        'type': fields.String,
                                        'id': fields.Integer
                                    }),
                                              as_list=True)
                            })),
                }))
    })

_abilities_fields_get = api.inherit(
    'AbilitiesFieldsGet', abilities_fields_with_relationships_put, {
        'type': fields.String(default='abilities'),
        'id': fields.Integer,
        'attributes': fields.Nested(abilities_fields_attributes),
    })

_abilities_fields_put = api.inherit(
    'AbilitiesFieldsPut', abilities_fields_with_relationships_put, {
        'type': fields.String(pattern='abilities', default='abilities'),
    })

abilities_fields_get = api.model(
    'AbilitiesRootGet', {'data': fields.Nested(_abilities_fields_get)})
abilities_fields_get_many = api.model(
    'AbilitiesRootGetMany',
    {'data': fields.Nested(_abilities_fields_get, as_list=True)})
abilities_fields_put = api.model(
    'AbilitiesRootPut', {'data': fields.Nested(_abilities_fields_put)})
コード例 #7
0
                        api.model(
                            'ContainersDataPost', {
                                'data':
                                fields.Nested(api.model(
                                    'ContainersPostData', {
                                        'type': fields.String,
                                        'id': fields.Integer
                                    }),
                                              as_list=True)
                            })),
                }))
    })

_containers_fields_get = api.inherit(
    'ContainersFieldsGet', containers_fields_with_relationships_post_put, {
        'type': fields.String(default='containers'),
        'id': fields.Integer,
        'attributes': fields.Nested(containers_fields_attributes),
    })

_containers_fields_post = api.inherit(
    'ContainersFieldsPost', containers_fields_with_relationships_post_put, {
        'type': fields.String(pattern='containers', default='containers'),
        'attributes': fields.Nested(containers_fields_attributes_post),
    })

_containers_fields_put = api.inherit(
    'ContainersFieldsPut', containers_fields_with_relationships_post_put, {
        'type': fields.String(pattern='containers', default='containers'),
        'attributes': fields.Nested(containers_fields_attributes_put),
    })
コード例 #8
0
ファイル: models.py プロジェクト: nosqlly/Todo-App
from flask_restplus import fields, reqparse
from app import api
from app.common.models import meta

state_parser = reqparse.RequestParser()
state_parser.add_argument('State', type=str, location='args')

meta_tasks = api.inherit('meta_tasks', meta,
                         {"is_archived": fields.Boolean(default=False)})

task_request = api.model('task_request', {
    'task_name': fields.String(required=True),
    'task_data': fields.String()
})

task_db_input = api.inherit('task_db_input', task_request,
                            {'meta': fields.Nested(meta_tasks)})

task_response = api.inherit('task_response', task_db_input,
                            {'_id': fields.String()})
コード例 #9
0
ファイル: containers.py プロジェクト: lxc-webpanel/lxc-rest
})

containers_fields_with_relationships_post_put = api.model('ContainersFieldsWithRelationshipsPost', {
    'relationships': fields.Nested(api.model('ContainersRelationshipsPost', {
        'users': fields.Nested(api.model('ContainersDataPost', {
            'data': fields.Nested(api.model('ContainersPostData', {
                'type': fields.String,
                'id': fields.Integer
            }), as_list=True)
        })),
    }))
})

_containers_fields_get = api.inherit('ContainersFieldsGet', containers_fields_with_relationships_post_put, {
    'type': fields.String(default='containers'),
    'id': fields.Integer,
    'attributes': fields.Nested(containers_fields_attributes),
})

_containers_fields_post = api.inherit('ContainersFieldsPost', containers_fields_with_relationships_post_put, {
    'type': fields.String(pattern='containers', default='containers'),
    'attributes': fields.Nested(containers_fields_attributes_post),
})

_containers_fields_put = api.inherit('ContainersFieldsPut', containers_fields_with_relationships_post_put, {
    'type': fields.String(pattern='containers', default='containers'),
    'attributes': fields.Nested(containers_fields_attributes_put),
})


containers_fields_get = api.model('ContainersRootGet', { 'data': fields.Nested(_containers_fields_get) })
コード例 #10
0
ファイル: models.py プロジェクト: nosqlly/Todo-App
from flask_restplus import fields
from app import api
from app.common.models import meta

user_base = api.model(
    'signup', {
        'email': fields.String(description="Email ID"),
        'first_name': fields.String(description="First Name"),
        'last_name': fields.String(description="Last Name"),
        'password': fields.String(description="Password")
    })

user_request = api.inherit(
    'user base', user_base,
    {'confirm_password': fields.String(description="Confirm password")})

user = api.inherit(
    'user', user_base, {
        'is_active':
        fields.Boolean(default=False, description="Account Activated or Not"),
        'meta':
        fields.Nested(meta)
    })
コード例 #11
0
from flask_restplus import fields, reqparse
from app import api
from app.common.models import meta
from app.task_rooms.tasks.models import task_response

state_parser = reqparse.RequestParser()
state_parser.add_argument('State', type=str, location='args')

room_request = api.model(
    'room_request',
    {'room_name': fields.String(required=True, description="Room name")})

meta_tasks = api.inherit('meta_tasks', meta,
                         {"is_archived": fields.Boolean(default=False)})

room_record = api.inherit(
    'room_record', room_request, {
        'users': fields.List(fields.String),
        'tasks': fields.List(fields.Nested(task_response)),
        'meta': fields.Nested(meta_tasks)
    })

room_response = api.inherit('room_response', room_record,
                            {'_id': fields.String()})

invite_user = api.model(
    'invite_user',
    {'email': fields.String(required=True, description='Enter Email ID')})
コード例 #12
0
ファイル: requests.py プロジェクト: Miso-K/lxd-api-gateway
requests_fields_attributes_put = api.model('RequestsFieldsAttributesPut', {
    'message': fields.String,
    'status': fields.String
})

requests_fields_attributes_post = api.model(
    'RequestsFieldsAttributesPost', {
        'action': fields.String,
        'message': fields.String,
        'status': fields.String,
        'meta_data': fields.String
    })

_requests_fields_post = api.inherit(
    'RequestsFieldsPost', requests_fields_with_relationships_put, {
        'type': fields.String(pattern='requests', default='requests'),
        'attributes': fields.Nested(requests_fields_attributes_post),
    })

_requests_fields_get = api.inherit(
    'RequestsFieldsGet', requests_fields_with_relationships_put,
    requests_fields_attributes, {
        'type': fields.String(default='requests'),
        'id': fields.Integer
    })

_requests_fields_put = api.inherit(
    'RequestsFieldsPut', requests_fields_with_relationships_put, {
        'type': fields.String(pattern='requests', default='requests'),
        'attributes': fields.Nested(requests_fields_attributes_put),
    })
コード例 #13
0
ファイル: models.py プロジェクト: gabrgomes/mongo_inventory
from flask_restplus import fields
from app import api

inventory_request = api.model(
    'inventory_request', {
        'inventory_name':
        fields.String(required=True, description="Inventory name"),
        'sigla':
        fields.String(required=True, description="Sigla")
    })

from app.common.models import meta
meta_inventory = api.inherit('meta_inventory', meta,
                             {"is_archived": fields.Boolean(default=False)})

from app.hosts.models import host_request
from app.groups.models import group_request, group_edit
inventory_record = api.inherit(
    'inventory_record',
    inventory_request,
    {
        'hosts': fields.Nested(host_request),
        'groups': fields.Nested(group_request),
        'all': fields.Nested(group_edit),
        #    'hosts': fields.List(fields.Raw),
        #    'groups': fields.List(fields.Raw),
        #    'all': fields.List(fields.Raw),
        'meta': fields.Nested(meta_inventory)
    })

from flask_restplus import reqparse
コード例 #14
0
ファイル: abilities.py プロジェクト: Miso-K/lxd-api-gateway
                'AbilitiesRelationshipsPost', {
                    'groups':
                    fields.Nested(api.model(
                        'AbilitiesDataPost', {
                            'id': fields.Integer,
                            'name': fields.String,
                            'category': fields.String
                        }),
                                  as_list=True)
                }))
    })

_abilities_fields_get = api.inherit(
    'AbilitiesFieldsGet', abilities_fields_with_relationships_put, {
        'type': fields.String(default='abilities'),
        'id': fields.Integer,
        'name': fields.String,
        'category': fields.String
    })

_abilities_fields_put = api.inherit(
    'AbilitiesFieldsPut', abilities_fields_with_relationships_put, {
        'type': fields.String(pattern='abilities', default='abilities'),
    })

abilities_fields_get = api.model(
    'AbilitiesRootGet', {'data': fields.Nested(_abilities_fields_get)})
abilities_fields_get_many = api.model(
    'AbilitiesRootGetMany',
    {'data': fields.Nested(_abilities_fields_get, as_list=True)})
abilities_fields_put = api.model(
コード例 #15
0
ファイル: abilities.py プロジェクト: lxc-webpanel/lxc-rest
abilities_fields_attributes = api.model('AbilitiesFieldsAttributes', {
    'name': fields.String
})

abilities_fields_with_relationships_put = api.model('AbilitiesFieldsWithRelationshipsPost', {
    'relationships': fields.Nested(api.model('AbilitiesRelationshipsPost', {
        'groups': fields.Nested(api.model('AbilitiesDataPost', {
            'data': fields.Nested(api.model('AbilitiesPostData', {
                'type': fields.String,
                'id': fields.Integer
            }), as_list=True)
        })),
    }))
})

_abilities_fields_get = api.inherit('AbilitiesFieldsGet', abilities_fields_with_relationships_put, {
    'type': fields.String(default='abilities'),
    'id': fields.Integer,
    'attributes': fields.Nested(abilities_fields_attributes),
})

_abilities_fields_put = api.inherit('AbilitiesFieldsPut', abilities_fields_with_relationships_put, {
    'type': fields.String(pattern='abilities', default='abilities'),
})


abilities_fields_get = api.model('AbilitiesRootGet', { 'data': fields.Nested(_abilities_fields_get) })
abilities_fields_get_many = api.model('AbilitiesRootGetMany', { 'data': fields.Nested(_abilities_fields_get, as_list=True) })
abilities_fields_put = api.model('AbilitiesRootPut', { 'data': fields.Nested(_abilities_fields_put) })
コード例 #16
0
        'stateful': fields.String
    })

snapshots_fields_attributes_put = api.model('SnapshotsFieldsAttributesPut',
                                            {'expires_at': fields.String})

_snapshots_fields_get = api.model(
    'SnapshotsFieldsGet', {
        'type': fields.String(default='snapshots'),
        'id': fields.Integer,
        'attributes': fields.Nested(snapshots_fields_attributes),
    })

_snapshots_fields_post = api.inherit(
    'SnapshotsFieldsPost', {
        'type': fields.String(pattern='snapshots', default='snapshots'),
        'attributes': fields.Nested(snapshots_fields_attributes_post),
    })

_snapshots_fields_put = api.inherit(
    'SnapshotsFieldsPut', {
        'type': fields.String(pattern='snapshots', default='snapshots'),
        'attributes': fields.Nested(snapshots_fields_attributes_put),
    })

snapshots_fields_get = api.model(
    'SnapshotsRootGet', {'data': fields.Nested(_snapshots_fields_get)})
snapshots_fields_get_many = api.model(
    'SnapshotsRootGetMany',
    {'data': fields.Nested(_snapshots_fields_get, as_list=True)})
snapshots_fields_post = api.model(